Skip to content

Instantly share code, notes, and snippets.

View darrenmartyn's full-sized avatar
💭
hacking

darrenmartyn

💭
hacking
View GitHub Profile
@apsun
apsun / hax.c
Last active April 22, 2024 05:49
Hook main() using LD_PRELOAD
/*
* Hook main() using LD_PRELOAD, because why not?
* Obviously, this code is not portable. Use at your own risk.
*
* Compile using 'gcc hax.c -o hax.so -fPIC -shared -ldl'
* Then run your program as 'LD_PRELOAD=$PWD/hax.so ./a.out'
*/
#define _GNU_SOURCE
#include <stdio.h>
@L-P
L-P / exec-notify.c
Created March 11, 2014 14:52
Watch process creation.
/* exec-notify, so you can watch your acrobat reader or vim executing "bash -c"
* commands ;-)
* Requires some 2.6.x Linux kernel with proc connector enabled.
*
* $ cc -Wall -ansi -pedantic -std=c99 exec-notify.c
*
* (C) 2007-2010 Sebastian Krahmer <krahmer@suse.de> original netlink handling
* stolen from an proc-connector example, copyright folows:
*/
/*