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')
网友评论