Skip to content

Instantly share code, notes, and snippets.

kennwhite / php_mitm_ssl_fopen.php
Created Jul 31, 2013
PHP fopen for SSL by default allows MITM (peer verification off)
View php_mitm_ssl_fopen.php
OpenSSL verify certificate is off by default in php 5.3+
There is no obvious php.ini option to reenable, so we're stuck w/
forcing it at runtime.
Usage: php -f this_file.php
Default - [Resource id #5]
Verify on - [Resource id #7]
kennwhite /
Created Jul 31, 2013
Push backup from remote box 1 to remote box 2 through local (box 1 has no direct access to box 2)
# Push remote box 1 to remote box 2 through local box (box 1 has no access to box 2)
ssh -i box1key user@remotebox1 \
"tar -czvf - remotedir1" \
| ssh -i box2key user@remotebox2 "cat >remotedir2.tgz"
kennwhite /
Last active Dec 21, 2015 — forked from return1/trim_enabler.txt
Enable SSD Trim support on Mac Lion & Mountain Lion. Original version by Grant Parnell.
# Original version by Grant Parnell is offline (
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
# Alternative to
# Method behind this madness described:
# See discussion in comments here:
# And here:
# And here:
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
# for Mountain Lion 10.8.3 - 10.8.4
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|
kennwhite /
Created Sep 1, 2013
Remove all extended attributes recursively on an OSX directory & files and fix "chown: ... Operation not permitted" and "chmod: ... Operation not permitted"
# This is the nuclear option. Use with extreme care
# Works up to and including Mountain Lion (10.8.x)
# Show all extended attributes
ls -lOe ~/dir-to-fix
# Remove no-change attributes
sudo chflags nouchg ~/dir-to-fix
# Recursively clear all entended attributes
kennwhite / aws_iam_billing_read_only.txt
Last active Jan 3, 2016
Setting up AWS IAM for read-only billing (complete recipe)
View aws_iam_billing_read_only.txt
Recipe for enabling billing access in AWS to a less privileged user
As *Root/Master* account owner:
1. Log into: (NOT IAM!)
2. My Account/Personal Information
3. Set security challenge questions (fav color/dog/movie, etc.)
# Script for backing up sqlite3 database with integrity checking
# Intended for use with cron for regular automated backups
# @author <>
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
View gist:9690720
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
' ') printf + ;;
*) printf '%%%X' "'$c"
You can’t perform that action at this time.