主要是执行下面的命令时遇到两个报错:python
from scapy.all import *
1."IndexError: list index out of range" 这个问题去google,查到说是由于安装cisco的缘由,须要修改pythonhome\Lib\site-packages\scapy\arch\windows目录下"init.py"(注意,init先后分别有两个下划线,不知为什么不能显示)文件的_exec_query_ps函数,修改内容以下:git
def _exec_query_ps(cmd, fields): """Execute a PowerShell query""" ps = sp.Popen([conf.prog.powershell] + cmd + ['|', 'select %s' % ', '.join(fields), '|', 'fl'], stdout=sp.PIPE, universal_newlines=True) l=[] for line in ps.stdout: if not line.strip(): #skip empty lines continue fv=line.split(':',1) if len(fv) == 1: l[-1] += fv[0].strip() continue else: l.append(fv[1].strip()) #l.append(line.split(':', 1)[1].strip()) if len(l) == len(fields): yield l l=[]
修改第一个问题后,再次执行"from scapy.all import *",报错:ImportError:cannt import name read_routesgithub
出现这个问题的缘由后来从一个群友处得知,是由于我安装的python是32-bit,计算机是64-bit.后来将python更换为64-bit,再执行"from scapy.all import *"就没有再出现什么奇葩的问题.shell
因此,你们在安装python时,尽肯能的安装和系统位数同样的版本.windows
附注: 第一个报错解决方法相关连接: https://github.com/secdev/scapy/issues/400app