Skip to content

Instantly share code, notes, and snippets.

@laanwj
laanwj / transifex_migrate_resource.py
Last active November 1, 2015 14:59
Transifex resource migration script
'''
Run the script providing the slug of the project and the slug of the old and new resource.
The new resource should already have been created.
Example:
Old resource slug: 'old'
New resource slug: 'new'
python migrate_project.py project old new
@laanwj
laanwj / gist:4464490
Last active December 10, 2015 16:58 — forked from anonymous/gist:4430497
[seq 0] [thread 0] in={
.command = gcvHAL_GET_BASE_ADDRESS,
.u = {
}
}
[seq 1] [thread 0] out={
.command = gcvHAL_GET_BASE_ADDRESS,
.status = gcvSTATUS_OK,
.u = {
.GetBaseAddress = {
@laanwj
laanwj / texinfo_kobo.tex
Created June 14, 2013 08:15
Texinfo.tex configuration for generating PDFs readable with Kobo Glo 6" screen size
\def\afivepaper{{\globaldefs = 1
\parskip = 2pt plus 1pt minus 0.1pt
\textleading = 12.5pt
%
\internalpagesizes{111mm}{94mm}%
{-.5in}{-.85in}%
{0pt}{8pt}%
{127mm}{100mm}%
\lispnarrowing = 0.2in
\tolerance = 800
MOV t0.x___, void, void, t0.xxxx
MOV t0._y__, void, void, t0.xxxx
BRANCH.GE void, t0.yyyy, u0.zzzz, label_20 ; !bit_1_21=1! !bit_2_30=2!
LSHIFT t0._y__, t0.xxxx, void, u0.wwww ; !bit_2_30=1!
LOAD t1._yzw, u0.xxxx, t0.yyyy, void
MOV t0._yzw, void, void, t1.yyzw
LSHIFT t2.x___, t0.xxxx, void, u0.wwww ; !bit_2_30=1!
LOAD t1.xyz_, u0.xxxx, t2.xxxx, void
MOV t2.xyz_, void, void, t1.xyzz
MUL t3.xyz_, t0.yzww, t2.xyzz, void
@laanwj
laanwj / gist:8580481
Created January 23, 2014 15:27
Windows Qt 5.2.0 Qt5Gui.pc
prefix=/home/ubuntu/staging64
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: Qt5 Gui
Description: Qt Gui module
Version: 5.2.0
Libs: -L${libdir} -lQt5Gui
@laanwj
laanwj / build_afl.sh
Created April 21, 2016 10:34
Build univalue for afl-fuzz
#!/bin/bash
AFLPATH=/store/orion/upstream/testing/afl
CC=${AFLPATH}/afl-gcc CXX=${AFLPATH}/afl-g++ ./configure --disable-shared
export AFL_HARDEN=1
make
@laanwj
laanwj / siptests.py
Last active June 8, 2016 13:11
Bitcoin SipHash 2_4 tests
#!/usr/bin/python3
# Uses https://github.com/majek/pysiphash
import siphash, struct, binascii
_twoQ = struct.Struct('<QQ')
def check_hash(data, value, sip=None):
if sip is None:
sip = siphash.SipHash_2_4(_twoQ.pack(0x0706050403020100, 0x0F0E0D0C0B0A0908))
v = sip.update(data).hash()
if v != value:
print('Mismatch for %s: %016x versus %016x' % (
@laanwj
laanwj / 18_smt2.py
Created August 10, 2016 18:33
microcorruption ctf: 'invert' hash for Hollywood level using z3 constriant solver
#!/usr/bin/python
from __future__ import division, print_function, unicode_literals
from z3 import *
import binascii, struct
def byteswp(a):
'''
Build expression to swap bytes in 16-bit word.
'''
return RotateLeft(a,8) # can also be RotateRight, or even Concat(Extract(), Extract())
@laanwj
laanwj / SecondDate-3.1.1.0.c
Last active August 19, 2016 21:17
Some functions and data structures from SECONDDATE implant control module (extracted using https://github.com/laanwj/dwarf_to_c)
/* Basetype: unsigned int */
typedef unsigned int size_t;
/* Basetype: unsigned char */
/* Basetype: short unsigned int */
/* Basetype: long unsigned int */
/* Basetype: signed char */
/* Basetype: short int */
/* Basetype: int */
/* Basetype: long long int */
/* Basetype: long long unsigned int */
@laanwj
laanwj / radare2_stackpointers.py
Last active September 24, 2016 16:18
Compute, at each instruction, the value of the stack pointer relative to the return address. This is a tool to aid in reverse-engineering functions without fixed base frame pointer.
#!/usr/bin/env python3
# W.J. van der Laan 2016
# Compute, at each instruction, the value of the stack pointer
# relative to the return address.
import sys
import json
import re
instructions = json.load(sys.stdin, strict=False)
debug = True