Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Enders joshenders

View GitHub Profile
@joshenders
joshenders / certchain.sh
Last active Jan 14, 2019
Simple Bash function to visualize PKI chain-of-trust
View certchain.sh
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 / ylint.sh
Created Dec 14, 2015
YAML syntax checker
View ylint.sh
function ylint() {
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <infile>"
return 1
fi
ruby -e "require 'yaml'; YAML.load_file('$1')"
}
@joshenders
joshenders / mitmproxy.md
Last active Feb 6, 2021
mitmproxy configuration for iPad
View mitmproxy.md

Successful mitmproxy-3.7 setup tested on OS X 10.13.6 and iPhone X running 12.1.4

Enable IP forwarding and disable ICMP redirects to keep the iPad sending traffic to the proxy

sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.redirect=0

net.inet.ip.forwarding
Enable IP forwarding between interfaces

@joshenders
joshenders / smokeping.sh
Last active Dec 17, 2020
Poor man's smokeping for OS X
View smokeping.sh
#!/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
View gist:1e80d260047687ab6132
jenders@jenders-mba threadedfractals :) $ make
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o utils.o utils.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 pngify.c utils.o -o pngify -lz
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 resample.c utils.o -o resample
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 render.c utils.o -o render -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 palette.c utils.o -o palette -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o circularlist.o circularlist.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o loader.o loader.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o mapper.o mapper.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 threaded.c circularlist.o loader.o mapper.o utils.o -o threaded -lm -lpthread -ldl
View bash word splitting issue
$ var=$(echo ' ab')
$ echo $var
ab
$ echo $var | xxd
0000000: 6162 0a ab.
$ if [[ "$var" =~ ^a ]]; then echo match; else echo not match; fi
not match
$ var=$(echo 'ab')
$ echo $var | xxd
@joshenders
joshenders / recover.sh
Last active Jan 5, 2016
ddrescue recovery script
View recover.sh
#!/bin/bash
function exit_with_usage() {
# usage: exit_with_usage
echo "Usage: ${0##*/} <src> <dest>" >&2
exit 1
}
function prompt() {
View gist:10ee8cd1c240b38b2dfe
if a1 and a2:
# Answers from both servers, compare rrsets
if a1 != a2:
header(args.ns1_name, ns1_port, args.ns2_name, ns2_port)
removed(a1, color=args.color_flag)
added(a2, color=args.color_flag)
# else:
# # Records both exist and match
# pass
elif a1 and not a2:
View dns_diff.txt
In [90]: str(r0.answer[0])
Out[90]: 'pinterest.com. 60 IN A 54.243.129.204\npinterest.com. 60 IN A 50.16.219.149\npinterest.com. 60 IN A 54.225.186.27\npinterest.com. 60 IN A 54.235.105.67\npinterest.com. 60 IN A 50.16.231.144\npinterest.com. 60 IN A 23.21.210.110\npinterest.com. 60 IN A 50.17.251.14\npinterest.com. 60 IN A 54.243.162.10'
In [91]: str(r1.answer[0])
Out[91]: 'pinterest.com. 60 IN A 54.197.238.4\npinterest.com. 60 IN A 174.129.10.138\npinterest.com. 60 IN A 50.16.211.7\npinterest.com. 60 IN A 54.225.188.149\npinterest.com. 60 IN A 174.129.209.56\npinterest.com. 60 IN A 54.225.139.43\npinterest.com. 60 IN A 54.225.169.36\npinterest.com. 60 IN A 50.17.208.61'
In [92]: if str(r0.answer[0]) == str(r1.answer[0]):
print('No problem')
....:
View gist:bcf44e6dfba37e317793
(dnsdiff)jenders@collaris/pts/0: dnsdiff $ ./dnsdiff.py --help
usage: dnsdiff.py [-h] -f FILENAME --from-ns NAMESERVER1 --to-ns NAMESERVER2
optional arguments:
-h, --help Show this help message and exit
-f FILENAME, --filename FILENAME
File containing resource records to verify. File is
expected to be a valid zone master file as described
here: https://tools.ietf.org/html/rfc1035#section-5
--from-ns NAMESERVER1