小编Mat*_*tan的帖子

使用dpkt库从DNS响应数据包中提取域名

我想产生的所有域名的列表及其相应的IP地址从PCAP文件,使用dpkt库可用这里

我的代码主要基于

filename = raw_input('Type filename of pcap file (without extention): ')
path = 'c:/temp/PcapParser/' + filename + '.pcap'
f = open(path, 'rb')
pcap = dpkt.pcap.Reader(f)
for ts, buf in pcap:
    #make sure we are dealing with IP traffic
    try:
        eth = dpkt.ethernet.Ethernet(buf)
    except:
        continue
    if eth.type != 2048:
        continue
    #make sure we are dealing with UDP protocol
    try:
        ip = eth.data
    except:
        continue
    if ip.p != 17:
        continue
    #filter on UDP assigned ports for DNS
    try:
        udp …
Run Code Online (Sandbox Code Playgroud)

parsing pcap python-2.7

4
推荐指数
1
解决办法
5104
查看次数

标签 统计

parsing ×1

pcap ×1

python-2.7 ×1