Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 1_phpunit-api.md
Created October 6, 2015 21:08 — forked from loonies/1_phpunit-api.md
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
@cmattoon
cmattoon / disasm.pl
Created October 8, 2015 18:48
disasm.pl
#!/usr/bin/perl -w
# Found at: http://www.ouah.org/RevEng/code/disasm.pl.txt
# Disasm.pl v0.4
#Assumes that the file we're working with is stripped
#TODO:
# 0. Sort NUMERICALLY on function call names, not lexographically
# 1. Get this to work if symbols are present
# 2. Add options or speed up the finding of unused functions (can we do it
# without an extra pass?)
@cmattoon
cmattoon / func_overload.py
Created October 18, 2015 15:57
Function Overloading - Alternative
#!/usr/bin/env python
from string import ascii_lowercase
def sum_list(values, ignore_invalid=True):
"""Returns the sum of a list of values.
String representations of integers ('0'-'9') are added at their
integer value, but letters have a value between 1-26.
(a=1, b=2, c=3, ...)
"""
total = 0
@cmattoon
cmattoon / Object.php
Last active November 4, 2015 19:11
PHP Base Object
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
class NotImplementedException extends BadMethodCallException {
public function __construct($message = null, $code = 0, $previous = null) {
parent::__construct($message, $code, $previous);
$this->message = "Method '{$message}' not implemented";
}
@cmattoon
cmattoon / .gitconfig
Created November 11, 2015 19:21
git aliases
## Some useful git aliases
## To apply aliases globally (for all repos on your computer), copy into ~/.gitconfig
## To add an alias to one repository only, add it to /path/to/repo/.git/config
##
## ALIASES THAT MENTION BRANCH/ORIGIN NAMES ('master', 'develop', 'origin', 'upstream') should be
## double-checked before adding to anything other than our repos, since these are relative terms.
## If you create a new repo, for example, that doesn't have a 'develop' branch, or 'origin' is not what
## you expect, it can mess things up. Most of them are safe for general use though.
##