Skip to content

Instantly share code, notes, and snippets.

View withzombies's full-sized avatar

Ryan Stortz withzombies

View GitHub Profile
@withzombies
withzombies / crackaddr_vuln.c
Last active January 23, 2024 09:51
halvar's reimplementation of mark dowd's crackaddr vulnerability
/*
Copyright (c) 2011, Thomas Dullien
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. Redistributions
@withzombies
withzombies / StructuredDataView.py
Last active October 3, 2018 19:00
Apply a structure to an address and access its members in BinaryNinja
#!/usr/bin/env python
# Copyright 2017 Ryan Stortz (@withzombies)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
$ python binja_memcpy.py /bin/bash
Analyzing /bin/bash
100038024 dst:<entry rsi>
src:<entry rdi>
n:<range: -0x80000000 to 0x7fffffff>
1000380c9 dst:<undetermined>
src:<entry rdi>
n:<range: -0x80000000 to 0x7fffffff>
def returnTypedString():
# type: () -> str
return "lol"
def returnUntypedString():
return "aww"
a = returnTypedString()
b = returnUntypedString()
>>> import binaryninja
>>> bv = binaryninja.BinaryViewType["Mach-O"].open("/bin/ls")
>>> bv.update_analysis_and_wait()
>>> t = bv.parse_type_string("int (*lol)(int one, void* two, size_t three)")
>>> t
(<type: int32_t (*)(int32_t one, void* two, uint64_t three)>, 'lol')
>>> ti = t[0]
>>> dir(ti)
['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'alignment', 'array', 'bool', 'calling_convention', 'can_return', 'const', 'count', 'element_type', 'enumeration', 'enumeration_type', 'float', 'function', 'get_string_after_name', 'get_string_before_name', 'handle', 'has_variable_arguments', 'int', 'modified', 'parameters', 'pointer', 'return_value', 'signed', 'structure', 'structure_type', 'target', 'type_class', 'unknown_type', 'void', 'width']
>>> ti.return_value
@withzombies
withzombies / opendns mitm
Created October 21, 2016 18:34
opendns is man-in-the-middling me
$ dig calendar.google.com @208.67.222.222
; <<>> DiG 9.8.3-P1 <<>> calendar.google.com @208.67.222.222
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19048
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;calendar.google.com. IN A
#include <iostream>
#include <experimental/optional>
#define LIFT(fname) \
[] (auto&&... args) -> decltype (auto) \
{ \
return fname (std::forward <decltype (args)> (args)...); \
}
template<typename Func, typename... Args>
@withzombies
withzombies / install-api.py
Created September 21, 2016 04:21
Install the Binary Ninja Python API
#!/usr/bin/env python
import os
import sys
import os.path
import site
try:
import binaryninja
print "Binary Ninja API Installed"
@withzombies
withzombies / 334x.py
Last active March 26, 2023 16:22
Script to solve the 334 cuts challenge from DEFCON 2016 quals using Binary Ninja
#!/usr/bin/env python
import sys
try:
import binaryninja
except ImportError:
sys.path.append("/Applications/Binary Ninja.app/Contents/Resources/python/")
import binaryninja
import time
import socket
@withzombies
withzombies / gist:3dfa993b050b1ba5253f
Created July 24, 2015 19:12
getting libreboard working
1 sudo apt-get update
2 sudo apt-get dist-upgrade
3 sudo reboot
4 ls
5 sudo shutdown -h now
6 sudo apt-get install git
7 git clone http://git.libreboard.com/libreboard/libreboard.git
8 ls
9 df -h
10 mkdir node