2013年6月20日 星期四

Runas 如何自帶密碼

 參考資料 :  http://blogger.liaohaha.tw/2012/05/runas.html

改用 windows script  比較好用 還可以加密


set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:[帳號] ""[程式]"""
WScript.Sleep 1000
WshShell.Sendkeys "[密碼]~"

~ 要留著喔!  ~表示carriage return。

 
 若不希望看到vbs 的密碼,可以至微軟官網下載 script encoder 將其加密為.vbe
http://www.microsoft.com/downloads/details.aspx?FamilyId=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en
 以上是舊資料了,微軟的網站已經不提供 此程式了,內建為 *.dll 檔了,這樣我就不知道怎麼用了,
所以,請上網去找 sce10en.exe  這個檔來下載安裝吧!  動手找找吧!






網站中都有介紹要把 script 內容改一下 (好幾各站都這樣寫,大概都是抄同一份吧!我好像也是),不過看起來也只是加上 rem 說明 , 以下是範例:

'**Start Encode**
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:administrator ""C:\WINDOWS\system32\shutdown.exe -s -f -t 02"""
WScript.Sleep 1000
WshShell.Sendkeys "password~"


--------------------

接著將完成的shutdown.vbs放在在screnc.exe的所在目錄下,並在此執行以下指令


screnc /l vbscript shutdown.vbs shutdown.vbe
接著給予與user 加密過的shutdown.vbe執行即可!


目前為止,這個方法還不錯可行的樣子!還要測試看看。

===================== 以下也可以用 不過 沒有比較好 
資料擷取自: http://tc.itkee.com/media/detail-1d31.html




使用 sanur,sanur 是一個小程序,能以管道的方法將密碼或者文件中的內容傳遞給 runas 程序。
runas | sanur password
runas | sanur /i [drive:][path]filename
特點:密碼明文保存。
----------------------------------
About SanurSanur is a tiny Win32 console utility that 'pipes' a password into the Windows 2000/XP/2003 Runas utility, thereby making Runas scriptable.
Licencing
Sanur is freeware. There is no fee for personal or corporate use. For more details see the 'readme.txt' file included in sanur.zip.
UsagePipe your normal Runas commandline into Sanur and specify the password on Sanur's commandline or use the /i switch to have Sanur read the password from a file:-
RUNAS <options> | SANUR password
RUNAS <options> | SANUR /i [drive:][path]filename

In otherwords, just add | SANUR password to the end of your working Runas command.
ExamplesPipe the password 'pa55w0rd' into Runas:-
runas /u:domain\username program.exe | sanur pa55w0rd
Pipe the password from the file named password.txt into Runas:-
runas /u:domain\username program.exe | sanur /i password.txt
Same as above but any Runas errors, such as a logon failure, will be displayed:-
runas /u:domain\username program.exe >&2 | sanur /i password.txt
Support
As of 2005-01-11 Sanur is no longer supported. If you are having problems getting Sanur to work please read the troubleshooting AND the FAQ pages, or seek an alternative solution. Please don't send me any emails relating to Sanur.
例:runas /u:domain\guest notepad.exe | sanur /i 123.jpg 我們使用guest用戶,密碼正在123.txt裏面,由於密碼是用明文存貯,不安全,所以將.txt改爲了.jpg,這樣就不能直接查看了,並把它設了 系統隱藏。

----------------------------------
相關頁面:
http://www.commandline.co.uk/sanur_unsupported/index.html3、使用 lsrunas,功能類似 sanur,不過它無需運行 runas,自帶完整的參數來執行。
特點:密碼明文保存。
相關頁面:
http://www.moernaut.com/default.aspx?item=lsrunas4、使用 lsrunase,lsrunas 的加強版本,可以使用加密的密碼。自帶一個小軟件 LSencrypt 用來生成加密的字串。
用法:
lsrunase /user:administrator /password:41BngA== /domain: /command:notepad.exe /runpath:c:\

所有的參數必須齊全,其中:
user 爲運行的賬號
password 爲密碼加密後的字串
domain 爲機器名或域名,也可留空代表本機
command 爲要運行的程序名,如果攜帶參數需要在命令的首尾加引號
runpath 爲程序啓動的路徑
特點:可以較完美的替代 runas,並避免直接將密碼明文保存在腳本中。
相關頁面:
http://www.moernaut.com/default.aspx?item=lsrunase5、使用 cpau,cpau 也是一個替代 runas 的程序,並且功能強大,可以使用加密的密碼。
用法:
cpau -u administrator -p password -ex notepad -file start_notepad.txt -enc
cpau -file start_notepad.txt -dec
以上命令可以先將要執行的指令加密保存爲一個文件,執行時載入此文件。
特點:可以保護執行的腳本及命令不被他人查看,但在使用網絡路徑時存在一些問題。
相關頁面:
http://www.joeware.net /win/free/tools/cpau.htm6、使用 autoit,autoit 是一個腳本自動化執行的工具,可以完成很多自動化的任務,並且可以將腳本編譯成 exe 文件來直接運行,從而達到了隱藏密碼信息的目的。
特點:功能強大,但操作複雜。
相關頁面:
http://www.autoitscript.com/autoit3/還有其他一些工具能夠完成類似的操作。

沒有留言:

張貼留言