Skip to content

Instantly share code, notes, and snippets.

@multun
multun / trickz.py
Last active January 13, 2023 17:45
Jupyter notebook / lab trickz
import tqdm
import tqdm.notebook
tqdm.tqdm = tqdm.notebook.tqdm
from tqdm import tqdm
import pdb
def custom_exc(shell, etype, evalue, tb, tb_offset=None):
shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset)
pdb.post_mortem(tb)
get_ipython().set_custom_exc((Exception,), custom_exc)
@multun
multun / hlil_visitor.py
Created August 6, 2022 22:38
BinaryNinja HLIL expression visitor
from dataclasses import dataclass
from typing import Callable
@dataclass
class ExprVisitor:
matcher: Callable[[HighLevelILInstruction], bool]
block: HighLevelILBasicBlock
def visit_insn(self, expr):
@multun
multun / zenhub-SAFe-bullshitizer.js
Last active May 12, 2022 18:03
zenhub SAFe bullshitizer
// ==UserScript==
// @name SAFe bullshitizer
// @version 1
// @grant none
// @include https://app.zenhub.com/*
// @include https://github.com/*
// ==/UserScript
console.log("starting replacement script");
@multun
multun / golang_re.md
Created October 15, 2020 15:07
Golang reverse engineering notes
  • golang has runtime type information. the format of the structure varies between compiler versions
  • convT2E converts some value to interface{}, and takes a pointer to a type and a value, and returns an interface
  • golang also always has function names / line info
@multun
multun / ackermann.py
Created September 9, 2020 09:40
Fast ackermann
from functools import lru_cache
@lru_cache(maxsize=1024)
def kn(a, b, order):
assert order >= 1
if order == 1:
return a ** b
sub_order = order - 1
res = a
@multun
multun / plugin_subclasses.py
Created April 18, 2020 07:48
A Mixin class for making class based plugins
#!/usr/bin/env python3
class PluginSubclassesMixin:
def __init_subclass__(cls, register_base=False, **kwargs):
super().__init_subclass__(**kwargs)
if PluginSubclassesMixin not in cls.__bases__:
return
cls.subclasses = []
if register_base:
@multun
multun / argparse.sh
Created April 17, 2020 17:22
A shell library for parsing arguments
# parse --my_option into the MY_OPTION variable
# also handles positional arguments
__args_list=()
__required_args_list=()
__unexport_args_list=()
normalize_argument() {
# uppercase
local argname="${1^^}"
import asyncio
async def merge_iter(iterables):
# create async iterators from the iterables
iterators = [iterable.__aiter__() for iterable in iterables]
# create an next() task per iterator
tasks = {asyncio.ensure_future(it.__anext__()): it for it in iterators}
try:
while tasks:
#include <type_traits>
#include <iostream>
template<class T>
struct BaseA {
static void test() {
std::cout << "int" << std::endl;
}
};
#include <type_traits>
#include <iostream>
template<class T, class Enable = void>
struct A {
static void test() {
std::cout << "int" << std::endl;
}
};