Skip to content

Instantly share code, notes, and snippets.

@oskar456
oskar456 / analyze_v6_only_preferred.py
Created July 15, 2022 12:14
Analyze IPv6-only preferred (option 108) in DHCP requests
View analyze_v6_only_preferred.py
#!/usr/bin/env python3
"""
Analyze a PCAP file containing DHCP Discover messages.
Print stats including number of unique MAC addresses,
number of MAC addresses requesting DHCP option 108
(IPv6-only Preferred) and MAC adresses flapping between
requesting and not requesting it.
To collect PCAP file, tcpdump can be used like this:
@oskar456
oskar456 / pref64.diff
Created July 5, 2022 11:42
A quick and dirty patch to add Pref64 RA option to odhcpd (RFC 8781)
View pref64.diff
diff --git a/src/router.c b/src/router.c
index 541c023..9ad79d4 100644
--- a/src/router.c
+++ b/src/router.c
@@ -390,6 +390,7 @@ enum {
IOV_RA_ROUTES,
IOV_RA_DNS,
IOV_RA_SEARCH,
+ IOV_RA_PREF64,
IOV_RA_ADV_INTERVAL,
@oskar456
oskar456 / a-poor-mans-hypervisor-scripts.md
Last active February 7, 2022 14:15
Poor man's VM hypervisor scripts
View a-poor-mans-hypervisor-scripts.md

A poor man's hypervisor scripts

These scripts are written mostly in bash in order to spawn a bunch of similar KVM VMs, have each have its own SSH key for the root account (which can be e-mailed to people) and be able to destroy all the machines easily once the work is done.

There is unfortunatelly no documentation whatsover.

@oskar456
oskar456 / gaitest.c
Last active May 24, 2021 11:09
Test getaddrinfo NAT64 synthesis on macOS
View gaitest.c
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <err.h>
int main(int argc, char *argv[]) {
@oskar456
oskar456 / atlas_claimer.sh
Last active March 4, 2021 08:45
Claim 1,000,000 RIPE Atlas credits every time you can
View atlas_claimer.sh
#!/bin/bash
# Dependencies: curl, jq, realpath, date (GNU), at
API_KEY="FIXME"
claim_endpoint() {
local regid=$1
curl -s -H "Content-Type: application/json" \
-H "Accept: application/json" \
@oskar456
oskar456 / data.yaml
Last active October 18, 2020 19:46
Ansible bug with datetime in data
View data.yaml
---
data_1:
- id: 1
key: hello
- id: 2
key: world
data_2:
- id: 1
@oskar456
oskar456 / wgwatchdog.sh
Last active February 27, 2023 03:44
Wireguard tunnel watchdog for OpenWRT
View wgwatchdog.sh
#!/bin/sh
check_reachability() {
local target="$1"
local retval
ping6 -c1 -W1 "$target" >/dev/null 2>&1
retval="$?"
[ "$retval" -eq 2 ] && {
ping -c1 -W1 "$target" >/dev/null 2>&1
retval="$?"
@oskar456
oskar456 / oneshot_setup.sh
Created July 5, 2020 17:23
Raspberry Pi Zero USB gadget mode with ethernet and serial
View oneshot_setup.sh
#!/bin/sh
# Enable gadget mode
echo "dtoverlay=dwc2,dr_mode=peripheral" >> /boot/config.txt
systemctl enable setupgadget.service
# alternatively: ln -s /etc/systemd/system/setupgadget.service /etc/systemd/system/basic.target.wants/setupgadget.service
# Enable getty on the virtual serial line
systemctl enable serial-getty@ttyGS0.service
# alternatively: ln -s /lib/systemd/system/serial-getty@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service
@oskar456
oskar456 / videocuttter.sh
Created July 2, 2020 18:29
Cut a video out of a long recording with fade in and out and volume normalization
View videocuttter.sh
#!/bin/bash
INFILE="input_video.mp4"
FPS=30
get_seconds() {
local seconds=0
IFS=":" read -ra T <<< "$1"
for x in "${T[@]}"; do
seconds=$(echo "$seconds * 60 + $x" | bc)
@oskar456
oskar456 / happykaktus.py
Created February 24, 2020 15:09
Scrap mujkaktus.cz and send news to a Telegram channel
View happykaktus.py
#!/usr/bin/env python3
import lxml.html
import urllib.request
from pathlib import Path
import requests
telegram_bot_token = "FIXME"
telegram_group_name = "@kvetinac"