Pycharm - 使用pwntools与WSL远程解释

问题描述 投票:1回答:2

我使用上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

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

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

我从这个函数(该环是其中的一部分)来接管终端是与因特网理解。也许这是有关我不是从终端上运行的事实?没有任何人看到这样的问题之前?有一些有用的技巧?

非常感谢你!

python pycharm stdout windows-subsystem-for-linux pwntools
2个回答
0
投票

目前尚无有效办法,我调试它,问题是initialization.it也可能涉及到的术语和TERMINFO.My解决方案的环境变量项修改/usr/local/lib/python2.7/dist-packages/pwnlib/args.py的最后一行,删除term.init(),用别的代替它绕过pwnlib的初始化。

替换此行:

调试pwntools:


0
投票

我有一个可能的解决方法,以及,它增加了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

© www.soinside.com 2019 - 2024. All rights reserved.