Last active
March 4, 2017 00:05
-
-
Save h-otter/530fb7da6bcaaf77b537c4337ccb5aa9 to your computer and use it in GitHub Desktop.
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 -eu | |
usage_exit() { | |
echo "Usage: $0 [-d user] [-u user]" 1>&2 | |
echo " -d: disable deny access from user" 1>&2 | |
echo " -u: kick $1 and deny access from user" 1>&2 | |
exit 1 | |
} | |
kick_user(){ | |
echo [+] kicking $1 and deny access | |
{ | |
usermod -L $1 | |
} || { | |
echo [-] if you are not root, please execute with sudo | |
exit 1 | |
} | |
pkill -KILL -u $1 | |
#echo [*] still logged in | |
#last | grep logged | |
echo [*] w command | |
w | |
su - | |
exit 0 | |
} | |
allow_access(){ | |
echo [+] allow access | |
{ | |
usermod -U $1 | |
} || { | |
echo [-] if you are not root, please execute with sudo | |
exit 1 | |
} | |
rm /root/.bash_history | |
exit 0 | |
} | |
while getopts :d:u:h OPT | |
do | |
case $OPT in | |
d) allow_access $OPTARG | |
;; | |
u) kick_user $OPTARG | |
;; | |
h) usage_exit | |
;; | |
\?) usage_exit | |
;; | |
esac | |
done | |
usage_exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
未検証
auditについて調査