Skip to content

Instantly share code, notes, and snippets.

@tmr232
tmr232 / defaults.py
Created March 4, 2014 19:44
Decorator to enable changing the values of default arguments in python functions.
from functools import wraps
class Default(object):
def __init__(self, name):
super(Default, self).__init__()
self.name = name
def set_defaults(defaults):
@tmr232
tmr232 / bitmapper.html
Created November 8, 2014 14:57
View a file as an image
<html>
<body>
<style>
#byte_content {
margin: 5px 0;
max-height: 100px;
overflow-y: auto;
overflow-x: hidden;
}
#byte_range { margin-top: 5px; }
def _remove_visual_c_ref(self, manifest_file):
try:
# Remove references to the Visual C runtime, so they will
# fall through to the Visual C dependency of Python.exe.
# This way, when installed for a restricted user (e.g.
# runtimes are not in WinSxS folder, but in Python's own
# folder), the runtimes do not need to be in every folder
# with .pyd's.
# Returns either the filename of the modified manifest or
# None if no manifest should be embedded.
@tmr232
tmr232 / settrace.py
Last active August 29, 2015 14:11
sys.settrace usage sample
import sys
import inspect
class Tracer(object):
def __init__(self):
self._indentation_level = 0
@property
def indentation_level(self):
@tmr232
tmr232 / construct.py
Last active August 29, 2015 14:14
New Construct Syntax
import operator
import construct
class ConstructGetter(object):
def __init__(self):
self._index = 0
def __getattr__(self, name):
@tmr232
tmr232 / demo.py
Created April 2, 2015 11:30
Construct Suggestion - Ordered Keyword Arguments
from easy_construct import cs, struct, Container
MyStruct = struct("MyStruct",
_0=cs.Magic("EZConstruct"),
variable=cs.UBInt32,
another_var=cs.UBInt16,
_1=cs.Padding(0x4),
array=cs.Bytes(13),
_2=cs.Magic("MagicEndsHere"),
)
@tmr232
tmr232 / FunctionBinding.js
Created November 16, 2012 14:27
Javascript function binding crap
// Define a class with a method
function MyClass(value) {
this.value = value;
this.function = function() {
return this.value;
};
}
// Instanciate the class
my_class = new MyClass("my value");

Building lldb on Mac

Create Codesign Certificate

First we need to create a certificate. The llvm provided a way to do that, but I found this way to work slightly better for me. Just substitute lldb_codesign for the certificate name, instead of gdb-cert.

Install swig dependency

def get_bb_id(graph, ea):
for block in graph:
if block.startEA <= ea and block.endEA > ea:
return block.id
start_ea = 0x15f9ad6
base_block_ea = 0x15f9a60
f = get_func(start_ea)
g = FlowChart(f, flags=FC_PREDS) #???
@tmr232
tmr232 / setdebugger.ps1
Created January 18, 2016 09:46
Enable or disable debugger-on-launch for Windows executables
Param(
[Parameter(Mandatory=$true)]
[string]$ExeName,
[switch]
$Disable
)
{
New-Item -Path "HKLM:\Software\Microsoft\Windows NT\currentversion\image file execution options" -Name $ExeName -Force