Python“jail”在xinetd上没有输出

2024-05-13 20:44:11 发布

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

我正在尝试在某处发现的一个不安全的Python“监狱”,当我在本地运行并执行它时,它工作得很好。然而,当我为它创建一个xinetd服务时,我可以对它进行netcat,它看起来确实是连接的,但是我看不到任何输出。python文件是:

#!/usr/bin/python -u

from sys import modules
modules.clear()
del modules

_raw_input = raw_input
_BaseException = BaseException
_EOFError = EOFError

__builtins__.__dict__.clear()
__builtins__ = None

print 'Get a shell, if you can...'

while 1:
  try:
    d = {'x':None}
    exec 'x='+_raw_input()[:50] in d
    print 'Return Value:', d['x']
  except _EOFError, e:
    raise e
  except _BaseException, e:
    print 'Exception:', e

xinetd文件是:

^{pr2}$

我只需连接“nc ip地址端口”。在

更新1: 当我越狱并输入任何命令,如'ls-la',我确实得到了输出。看来打印报表有问题吗?在


Tags: 文件nonemodulesinputrawusrprintclear