Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #This Python script checks for operating system artifacts
- #By Enigma
- import os
- # Color Codes:
- # Green (Success) = \033[92m
- # Red (Error) = \033[93m
- ## Setting global print variables
- openrc = ("\n\033[92m rc-status: \033[0m")
- sysd = ("\n\033[92m systemctl-status: \033[0m")
- runit = ("\n\033[92m /var/service: \033[0m")
- init_ = ("\n\033[93m no init status available \033[0m")
- mounts = ("\n\033[92m /proc/mounts: \033[0m")
- mounts_ = ("\n\033[93m /proc/mounts does not exist \033[0m")
- hosts = ("\n\033[92m Trusted host relationship: \033[0m")
- hosts_ = ("\n\033[93m /etc/hosts.allow does not exist \033[0m")
- passwd = ("\n\033[92m Account creation order: \033[0m")
- passwd_ = ("\n\033[93m /etc/passwd does not exist \033[0m")
- UUID_0 = ("\n\033[92m UUID 0: \033[0m")
- crontab = ("\n\033[92m /etc/crontab: \033[0m")
- crontab_ = ("\n\033[93m /etc/crontab does not exist \033[0m")
- cron_allow = ("\n\033[92m /etc/cron.allow: \033[0m")
- cron_allow_ = ("\n\033[93m /etc/cron.allow does not exist \033[0m")
- cron_deny = ("\n\033[92m /etc/cron.deny: \033[0m")
- cron_deny_ = ("\n\033[93m /etc/cron.deny does not exist \033[0m")
- cron_hourly = ("\n\033[92m /etc/cron.hourly/: \033[0m")
- cron_hourly_ = ("\n\033[93m /etc/cron.hourly/ does not exist \033[0m")
- cron_daily = ("\n\033[92m /etc/cron.daily/: \033[0m")
- cron_daily_ = ("\n\033[93m /etc/cron.daily/ does not exist \033[0m")
- cron_weekly = ("\n\033[92m /etc/cron.weekly/: \033[0m")
- cron_weekly_ = ("\n\033[93m /etc/cron.weekly/ does not exist \033[0m")
- cron_monthly = ("\n\033[92m /etc/cron.monthly/: \033[0m")
- cron_monthly_ = ("\n\033[93m /etc/cron.monthly/ does not exist \033[0m")
- log = ("\n\033[92m /var/log: \033[0m")
- log_ = ("\n\033[93m /var/log/ does not exist \033[0m")
- # Defining functions
- def _init():
- if os.path.exists('/etc/rc.conf') == True:
- print (openrc)
- os.system('rc-status')
- elif os.path.exists('/etc/systemd') == True:
- print (sysd)
- os.system('systemctl-status')
- elif os.path.exists('/var/service') == True:
- print (runit)
- os.system('cat /var/service')
- else:
- print (init_)
- def _mounts():
- if os.path.exists('/proc/mounts') == True:
- print (mounts)
- os.system('cat /proc/mounts')
- else:
- print (mounts_)
- def _hosts():
- if os.path.exists('/etc/hosts.allow') == True:
- print (hosts)
- os.system('cat /etc/hosts.allow')
- else:
- print (hosts_)
- def _passwd():
- if os.path.exists('/etc/passwd') == True:
- print (passwd)
- os.system('cat /etc/passwd | sort -nk3 -t:')
- print (UUID_0)
- os.system('cat /etc/passwd | grep x:0: | cut -d ":" -f 1')
- else:
- print (passwd_)
- def _crontab():
- if os.path.exists('/etc/crontab') == True:
- print (crontab)
- os.system('cat /etc/crontab')
- else:
- print (crontab_)
- def _cron_allow():
- if os.path.exists('/etc/cron.allow') == True:
- print (cron_allow)
- os.system('cat /etc/cron.allow')
- else:
- print (cron_allow_)
- def _cron_deny():
- if os.path.exists('/etc/cron.deny') == True:
- print (cron_deny)
- os.system('cat /etc/cron.deny')
- else:
- print (cron_deny_)
- def _cron_hourly():
- if os.path.isdir('/etc/cron.hourly/') == True:
- print (cron_hourly)
- for file in os.listdir('/etc/cron.hourly/'):
- print(file)
- else:
- print (cron_hourly_)
- def _cron_daily():
- if os.path.isdir('/etc/cron.daily/') == True:
- print (cron_daily)
- for file in os.listdir('/etc/cron.daily/'):
- print(file)
- else:
- print (cron_daily_)
- def _cron_weekly():
- if os.path.isdir('/etc/cron.weekly/') == True:
- print (cron_weekly)
- for file in os.listdir('/etc/cron.weekly/'):
- print(file)
- else:
- print (cron_weekly_)
- def _cron_monthly():
- if os.path.isdir('/etc/cron.monthly/') == True:
- print (cron_monthly)
- for file in os.listdir('/etc/cron.monthly/'):
- print(file)
- else:
- print (cron_monthly_)
- def _log():
- if os.path.isdir('/var/log/') == True:
- print (log)
- for file in os.listdir('/var/log/'):
- print(file)
- else:
- print (log_)
- ## Defining the main function to call each other function
- def main():
- _init()
- _mounts()
- _hosts()
- _passwd()
- _cron_allow()
- _cron_deny()
- _crontab()
- _cron_hourly()
- _cron_daily()
- _cron_weekly()
- _cron_monthly()
- _log()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement