提取.pcap文件中的host

2019-12-04  本文已影响0人  Aedda
from scapy.all import rdpcap
import re


def extract_host(src):
    all_ls = []
    packets = rdpcap(str(src))
    print(repr(packets))
    for data in packets:
        res = repr(data)
        ls = re.findall('Host: (.*?)\\\\r\\\\n', res)
        if len(ls) > 0:
            for i in ls:
                all_ls.append(i)
    all_ls = list(set(all_ls))
    for host in all_ls:
        print(host)


extract_host('./报文.pcap')
上一篇下一篇

猜你喜欢

热点阅读