-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo.sh
More file actions
111 lines (84 loc) · 2.67 KB
/
sysinfo.sh
File metadata and controls
111 lines (84 loc) · 2.67 KB
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
#!/bin/bash
#script created by ioef aka Dr_Ciphers
clear
echo -e "Hostname\t:" `hostname`
echo -e "IP\t\t: "`host \`hostname\` | cut -d' ' -f4`
echo -e "System Time\t:" `date +%H:%H:%S`
echo -e "Uptime\t\t:" `uptime | awk '{print $3" "$4}'` | cut -d',' -f1
#acquire the username of the logged in user
getwhoami=`whoami`
#acquire the OS and store it for futher usage
OS=`uname -s`
echo -e "username\t:" $getwhoami
if [ "$OS" == "OpenBSD" ]; then
echo -e "Lastlog\t\t:" `last | grep $getwhoami | grep "still"`
fi
if [ "$OS" == "Linux" ]; then
echo -e "Lastlog\t\t:" `lastlog | grep $getwhoami | cut -d' ' --complement -f1`
fi
echo -e "Groups\t\t:" `groups`
echo -e "working dir\t: "`pwd`
echo
echo "CPU"
echo "=========================================================================="
echo "This is `uname -s` running on a `uname -m` processor."
if [ "$OS" == "Linux" ]; then
echo "CPU Model:" `cat /proc/cpuinfo | grep "model name" | sort -u | cut -d":" -f2`
fi
if [ "$OS" == "OpenBSD" ]; then
sysctl hw | grep hw.model | sort -u | cut -d"=" -f2
fi
echo
echo "Memory"
echo "=========================================================================="
if [ "$OS" == "OpenBSD" ]; then
top -d1 | sed '5q;d'
fi
if [ "$OS" == "Linux" ]; then
free -h | head -2
fi
echo
echo
echo "Disk usage"
echo "================================================"
df -h
echo
echo "Network Information"
echo "================================================"
#code to find the default Gateway either on Linux or OpenBSD
if [ "$OS" == "Linux" ]; then
echo -e "Gateway\t\t:" `sudo route -n | awk '/^0.0.0.0/{ printf $2"\n" } '`
fi
if [ "$OS" == "OpenBSD" ]; then
echo -e "Gateway\t\t:" `sudo route -n show | awk '/^default/{ printf $2"\n" } '`
fi
#echo "DNS" `nslookup ls | grep Server:`
echo -e "DNS Server(s)\t:" `cat /etc/resolv.conf | grep nameserver | cut -d" " -f2`
echo
echo "Network Listening Services (IPv4)"
echo "================================================================================================"
sudo netstat -a | grep "LISTEN"
echo
echo "Services"
echo "=========================="
if [ "$OS" == "OpenBSD" ]; then
services=`rcctl ls on`
for service in $services;
do
echo "[+] $service";
done;
fi
if [ "$OS" == "Linux" ]; then
#fetch the running services and redirect the stderr
#to /dev/null
services=`sudo service --status-all 2>/dev/null`
#check for tor
echo "$services" | grep -q "[ + ] tor"
if [ $? -eq 0 ]; then
echo "Tor is up and running"
fi
echo "$services" | grep -q "[ + ] nginx"
if [ $? -eq 0 ]; then
echo "Nginx is up and running"
fi
fi