Skip to content

Instantly share code, notes, and snippets.

View JonathonReinhart's full-sized avatar

Jonathon Reinhart JonathonReinhart

View GitHub Profile
@JonathonReinhart
JonathonReinhart / nbdinfo.py
Last active August 23, 2022 06:54
Linux NBD (Network Block Device) info
#!/usr/bin/env python3
# Show Linux NBD (Network Block Device) info
# Requires Python 3.7+
# Author: Jonathon Reinhart
# License: MIT
from dataclasses import dataclass
from pathlib import Path
class NotConnected(Exception):
pass
@JonathonReinhart
JonathonReinhart / kvm_emulate.md
Created July 27, 2022 04:14
KVM Emulate Flowchart

When does Linux KVM emulate instructions?

Flow Chart

graph LR

x86_emulate_instruction --> x86_emulate_insn
emulate_instruction --> x86_emulate_instruction
@JonathonReinhart
JonathonReinhart / partclone
Created July 19, 2022 18:04
Magic file for partclone image format
# This is a magic(5) description for partclone(8) output files.
# References:
# https://github.com/Thomas-Tsai/partclone/blob/master/src/partclone.h
# Structure: `image_head_v2`
# magic (16)
0 string partclone-image Partclone image
################################################################################
# Version 1
@JonathonReinhart
JonathonReinhart / mouselog.html
Created July 19, 2022 13:39
Mouse click log
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mousedown demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="trigger" style="border-style: solid">Click here to log.</div>
@JonathonReinhart
JonathonReinhart / gen-selfsign-cert.sh
Created July 11, 2022 06:39
Simply generate a self-signed certificate for a DNS name
#!/bin/bash
# Simply generate a self-signed certificate for a DNS name
# Options
NUMDAYS=3650 # 10 years
error() {
echo "Error: $1"
exit 1
}
@JonathonReinhart
JonathonReinhart / check-certkey.sh
Created July 11, 2022 06:38
Verify X.509 certificate and key match
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "Usage: $(basename $0) CERTFILE KEYFILE"
exit 1
fi
certpath="$1"
keypath="$2"
@JonathonReinhart
JonathonReinhart / svcwait.sh
Created February 11, 2022 22:19
Wait for service to accept connections, using bash /dev/tcp
#!/bin/bash
host="127.0.0.1"
port="13337"
maxwait=5
dur=0
while true; do
( echo -n "" > /dev/tcp/$host/$port ) 2>/dev/null
if [[ $? -eq 0 ]]; then
@JonathonReinhart
JonathonReinhart / parse_121.py
Created February 9, 2022 03:09
RFC3442 Classless Route Option (121) parser
#!/usr/bin/env python3
# https://www.rfc-editor.org/rfc/rfc3442.html
from binascii import unhexlify
from socket import inet_ntop, AF_INET
from io import BytesIO
import math
"""
Classless Route Option Format
@JonathonReinhart
JonathonReinhart / dropbox.md
Created October 15, 2021 21:37
Installing Dropbox on Linux

See https://www.dropbox.com/install?os=lnx

curl -L -O https://www.dropbox.com/download?dl=packages/ubuntu/dropbox_2020.03.04_amd64.deb

apt install python3-gpg
apt install ./dropbox_*.deb

dropbox start -i
@JonathonReinhart
JonathonReinhart / travis-debug.md
Last active October 3, 2021 03:46
Remotely debugging Travis CI

This is a method of using ngrok to live-debug a Travis CI build.

(This is from some terse notes I took while working on staticx and hasn't been re-verified.)

Add to .travis.yml:

env:
  NGROK_TOKEN=...

addons: