Skip to content

Instantly share code, notes, and snippets.

@ryanchapman
ryanchapman / print_cert_signatures.py
Last active June 12, 2020 20:11
Print certificate signatures that can be used with certificate pinning on iOS and Android
#!/usr/bin/env python
#
# Print certificate signatures that can be used with certificate pinning on iOS and Android
#
# usage: cat cert_bundle.pem | ./print_cert_signatures.py
# usage: openssl s_client -connect fqdn:443 -showcerts </dev/null 2>/dev/null | ~/bin/print_cert_signatures.py
#
# example:
# $ openssl s_client -connect www.google.com:443 -showcerts </dev/null 2>/dev/null | ~/bin/print_cert_signatures.py
# Certificate 1 of 2:
rchapman@linux:~$ curl icanhazip.com
1.2.3.4
VB=/Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/VBoxManage; for vm in $($VB list vms | awk '{print $1}' | tr -d '"'); do $VB showvminfo $vm 2>&1 | grep 'State:.*running' &>/dev/null || continue; perl -e 'print "=" x 80 . "\n"'; echo $vm; $VB showvminfo $vm 2>&1 | egrep '^(Name|Guest OS|UUID|Config file|Memory size|Number of CPUs):|NIC.*Rule|Name:.*Host path:'; done
@ryanchapman
ryanchapman / test.c
Last active August 29, 2015 14:13
write a string to standard output using syscall(2)
/* save as test.c, compile with gcc test.c -o test -m64 */
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
void main() {
const char *buf="test\n";
syscall(1, /* sys_write */
1, /* stdout */
buf, /* buf, or string to write to stdout */
@ryanchapman
ryanchapman / gist:4064825
Created November 13, 2012 09:25
Nagios nsca incoming statistics
mmdd=`date | sed 's|^\(... \)\(... ..\)\( ..:..:.. ... ....\)|\2|'`; hour=`date +%H`; echo; echo -n "Number of hosts sending us nsca results: "; cat /var/log/messages | egrep 'START:.*from=' | sed 's|\(.*from=\)\(.*\..*\..*\..*\)$|\2|g' | sort -u | wc -l; echo " ATTEMPTS/MIN FAILS/MIN"; min=0; while [ $min -lt 61 ]; do min_formatted=`printf "%2.2d" $min`; echo -n "${mmdd} ${hour}:${min_formatted} "; printf "%8.8s" `cat /var/log/messages | grep 'START: nsca pid=' | grep "${mmdd} ${hour}:${min_formatted}:" | wc -l`; printf " %8.8s\n" `cat /var/log/messages | grep 'FAIL: nsca' | grep "${mmdd} ${hour}:${min_formatted}:" | wc -l`;min=$((min+1)); done