gpt4 book ai didi

python - Pycharm - 在 WSL 上使用带有远程解释器的 pwntools

转载 作者:行者123 更新时间:2023-12-05 04:05:26 25 4
gpt4 key购买 nike

我在 WSL 上的 pycharm 上使用远程解释器(使用本教程配置它:https://www.jetbrains.com/help/pycharm/using-wsl-as-a-remote-interpreter.html)

我能够成功运行我需要的一切,但是当我尝试使用 pwntools ( https://github.com/Gallopsled/pwntools ) 时,我能够在 WSL bash python 解释器上成功导入它,但在 Pycharm 上却没有。

这是我运行的:

from pwn import *

在 Pycharm 上它被卡住了,我打断了它,这是异常的痕迹(它卡住的地方):

ssh://shahar@localhost:22/usr/bin/python -u /tmp/pycharm_project_271/pwnablekr/fd.py
Traceback (most recent call last):
File "/tmp/pycharm_project_271/pwnablekr/fd.py", line 1, in <module>
from pwn import *
File "/home/shahar/.local/lib/python2.7/site-packages/pwn/__init__.py", line 6, in <module>
pwnlib.args.initialize()
File "/home/shahar/.local/lib/python2.7/site-packages/pwnlib/args.py", line 208, in initialize
term.init()
File "/home/shahar/.local/lib/python2.7/site-packages/pwnlib/term/__init__.py", line 74, in init
term.init()
File "/home/shahar/.local/lib/python2.7/site-packages/pwnlib/term/term.py", line 109, in init
c = os.read(fd.fileno(), 1)
KeyboardInterrupt

Process finished with exit code 1
enter code here

在我的 WSL bash 上它运行得很好:

shahar@MYCOMPUTERNAME:/mnt/c/Users/shahar$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pwn import *
>>>

当我查看它卡住的那段代码时(从异常的痕迹来看):

while True:
c = os.read(fd.fileno(), 1)
s += c
if c == 'R':
break

在脚本的开头作为全局变量:

fd = sys.stdout

我从互联网上了解到这个函数(这个循环是其中的一部分)与接管终端有关。也许这与我不是从终端运行的事实有关?以前有人见过这种问题吗?有一些有用的提示吗?

非常感谢!

最佳答案

我也有一个潜在的修复方法,它正在向环境中添加一个 PWNLIB_NOTERM。

import os
os.environ['PWNLIB_NOTERM'] = 'True' # Configuration patch to allow pwntools to be run inside of an IDE
import pwn

Screenshot showing it runs and we get an Encoder object instance

关于python - Pycharm - 在 WSL 上使用带有远程解释器的 pwntools,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51225662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com