scapy回放pcap包

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值