Skip to content

Instantly share code, notes, and snippets.

View cetfor's full-sized avatar

John Toterhi cetfor

View GitHub Profile
@cetfor
cetfor / challenge.c
Created January 22, 2021 21:44
Scripts and code for HackOvert Z3 function modeling
// Challenge from:
// https://www.reddit.com/r/ExploitDev/comments/gv72xr/reverse_engineer_passphrase_check/
#include <stdio.h>
#include <string.h>
int check(char* input) {
if (strlen(input) != 15) {
return 0;
} else {
import binaryninja
sources = [
'snprintf', # int snprintf ( char * s, size_t n, const char * format, ... );
'sprintf', # int sprintf ( char * s, const char * format, ... );
]
sinks = [
'system', # int system(const char *command);
]
#Checks system calls for command injection patterns
#@author
#@category HackOvert
#@keybinding
#@menupath
#@toolbar
from ghidra.app.decompiler import DecompileOptions
from ghidra.app.decompiler import DecompInterface
from ghidra.program.model.pcode import Varnode
@cetfor
cetfor / test.py
Last active October 29, 2020 14:18
Binary Ninja Update Analysis Test
import argparse
import binaryninja
import sys
import tempfile
import time
import math
import os
from multiprocessing import Pool, TimeoutError, cpu_count
import binaryninja
import networkx as nx
target = "cwe369B_ARM32"
RETURN_MAP = {
'atoi': 0,
}
import binaryninja
import networkx as nx
target = "cwe369B_x64"
RETURN_MAP = {
'atoi': 0,
}
target_operations = [
import binaryninja
import networkx as nx
target = "cwe369A_x64"
target_operations = [
binaryninja.MediumLevelILOperation.MLIL_DIVS,
binaryninja.MediumLevelILOperation.MLIL_DIVS_DP,
binaryninja.MediumLevelILOperation.MLIL_DIVU,
binaryninja.MediumLevelILOperation.MLIL_DIVU_DP,
@cetfor
cetfor / BuildAssignmentGraph.py
Created February 8, 2020 23:04
Build a NetworkX digraph of MLIL SSA assignments for data flow analysis
import binaryninja
import networkx as nx
target = "cwe369A_x64"
def build_symbol_graph(bv, func):
graph = nx.DiGraph()
for func in bv.functions:
for block in func.medium_level_il.ssa_form:
for instr in block:
# Get MLIL SSA form
import binaryninja
target = "cwe369A_x64"
target_operations = [
binaryninja.MediumLevelILOperation.MLIL_DIVS,
binaryninja.MediumLevelILOperation.MLIL_DIVS_DP,
binaryninja.MediumLevelILOperation.MLIL_DIVU,
@cetfor
cetfor / GetMLILOperands.py
Created February 8, 2020 18:53
Get MLIL SSA form and print operands
# Get MLIL SSA form and print operands
import binaryninja
target = "cwe369A_x64"
print("Analyzing file: {}".format(target))
bv = binaryninja.BinaryViewType.get_view_of_file(target)
bv.add_analysis_option('linearsweep')