Skip to content

Instantly share code, notes, and snippets.

@cmattoon
cmattoon / aslr.py
Created September 27, 2015 20:43
Enable/Disable ASLR on Linux
#!/usr/bin/env python
"""
mv aslr.py /usr/bin/aslr && chmod +x /usr/bin/aslr
Be careful!
"""
import os, sys
FLAG_ENABLE = 2
FLAG_DISABLE = 0
@cmattoon
cmattoon / pruppet.pp
Created September 18, 2015 20:16
Puppet file vs. URL
# Assume a file located at /etc/puppet/environments/development/modules/foo/files/bar/baz.txt
$file_contents = file('foo/bar/baz.txt', '/dev/null')
if $file_contents != '' {
file { '/tmp/baz.txt':
content => $file_contents
}
}
## OR...
$file_url = 'puppet:///modules/foo/bar/baz.txt'
file { '/tmp/baz.txt':
@cmattoon
cmattoon / usersetting
Created September 8, 2015 01:57
RedStar OS /tmp/usersetting
#!/bin/sh
if [ "$1x" != "x" ];then
. $1
fi
isExist=`cat /etc/group | grep admin:x`
if [ "$isExist" = "" ]; then
cat /etc/group>/tmp/group.tmp
echo "Adding 'admin' group..."
@cmattoon
cmattoon / gist:a63e75075e9bb4ccd50b
Created August 26, 2015 13:51
Most common errors in apache log
# Relies on log format:
# [Wed Aug 26 00:00:00 2015] [error] [client 123.45.67.8] Error message here
cat /var/log/apache2/error.log | awk '{out=$9;for(i=9;i<=NF;i++){out=out" "$i}; print out}' | sed s/,\ referer.*// | sort | uniq -c | sort -nr
@cmattoon
cmattoon / example.md
Created July 15, 2015 13:53
File Transfer with Netcat

Transfer files from A (172.21.1.2) to B (172.21.1.3) using netcat and gzip compression on port 7000.

Optionally uses pipeviewer (pv), which'll probably need installed if you're on Ubuntu (apt-get install pv)

On machine A:

cd src-dir/

tar -zc * | pv | nc 172.21.1.3 7000

On machine B:

@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;
}
}
@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 / 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 / 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 / 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"