PC-PC设备环接,直接回放
# xxx.pcap 不要超过200MB, 太占内存, 会加载很久的, 甚至存在卡死的风险
import sys
import os
import re
from scapy.all import *
req_iface = "eth1"
resp_iface = "eth3"
left_side = []
right_side = []
req_mac = ''
resp_mac = ''
def get_mac(eth):
cmd = "ip link list %s | sed -n 's;^.*link/ether \([[:xdigit:]:]\{17\}\) brd.*$;\\1;p'" % eth
for line in os.popen(cmd):
if line != "":
return line.strip()
return ""
class Send:
def __init__(self, path):
self.all_pcap_ip = {}
self.path = path
def run(self):
if not os.path.isfile(self.path):
print('input path error')
else:
self.send_pcap(self.path)
def send_pcap(self, one_pcap):
packets = rdpcap(one_pcap)
address_dict = {}
one_pcap_address = []
global left_side
globa