Skip to content

Instantly share code, notes, and snippets.

View hartwork's full-sized avatar
🇺🇦

Sebastian Pipping hartwork

🇺🇦
View GitHub Profile
@hartwork
hartwork / useram.c
Created September 30, 2026 14:48
Determine the amount of RAM that can be allocated in practice
// Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org>
// Licensed under the Apache license version 2.0
//
// Compile and run with:
// # gcc -std=c99 -Wall -Wextra -Werror useram.c && ./a.out malloc
#include <assert.h>
#include <limits.h>
#include <locale.h>
#include <stdbool.h>
@hartwork
hartwork / attribute_collision_check_payload_2.py
Created May 28, 2026 14:53
CVE-2026-45186 libexpat attack payload generator (use responsibly)
# Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org>
# Original idea by Nick Wellnhofer
# SPDX-License-Identifier: MIT
import argparse
import string
parser = argparse.ArgumentParser()
parser.add_argument("times", metavar="COUNT", type=int)
@hartwork
hartwork / result_pipe.ts
Created May 17, 2025 20:08
Wait for callbacks to finish and access their results in TypeScript
#! /usr/bin/env node
// Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
// SPDX-License-Identifier: 0BSD
import { Sema } from "async-sema";
// eslint-disable-next-line @typescript-eslint/no-require-imports
import assert = require("node:assert");
class ResultPipe<T> {
@hartwork
hartwork / wait_for_callback_finish.ts
Last active May 18, 2025 21:39
Demo waiting for a callback to finish in TypeScript
#! /usr/bin/env node
// Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
// SPDX-License-Identifier: 0BSD
function callCallbackSomeTime(callback: () => void): void {
setTimeout(function () {
callback();
}, 2000);
}
@hartwork
hartwork / timezone_logging_demo.py
Created May 5, 2025 15:18
Demo Python logging with time zone information for field `asctime`
#! /usr/bin/env python3
# Copyright (c) Sebastian Pipping <sebastian@pipping.org>
#
# Licensed under Zero-Clause BSD
# SPDX-License-Identifier: 0BSD
import datetime
import logging
@hartwork
hartwork / selenium_check_url.py
Last active April 30, 2025 14:29
Check a URL using Selenium
#! /usr/bin/env python3
# Check a URL using headless Selenium
# Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
#
# Licensed under GNU Affero General Public License v3.0 or later
# SPDX-License-Identifier: AGPL-3.0-or-later
import argparse
import json
import sys
@hartwork
hartwork / demo_libfuzzer_coverage.cxx
Created February 11, 2025 12:55
Demo effectiveness of coverage-guided fuzz testing with libFuzzer (https://llvm.org/docs/LibFuzzer.html#id30)
// Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
// Licensed under the MIT license
#include <cstdint>
#include <signal.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size >= 1 && Data[0] == 'H') {
if (Size >= 2 && Data[1] == 'e') {
if (Size >= 3 && Data[2] == 'l') {
@hartwork
hartwork / show_libfuzzer_input.cxx
Last active February 11, 2025 12:20
libFuzzer fuzzer that dumps its input to stdout to get a sense of the effect of a given dictionary file (fuzzer argument "-dict=FILE")
// Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
// Licensed under the MIT license
#include <cctype> // isprint(3)
#include <cstdint>
#include <cstdio> // putchar(3), printf(3)
#include <sys/param.h> // MIN(3)
static const unsigned int MAX_LEN = 30;
#! /usr/bin/env python3
# Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
# Licensed under the MIT license
import decimal
import math
import sys
from decimal import Decimal
import pylab
@hartwork
hartwork / test_pidgin_plugin_loadable.c
Created September 2, 2024 15:03
Test a Pidgin plug-in file (.dll or .so) for loadability as a GModule (originally made for Lurch in 2022)
// Copyright (c) 2022 Sebastian Pipping <sebastian@pipping.org>
// Licensed under the GPL v2 or later
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <gmodule.h>