Skip to content

Instantly share code, notes, and snippets.

@joshenders
joshenders / partscan.sh
Created August 31, 2011 10:24
NTFS partition scanner
#!/bin/bash
start=1048576 # decimal offset of data on drive (past MBR, 1MB)
end=10485760 # decimal offset of data on drive (well past weird '...U...N.b..' structures, 10MB)
image=/mnt/seagate/wd_backup.img
mount=/mnt/wd
for ((offset=$start; offset<=$end; offset++)); do
echo "trying offset: $offset"
status="$(mount -o ro,offset=$offset,loop -t ntfs $image $mount >/dev/null 2>&1; echo $?)"
@joshenders
joshenders / smokeping.sh
Last active July 26, 2022 18:43
Poor man's smokeping for OS X
#!/bin/bash
# https://gist.github.com/joshenders/52cb78bedaea6787faac
# This script uses the BSD variants of commands and is intended to
# be run on an unmodified installation of OSX.
pmset noidle &
now=$(date +%s)
duration=$((86400*3)) # 3days
@joshenders
joshenders / certchain.sh
Last active August 26, 2021 18:19
Simple Bash function to visualize PKI chain-of-trust
function certchain() {
# Usage: certchain
# Display PKI chain-of-trust for a given domain
# GistID: https://gist.github.com/joshenders/cda916797665de69ebcd
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
return 1
fi
local host_port="$1"
@joshenders
joshenders / lldb-hand-rolled-headers.md
Created October 18, 2020 21:05 — forked from zcutlip/lldb-hand-rolled-headers.md
Importing Hand-Rolled C Header Files in LLDB

Importing Hand-Rolled C Header Files in LLDB

Scenario

  • We're debugging a dylib, libhello.dylib
  • The dylib is linked from hello
  • The exported function is helloworld()
  • We do not have source, but have reversed a struct from the library and created a hand-crafted header file

Header File

@joshenders
joshenders / make_ipxe_uefi_usb.md
Created August 29, 2017 08:10 — forked from AdrianKoshka/make_ipxe_uefi_usb.md
Making a UEFI bootable iPXE USB drive

Making a UEFI bootable iPXE USB drive

Build the UEFI executable for iPXE

# First we'll clone iPXE
$ git clone git://git.ipxe.org/ipxe.git
# Go into the src directory of the cloned git repo
$ cd ipxe/src
# Compile the UEFI iPXE executable
@joshenders
joshenders / sabnzbdplus.default
Last active December 8, 2017 19:50
Installing sabnzbdplus on Debian Wheezy from source
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.
@joshenders
joshenders / zfs
Last active November 12, 2017 18:58
/etc/sudoers.d/zfs
# Allow read-only ZoL commands to be called through sudo without a password.
# Cmnd alias specification
Cmnd_Alias RO_ZFS = \
/sbin/zfs "", /sbin/zfs help *, \
/sbin/zfs get, /sbin/zfs get *, \
/sbin/zfs list, /sbin/zfs list *, \
/sbin/zpool "", /sbin/zpool help *, \
/sbin/zpool iostat, /sbin/zpool iostat *, \
/sbin/zpool list, /sbin/zpool list *, \
@joshenders
joshenders / libhttpd.c.patch
Created February 8, 2015 06:51
X-Forwarded-For patch for thttpd-2.26
--- libhttpd.c 2014-12-10 12:53:07.000000000 -0800
+++ libhttpd.c.patched 2015-02-07 22:44:59.183663432 -0800
@@ -2231,6 +2231,12 @@
if ( strcasecmp( cp, "keep-alive" ) == 0 )
hc->keep_alive = 1;
}
+ else if ( strncasecmp( buf, "X-Forwarded-For:", 16 ) == 0 )
+ { // Use real IP if available
+ cp = &buf[16];
+ cp += strspn( cp, " \t" );
@joshenders
joshenders / varnish.init.patch
Last active December 13, 2016 01:22
Patch for varnish-3.0.2-0ubuntu0.1 to enable safe stop
--- debian/varnish.init 2016-12-13 01:13:34.465123880 +0000
+++ debian/varnish.init.new 2016-12-13 01:18:50.215749771 +0000
@@ -88,8 +88,10 @@
log_daemon_msg "Reloading $DESC" "$NAME"
if /usr/share/varnish/reload-vcl -q; then
log_end_msg 0
+ return 0
else
log_end_msg 1
+ return 1
@joshenders
joshenders / reload-vcl.patch
Last active December 11, 2016 10:34
reload-vcl patch for config discards and safe stop
--- reload-vcl 2011-10-29 13:24:10.000000000 +0000
+++ /usr/share/varnish/reload-vcl 2016-12-11 09:51:08.696300339 +0000
@@ -1,9 +1,13 @@
#!/bin/sh
-
+#
# reload-varnish: Script to reload varnishd from VCL defined in
# /etc/default/varnish.
#
# Stig Sandbeck Mathisen <ssm@debian.org>