[ SEA-GHOST MINI SHELL]

Path : /proc/2/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/root/var/lib/zabbix/orphanhomes.py

#!/usr/bin/env python2.7
import commands
import pwd
import os

def get_orphan_uid(uid):
  """Return uid only if user not found"""
  try:
    pwd.getpwuid(uid)[0]
    return False
  except:
    return uid

def get_mountpoints():
  """Return the list of system mount points"""
  mount = commands.getoutput('df -Ph')
  mntlines = mount.split('\n')[1::] # [1::] trims the first line (column names)
  return map(lambda line: line.split()[5], mntlines)


def get_subdir_users(a_dir):
  """Return orphan user ids of all subdirectores of given directory
 (excluding symbolic links). Also returns the name of the directory
  where such a user is found"""
  for name in os.listdir(a_dir):
    subdir = os.path.join(a_dir, name)
    if os.path.isdir(subdir) and not os.path.islink(subdir):
      uid = os.stat(subdir).st_uid
      orphan_uid = get_orphan_uid(uid)
      if orphan_uid:
        yield orphan_uid, a_dir


if __name__ == "__main__":
  users = []
  for mount in get_mountpoints():
    if 'home' in mount:
      users.extend(get_subdir_users(mount))

  print ', '.join('%d: %s' % (x[0], x[1]) for x in users)


SEA-GHOST - SHELL CODING BY SEA-GHOST