Skip to content

Instantly share code, notes, and snippets.


Robin David RobinDavid

View GitHub Profile
RobinDavid /
Created Aug 30, 2020
SMT formula very hard to solve, even though its size is rather small
#!/usr/bin/env python3
import z3
a = z3.BitVec("a", 8)
b = z3.BitVec("b", 8)
c = z3.BitVec("c", 8)
d = z3.BitVec("d", 8)
e = z3.BitVec("e", 8)
solver = z3.SolverFor("QF_BV")
RobinDavid /
Created Jun 28, 2020
Tokenize a given line as provided by IDA
import ida_lines
import ida_kernwin
from enum import Enum
def tokenize_line(line):
COLOR_ON = "\x01"
COLOR_OFF = "\x02"
tag_mapping = Enum("TagMapping", {x: getattr(ida_lines, x) for x in dir(ida_lines) if (x.startswith("SCOLOR_") and x not in blacklist)})
RobinDavid /
Created Apr 28, 2020
Getting all problems in IDA Pro
import ida_ida
import ida_problems
import ida_idaapi
from enum import IntEnum
PrType = IntEnum("PrType", {x: getattr(ida_problems, x) for x in dir(ida_problems) if x.startswith("PR_") and x!="PR_END"})
problems = {}
RobinDavid /
Created Apr 10, 2020
IDA Pro iteratively restore all snapshots
import ida_kernwin
import ida_loader
ss = ida_loader.snapshot_t()
ccs = list(ss.children)
def callback(param1, param2):
RobinDavid /
Created Aug 8, 2019
Sum the size of all the shared libraries for a given dynamic ELF
#!/usr/bin/env python3
import sys
from pathlib import Path
import lddwrap
from hurry.filesize import size
def get_shared_size(filepath):
deps = lddwrap.list_dependencies(Path(filepath))
tot_size = 0
for d in deps:
RobinDavid /
Created Mar 29, 2018
Launch a function in a proces with a timeout on the execution time.
from multiprocessing import Process, Queue
def deadline(timeout, f, *args):
queue = Queue() #using to get the result
def subproc_function(queue, f, *args):
res = f(*args)
proc = Process(target=subproc_function, args=(queue, f) +args) #creation of a process calling longfunction with the specified arguments
proc.start() #lauching the processus on another thread
res = queue.get(timeout=timeout) #getting the resultat under 1 second or stop
RobinDavid /
Created Mar 23, 2018
Connecting programmatically (in python) to an existing jupyter kernel (from its file)
file = "/run/user/1000/jupyter/kernel-7365.json"
from jupyter_client.blocking import BlockingKernelClient
client = BlockingKernelClient(connection_file=file)
RobinDavid /
Created Jun 12, 2017
Download the first image of a wikipedia article
import sys
import lxml.html
from path import Path
import wikipedia
import requests
def dl_image(search_str):
page =
html = lxml.html.fromstring(page.html())
imgs = html.xpath("//img")
RobinDavid /
Last active May 26, 2017
Take a webpage screenshot
from selenium import webdriver
import sys
url_input = ("file://" if not sys.argv[1].startswith("http") else "") + sys.argv[1]
image_output = sys.argv[2]
driver = webdriver.Chrome() # or PhantomJS() not to open a windows (require phantomjs)
if driver.save_screenshot(image_output):
print("Save ok !")
RobinDavid /
Last active Apr 26, 2017
Binary diffing two files
#require zsh and colordiff (credits:
diff -y <(xxd $1) <(xxd $2) | colordiff
You can’t perform that action at this time.