only load scapy when needed

This commit is contained in:
n1nj4sec 2022-11-06 21:37:39 +01:00
parent 88712d85cf
commit 0a10ba1cfd
1 changed files with 2 additions and 1 deletions

View File

@ -11,7 +11,6 @@ import sys
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import Ether, PcapWriter
from threading import Event
from pupy.pupylib.PupyModule import (
@ -53,6 +52,7 @@ class TcpdumpModule(PupyModule):
# cls.arg_parser.add_argument("command", choices=["start", "stop"])
def printer(self, pcap_writer=None, print_summary=True):
from scapy.all import Ether
def pkt_callback(pkt):
try:
pkt = Ether(pkt)
@ -85,6 +85,7 @@ class TcpdumpModule(PupyModule):
pktwriter = None
if args.save_pcap:
from scapy.all import PcapWriter
config = self.client.pupsrv.config
filepath = config.get_file('pcaps', {'%c': self.client.short_name()})
pktwriter = PcapWriter(filepath, append=True, sync=True)