Skip to content

Instantly share code, notes, and snippets.

View flounderK's full-sized avatar
💭
Screaming in confusion

Clif Wolfe flounderK

💭
Screaming in confusion
  • Good god I’m lost
View GitHub Profile
@flounderK
flounderK / build_aarch64_glibc.sh
Created November 5, 2023 16:07
cross compile glibc for aarch64
sudo apt install gcc-aarch64-linux-gnu
sudo apt install crossbuild-essential-arm64
sudo apt install crossbuild-essential-armel
sudo apt install gcc-arm-linux-gnueabi gcc-arm-none-eabi
git clone https://sourceware.org/git/glibc.git
cd glibc
mkdir build
cd build
# hg update --clean # clean
# hg purge
hg clone https://gmplib.org/repo/gmp
cd gmp
./.bootstrap
mkdir build
cd build
@flounderK
flounderK / hexdumppy.py
Last active December 27, 2023 19:25
hex dump in python
import string
def batch(it, sz):
for i in range(0, len(it), sz):
yield it[i:i+sz]
def hexdump_str(bytevals, offset=0, bytes_per_line=16, bytegroupsize=2):
# get max address size
@flounderK
flounderK / group_by_increment.py
Last active November 21, 2024 18:14
A python function to group sections of an iterable's elements if they are within a specified bounds of the values around them
def group_by_increment(iterable, group_incr, field_access=None, do_sort=True):
"""
Identify series of values that increment/decrement
within a bounds @group_incr, grouping them into lists.
The comparison to determine whether a value belongs in a group is
if (prev_val + group_incr) <= curr_val:
@iterable: iterable. This must be sorted for this function to work correctly.
@group_incr: amount to be added to a value to determine
@field_access: optional function to run on each element of the iterable to get
@flounderK
flounderK / create_ghidra_fidb.sh
Created December 22, 2023 23:52
create ghidra fidb
sudo apt install gcc-aarch64-linux-gnu
sudo apt install crossbuild-essential-arm64
sudo apt install crossbuild-essential-armel
sudo apt install gcc-arm-linux-gnueabi gcc-arm-none-eabi
git clone https://sourceware.org/git/glibc.git
cd glibc
mkdir build
cd build
@flounderK
flounderK / build_snort3.sh
Created January 19, 2024 14:22
building snort3
# build libdaq from source
git clone https://github.com/snort3/libdaq
cd libdaq
./bootstrap
mkdir build
cd build
../configure
make
cd ../../
@flounderK
flounderK / python_ctypes_primitives.py
Created March 2, 2024 15:56
python ctypes primitives
import ctypes
def arb_read(addr, size=4):
return bytes((ctypes.c_byte*size).from_address(addr))
def arb_write(addr, byts):
(ctypes.c_byte*len(byts)).from_address(addr)[:] = byts
def rough_addr_of(a):
@flounderK
flounderK / gist:aa8181351777c8056bb056f8285287a5
Last active April 11, 2025 02:28
gather code coverage information with gcov in gcc
# build targets with code coverage, CFLAGS bit only works if `+=` is used in the make file
CFLAGS="-fprofile-arcs -ftest-coverage" make CC=gcc
# <run test case>
# create files for all coverage reached by test case (don't use if using lcov)
find . -type f -iname '*.gcda' |xargs gcov
# generate coverage file for gcda files under this directory
lcov -c -d . -o coverage.info
CFLAGS="-fsanitize=undefined" make
@flounderK
flounderK / gist:de6bce77ea4bea357eff227542eae65b
Created April 11, 2025 02:53
gather code coverage with clang
clang -fprofile-instr-generate -fcoverage-mapping -o main main.c
LLVM_PROFILE_FILE="prof.profraw" ./main
# merge many profraw files into a profdata
llvm-profdata merge -sparse prof.profraw -o prof.profdata
# show coverage
llvm-cov show ./main -instr-profile=prof.profdata