Skip to content

Instantly share code, notes, and snippets.

@sebschrader
sebschrader / generate_localized_key.c
Last active March 1, 2022 20:27
Generate localized SNMPv3 keys from password and engine id
// Needs to be linked with BSD message digest library libmd (-lmd)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sysexits.h>
#include <sha1.h>
#include <md5.h>
typedef unsigned char u_char;
@sebschrader
sebschrader / openvpn.yml
Created March 20, 2020 15:36
YAML Anchors und Jinja2-Loops im Ansible Inventory
openvpn_virtual_server_defaults: &openvpn_virtual_server_defaults
port: 1194
scheduler: wlc
type: tun
method: NAT
control_cipher: AES-256-GCM
control_mac: SHA384
tunnel_mtu: 1400
# Renegotiate after half a day
renegotiation_interval: 43200
@sebschrader
sebschrader / pam_dump.c
Last active January 9, 2020 13:31
PAM module that dumps the internal PAM state. Useful for debugging your own PAM modules without recompiling PAM.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
struct handler {
int handler_type;
int (*func)(pam_handle_t *pamh, int flags, int argc, char **argv);
int actions[_PAM_RETURN_VALUES];
@sebschrader
sebschrader / dhcp-spoof.py
Created February 6, 2019 18:27
Spoof DHCP Requests with Scapy
import codecs
from scapy.all import BOOTP, DHCP, Ether, IP, UDP, sendp
def do_request(iface, hwaddr, ip):
pkt = Ether(src=hwaddr, dst="ff:ff:ff:ff:ff:ff")
pkt /= IP(src="0.0.0.0", dst="255.255.255.255")
pkt /= UDP(sport=68, dport=67)
pkt /= BOOTP(
chaddr=codecs.decode(hwaddr.replace(':', ''), 'hex'),
@sebschrader
sebschrader / output.txt
Last active January 18, 2018 12:33
Python unittest TestCase setUp and tearDown behavior
============================= test session starts ==============================
platform linux -- Python 3.6.3, pytest-3.3.1, py-1.5.0, pluggy-0.6.0
rootdir: /tmp/tmp.qJ0GaB9IXd/build, inifile:
plugins: cov-2.5.1
collected 5 items
test.py ..... [100%]
==================================== PASSES ====================================
_________________________________ Test1.test_1 _________________________________
@sebschrader
sebschrader / config.py.sample
Last active October 5, 2016 14:18
GitHub Release Hook to run Jekyll
# SECRET must be a bytes object
SECRET = b"correcthorsebatterystaple"
TARGET_DIR = "/var/www/htdocs/my-site"
REPO_DIR = "/var/lib/my-repo.git"