网站地图    收藏   

主页 > 后端 > 网站安全 >

runas 命令的使用及RUNAS自动输入密码的方法 - Wi

来源:自学PHP网    时间:2015-04-17 18:33 作者: 阅读:

[导读] 在win2k中,开始→程序→附件 ,找到计算器,按住shift键,点右键,选择“运行方式 ...”,这时候,会弹出对话框,询问你要使用哪个用户身份来运行该程序 。不知道大家是否使用过...

在win2k中,开始→程序→附件 ,找到计算器,按住shift键,点右键,选择“运行方式 ...”,这时候,会弹出对话框,询问你要使用哪个用户身份来运行该程序 。
不知道大家是否使用过win2k的这个功能,如果大家是使用win2k的英文版本的话,在按住shift后选择的就不是“运行方式 ...”而是“runas...”,也就是今天要讲的这个命令。
在cmd中输入runas,会得到帮助,今天,我们只将它最简单的用法,就是怎么样使用这个命令来以另外一个用户身份运行一个程序。

其实,命令非常简单:
runas /user:user_name program.exe
user_name是要使用哪个用户运行该程序就写上哪个用户名,program.exe是程序名,如果program.exe不在system32目录下的话,需要指明具体路径。
为了证明这个过程,做一个实验,那就是使用guest帐号来运行at命令,查看当前的计划任务清单,大家都知道,guest默认情况下是没有此权限的,因此,只要这个命令真的起作用的话,会出现“拒绝访问”的字样,在这里,我们使用这个命令:
runas /user:guest "cmd.exe cmd/k at.exe"
cmd.exe 是调用cmd这个程序,而cmd/k则是指cmd命令后跟/k参数,目的是为了是当前的执行结果的屏幕保留 。

(注意:这里由于命令过长,而且中间有空格,所以用引号引起来,如果只有一个命令,例如at.exe的话,那么就不需要有引号了)

例:
(1)runas   /user:administrator   "C:Program FilesAutoCAD R14acad.exe"
(2)输入密码:(输入时密码会看不到)
(3)这样就可以用“administrator"用户权限来启动那个程序了,通常我们可以使用它来执行安装程序,即可做到不用切换用户来安装“

由于运行的程序是在一个新窗口中打开,而不是在原来的cmd窗口中打开,所以,如果我不使用cmd.exe cmd/k这个参数的话,窗口会一闪而过,看不到效果。

运行完这个命令后,会要求guest的密码,填上,回车,等一会,一会就会出现一个cmd窗口,里面写着“拒绝访问”,而且,在cmd窗口上沿还有“(运行为guest)”的字样。
这个工具还可以在域中使用,而且还可以加上个人配置文件,实在是很爽 ~~~
-------
RUNAS 用法:

RUNAS [/profile] [/env] [/netonly] /user:<UserName> program

/profile     如果需要加载用户的配置文件
/env       要使用当前环境,而不是用户的环境。
/netonly     只在指定的凭据限于远程访问的情况下才使用
/user    <UserName> 应使用 USER@DOMAIN 或 DOMAINUSER 形式
program    EXE. 的命令行。参阅下面的例子

例如:
> runas /profile /user:mymachineadministrator cmd
> runas /profile /env /user:mydomainadmin "mmc %windir%system32dsa.msc"
> runas /env /user:user@domain.microsoft.com "notepad "my file.txt""

注意: 只有在被提示时才输入用户的密码。
注意: USER@DOMAIN 与 /netonly 不兼容。
但由于RUNAS每次都要自己输入密码,很是麻烦,我们也可以改用其它方法:
自动输入RUNAS密码的方法
以非管理员用户登录时,如果要用管理员权限运行程序的话,需要用到 runas 命令,在使用脚本运行时,无法简单的利用管道来输入密码,有以下方法可免除每次需要输入密码的麻烦。
1、使用系统自带的 runas /savecred 选项,第一次输入密码后,会保存凭据。
特点:无法限制能够运行的命令,安全性差。

2、使用 sanur,sanur 是一个小程序,能以管道的方法将密码或者文件中的内容传递给 runas 程序。
runas | sanur password
runas | sanur /i [drive:][path]filename
特点:密码明文保存。
----------------------------------
About Sanur
Sanur 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.
Usage
Pipe your normal Runas commandline into Sanur and specify the password on Sanurs 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.
Examples
Pipe the password pa55w0rd into Runas:-
runas /u:domainusername program.exe | sanur pa55w0rd
Pipe the password from the file named password.txt into Runas:-
runas /u:domainusername program.exe | sanur /i password.txt
Same as above but any Runas errors, such as a logon failure, will be displayed:-
runas /u:domainusername 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 dont send me any emails relating to Sanur.
例:runas /u:domainguest notepad.exe | sanur /i 123.jpg 我们使用guest用户,密码正在123.txt里面,由于密码是用明文存贮,不安全,所以将.txt改为了.jpg,这样就不能直接查看了,并把它设了系统隐藏。

----------------------------------
相关页面:
http://www.commandline.co.uk/sanur_unsupported/index.html

3、使用 lsrunas,功能类似 sanur,不过它无需运行 runas,自带完整的参数来执行。
特点:密码明文保存。
相关页面:
aspx?item=lsrunas">http://www.moernaut.com/default.aspx?item=lsrunas

4、使用 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=lsrunase

5、使用 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.htm

6、使用 autoit,autoit 是一个脚本自动化执行的工具,可以完成很多自动化的任务,并且可以将脚本编译成 exe 文件来直接运行,从而达到了隐藏密码信息的目的。
特点:功能强大,但操作复杂。
相关页面:
http://www.autoitscript.com/autoit3/

还有其他一些工具能够完成类似的操作。
参考页面:
http://www.commandline.co.uk/sanur/

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论