Skip to content

Instantly share code, notes, and snippets.

blah blah
# Examples of various error handling mechanisms and if-statements.
def something(x,y):
if !x:
raise "argh!"
else:
if !y:
raise "oh noes!"
else:
return "Happy"
@zedshaw
zedshaw / gist:10324409
Created April 9, 2014 22:18
Checking SILC toolkit for exploitable string functions
Checking silc tookit for bad string functions using:
egrep -r '[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)' .
Result is below. Not great but about 300 is a manageable target to audit and improve.
./contrib/regexpr.c: strcpy(buf, "end");
./contrib/regexpr.c: strcpy(buf, "bol");
./contrib/regexpr.c: strcpy(buf, "eol");
./contrib/regexpr.c: strcpy(buf, "set ");
@zedshaw
zedshaw / gist:6969554
Created October 14, 2013 01:49
Wrapper for a django handler that adds the CORS stuff.
from functools import wraps
from urlparse import urlparse
def cors(func):
def add_basic_headers(resp, url):
resp['Access-Control-Allow-Origin'] = url.scheme + "://" + url.netloc
resp['Access-Control-Allow-Credentials'] = 'true'
resp['Access-Control-Allow-Methods'] = 'GET'
resp['Access-Control-Allow-Headers'] = 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'