Skip to content

Instantly share code, notes, and snippets.

@offlinemark
offlinemark / lowercase.py
Created July 27, 2013 23:30
Makes all directories in current directory lowercase.
import os, os.path
for thing in os.listdir('.'):
if thing[0] == '.':
continue
elif os.path.isdir(thing):
os.rename(thing, thing.lower())
@offlinemark
offlinemark / mou_refresh
Created January 6, 2014 17:53
Hack to refresh Mou markdown editor
#!/bin/bash
kill `ps -fu mark | grep -v grep | grep Mou | cut -d " " -f 5`
open notes.md
@offlinemark
offlinemark / clean.py
Created February 28, 2014 22:05
Using a positive security model (whitelist), sanitize username input for a login form, for example.
import re
def is_clean(username):
# usernames are allowed to have a-zA-Z0-9_.
# nothing else
if re.search('[^\w.]', username):
return False
else:
return True
@offlinemark
offlinemark / opcodes.sh
Created April 2, 2014 02:59
bash one-liner for converting binary object file to shellcode ( i didn't write this)
for i in $(objdump -d shell.o -M intel |grep "^ " |cut -f2); do echo -n '\x'$i; done;echo
@offlinemark
offlinemark / sc.txt
Created April 3, 2014 15:19
class linux x86 shellcode (i didn't write this)
\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x89\xc2\xb0\x0b\xcd\x80
@offlinemark
offlinemark / fsm_ff.py
Last active August 29, 2015 13:58
Generates the necessary flip flop inputs for a finite state machine with 3 bit state encodings
#!/usr/bin/env python
def ff(a, b):
if a == 0 and b == 0:
print '0 X',
elif a == 0 and b == 1:
print '1 X',
elif a == 1 and b == 0:
print 'X 1',
@offlinemark
offlinemark / whitespace
Created April 8, 2014 14:36
vim command to clear all random tab whitespace
%s/\t$//g
@offlinemark
offlinemark / gist:10519907
Last active August 29, 2015 13:59
bash one-liner that enumerates your $PATH and finds any executables that match a certain substring (the string before the last semicolon). Useful for when you're pretty sure you have a certain command on your system but you're not exaclty sure what it's called and "man -k" or "apropos" are too verbose
for path in `echo $PATH | sed "s/:/ /g"`; do printf "\n$path\n-----\n\n" ; ls $path | grep hex; done
@offlinemark
offlinemark / penum.fish
Created April 12, 2014 05:31
"Path Enumerator" - same thing as the bash one liner below; looks through your $PATH for commands that match a substring
function penum --description "enumerates $PATH looking for commands that partially match first parameter"
for each in $PATH
printf "\n$each\n---\n"
ls -l $each | grep $argv[1]
end
end
@offlinemark
offlinemark / gist:11227905
Created April 23, 2014 18:50
fix for vagrant "vboxfs" error. run in guest.
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions