Skip to content

Instantly share code, notes, and snippets.

View djoreilly's full-sized avatar

Darragh O'Reilly djoreilly

View GitHub Profile
@djoreilly
djoreilly / monty-hall.py
Created February 18, 2025 13:36
Monty Hall problem simulation
# monty hall problem simulation https://en.wikipedia.org/wiki/Monty_Hall_problem
import random
ITERATIONS = 10000
stick_count = 0
stick_wins = 0
switch_count = 0
switch_wins = 0
@djoreilly
djoreilly / go-vuln-cve.py
Last active January 16, 2025 14:36
Add CVEs to govulncheck report
#!/usr/bin/env python3
# govulncheck ./... | go-vuln-cve.py
import json
import re
import sys
from urllib.request import urlopen
GO_PAT=re.compile('^Vulnerability.*(GO-[0-9]{4}-[0-9]+)')
@djoreilly
djoreilly / example.go
Created June 18, 2024 16:07
velociraptor api client in golang
// see https://docs.velociraptor.app/docs/server_automation/server_api/
// for how to create the api config file.
// see https://github.com/Velocidex/pyvelociraptor/tree/master for python bindings
package main
import (
"context"
"crypto/tls"
@djoreilly
djoreilly / poolBench_test.go
Last active September 14, 2023 10:01 — forked from 0xc0d/poolBench_test.go
sync.Pool Benchmark test
// go test -bench=.
package main
import (
"sync"
"testing"
)
type Person struct {
@djoreilly
djoreilly / wg.md
Last active July 1, 2022 15:54
WireGuard MicroOS Raspberry Pi

WireGuard on MicroOS / Raspberry Pi

Install MicroOS

Download the Raspberry Pi image from https://en.opensuse.org/Portal:MicroOS/Downloads and copy it the MicsoSD card.

# xz -d openSUSE-MicroOS.aarch64-ContainerHost-RaspberryPi.raw.xz
# dd bs=4M if=openSUSE-MicroOS.aarch64-ContainerHost-RaspberryPi.raw of=/dev/mmcblk0 iflag=fullblock oflag=direct status=progress; sync
@djoreilly
djoreilly / interrupted.go
Last active August 26, 2021 16:01
Prevent shell from sending signals to children and detect if signals caught
package main
import (
"fmt"
"os"
"os/exec"
"os/signal"
"syscall"
"time"
)
@djoreilly
djoreilly / pp-iptables.py
Last active February 24, 2025 18:03
Pretty print iptables output. Align columns and strip out comments.
#!/usr/bin/python3
import re
import sys
from tabulate import tabulate
comments_re = re.compile(r'/\*.*\/')
in_chain, eof = False, False
headers, table = [], []
@djoreilly
djoreilly / metadata-server.go
Last active March 1, 2021 10:52
Allows Libvirt VMs with cloud-init to get users public ssh key
package main
import (
"flag"
"io"
"io/ioutil"
"log"
"net/http"
"os/user"
"path/filepath"
@djoreilly
djoreilly / send-vxlan-loop.py
Last active January 17, 2023 07:12
Reproduce OVS v2.7 memory leak
# send vxlan pkts from netns to ovs on same host
# keep changing the src mac so learn action creates/updates 1000 flows
# ip netns exec ns1 ./send-vxlan-loop.py
import time
from scapy.all import *
# https://home.regit.org/2014/04/speeding-up-scapy-packets-sending/
sock = conf.L2socket(iface='veth-ns')
@djoreilly
djoreilly / ovs-sort-flows.py
Created January 19, 2021 15:16
Sort and tabulate the output of ovs-ofctl dump-flows
'''
Make the output of ovs-ofctl dump-flows more readable
'''
import re
import sys
from tabulate import tabulate
PAT = re.compile("^ cookie.*table=(\d+), n_packets=(\d+).+ priority=(\d+),*(.*) actions=(.+)")
if len(sys.argv) == 2: