Skip to content

Instantly share code, notes, and snippets.

View stephen-soltesz's full-sized avatar

Stephen Soltesz stephen-soltesz

View GitHub Profile
@pboothe
pboothe / fake.sh
Created June 6, 2018 17:34
A command that spies on a binary by being run in its place, calling the original and forking all input and output to logfiles as well as the called subprocess
#!/bin/bash
OUTPUT=$(mktemp -d --tmpdir=/tmp "$(date -Iseconds).$(basename $0).XXXXXXX")
echo "$@" > "${OUTPUT}/cmdline"
env > "${OUTPUT}/env"
cat - \
| tee "${OUTPUT}/input" \
| /usr/cni/bin/$(basename $0) $@ \
| tee "${OUTPUT}/output"
cd "${OUTPUT}"