Stuff

Cron for keeping system up to date

0 18 * * * yum clean all ; yum update -y; reboot

Add to .bashrc for clear git/hg branch indication

function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/ (git: 1)/'
}

function parse_hg_branch () {
hg branch 2> /dev/null | sed -e 's/(.*)/ (hg: 1)/'
}

GREEN="[\033[1;32m]"
CYAN="[\033[1;36m]"
WHITE="[\033[1;97m]"
NO_COLOR="[\033[0m]"

PS1="$WHITE[$GREENw$CYAN$(parse_git_branch)$CYAN$(parse_hg_branch)$WHITE]$ $NO_COLOR"

How to find and replace a string in files recursively

find . -type f -exec sed -i 's/foo/bar/g' {} +

Commit code from branch to master, using rebase

git status
git fetch -ap
git rebase origin/master
git mergetool
git rebase --continue
git push -f
git log
git rebase -i HEAD~<number of commits>
git log
git push -f

Look at a disassembly of raw shellcode from a metasploit payload

sudo msfpayload -p linux/x86/shell_bind_tcp R | ndisasm -u -

Look at step by step output of shellcode using libemu
(-vvv very verbose output, S shellcode from stdin, s # of iterations)

sudo msfpayload -p linux/x86/shell_bind_tcp R | ./sctest -vvv -Ss 100000

Look at step by step output of shellcode using libemu to produce a graphic
(-vvv very verbose output, S shellcode from stdin, s # of iterations, -G .dot graph file)

sudo msfpayload -p linux/x86/shell_bind_tcp R | ./sctest -vvv -Ss 100000 -G shell_bind_tcp.dot
dot shell_bind_tcp.dot -Tpng -o shell_bind_tcp.png

Visual binary files

( echo "P5 512 2048 255" ; cat [filename] ) > [filename].pgm

Create non-empty empty directory structure to add Git project
You can’t add empty directories to git, this shell script adds .gitignore, which is ignored by git :), to all directories so git will add them.

find . -name .git -prune -o -type d -empty -exec touch {}/.gitignore ;

Reverse Engineering Algorithm (Windows binaries)

1. Gather information
	- Import Address Table
	- strings
	- dynamic analysis
2. Identify function of interest
3. Identify CALLs
4. Identify algorithms and data structures
5. Goto 2

Entering Unicode Characters (Debian/Ubuntu)

Hold CTRL+SHIFT+u Release, type hex code for character

OpenBSD Radeon HD7850 Fix

boot -c
disable radeondrm

# pkg_add http://firmware.openbsd.org/firmware/snapshots/radeondrm-firmware-20150927.tgz
# reboot