-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsshaudit.sh
94 lines (82 loc) · 1.71 KB
/
sshaudit.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
##
# SSH internal audit
# - Check authentication logs for failed logins
# - Check user sudo command history
# - Check bash history
# - Panic button to kill user session
##
server_name=$(hostname)
function flogin_check() {
echo ""
echo "Failed logins on ${server_name} are: "
egrep "Failed|Failure" /var/log/auth.log
echo ""
}
function userhistory_check() {
echo "Please enter the username:"
read uname
echo ""
echo "History of $uanme on ${server_name}: "
echo ""
tail /var/log/auth.log | grep $uname
echo ""
}
function bashhistory_check() {
echo "Please enter the username:"
read uname
echo "Bash history of $uname on ${server_name}: "
echo ""
sudo nano /home/$uname/.bash_history
echo ""
}
function panic_check() {
w
echo "Type the username to kill the remote session"
read uname
echo "kill user session on ${server_name}: "
sudo killall -u $uname
echo ""
}
function all_checks() {
flogin_check
userhistory_check
bashhistory_check
panic_check
}
##
# Color Variables
##
green='\e[32m'
blue='\e[34m'
clear='\e[0m'
##
# Color Functions
##
ColorGreen(){
echo -ne $green$1$clear
}
ColorBlue(){
echo -ne $blue$1$clear
}
menu(){
echo -ne "
SSH Internal Audit
$(ColorGreen '1)') Check failed logins
$(ColorGreen '2)') User Command History
$(ColorGreen '3)') Bash History of User
$(ColorGreen '4)') Panic Kill User Session
$(ColorGreen '0)') Exit
$(ColorBlue 'Choose an option:') "
read a
case $a in
1) flogin_check ; menu ;;
2) userhistory_check ; menu ;;
3) bashhistory_check ; menu ;;
4) panic_check ; menu ;;
0) exit 0 ;;
*) echo -e $red"Wrong option."$clear; WrongCommand;;
esac
}
# Call the menu function
menu