Skip to content

Instantly share code, notes, and snippets.

@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 ");
# 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"
blah blah
@zedshaw
zedshaw / safercopy.c
Created January 4, 2015 17:18
A simple version of copying via string lengths then breaking it on purpose
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define MAXLINE 10 // in the book this is 1000
void safercopy(size_t to_length, char to[], size_t from_length, char from[])
{
int i = 0;
import os
import csv
import sys
data = {}
completed = []
base_url = "https://www.amazon.com/gp/your-account/order-history/ref=oh_aui_search?opt=ab&search=%s"
def amzn_url(order_id):
return base_url % order_id
import os
import csv
import sys
data = {}
completed = []
base_url = "https://www.amazon.com/gp/your-account/order-history/ref=oh_aui_search?opt=ab&search=%s"
def amzn_url(order_id):
return base_url % order_id
import os
import csv
import sys
data = {}
completed = []
base_url = "https://www.amazon.com/gp/your-account/order-history/ref=oh_aui_search?opt=ab&search=%s"
def amzn_url(order_id):
return base_url % order_id
@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'
@zedshaw
zedshaw / safercopy_smash.c
Created January 4, 2015 19:07
Demonstration of using a pointer to alter the operation of another function in C.
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define MAXLINE 10 // in the book this is 1000
void safercopy(size_t to_length, char to[], size_t from_length, char from[])
{
int i = 0;
@zedshaw
zedshaw / lua_jester_sqlite.nim
Created February 24, 2017 03:20
Quick hack to sort out Lua in Jester with SQL DB in Nim
import db_sqlite
import jester, asyncdispatch, htmlgen
import nimLUA
let db = open("test.sqlite3", nil, nil, nil)
proc render(page: string, name: string) : string =
var L = newNimLua()
discard L.pushstring(name)
L.setglobal("name")