Skip to content

Instantly share code, notes, and snippets.

View djoreilly's full-sized avatar

Darragh O'Reilly djoreilly

View GitHub Profile
@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 May 31, 2024 21:14
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:
@djoreilly
djoreilly / mk-vxlan.sh
Created February 17, 2020 10:08
Linux VxLAN performance test setup script
#!/bin/bash
set -xe
# $0 host dev remote_ip
# host is 1 or 2
# on vmA
# ./mk-vx.sh 1 ens3 10.10.10.9
# on vmB
# ./mk-vx.sh 2 ens3 10.10.10.15
@djoreilly
djoreilly / dump-vm-neutron-info.py
Created January 15, 2020 16:08
Gather neutron info for VM connectivity problems
"""
Script to gather neutron info for vm connectivity problems.
Gets the vm's ports, networks, subnets, security groups
and router, external networks and floatingips.
source .openrc admin
python dump-vm-neutrn-info.py VM_ID
"""
import sys
import os_client_config