Created
June 6, 2018 17:34
-
-
Save pboothe/c90b0a64fe5333bfd29d3538d9482729 to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" | |
cat cmdline \ | |
<(echo ===) \ | |
env \ | |
<(echo ===) \ | |
input \ | |
<(echo ===) \ | |
output \ | |
> summary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently only works with binaries in /usr/cin/bin