scapy安装


1、安装

1)下载源文件

wget https://pypi.python.org/packages/6d/72/c055abd32bcd4ee6b36ef8e9ceccc2e242dea9b6c58fdcf2e8fd005f7650/scapy-2.3.2.tar.gz#md5=b8ca06ca3b475bd01ba6cf5cdc5619af

2)解压,然后进入目录,执行安装命令,如下

[root@LFA-L0038215 ~]# tar xvf scapy-2.3.2.tar.gz
[root@LFA-L0038215 ~]# cd scapy-2.3.2/
[root@LFA-L0038215 ~]# ls
bin  doc  MANIFEST.in  PKG-INFO  run_scapy  scapy  setup.py  test
[root@LFA-L0038215 ~]# python setup.py install

2 使用命令

>>> a=Ether()/IP(dst="www.baidu.com")/TCP()/"GET index.html HTTP/1.0 \n\n"

>>> hexdump(a)

0000   00 16 3F AA AA AA 02 01  02 74 00 2F 08 00 45 00   ..?......t./..E.

0010   00 42 00 01 00 00 40 06  63 1A 78 34 4E AE 77 4B   .B....@.c.x4N.wK

0020   D9 6D 00 14 00 50 00 00  00 00 00 00 00 00 50 02   .m...P........P.

0030   20 00 90 5C 00 00 47 45  54 20 69 6E 64 65 78 2E    ..\..GET index.

0040   68 74 6D 6C 20 48 54 54  50 2F 31 2E 30 20 0A 0A   html HTTP/1.0 ..

>>> 

>>> b=str(a)

>>> b

'\x00\x16?\xaa\xaa\xaa\x02\x01\x02t\x00/\x08\x00E\x00\x00B\x00\x01\x00\x00@\x06c\x1ax4N\xaewK\xd9m\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x90\\\x00\x00GET index.html HTTP/1.0 \n\n'

>>> c=Ether(b)

>>> c

<Ether  dst=00:16:3f:aa:aa:aa src=02:01:02:74:00:2f type=IPv4 |<IP  version=4L ihl=5L tos=0x0 len=66 id=1 flags= frag=0L ttl=64 proto=tcp chksum=0x631a src=120.52.78.174 dst=119.75.217.109 options=[] |<TCP  sport=ftp_data dport=http seq=0 ack=0 dataofs=5L reserved=0L flags=S window=8192 chksum=0x905c urgptr=0 options=[] |<Raw  load='GET index.html HTTP/1.0 \n\n' |>>>>

>>> a

<Ether  type=IPv4 |<IP  frag=0 proto=tcp dst=Net('www.baidu.com') |<TCP  |<Raw  load='GET index.html HTTP/1.0 \n\n' |>>>>


你可能感兴趣的:(python)