2017-07-26 58 views
0

我在windows環境下Scapy的正常工作。但我無法讀取控制檯上的輸出。問題在於我的導入scapy的具體文件。如果我直接運行scapy,那麼控制檯上的輸出是可讀的格式。Pyreadline不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 

回答

0

通過安裝包「COLORAMA」能夠解決問題。這個問題已經在以下thread討論的答案給出爲好。安裝軟件包後,我在腳本中添加了以下代碼。

from colorama 
init(convert=True)