Skip to content

Instantly share code, notes, and snippets.

View JonathonReinhart's full-sized avatar

Jonathon Reinhart JonathonReinhart

View GitHub Profile
@MidSpike
MidSpike / readme.md
Last active February 5, 2024 18:09
CVE-2022-23812 | RIAEvangelist/node-ipc is malware / protest-ware
@adamhooper
adamhooper / c_clone.py
Last active December 16, 2023 23:27
Call Linux clone() from within Python
import ctypes
import os
import signal
from typing import Callable
libc = ctypes.CDLL("libc.so.6", use_errno=True)
# <linux/prctl.h>
PR_SET_NAME = 15
PR_SET_SECCOMP = 22
@JonathonReinhart
JonathonReinhart / ctypes_structs_example.py
Last active November 4, 2022 13:39
Using Python ctypes to manipulate binary data
#!/usr/bin/env python3
from __future__ import print_function
from tempfile import TemporaryFile
from binascii import hexlify
from ctypes import *
class StructHelper(object):
def __get_value_str(self, name, fmt='{}'):
val = getattr(self, name)
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active November 5, 2023 12:14
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@pypt
pypt / pyyaml-duplicates.py
Created September 9, 2015 22:10
PyYAML: raise exception on duplicate keys on the same document hierarchy level
import yaml
from yaml.constructor import ConstructorError
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
def no_duplicates_constructor(loader, node, deep=False):
#include <lang/libc-ext.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
char * normalize_path(char* pwd, const char * src, char* res) {
size_t res_len;
size_t src_len = strlen(src);