Pyreadline与scapy无法正常工作

时间:2017-07-26 12:54:13

标签: python-2.7 scapy

我在windows环境中使用scapy。但我无法在控制台上读取输出。问题出在我导入scapy的特定文件中。如果我直接运行scapy,那么控制台上的输出是可读格式。

Welcome to Scapy (2.3.3)
Working
>>> packet = TCP()
>>> packet.show()
←[0m###[←[0m ←[31m←[1mTCP←[0m ←[0m]###←[0m
  ←[34msport←[0m←[0m=←[0m ←[35mftp_data←[0m
  ←[34mdport←[0m←[0m=←[0m ←[35mhttp←[0m
  ←[34mseq←[0m←[0m=←[0m ←[35m0←[0m
  ←[34mack←[0m←[0m=←[0m ←[35m0←[0m
  ←[34mdataofs←[0m←[0m=←[0m ←[35mNone←[0m
  ←[34mreserved←[0m←[0m=←[0m ←[35m0←[0m
  ←[34mflags←[0m←[0m=←[0m ←[35mS←[0m
  ←[34mwindow←[0m←[0m=←[0m ←[35m8192←[0m
  ←[34mchksum←[0m←[0m=←[0m ←[35mNone←[0m
  ←[34murgptr←[0m←[0m=←[0m ←[35m0←[0m
  ←[34moptions←[0m←[0m=←[0m ←[35m[]←[0m

>>>
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Python27\lib\atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "C:\Python27\lib\site-packages\scapy\main.py", line 244, in scapy_write_h
istory_file
    readline.write_history_file(conf.histfile)
  File "C:\Python27\lib\site-packages\pyreadline\rlmain.py", line 169, in write_
history_file
    self.mode._history.write_history_file(filename)
  File "C:\Python27\lib\site-packages\pyreadline\lineeditor\history.py", line 94
, in write_history_file
    fp.write(ensure_str(line.get_line_text()))
  File "C:\Python27\lib\site-packages\pyreadline\lineeditor\lineobj.py", line 25
6, in get_line_text
    buf = list(map(ensure_unicode, buf))
NameError: global name 'map' is not defined
Error in sys.exitfunc:
Traceback (most recent call last):
  File "C:\Python27\lib\atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "C:\Python27\lib\site-packages\scapy\main.py", line 244, in scapy_write_h
istory_file
    readline.write_history_file(conf.histfile)
  File "C:\Python27\lib\site-packages\pyreadline\rlmain.py", line 169, in write_
history_file
    self.mode._history.write_history_file(filename)
  File "C:\Python27\lib\site-packages\pyreadline\lineeditor\history.py", line 94
, in write_history_file
    fp.write(ensure_str(line.get_line_text()))
  File "C:\Python27\lib\site-packages\pyreadline\lineeditor\lineobj.py", line 25
6, in get_line_text
    buf = list(map(ensure_unicode, buf))
NameError: global name 'map' is not defined

1 个答案:

答案 0 :(得分:0)

安装包裹' Colorama'能够解决问题。此问题已在以下thread中进行了讨论,并给出了答案。安装软件包后,我将以下代码添加到我的脚本中。

from colorama
init(convert=True)