Skip to content

Instantly share code, notes, and snippets.

oskar456 /
Created July 15, 2022 12:14
Analyze IPv6-only preferred (option 108) in DHCP requests
#!/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 / 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 {
oskar456 /
Last active February 7, 2022 14:15
Poor man's VM hypervisor scripts

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 / 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 /
Last active March 4, 2021 08:45
Claim 1,000,000 RIPE Atlas credits every time you can
# Dependencies: curl, jq, realpath, date (GNU), at
claim_endpoint() {
local regid=$1
curl -s -H "Content-Type: application/json" \
-H "Accept: application/json" \
oskar456 / data.yaml
Last active October 18, 2020 19:46
Ansible bug with datetime in data
View data.yaml
- id: 1
key: hello
- id: 2
key: world
- id: 1
oskar456 /
Last active February 27, 2023 03:44
Wireguard tunnel watchdog for OpenWRT
check_reachability() {
local target="$1"
local retval
ping6 -c1 -W1 "$target" >/dev/null 2>&1
[ "$retval" -eq 2 ] && {
ping -c1 -W1 "$target" >/dev/null 2>&1
oskar456 /
Created July 5, 2020 17:23
Raspberry Pi Zero USB gadget mode with ethernet and serial
# 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/
# 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/
oskar456 /
Created July 2, 2020 18:29
Cut a video out of a long recording with fade in and out and volume normalization
get_seconds() {
local seconds=0
IFS=":" read -ra T <<< "$1"
for x in "${T[@]}"; do
seconds=$(echo "$seconds * 60 + $x" | bc)
oskar456 /
Created February 24, 2020 15:09
Scrap and send news to a Telegram channel
#!/usr/bin/env python3
import lxml.html
import urllib.request
from pathlib import Path
import requests
telegram_bot_token = "FIXME"
telegram_group_name = "@kvetinac"