-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsysloganalyzer.sh
executable file
·164 lines (145 loc) · 5.18 KB
/
sysloganalyzer.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /bin/bash
# Copyright © 2020-2022
# Initializes the colors
function initialize_colors() {
normal_color="\e[1;0m"
green_color="\033[1;32m"
green_color_title="\033[0;32m"
red_color="\033[1;31m"
red_color_slim="\033[0;031m"
blue_color="\033[1;34m"
cyan_color="\033[1;36m"
brown_color="\033[0;33m"
yellow_color="\033[1;33m"
pink_color="\033[1;35m"
white_color="\e[1;97m"
}
# Prints the intro
function print_intro() {
clear
echo -e "${red_color} _______ _______ _______ _______ _______ _______ _______ _____ "
sleep 0.15 && echo -e " ( ____ \( ____ )( ____ )( ___ )( ____ )( ____ \( __ ) / ___ \ "
sleep 0.15 && echo -e " | ( \/| ( )|| ( )|| ( ) || ( )|| ( \/| ( ) |( ( ) )Presents"
sleep 0.15 && echo -e " | (__ | (____)|| (____)|| | | || (____)|| (____ | | / |( (___) |SysLog Analyzer"
sleep 0.15 && echo -e " | __) | __)| __)| | | || __)(_____ \ | (/ /) | \____ |"
sleep 0.15 && echo -e " | ( | (\ ( | (\ ( | | | || (\ ( ) )| / | | ) |"
sleep 0.15 && echo -e " | (____/\| ) \ \__| ) \ \__| (___) || ) \ \__/\____) )| (__) |/\____) )"
sleep 0.15 && echo -e " (_______/|/ \__/|/ \__/(_______)|/ \__/\______/ (_______)\______/ ${normal_color}"
sleep 2
clear
}
# Print Header
function print_header() {
clear
echo -e "${green_color_title}***************************** Syslog Analyzer - Main Main ******************************${normal_color}"
sleep 0.15 && echo -e "${yellow_color} Copyright © 2020-2022${normal_color}"
sleep 0.15 && echo -e "\n"
}
# Print Options
function print_options() {
sleep 0.15 && echo -e "${green_color}Select an option from menu:${normal_color}"
sleep 0.15 && echo -e "${blue_color}---------${normal_color}"
sleep 0.15 && echo -e "0. Exit script"
sleep 0.15 && echo -e "1. Open Realtime Authentication log"
sleep 0.15 && echo -e "2. Open Realtime System Log"
sleep 0.15 && echo -e "3. Open Realtime Kernal Log"
sleep 0.15 && echo -e "${blue_color}---------${normal_color}"
sleep 0.15 && echo -e "4. About & Credits"
sleep 0.15 && echo -e "${blue_color}---------${normal_color}"
read -rp "> " option_selected
}
# Checks if the script is running as root user
function check_root_user() {
if [ "$EUID" -ne 0 ]
then
print_header
echo -e "${red_color}Script Not Running as root!!..............Run again as root!\n"
exit
fi
}
# Exit Script
function exit_script() {
echo -e "\n${red_color}Exiting Script!....................${normal_color}\n"
exit
}
# Auth Log Monitor
function auth_log_monitor() {
echo "${red_color}Opening Auth-Log Realtime Monitor${normal_color}"
xterm -e tail -f /var/log/auth.log
}
# System Log Monitor
function sys_log_monitor() {
echo "${red_color}Opening Realtime System Log Monitor${normal_color}"
xterm -e tail -f /var/log/syslog
}
# Kernal Log Monitor
function kernal_log_monitor() {
echo "${red_color}Opening Realtime System Log Monitor${normal_color}"
xterm -e tail -f /var/log/kern.log
}
# Invalid Option Selected
function invalid_option() {
echo -e "${red_color}Invalid Option! Try Again!....................${normal_color}"
}
# Main Case
function main_case() {
case "$option_selected" in
0)
exit_script
;;
1)
auth_log_monitor
;;
2)
sys_log_monitor
;;
3)
kernal_log_monitor
;;
4)
about_credits
;;
*)
invalid_option
;;
esac
}
# About & Credits
function about_credits() {
clear
echo -e "${green_color_title}***************************** Syslog Analyzer - About & Credits ******************************${normal_color}"
sleep 0.15 && echo -e "${yellow_color} Copyright © 2020-2022${normal_color}"
sleep 0.15 && echo -e "\n"
sleep 0.15 && echo -e "${red_color} _______ _______ _______ _______ _______ _______ _______ _____ "
sleep 0.15 && echo -e " ( ____ \( ____ )( ____ )( ___ )( ____ )( ____ \( __ ) / ___ \ "
sleep 0.15 && echo -e " | ( \/| ( )|| ( )|| ( ) || ( )|| ( \/| ( ) |( ( ) )Presents"
sleep 0.15 && echo -e " | (__ | (____)|| (____)|| | | || (____)|| (____ | | / |( (___) |SysLog Analyzer"
sleep 0.15 && echo -e " | __) | __)| __)| | | || __)(_____ \ | (/ /) | \____ |"
sleep 0.15 && echo -e " | ( | (\ ( | (\ ( | | | || (\ ( ) )| / | | ) |"
sleep 0.15 && echo -e " | (____/\| ) \ \__| ) \ \__| (___) || ) \ \__/\____) )| (__) |/\____) )"
sleep 0.15 && echo -e " (_______/|/ \__/|/ \__/(_______)|/ \__/\______/ (_______)\______/ ${normal_color}"
sleep 0.15 && echo -e "\n"
sleep 0.15 && echo -e "${blue_color}This script was developed as part of OS project for SEM 4${normal_color}"
sleep 0.15 && echo -e "${blue_color}---------${normal_color}"
sleep 0.15 && echo -e "${pink_color}Contact:${normal_color}\n"
sleep 0.15 && echo -e "${green_color}Alan${normal_color} https://github.com/iwtga"
sleep 0.15 && echo -e "\nPress [Enter] key to continue..."
read escape
}
# Main Menu
function main_menu() {
while true
do
print_header
print_options
main_case
done
}
# Main
main () {
initialize_colors
print_intro
check_root_user
main_menu
}
main