2009年3月5日星期四

runas的高级替代工具

windows的runas给了管理员很多方便的地方,但是因为其不能用管道输入密码,无法做在批处理和脚本中。而CPAU可以直接参数中输入密码,而且可以将密码加密,实现了runas的功能。这样管理员就可以将它写入批处理中交普通用户去实现某些需要高级权限的应用。

详细使用说明

CPAU -u user [-p password] -ex "WhatToRun" [switches]

user User to log on as. Ex: user or domain\user
password User's password
WhatToRun What to execute

Switches: (designated by - or /)
-profile Do local logon with profile instead of net logon
-localwithprofile Alias for -profile
-lwp Alias for -profile
-localwithoutprofile Local logon but do not load profile.
-lwop Alias for -localwithoutprofile
-k Prefix command with cmd /k to leave window open
-c Prefix command with cmd /c to close window after exec.
-pipepwd Special method allows you to pipe password in
-enc Encrypt a job file for later user
-dec Use an ecrypted job file
-file Specify job file to execute or create
-wait Wait for process completion before returning.
-outprocexit Used with -wait, the errorlevel variable has the
exit code of the spawned process instead of cpau.
-cwd x Start at working directory x.
-hide Start the new process in a hidden state.
-title x Allow you specify title of command prompt windows.
-crc file[,file,file] This option allows you to encode
CRC info for files in the job file. When decoded
the CRC have to match or the program bombs. Note that
it will not chase paths looking for the file, you must
specify the exact path.
-nowarn Don't output warning about network logon.

Ex1:
cpau -u joehome\joe -p logon -ex "perl cleanup.pl" -lwp
Runs perl script cleanup.pl as joehomejoe

Ex2:
cpau -u joehome\joe -p logon -ex "perl cleanup.pl" -enc -file cleanup.job
Creates job file called cleanup.job to run perl script cleanup.pl as joehomejoe

Ex3:
cpau -dec -file cleanup.job -lwp
Execute job file cleanup.job

Ex4:
cpau -u joehome\joe -p logon -ex "perl cleanup.pl" -wait -lwp
Runs perl script cleanup.pl as joehomejoe and waits for process to end

Ex5:
cpau -u joe -p logon -ex notepad.exe -lwp
Runs notepad as user joe

Ex6:
cpau -u joehome\joe -p logon -ex logonscript.cmd -lwp
Runs logon script in current directory as user joe (see note below)

Ex7:
cpau -u joehome\joe -p logon -ex logonscript.cmd -lwp -cwd c:\temp
Runs logon script in/from c:\temp as user joe (see note below)

Ex8:
cpau -u joe -p logon -ex logonscript.cmd -enc -file logon.job -crc logonscript.cmd
Encodes logon.job file and CRC protects the batch file

应用实例:普通用户有时需要更改本机的时间和日期,先用

CPAU -u administrator -p password -ex "control timedate.cpl" -enc -file time.job

生成一个time.job文件,该文件已经将管理员的密码加密存放。

建立time.bat批处理:

cpau -dec -file timedate.job -lwop

可以通过winrar将cpau.exe、timedate.job和time.bat封装在一个exe文件中使其自动执行。这样就及保密了管理员密码,有使普通用户可以更改系统时间日期。

点击这里下载:CPAU.EXE


没有评论:

发表评论