linuxScapy進(jìn)行arp數(shù)據(jù)包詳細(xì)過程

root@hak:~# scapy
WARNING: No route found for IPv6 destination :: (no default route?)
INFO: Can't import python ecdsa lib. Disabled certificate manipulation tools
Welcome to Scapy (unknown.version)

創(chuàng)新互聯(lián)公司主要從事做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)井陘礦,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108

a=Ether()/ARP()
a.show()
###[ Ethernet ]###
dst= 00:50:56:ef:49:1f
src= 00:0c:29:e2:bb:15
type= 0x806
###[ ARP ]###
hwtype= 0x1
ptype= 0x800
hwlen= 6
plen= 4
op= who-has
hwsrc= 00:0c:29:e2:bb:15
psrc= 192.168.80.250
hwdst= 00:00:00:00:00:00
pdst= 0.0.0.0

arp1=srp(Ether(src='00:0c:29:e2:bb:15',dst='FF:FF:FF:FF:FF:FF')/ARP(op=1,hwsrc='00:0c:29:e2:bb:15',hwdst='00:00:00:00:00:00',psrc='192.168.80.250',pdst='192.168.80.251',))
Begin emission:
*Finished to send 1 packets.

Received 1 packets, got 1 answers, remaining 0 packets
1)>>> print(arp1)
(<Results: TCP:0 UDP:0 ICMP:0 Other:1>, <Unanswered: TCP:0 UDP:0 ICMP:0 Other:0>)
產(chǎn)生收到響應(yīng)與沒收到響應(yīng)元組;
2)查看arp1的數(shù)據(jù)類型:

print(type(arp1))
<type 'tuple'> 為元組
3)用元組的方法只打印接收?qǐng)?bào)文:
print(arp1[0])
<Results: TCP:0 UDP:0 ICMP:0 Other:1>
4)顯示arp1[0]數(shù)據(jù)類型:
print(type(arp1[0]))
<class 'scapy.plist.SndRcvList'>
5)查看該'scapy.plist.SndRcvList數(shù)據(jù)類型處理方法(上網(wǎng)查看https://fossies.org/dox/scapy-2.3.3/)用res的方法
6)產(chǎn)生響應(yīng)數(shù)據(jù)包中的發(fā)送與接收的包,并把包res方法列出來
print(arp1[0].res)*第一對(duì)發(fā)送包與收發(fā)包
[(<Ether dst=FF:FF:FF:FF:FF:FF src=00:0c:29:e2:bb:15 type=0x806 |<ARP op=who-has hwsrc=00:0c:29:e2:bb:15 psrc=192.168.80.250 hwdst=00:00:00:00:00:00 pdst=192.168.80.251 |>>, <Ether dst=00:0c:29:e2:bb:15 src=00:0c:29:21:fd:03 type=0x806 |<ARP hwtype=0x1 ptype=0x800 hwlen=6 plen=4 op=is-at hwsrc=00:0c:29:21:fd:03 psrc=192.168.80.251 hwdst=00:0c:29:e2:bb:15 pdst=192.168.80.250 |<Padding load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>)]
7)提出收包數(shù)據(jù)
print(arp1[0].res[0][1])
8)查看arp1[0].res[0][1]數(shù)據(jù)類型:
print(type(arp1[0].res[0][1]))
<class 'scapy.layers.l2.Ether'>
9)查看該scapy.layers.l2.Ether數(shù)據(jù)類型處理方法(上網(wǎng)查看https://fossies.org/dox/scapy-2.3.3/)用
Static Public Attributes
string name = "Ethernet"

list fields_desc

的方法
10)用fields方法(產(chǎn)生相應(yīng)得字典)提取收包數(shù)據(jù):
print(arp1[0].res[0][1].fields)
{'src': '00:0c:29:21:fd:03', 'dst': '00:0c:29:e2:bb:15', 'type': 2054}
11)用show方法讀取收包數(shù)據(jù):
print(arp1[0].res[0][1].show())
###[ Ethernet ]###
dst= 00:0c:29:e2:bb:15
src= 00:0c:29:21:fd:03
type= 0x806
###[ ARP ]###
hwtype= 0x1
ptype= 0x800
hwlen= 6
plen= 4
op= is-at
hwsrc= 00:0c:29:21:fd:03
psrc= 192.168.80.251
hwdst= 00:0c:29:e2:bb:15
pdst= 192.168.80.250
###[ Padding ]###
load= '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
12)用show方法讀取收包數(shù)據(jù)中ARP:

print(arp1[0].res[0][1][1].show())
###[ ARP ]###
hwtype= 0x1
ptype= 0x800
hwlen= 6
plen= 4
op= is-at
hwsrc= 00:0c:29:21:fd:03
psrc= 192.168.80.251
hwdst= 00:0c:29:e2:bb:15
pdst= 192.168.80.250
###[ Padding ]###
load= '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
13)產(chǎn)生自己想要的print結(jié)果:
print('ip:' + arp1[0].res[0][1][1].fields['psrc']+ ' mac:' + arp1[0].res[0][1][1].fields['hwsrc'])
ip:192.168.80.251 mac:00:0c:29:21:fd:03
14)數(shù)據(jù)結(jié)構(gòu):

網(wǎng)站名稱:linuxScapy進(jìn)行arp數(shù)據(jù)包詳細(xì)過程
文章網(wǎng)址:http://muchs.cn/article46/jepoeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、自適應(yīng)網(wǎng)站、全網(wǎng)營銷推廣網(wǎng)站排名、網(wǎng)站導(dǎo)航、電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化