C : chroot 内的 system() 调用
我有一个用 C 编写的程序,它在监狱内运行 chroot,它会进行一些系统调用,例如 system ("ls")
。问题是当我在监狱内运行该程序时,该程序不会执行系统调用。我已经包含了可执行文件的所有必要库(使用 ldd
bash 命令找到它们),以及 bash 可执行文件( /bin/bash
),以及它的库(也使用 ldd 找到)。似乎少了点什么。有人对此有什么想法吗?
I have a program written in C, which runs chrooted, inside a jail, that makes some system calls e.g system ( "ls" )
. The problem is that the program does not execute the system calls when I run it inside the jail. I have included all the necessary libraries of the executable ( found them with ldd
bash command ), along with the bash executable ( /bin/bash
), and it's libraries ( also found with ldd
). It seems that something is missing. Does anyone have an idea about that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据定义,
system
运行“/bin /sh -c <命令>"。将
/bin/sh
复制到您的 chroot 监狱(或将其链接到 /bin/bash),您应该可以开始了。By definition,
system
runs "/bin/sh -c <command>".Copy
/bin/sh
to your chroot jail (or link it to /bin/bash) and you should be good to go.这可能有效,但拥有 chroot 的目的通常是为了防止攻击者执行任意 shell 命令。一旦你将 /bin/sh 放入 chroot 监狱中,你就已经消除了拥有 chroot 监狱的任何目的。
That might work, but the purpose of having a chroot is generally to prevent attackers from being able to execute arbitrary shell commands. Once you have put /bin/sh into a chroot jail you've eliminated any purpose to having the chroot jail in the first place.