-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinuxprivcheck.py
29 lines (26 loc) · 2.33 KB
/
linuxprivcheck.py
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
import os
import subprocess as sub
osInfo={'OS':{'cmd':'cat /etc/issue','name':'Linux Version'},'HOSTNAME':{'cmd':'hostname','name':'System Hostname'},'KERNEL':{'cmd':'cat /proc/version','name':'Kernel Version!'},'UPTIME':{'cmd':'uptime','name':'Server uptime'}}
netInfo={'NETWOK INFO':{'cmd':'ifconfig -a','name':'IP Info!'},'ROUTE':{'cmd':'route -n','name':'ROUTE'},'PORTS':{'cmd':'netstat -ntlp | grep LISTEN','name':'LISTEN PORTS!'},'CONNECTIONS':{'cmd':'netstat -atlp | grep ESTABLISHED','name':'Established Connections!'}}
diskInfo={'DISK':{'cmd':'df -h','name':'DISK USAGE'}}
cpu_mem_Info={'CPUCOUNT':{'cmd':'cat /proc/cpuinfo | grep processor','name':'Cpu Count'},'CPUUSAGE':{"cmd":"grep 'cpu' /proc/stat | awk '{usage=($2+$4)/($2+$4+$5)} END {print usage}'",'name':'Cpu utilization'},'PROCCPU':{'cmd':'ps aux --sort=-pcpu | head -10','name':'Top 10 Process CPU utilization'},'MEMSTAT':{'cmd':'vmstat 2 5','name':'Memory Stats'},'MEMTOTAL':{'cmd':'cat /proc/meminfo | grep MemTotal:','name':'TotalMemory'},'MEMUTIL':{'cmd':'ps -aux --sort=-pcpu | head -10','name':'Top 10 Process Mem Utilization'}}
userInfo={'USERS':{'cmd':' cut -d : -f 1 /etc/passwd','name':'System Users'},'CLOGGIN':{'cmd':'w','name':'Current Login'}}
vul_Analysis={'BASH':{"cmd":"x='() { :;}; echo VULNERABLE' bash -c :",'name':'Bash Vulnerbility'},'GLIBC':{"cmd":"wget https://raw.githubusercontent.com/nadeemshahzad/Linux-vulnerability-analysis/master/GHOST.c && gcc GHOST.c -o GHOST && ./GHOST","name":"Glibc Vulnerbility"},'WWDIR':{'cmd':"find / -wholename '/proc/*' -prune -o -perm -0002 -type d -exec ls -ld {} \;","name":"world-writeable Linux Directories"},'WWFILES':{'cmd':"find / -wholename '/proc/*' -prune -o -perm -0002 -type f -exec ls -ld {} \;",'name':'world-writable Linux Files'}}
SystemInfo=[osInfo,netInfo,diskInfo,cpu_mem_Info,userInfo,vul_Analysis]
#SystemInfo=[vul_Analysis]
def checkInfo(sInfo):
for item in sInfo:
cmd=sInfo[item]['cmd']
name=sInfo[item]['name']
print '[+]', name
out,err=sub.Popen([cmd],stdout=sub.PIPE,stderr=sub.PIPE,shell=True).communicate()
results=out.split('\n')
for result in results:
if result.strip() != "":
print result
for item in SystemInfo:
if os.getuid() == 0:
checkInfo(item)
else:
print "run this script as super user"
break