创建一个Chroot监狱并将所有系统文件复制到监狱 [英] Create a Chroot Jail and copy all system files into jail

查看:220
本文介绍了创建一个Chroot监狱并将所有系统文件复制到监狱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在linux中创建chroot监狱,但我无权访问ls/cd/gcc/g ++之类的任何系统文件.我需要复制到chroot监狱的必要libs/bin/systme文件是什么?

I am creating chroot jail in linux , but i do not have access to any system file like ls/cd/gcc/g++. What are the necessary libs/bin/systme files i need to copy to my chroot jail ?

推荐答案

可执行文件(如ls/cd/gcc/g ++),它们依赖于共享库(除非您没有将它们静态地构建).因此,您需要做的就是将所有这些共享库依赖项复制到适当的位置到您的chroot监狱中,您还需要查找那些共享依赖项是什么.要找出您需要"ldd"的帮助.

Executables like ls/cd/gcc/g++, they depend on shared library (unless you didn't build them to be statically). So, what you need to do is copy all those shared library dependencies to appropriate location into your chroot jail, also you need to find what are those shared dependencies are. To find out you need help from "ldd".

要查看gcc具有哪些共享依赖项,请执行以下操作:

To see what shared dependencies gcc has, do the following:

           ldd /usr/bin/gcc

在我的系统上,它显示以下输出:

On my system it shows the following output:

linux-vdso.so.1 =>  (0x00007fffd9bff000)
libc.so.6 => /lib64/libc.so.6 (0x00000030c9c00000)
/lib64/ld-linux-x86-64.so.2 (0x00000030c9800000)

因此,gcc具有标准c库libc.so的依赖关系,并且还需要ld(可执行加载程序),将这些共享库与gcc一起放入chroot监狱的适当位置(即/lib64下的libc).因此,在您调用gcc时,gcc可以加载必要的内容.

So, gcc has the dependency of standard c library libc.so and it also needs ld (executable loader), place these shared libraries into appropriate place (i.e libc under /lib64) into your chroot jail, along with gcc. So gcc can load necessary stuffs while you call gcc.

这篇关于创建一个Chroot监狱并将所有系统文件复制到监狱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆