渗透测试 | 信息收集之贯穿全局
字数 3929 2025-08-11 17:40:24
渗透测试信息收集全面指南
信息收集概述
信息收集是渗透测试中最关键的阶段,决定了后续测试的广度和深度。本指南将全面介绍渗透测试各阶段的信息收集技术和方法。
授权与范围确认
- 授权测试范围:必须明确哪些系统/资产可以测试,哪些禁止测试
- 目标备忘录:将所有授权测试目标整理成清单
域名信息收集
Whois查询
- 用途:查询域名注册信息(所有人、注册商、注册/到期时间等)
- 工具:
- 命令行:
whois - 在线查询:
- http://whois.chinaz.com/
- https://www.virustotal.com/gui/home/url
- https://www.threatminer.org/
- 命令行:
DNS信息收集
重点关注:
- 域名注册商
- 管理员联系方式(电话/邮箱)
- 子域名信息
常用工具:
- https://site.ip138.com/
- http://ce.baidu.com/index/getRelatedSites?site_address=baidu.com
- https://www.circl.lu/services/passive-dns/#passive-dns
- https://hackertarget.com/find-dns-host-records/
- https://riddler.io/search?q=pld:baidu.com
- https://dns.bufferover.run/dns?q=.baidu.com
- https://dnsdb.io/zh-cn/search?q=baidu.com
- http://ipv4info.com/
- https://www.robtex.com/dns-lookup/
- https://alexa.chinaz.com/
- https://searchdns.netcraft.com/
- https://docs.securitytrails.com/v1.0/reference#get-domain
- https://dnsdumpster.com/
- http://www.sitedossier.com/
- https://www.threatcrowd.org/
- https://siterankdata.com/
- https://findsubdomains.com/
企业信息收集
- 小蓝本
- 启信宝
- 搜赖网
- 天眼查
- 企查查
- 信用视界
- 备案查询:https://www.beian88.com/
网站目录与文件挖掘
重点关注
- robots.txt:可能泄露敏感目录
- 网站备份文件(源码、配置、数据库)
- 后台目录(弱口令、爆破)
- 安装包(可能包含数据库信息)
- 上传目录(文件上传漏洞)
- MySQL管理接口
- 安装页面
- phpinfo文件
- 编辑器(如fck、ke等)
- IIS短文件利用
探测工具
- IntelliTamper
- wwwscan
- 御剑
- weakfilescan
- dirbuster
- dirb
- QWASP
- Google Hacking
物理路径探测方法
- 探针文件:phpinfo.php、info.php、test.php
- 报错信息:404页面、动态URL加特殊符号
- 后台信息:CMS版本、组件、数据库信息等
- IIS特性:IIS7-IIS8.5可能泄露路径
- 搜索引擎
邮件服务器信息
- 可能存在的漏洞:XSS、SQL、XXE、心脏出血等
- 弱口令爆破
- 钓鱼攻击
- 可能是外网入口(传递VPN/服务器密码)
敏感文件泄露
- GitHub/Gitee代码托管平台
- CMS识别
- 源码泄露(git、svn、hg等)
- 网站备份压缩文件
- WEB-INF/web.xml泄露
- DS_Store文件泄露
- SWP文件泄露
- CVS/Bzr泄露
- composer.json泄露
Google Hacking语法
"Login: " "password =" filetype:xls
allinurl: auth_user_file.txt
filetype:xls inurl:"password.xls"
intitle:login password
intitle:"Index of" master.passwd
index of / **backup**
intitle:index.of people.lst
intitle:index.of passwd.bak
intitle:"Index of" pwd.db
intitle:"Index of .. etc" passwd
index.of passlist.txt
index.of.secret
filetype:xls username password email
"# PhpMyAdmin MySQL-Dump" filetype:txt
inurl:ipsec.secrets-history-bugs
inurl:ipsec.conf-intitle:manpage
inurl:"wvdial.conf" intext:"password"
inurl:"user.xls" intext:"password"
filetype:ldb admin
inurl:search/admin.php
inurl:password.log filetype:log
filetype:reg HKEY_CURRENT_USER username
"http://username:password@www..." filetype:bak inurl:"htaccess|passwd|shadow|htusers"
filetype:ini ws_ftp pwd
intitle:"Index of" pwd.db
inurl:admin inurl:backup intitle:index.of
"Index of/" "Parent Directory" "WS_FTP.ini" filetype:ini WS_FTP PWD
ext:pwd inurl:(service|authors|administrators|users
filetype:sql ("passwd values" "password values" "pass values")
子域名挖掘工具
- Sylas:https://github.com/Acmesec/Sylas
- SubDomainsBrute
- wydomain:https://github.com/ring04h/wydomain.git
- layer
- 御剑
- 7kbscan
- dnsenum
- OneForAll:https://github.com/shmilylty/OneForAll
端口与服务识别
常见端口及服务
- 3306:MySQL
- 1433:MSSQL
- 1521:Oracle
- 5432:PostgreSQL
- 6379:Redis
- 27017:MongoDB
- 8080:Tomcat/Resin/Jetty
- 137:Samba
- 5900:VNC
- 443:HTTPS
- 21:FTP(弱密码)
- 22:SSH(弱密码)
- 23:Telnet(弱密码)
- 25:邮件伪造
- 53:DNS漏洞
- 161:SNMP(默认团体字符串)
端口扫描工具
- nmap
指纹识别
工具与资源
- WhatWeb:https://whatweb.net/
- BugScaner:http://whatweb.bugscaner.com/look/
- 云悉指纹:http://www.yunsee.cn/finger.html
- CMSmap:https://github.com/dionach/CMSmap
- kali wpScan(针对WordPress)
- kali joomScan(针对Joomla!)
- 潮汐指纹:http://finger.tidesec.net/
- 数字观星:https://fp.shuziguanxing.com/#
- Wappalyzer:https://github.com/AliasIO/wappalyzer
真实IP查找
方法
- 多地ping测试(17ce.com)
- 邮箱服务器分析
- 证书信息
- 备案信息
- 接口分析
- SSRF记录
- 测试文件扫描
- 黑暗引擎(FOFA)icon识别
- 全网扫描:https://github.com/Tai7sy/fuckcdn
- RSS订阅
- APP反编译
- 修改hosts文件
超级ping工具
- https://www.itdog.cn/
- https://ping.sx/
- http://ping.chinaz.com/
- http://ping.aizhan.com/
- http://ce.cloud.360.cn/
- https://www.17ce.com/
WAF识别
方法
- 手工:提交恶意数据测试
- 工具:
- WAFW00F
- Nmap
- Sqlmap
社会工程学
信息收集渠道
- QQ、微博、支付宝、脉脉、领英、闲鱼、短视频、人人、贴吧、论坛
- 外网信息(推特、ins、fb等)
- 近源攻击(伪装客服/员工)
- 钓鱼攻击
参考资源
- 《欺骗的艺术》
搜索引擎利用
- Google:google.com
- Shodan:shodan.io
- Censys:censys.io
- Hunter:hunter.io
- FOFA:fofa.so
- ZoomEye:zoomeye.org
- 360Quake
- PublicWWW:publicwww.com
- Pulsedive:pulsedive.com
- Intelx:intelx.io
- WiGLE:wigle.net
- Reposify:reposify.com
- GreyNoise:viz.greynoise.io
扩展思路
- 网盘泄露
- 公众号
- 小程序
内网横向移动
信息收集重点
- 用户列表
- Windows用户
- 邮件用户(通常是域用户)
- 进程列表
- 杀毒软件/安全监控工具
- 邮件客户端、VPN、FTP等
- 服务列表
- 安全防范相关服务
- 存在问题的服务
- 端口列表
- 开放端口对应服务
- 补丁列表
- Windows补丁
- 第三方软件漏洞
- 本机共享
- 共享列表及权限
- 用户习惯
- 历史记录
- 收藏夹
- 文档等
Windows密码获取工具
- mimikatz
- wce
- Invoke-WCMDump
- mimiDbg
- LaZagne
- nirsoft_package
- QuarksPwDump
- fgdump
- 星号查看器
Linux密码获取工具
- LaZagne
- mimipenguin
浏览器密码获取
- HackBrowserData
- SharpWeb
- SharpDPAPI
- 360SafeBrowsergetpass
其他密码工具
- SharpDecryptPwd
- Decrypt_Weblogic_Password
- OA-Seeyou
常用内网命令
ipconfig /all # 查询本机IP段和域信息
net user # 本机用户列表
net localgroup administrators # 本机管理员
net user /domain # 查询域用户
net group /domain # 查询域工作组
net group "domain admins" /domain # 查询域管理员
net view # 查询同一域内机器列表
net view /domain # 查询域列表
dsquery computer domainroot -limit 65535 # 列出域内所有机器名
dsquery user domainroot -limit 65535 # 列出域内所有用户名
dsquery subnet # 列出域内网段划分
dsquery group # 列出域内分组
dsquery ou # 列出域内组织单位
dsquery server # 列出域控制器
net time /domain # 查询域控制器
内网提权
信息收集
系统信息
cat /etc/issue
cat /etc/*-release
cat /etc/lsb-release # Debian
cat /etc/redhat-release # Redhat
uname -a # 内核版本
uname -mrs # 系统架构
rpm -q kernel # Redhat内核
dmesg | grep Linux
ls /boot | grep vmlinuz-
环境变量
cat /etc/profile
cat /etc/bashrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.bash_logout
env
set
echo $PATH
应用与服务
ps aux
ps -ef
top
cat /etc/services
ps aux | grep root
ls -alh /usr/bin/
ls -alh /sbin/
dpkg -l # Debian
rpm -qa # Redhat
ls -alh /var/cache/apt/archives
ls -alh /var/cache/yum/
服务配置检查
cat /etc/syslog.conf
cat /etc/chttp.conf
cat /etc/lighttpd.conf
cat /etc/cups/cupsd.conf
cat /etc/inetd.conf
cat /etc/apache2/apache2.conf
cat /etc/my.conf
cat /etc/httpd/conf/httpd.conf
cat /opt/lampp/etc/httpd.conf
ls -aRl /etc/ | awk '$1 ~ /^.*r.*/'
计划任务
crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/at.allow
cat /etc/at.deny
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root
敏感信息搜索
grep -i user [filename]
grep -i pass [filename]
grep -C 5 "password" [filename]
find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password"
网络信息
/sbin/ifconfig -a
cat /etc/network/interfaces
cat /etc/sysconfig/network
cat /etc/resolv.conf
cat /etc/sysconfig/network
cat /etc/networks
iptables -L
hostname
dnsdomainname
网络连接
netstat -anlp
netstat -ano
lsof -i
lsof -i :80
grep 80 /etc/services
netstat -antup
netstat -antpx
netstat -tulpn
chkconfig --list
chkconfig --list | grep 3:on
last
arp -e
route
/sbin/route -nee
数据包嗅探
tcpdump tcp dst 192.168.1.7 80 and tcp dst 10.5.5.252 21
交互shell获取
python -c 'import pty;pty.spawn("/bin/bash")'
echo os.system('/bin/bash')
/bin/sh -i
文件系统信息
mount
df -h
cat /etc/fstab
文件权限检查
find / -perm -1000 -type d 2>/dev/null # Sticky bit
find / -perm -g=s -type f 2>/dev/null # SGID
find / -perm -u=s -type f 2>/dev/null # SUID
find / -perm -g=s -o -perm -u=s -type f 2>/dev/null
可写目录
find / -writable -type d 2>/dev/null
find / -perm -222 -type d 2>/dev/null
find / -perm -o w -type d 2>/dev/null
find / -perm -o x -type d 2>/dev/null
find / $ -perm -o w -perm -o x $ -type d 2>/dev/null
问题文件检查
find / -xdev -type d $ -perm -0002 -a ! -perm -1000 $ -print
find /dir -xdev $ -nouser -o -nogroup $ -print
开发工具检查
find / -name perl\*
find / -name python\*
find / -name gcc\*
find / -name cc
文件上传方式
find / -name wget
find / -name nc*
find / -name netcat*
find / -name tftp*
find / -name ftp
用户信息
who
w
last
cat /etc/passwd | cut -d: -f1
grep -v -E "^#" /etc/passwd
cat /etc/sudoers
sudo -l
敏感文件检查
cat /etc/passwd
cat /etc/group
cat /etc/shadow
ls -alh /var/mail/
ls -ahlR /root/
ls -ahlR /home/
cat ~/.bash_history
cat ~/.nano_history
cat ~/.atftp_history
cat ~/.mysql_history
cat ~/.php_history
SSH密钥检查
cat ~/.ssh/authorized_keys
cat ~/.ssh/identity.pub
cat ~/.ssh/identity
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa
cat ~/.ssh/id_dsa.pub
cat ~/.ssh/id_dsa
cat /etc/ssh/ssh_config
cat /etc/ssh/sshd_config
cat /etc/ssh/ssh_host_dsa_key.pub
cat /etc/ssh/ssh_host_dsa_key
cat /etc/ssh/ssh_host_rsa_key.pub
cat /etc/ssh/ssh_host_rsa_key
cat /etc/ssh/ssh_host_key.pub
cat /etc/ssh/ssh_host_key
可写配置文件
ls -aRl /etc/ | awk '$1 ~ /^.*w.*/' 2>/dev/null
ls -aRl /etc/ | awk '$1 ~ /^..w/' 2>/dev/null
ls -aRl /etc/ | awk '$1 ~ /w.$/' 2>/dev/null
find /etc/ -readable -type f 2>/dev/null
find /etc/ -readable -type f -maxdepth 1 2>/dev/null
网站文件检查
ls -alh /var/www/
ls -alh /srv/www/htdocs/
ls -alh /usr/local/www/apache22/data/
ls -alh /opt/lampp/htdocs/
ls -alh /var/www/html/
日志文件检查
cat /etc/httpd/logs/access_log
cat /etc/httpd/logs/access.log
cat /etc/httpd/logs/error_log
cat /etc/httpd/logs/error.log
cat /var/log/apache2/access_log
cat /var/log/apache2/access.log
cat /var/log/apache2/error_log
cat /var/log/apache2/error.log
cat /var/log/apache/access_log
cat /var/log/apache/access.log
cat /var/log/auth.log
cat /var/log/chttp.log
cat /var/log/cups/error_log
cat /var/log/dpkg.log
cat /var/log/faillog
cat /var/log/lastlog
cat /var/log/messages
cat /var/log/secure
cat /var/log/syslog
cat /var/log/wtmp
cat /var/log/xferlog
cat /var/log/yum.log
cat /var/run/utmp
cat /var/webmin/miniserv.log
cat /var/www/logs/access_log
cat /var/www/logs/access.log
ls -alh /var/lib/dhcp3/
ls -alh /var/log/postgresql/
ls -alh /var/log/proftpd/
ls -alh /var/log/samba/
Windows提权
检测工具
- Windows-Exploit-Suggester
- WinSystemHelper
- wesng
- http://bugs.hacking8.com/tiquan/
利用工具
- windows-kernel-exploits
- BeRoot
报告撰写
报告要素
- 规范信息:目标、受众、时间、密级等
- 漏洞证明:截图、时间戳、脚本、日志记录
- 复现步骤
不同受众
- 甲方报告:通俗易懂,侧重危害和修复建议
- 技术人员报告:专业技术细节,复现步骤和原理
总结
信息收集是渗透测试的基础,本指南涵盖了从外网信息收集到内网横向移动的全面技术和方法。实际测试中应根据目标环境和授权范围灵活运用这些技术,并不断更新知识库以应对新的安全挑战。