带pysandbox的受限函数(RF)

2024-05-17 09:54:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题和herehere完全一样。你知道吗

我还使用simple2.py对该程序生成的可执行文件进行沙盒处理test1.c

 #include<stdio.h>
 int main(){
     puts("Hello World");
     return 0;
 }

我正在使用以下命令构建可执行文件:

gcc -static test1.c

在此之后,如果我这样做:

ldd a.out

我得到输出:

not a dynamic executable

但是,运行sample2.py时的结果仍然是

result: RF
cpu: 0ms
mem: 952kB

我到底做错了什么?你知道吗


Tags: py程序沙盒可执行文件helloworldreturnhere
2条回答

RF结果代码很可能是由于文件操作的意外系统调用(即SYS\u open()、SYS\u close()、SYS\u stat()、…)。当(1)目标程序实际执行文件操作时,以及(或)当(2)它被动态链接并且需要在运行时加载.so库时,就会发生这种情况。因为目标程序不调用文件操作,所以它属于后一种情况。你知道吗

然后,为了解决射频结果

statically link the target program to avoid dependencies on shared libraries; or,
extend the policy rules in the wrapper script to handle relevant SYSCALL / SYSRET events;

对于静态链接系统调用,我们使用ex0,1,2的系统调用代码 3系统读取 1-系统出口 等等 通过链接了解更多详细信息 代码为的系统调用列表链接: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html

我改变这个:

x86_=集合([0,1,5,8,9,10,11,12,16,21,25,63,89158219231])

为此:

x86_=集合([0,1,2,3,4,5,8,9,10,11,12,16,21,25,63,89158219231,])

在sample2.py中,它是有效的。你知道吗

修改后的sample2.py可在my github存储库链接中找到: https://github.com/palashmaran/libsandbox.git

我改变这个:

x86_64=set([0,1,5,8,9,10,11,12,16,25,63,158,219,231])

为此:

x86_64=set([0,1,5,8,9,10,11,12,16,21,25,63,89,158,219,231])

在sample2.py中,它是有效的。你知道吗

相关问题 更多 >