Skip to content

Instantly share code, notes, and snippets.

@cmattoon
cmattoon / phpunit_install.sh
Last active August 29, 2015 14:16
PHPUnit Install Script
#!/bin/bash
if [ "$EUID" != "0" ]; then
echo "You must be root"
exit 1;
fi
wget https://phar.phpunit.de/phpunit.phar -O /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit
echo "$(which phpunit)"
@cmattoon
cmattoon / After
Last active August 29, 2015 14:16
Removing commit #5 with git rebase
a2971b1 (HEAD, master) Commit # {10} [Curtis Mattoon]
0 0 file_10
feb3de8 Commit # {9} [Curtis Mattoon]
0 0 file_9
cc74178 Commit # {8} [Curtis Mattoon]
0 0 file_8
bfcbc72 Commit # {7} [Curtis Mattoon]
@cmattoon
cmattoon / command.sh
Last active August 29, 2015 14:16
Extract a table from mysql dump
# The basic command that gets run
sed -n '/CREATE TABLE.*table/,/UNLOCK TABLES/p' full_database_backup.sql > table.sql
@cmattoon
cmattoon / args_error.sh
Last active August 29, 2015 14:16
Bash Script Default Parameter Demo
#!/bin/bash
# Triggers an error of params are empty.
username=${1:?"You must specify a username"}
password=${2:?"You must specify a password"}
echo "Setting password for ${username} to ${password}"
exit 0;
@cmattoon
cmattoon / .htaccess
Created March 13, 2015 00:48
InfoSecInstitute CTF - Level 2 - Content-Type Examples
# The .htaccess rewrite rule used to make "apple.php" look like "apple.png"
RewriteEngine On
RewriteBase /fakeimg/
RewriteRule ^apple.png$ apple.php
@cmattoon
cmattoon / uri.js
Last active August 29, 2015 14:17 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@cmattoon
cmattoon / decode.py
Created March 18, 2015 01:31
Decode a QR code
#!/usr/bin/env python
"""
Decodes a QR code image.
Usage: ./decode.py /path/to/image
"""
import qrtools, sys
qr = qrtools.QR()
qr.decode(sys.argv[1])
print("Message is: %s" % (qr.data))
@cmattoon
cmattoon / rotsolver.py
Last active August 29, 2015 14:17
Caesar Cipher Solver
#!/usr/bin/python
"""Brute-forces a ROT cipher
http://cmattoon.com/infosec-institute-ctf-level-4/
"""
def rot(text, n):
"""Rotates 'text' by 'n' positions"""
output = ''
for char in text.lower(): # don't use uppercase values
x = ord(char)
@cmattoon
cmattoon / README.md
Last active July 1, 2024 14:32
Visual Binary Analysis

MySQL Dump

This shade of green happens to correspond to mostly-ASCII characters. This color green correlates to mostly ASCII chars

GPG Encryption

Symmetric (gpg -c) encryption of the above MySQL dump. Encryption - Random Colors in Random Places

@cmattoon
cmattoon / LateStaticBinding.php
Created July 2, 2015 14:56
Late Static Binding in PHP
class Foo {
public static $attr = 'foo';
public static function getAttr() {
return static::$attr;
}
public static function getAttr2() {
return self::$attr;
}
}