博客摘录「 PsExec用法及远程操控执行脚本举例」2023年4月20日

PsExec用法及远程操控执行脚本举例一、 简介PsExec是一种轻量级的telnet替代品,可以在其他系统上执行进程,完成控制台应用程序的完全交互,而无需手动安装客户端软件。PsExec强大的用途是在远程系统上启动交互式命令提示,远程启动执行包括IpConfig等cmd命令,故能够远程启动服务器上程序、脚本等。二、 环境配置2.1 安装PsTools安装PsTools到执行远程命令的本地环境,安装过程非常简单,只需要下载压缩包,解压,配置本地环境即可,如果不配置本地环境,可以直接在解压文件夹中执行cmd或PowerShell打开Download:下载PSTools配置本地环境变量或解压压缩包,在压缩包下按住Shift鼠标右击,打开命令窗口,下图表示安装成功。2.2 配置执行环境配置PsExec命令执行远程服务器文件替换脚本的执行环境,以下配置是针对于执行远程服务器进行文件替换,拷贝的脚本操作,若无该需求,可以尝试忽略。1.进入远程服务器打开控制台cmd,输入 net share ipc$2.继续输入 net share admin$三、 PsExec使用说明用法:psexec [\ computer [,computer2 [,…] | @file ]] [ - u user [-p psswd] [ - ns] [ - r servicename] [ - h] [ - l] [ - s | -e] [ - x] [ - i [session]] [ -c executable [-f | -v]] [ - w directory] [ - d] [ - ] [ - an,n,…] cmd [arguments]参数说明:参数 描述-a Separate processors on which the application can run with commas where 1 is the lowest numbered CPU. For example, to run the application on CPU 2 and CPU 4, enter: “-a 2,4”-c Copy the specified executable to the remote system for execution. If you omit this option the application must be in the system path on the remote system.-d Don’t wait for process to terminate (non-interactive).-e Does not load the specified account’s profile.-f Copy the specified program even if the file already exists on the remote system.-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.-h If the target system is Vista or higher, has the process run with the account’s elevated token, if available.-l Run process as limited user (strips the Administrators group and allows only privileges assigned to the Users group). On Windows Vista the process runs with Low Integrity.-n Specifies timeout in seconds connecting to remote computers.-p Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password.-r Specifies the name of the remote service to create or interact with.-s Run the remote process in the System account.-u Specifies optional user name for login to remote computer.-v Copy the specified file only if it has a higher version number or is newer on than the one on the remote system.-w Set the working directory of the process (relative to remote computer).-x Display the UI on the Winlogon secure desktop (local system only).-priority Specifies -low, -belownormal, -abovenormal, -high or -realtime to run the process at a different priority. Use -background to run at low memory and I/O priority on Vista.computer Direct PsExec to run the application on the remote computer or computers specified. If you omit the computer name, PsExec runs the application on the local system, and if you specify a wildcard (\*), PsExec runs the command on all computers in the current domain.@file PsExec will execute the command on each of the computers listed in the file.cmd Name of application to execute.arguments Arguments to pass (note that file paths must be absolute paths on the target system).-accepteula This flag suppresses the display of the license dialog.中文对照参数 描述-a 应用程序可以使用逗号运行的单独处理器,其中1是编号最小的CPU。例,如要在CPU 2和CPU 4上运行应用程序,输入:“ - a 2,4”-c 将指定的可执行文件复制到远程系统以供执行。如果省略此选项,则应用程序必须位于远程系统上的系统路径中。-d 不必等待进程终止(非交互式)。-e 不加载指定帐户的配置文件。-f 即使远程系统上已存在该文件,也要复制指定的程序。-i 运行该程序,使其与远程系统上指定会话的桌面交互。如果未指定会话,则进程将在控制台会话中运行。-h 如果目标系统是Vista或更高版本,则使用帐户的提升令牌(如果可用)运行该流程。-l 以受限用户身份运行进程(剥离Administrators组并仅允许分配给Users组的权限)。在Windows Vista上,该过程以低完整性运行。-n 指定连接到远程计算机的超时秒数。-p 指定用户名的可选密码。如果省略此项,系统将提示您输入隐藏密码。-r 指定要创建或与之交互的远程服务的名称。-s 在系统帐户中运行远程进程。-u 指定登录到远程计算机的可选用户名。-v 仅当指定文件的版本号较高或比远程系统上的版本更新时才复制该文件。-w 设置进程的工作目录(相对于远程计算机)。-x 在Winlogon安全桌面上显示UI(仅限本地系统)。-priority 指定-low,-belownormal,-abovenormal,-high或-realtime以不同的优先级运行进程。使用-background在Vista上以低内存和I / O优先级运行。computer 直接PsExec在指定的远程计算机或计算机上运行应用程序。如果省略计算机名称,PsExec将在本地系统上运行该应用程序,如果指定通配符(\ *),PsExec将在当前域中的所有计算机上运行该命令。@file PsExec将在文件中列出的每台计算机上执行该命令。cmd 要执行的应用程序的名称。arguments 要传递的参数(请注意,文件路径必须是目标系统上的绝对路径)。-accepteula 该标志禁止显示许可证对话框。四、 应用举例1.远程操控执行脚本PsExec \\远程服务器IP -u 登录名 -p 密码 -d -i 0 "脚本路径\本地文件替换脚本.bat"1关于文件替换脚本的创建可以参考这里:window下本地、远端文件替换脚本bat及举例2.官网例子(1)以下命令在\ marklap上启动交互式命令提示符:psexec \\ marklap cmd1(2)此命令使用/ all开关在远程系统上执行IpConfig,并在本地显示结果输出:psexec \\ marklap ipconfig / all1(3)此命令将程序test.exe复制到远程系统并以交互方式执行它:psexec \\ marklap -c test.exe1(4)指定已安装在远程系统上的程序的完整路径(如果它不在系统的路径上):psexec \\ marklap c:\ bin \ test.exe1(5)在系统帐户中以交互方式运行Regedit以查看SAM和SECURITY密钥的内容::psexec -i -d -sc:\ windows \ regedit.exe1(6)要使用受限用户权限运行Internet Explorer,请使用以下命令:psexec -l -d“c:\ program files \ internet explorer \ iexplore.exe”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值