Skip to content

Instantly share code, notes, and snippets.

View Birch-san's full-sized avatar

Birch-san

View GitHub Profile
@Birch-san
Birch-san / update_ungoogled_chromium_extensions.sh
Created May 30, 2018 15:35 — forked from pjv/update_ungoogled_chromium_extensions.sh
get latest version of installed ungoogled chromium extensions
#!/usr/bin/env bash
# dependencies:
# https://www.npmjs.com/package/chrome-web-store-item-property-cli
# https://stedolan.github.io/jq/
# curl
# Ascertain directory in which script lives; compatible with all UNIX
# Thanks to kenorb
# http://stackoverflow.com/a/17744637/5257399
@Birch-san
Birch-san / make_portable.sh
Last active March 1, 2023 18:33
Make a macOS executable binary or .dylib portable
#!/usr/bin/env bash
# Licensed by author Alex Birch under CC BY-SA 4.0
# https://creativecommons.org/licenses/by-sa/4.0/
# Example input:
# ./make_portable.sh mycoolbinary
# where mycoolbinary is a mach-o object file
# (for example an executable binary or a .dylib)
#
@Birch-san
Birch-san / http-parse-bespoke.py
Last active July 19, 2018 22:18
Count HTTP bytes inbound, outbound, grouped by an aspect of URL in HTTP request URI
#!/usr/bin/python
#
#Bertrone Matteo - Polytechnic of Turin
#November 2015
#
#Additions made by Alex Birch, July 2018
#to correlate HTTP reply back to HTTP request, and accumulate & print statistics
#
#eBPF application that parses HTTP packets
#and extracts (and prints on screen) the URL contained in the GET/POST request.
@Birch-san
Birch-san / http-parse-seq.py
Created August 12, 2018 15:26
BCC TCP packet sequence number logger
#!/usr/bin/python
#
# Forked from https://github.com/iovisor/bcc/blob/master/examples/networking/http_filter/http-parse-complete.py
# I've removed almost all functionality. It now simply prints the sequence number of every packet submitted, and does not perform any cleanup.
# =====
#Bertrone Matteo - Polytechnic of Turin
#November 2015
#
#eBPF application that parses HTTP packets
#and extracts (and prints on screen) the URL contained in the GET/POST request.
@Birch-san
Birch-san / http-minimal.py
Created October 8, 2018 22:56
Just print sequence numbers of all TCP packets
#!/usr/bin/python
# invoke with:
# sudo ./http-minimal.py -i docker0
from bcc import BPF
from sys import argv
import socket
import os
@Birch-san
Birch-san / sshfs_mount.sh
Last active October 27, 2018 22:26
How to use OSXFUSE + SSHFS to mount/unmount a remote filesystem
#!/bin/sh
# mounts a host named 'mycoolhost' (as described in SSH config):
# ./sshfs_mount.sh
# unmount:
# ./sshfs_mount.sh 0
REMOTE_HOST='mycoolhost'
REMOTE_DIR='/home/mycooluser'
VOLNAME="$REMOTE_HOST"
@Birch-san
Birch-san / hex_printf.cpp
Created November 20, 2018 19:02
Printing 64-bit unsigned integer as hexadecimal
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char** argv) {
uint64_t val = (1ULL<<29) -1ULL;
printf("0x%" PRIx64 "\n", val);
return 0;
}
@Birch-san
Birch-san / pwnedpass.sh
Last active March 19, 2024 09:38
Detect whether any password in your KeePassXC database was exposed in a data breach (using Troy Hunt's Pwned Passwords API)
#!/usr/bin/env bash
# Licensed by author Alex Birch under CC BY-SA 4.0
# https://creativecommons.org/licenses/by-sa/4.0/
# detects whether any of your passwords have been exposed in a data breach, by
# submitting (prefixes of hashes of) all your passwords to Troy Hunt's
# Pwned Passwords API.
# https://haveibeenpwned.com/Passwords
@Birch-san
Birch-san / pluck.js
Created May 6, 2019 16:49 — forked from kevincennis/pluck.js
Karplus-Strong with Web Audio API
function Pluck( ctx ) {
this.sr = ctx.sampleRate;
this.pro = ctx.createScriptProcessor( 512, 0, 1 );
this.pro.connect( ctx.destination );
}
Pluck.prototype.play = function( freq ) {
var N = Math.round( this.sr / freq ),
impulse = this.sr / 1000,
y = new Float32Array( N ),
@Birch-san
Birch-san / -dd
Created July 25, 2020 20:29
5-byte memcpy, 8-byte-aligned goes bang
sudo ./src/bpftrace -v -e 'struct F {char s[5];} u:./tests/testprogs/string_args:print { $a = ((struct F*)arg0)->s; }' -c ./tests/testprogs/string_args
0: (bf) r6 = r1
1: (79) r3 = *(u64 *)(r6 +112)
2: (bf) r1 = r10
3: (07) r1 += -29
4: (b7) r2 = 5
5: (85) call bpf_probe_read#4
last_idx 5 first_idx 0
regs=4 stack=0 before 4: (b7) r2 = 5