Skip to content

Instantly share code, notes, and snippets.

@speakinghedge
speakinghedge / dispatch_hook_demo.py
Last active February 5, 2019 21:01
scapy - demo of dispatch_hook method to dissect next layer based on payload data instead of lower layer attribute(s)
"""
This demo of the dispatch_hook uses a hypothetical protocol running on
top of Ethernet using Ether-type 0xa5b4:
Ethernet [ Foo | Bar ] Baz
Foo : Type String
Bar : Type Short String
@speakinghedge
speakinghedge / debian-netinst-serial-console.md
Last active May 3, 2024 16:09
Debian 9.5 netinstall - add serial console (for install on Gateprotect GPO 150)

how to

  • install dependencies
> sudo apt-get install isolinux xorriso
  • get Debian netinst iso
  • create iso org dir
> mkdir iso-org
from scapy.all import *
from scapy.layers.l2 import *
import socket
ETH_P_ALL = 0x0003
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
def dump_layers(frm):
@speakinghedge
speakinghedge / mac-sec-testbed.sh
Created April 24, 2018 20:19
simple testbed for playing with mac-sec using Linux network namespaces and two veth-pairs
#! /bin/bash
#
# namespace namespace
# mac_sec_ns_0 mac_sec_br mac_sec_ns_1
# +-----------+-----------+
# mac_sec_0_0----|mac_sec_0_1|mac_sec_0_1|----mac_sec_1_0
# +-----------+-----------+
#
ip link add dev mac_sec_if_0_0 type veth peer name mac_sec_if_0_1
@speakinghedge
speakinghedge / foosocket.py
Created March 12, 2018 20:19
use socketpair to test scapy sniff()
from scapy.all import *
class FooSocket(Thread, SuperSocket):
def __init__(self, frame_defs):
super(FooSocket, self).__init__()
self._frame_defs = frame_defs
self.ins = None
def __enter__(self):