【Python】第三方程序、库【scapy】
关于scapy的简介在https://github.com/secdev/scapy/有比较详细的描述,摘取原文中一段儿“它可以轻松处理大多数经典任务,如扫描,跟踪路由,探测,单元测试,攻击或网络发现(它可以取代hping,85%的nmap,arpspoof,arp-sk,arping,tcpdump,wireshark,p0f等)”
安装scapy可以在线安装和离线安装(作者采用离线安装)
一、在线安装(当前所处的环境或者说时间节点,需要翻墙或者代理)
1 2 3 4 5 6 7 8 9 10 |
[root@xxf ~]# pip3 install scapy Collecting scapy Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5d10f85f60>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scapy/ Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5d10f855c0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scapy/ Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5d10f852e8>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scapy/ Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5d10f85438>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scapy/ Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5d10f85908>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scapy/ Could not find a version that satisfies the requirement scapy (from versions: ) No matching distribution found for scapy [root@xxf ~]# |
二、离线安装
1)下载安装包scapy-2.4.0.tar.gz
2)上传至python环境所在的服务器、解包
3)安装
1 2 3 4 |
[root@xxf scapy-2.4.0]# ls bin build doc MANIFEST.in PKG-INFO README run_scapy scapy setup.cfg setup.py test [root@xxf scapy-2.4.0]# [root@xxf scapy-2.4.0]# python3 setup.py install |
4)验证(有三个警告和几个提示信息,是因为我们没有安装一些可选包,提示一些功能不可用,但基本的功能是没有问题的)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[root@xxf scapy-2.4.0]# scapy WARNING: Cannot read wireshark manuf database INFO: Can't import matplotlib. Won't be able to plot. INFO: Can't import PyX. Won't be able to use psdump() or pdfdump(). WARNING: No route found for IPv6 destination :: (no default route?) INFO: Can't import python-cryptography v1.7+. Disabled WEP decryption/encryption. (Dot11) INFO: Can't import python-cryptography v1.7+. Disabled IPsec encryption/authentication. WARNING: IPython not available. Using standard Python shell instead. AutoCompletion, History are disabled. aSPY//YASa apyyyyCY//////////YCa | sY//////YSpcs scpCY//Pp | Welcome to Scapy ayp ayyyyyyySCP//Pp syY//C | Version 2.4.0 AYAsAYYYYYYYY///Ps cY//S | pCCCCY//p cSSps y//Y | https://github.com/secdev/scapy SPPPP///a pP///AC//Y | A//A cyP////C | Have fun! p///Ac sC///a | P////YCpc A//A | Craft me if you can. scccccp///pSP///p p//Y | -- IPv6 layer sY/////////y caa S//P | cayCyayP//Ya pY/Ya sY/PsY////YCc aC//Yp sc sccaCY//PCypaapyCP//YSs spCPY//////YPSps ccaacs >>> |