Created
June 24, 2025 11:14
-
-
Save Elektordi/790fe36bfbcce7fd6f72f7daabd8b3f5 to your computer and use it in GitHub Desktop.
Convert cisco debug pppoe packets to pcap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from scapy.all import * | |
import re | |
in_file = open(sys.argv[1], "rt") | |
out_file = open(sys.argv[2], "wb") | |
buffer = b"" | |
packets = [] | |
for l in in_file: | |
if re.match("\t [0-9A-F ]+", l.rstrip()): | |
b = bytes.fromhex(l.strip().replace(" ", "").replace("...","")) | |
buffer += b | |
continue | |
if buffer: | |
packets.append(buffer) | |
buffer = b"" | |
wrpcap(out_file, [Ether(p) for p in packets]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from scapy.all import * | |
import re | |
in_file = open(sys.argv[1], "rt") | |
out_file = open(sys.argv[2], "wb") | |
packets = [] | |
for l in in_file: | |
r = re.search("(I|O) dst ([0-9a-f\.]{14}) src ([0-9a-f\.]{14}): len [0-9]+ 0x([0-9a-f]+)", l.strip()) | |
if not r: | |
continue | |
dstmac = bytes.fromhex(r.group(2).replace(".", "")) | |
srcmac = bytes.fromhex(r.group(3).replace(".", "")) | |
raw = bytes.fromhex(r.group(4)) | |
p = Ether(dst=dstmac, src=srcmac)/PPPoED(raw) | |
packets.append(p) | |
wrpcap(out_file, [Ether(p) for p in packets]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment