Skip to content

Instantly share code, notes, and snippets.

View HunterKohler's full-sized avatar
🇺🇸
Working from the USA

Hunter Kohler HunterKohler

🇺🇸
Working from the USA
  • United States
View GitHub Profile
@HunterKohler
HunterKohler / shellcode-execve.S
Last active October 3, 2022 06:09
execve shellcode linux 32-bit little-endian
# Shellcode (linux, 32-bit, little-endian)
# ---------
# execve("/bin/sh", { "/bin/sh", "-p" }, NULL)
start:
# Calculate and store "-p"
mov $0x0101712E, %eax
sub $0x01010101, %eax
push %eax
mov %esp, %ecx
class PromiseHandle<T> {
private _resolve!: (value: T | PromiseLike<T>) => void;
private _reject!: (reason?: unknown) => void;
private _promise: Promise<T>;
private _resolved: boolean = false;
private _rejected: boolean = false;
public constructor() {
this._promise = new Promise<T>((resolve, reject) => {
this._resolve = resolve;
@HunterKohler
HunterKohler / uuid.ts
Created May 26, 2022 20:24
Idiomatic UUID type to avoid primitive obsession in object mapping. (typescript)
import crypto from "crypto";
const UUIDPattern =
/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
export class InvalidUUIDError extends Error {
public get name() {
return this.constructor.name;
}
@HunterKohler
HunterKohler / threads.c
Last active March 2, 2022 17:07
Start of a super-simple UNIX ISO-C11 threads header.
/*
* Copyright (C) 2021-2022 John Hunter Kohler <jhunterkohler@gmail.com>
*/
#include <stdlib.h>
#include <stdatomic.h>
#include <errno.h>
#include "threads.h"
union thrd_routine_info {
int ret;
@HunterKohler
HunterKohler / fs.ts
Created January 31, 2022 20:47
Alright file system walker
/*
* Copyright (C) 2021 Hunter Kohler <jhunterkohler@gmail.com>
*/
import fs from "fs";
import path from "path";
interface WalkdirOptions {
withFileTypes?: boolean;
followlinks?: boolean;
files?: boolean;
@HunterKohler
HunterKohler / .eslintrc.json
Created January 25, 2022 08:12
Personal ESLint Config
{
"$schema": "https://json.schemastore.org/eslintrc",
"env": {
"es6": true,
"node": true
},
"plugins": [],
"extends": [],
"globals": {},
"ignorePatterns": [],
@HunterKohler
HunterKohler / reljmp.c
Last active January 8, 2022 07:17
Replace functions by loading library symbols and writing a unconditional jump. (x86 only)
/*
* Copyright (C) 2021 Hunter Kohler <jhunterkohler@gmail.com>
*/
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include "reljump.h"
size_t page_size()
{
@HunterKohler
HunterKohler / pip-upgrade-all
Last active December 24, 2021 21:53
Update all global pip dependencies with a simple script
#!/usr/bin/env python3
import pathlib
import subprocess
import tempfile
def main():
result = subprocess.run(
["pip3", "freeze"], text=True, capture_output=True, check=True)
@HunterKohler
HunterKohler / .gitignore
Last active April 3, 2022 08:26
General .gitignore base for all projects.
# System Files
.DS_Store
# Editor Files
.vscode/
# Build Directories
bin/
build/
dist/
@HunterKohler
HunterKohler / iterator.h
Created December 2, 2021 01:52
STL Container iterator wrapper
/*
* Wraps the template parameter without changing any semantics. Good
* for wrapping pointers.
*/
template <typename Iterator>
class normal_iterator {
public:
using difference_type = typename std::iterator_traits<Iterator>::difference_type;
using value_type = typename std::iterator_traits<Iterator>::value_type;
using pointer = typename std::iterator_traits<Iterator>::pointer;