文章总结: 文档详细介绍了OSCP认证学习中的信息收集技术,分为被动信息收集(如whois枚举、谷歌黑客、Netcraft、开源代码分析、Shodan、安全头和SSL/TLS检查)和主动信息收集(如DNS枚举、端口扫描、NMAP使用、SMB枚举、SMTP枚举和SNMP枚举)。文章提供了具体的命令和工具使用方法,对准备OSCP考试的人员具有实用价值。
综合评分: 89
文章分类: 渗透测试,WEB安全,安全工具,漏洞分析,红队
OSCP | 信息收集
原创
小A法师
高级红队专家
2024年6月22日 07:09
北京
教材和学习方式详见开篇:OSCP学习之路-开篇
本篇对应教材第六章,主要分两部分“被动信息收集”和“主动信息收集”,记录使用工具和命令
6.2 被动信息收集
1 whois枚举
查域名(-h后面是whois服务器)
whois megacorpone.com -h 192.168.50.251
查IP
whois 38.100.193.70 -h 192.168.50.251
2 谷歌黑客
查域名
site:megacorpone.com
查看指定文件类型
site:megacorpone.com filetype:txt
排除文件类型
site:megacorpone.com -filetype:html
查找目录遍历
intitle:"index of" "parent directory"
更多参考
https://www.exploit-db.com/google-hacking-database https://dorksearch.com/
3 Netcraft
地址
searchdns.netcraft.com
4 开源代码
网站
https://github.com/https://gist.github.com/https://about.gitlab.com/https://sourceforge.net/
搜索指定文件
owner:megacorpone path:users
使用工具
https://github.com/michenriksen/gitrobhttps://github.com/zricethezav/gitleaks
命令
gitleaks-linux-arm64 -v -r=https://github.com/xxx/xxx
5 Shodan
搜索host
hostname:megacorpone.com
增加端口信息
hostname:megacorpone.com port:"22"
6 Security Headers and SSL/TLS
网站
https://securityheaders.com/https://www.ssllabs.com/ssltest/
6.3 主动信息收集
1 DNS枚举
DNS记录类型
NS: Nameserver records contain the name of the authoritative servers hosting the DNS records for a domain. A: Also known as a host record, the "a record" contains the IPv4 address of a hostname (such as www.megacorpone.com). AAAA: Also known as a quad A host record, the "aaaa record" contains the IPv6 address of a hostname (such as www.megacorpone.com). MX: Mail Exchange records contain the names of the servers responsible for handling email for the domain. A domain can contain multiple MX records. PTR: Pointer Records are used in reverse lookup zones and can find the records associated with an IP address. CNAME: Canonical Name Records are used to create aliases for other host records. TXT: Text records can contain any arbitrary data and be used for various purposes, such as domain ownership verification.
查域名ip
host www.megacorpone.com
查邮件服务器等其他记录类型
host -t mx megacorpone.comhost -t txt megacorpone.com
批量枚举域名对应ip
for ip in $(cat list.txt); do host $ip.megacorpone.com; done
批量枚举ip对应域名
for ip in $(seq 200 254); do host 51.222.169.$ip; done | grep -v "not found"
使用工具自动枚举
dnsrecon -d megacorpone.com -t stddnsrecon -d megacorpone.com -D ~/list.txt -t brtdnsenum megacorpone.co
A记录枚举
nslookup mail.megacorptwo.com
指定DNS服务器枚举
nslookup -type=TXT info.megacorptwo.com 192.168.50.151
2 端口扫描
-w 超时时间-z zero-I/O mode(无数据)
TCP
nc -nvv -w 1 -z 192.168.50.152 3388-3390
UDP
nc -nv -u -z -w 1 192.168.50.149 120-123
3 NMAP端口扫描
普通扫描
nmap 192.168.50.149
全端口扫描
nmap -p 1-65535 192.168.50.149
SYN扫描
sudo nmap -sS 192.168.50.149
TCP连接扫描
nmap -sT 192.168.50.149
UDP扫描
sudo nmap -sU 192.168.50.149
UDP+SYN扫描
sudo nmap -sU -sS 192.168.50.149
存活主机枚举
nmap -sn 192.168.50.1-253nmap -v -sn 192.168.50.1-253 -oG ping-sweep.txtgrep Up ping-sweep.txt | cut -d " " -f 2
指定端口及服务枚举
nmap -p 80 192.168.50.1-253 -oG web-sweep.txtgrep open web-sweep.txt | cut -d" " -f2
Top 20端口扫描
nmap -sT -A --top-ports=20 192.168.50.1-253 -oG top-port-sweep.txt
操作系统指纹
sudo nmap -O 192.168.50.14 --osscan-guess
服务枚举
nmap -sT -A 192.168.50.14
nmap脚本扫描
nmap --script http-headers 192.168.50.6
powershell端口扫描
Test-NetConnection -Port 445 192.168.50.151
1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("192.168.50.151", $_)) "TCP port $_ is open"} 2>$null
4 SMB枚举
nmap端口扫描(139、445)
nmap -v -p 139,445 -oG smb.txt 192.168.50.1-254
udp 137端口枚举(-r参数)
sudo nbtscan -r 192.168.50.0/24
nmap脚本相关
ls -1 /usr/share/nmap/scripts/smb*nmap -v -p 139,445 --script smb-os-discovery 192.168.50.152
查看SMB共享
net view \\dc01 /all
5 SMTP枚举
枚举主机用户
nc -nv 192.168.50.8 25VRFY rootVRFY idontexist
自动脚本
#!/usr/bin/pythonimport socketimport sysif len(sys.argv) != 3: print("Usage: vrfy.py <username> <target_ip>") sys.exit(0)# Create a Sockets = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# Connect to the Serverip = sys.argv[2]connect = s.connect((ip,25))# Receive the bannerbanner = s.recv(1024)print(banner)# VRFY a useruser = (sys.argv[1]).encode()s.send(b'VRFY ' + user + b'\r\n')result = s.recv(1024)print(result)# Close the sockets.close()
使用
python3 smtp.py root 192.168.50.8
powershell枚举
Test-NetConnection -Port 25 192.168.50.8telnet 192.168.50.8 25VRFY root
6 SNMP枚举
windows snmp
1.3.6.1.2.1.25.1.6.0 System Processes1.3.6.1.2.1.25.4.2.1.2 Running Programs1.3.6.1.2.1.25.4.2.1.4 Processes Path1.3.6.1.2.1.25.2.3.1.4 Storage Units1.3.6.1.2.1.25.6.3.1.2 Software Name1.3.6.1.4.1.77.1.2.25 User Accounts1.3.6.1.2.1.6.13.1.3 TCP Local Ports
nmap扫描udp的161端口
sudo nmap -sU --open -p 161 192.168.50.1-254 -oG open-snmp.txt
echo public > communityecho private >> communityecho manager >> communityfor ip in $(seq 1 254); do echo 192.168.50.$ip; done > ipsonesixtyone -c community -i ips
自动化工具
snmpwalk -c public -v1 -t 10 192.168.50.151
枚举windows用户
snmpwalk -c public -v1 192.168.50.151 1.3.6.1.4.1.77.1.2.25
枚举windows进程
snmpwalk -c public -v1 192.168.50.151 1.3.6.1.2.1.25.4.2.1.2
枚举安装软件
snmpwalk -c public -v1 192.168.50.151 1.3.6.1.2.1.25.6.3.1.2
枚举开放端口
snmpwalk -c public -v1 192.168.50.151 1.3.6.1.2.1.6.13.1.3
我在第一篇里提到的一些有价值的认证,还有什么质量高的认证考试我没想到的,可以私我
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:高级红队专家 小A法师《OSCP | 信息收集》