[ SEA-GHOST MINI SHELL]

Path : /proc/3/cwd/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/3/cwd/var/lib/zabbix/check_localdomains.py

#!/usr/bin/env python3
"""
This script checks and compares the following files:
- /etc/localdomains
- /etc/remotedomains
- /etc/userdomains
"""
import subprocess

def count_lines(filename):
    """See: https://gist.github.com/zed/0ac760859e614cd03652"""
    out = subprocess.Popen(['wc', '-l', filename],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT
                         ).communicate()[0]
    return int(out.partition(b' ')[0])

def compare_files():
    try:
        """
        Compare number of lines of provided files and return False if compared length
        is bigger then 98% of lines in userdomains
        """
        local_len = count_lines('/etc/localdomains')
        remote_len = count_lines('/etc/remotedomains')
        user_len = count_lines('/etc/userdomains')

        compared_len = user_len - (local_len + remote_len)

        return compared_len > user_len * 0.02
    except:
        print(100500)
        exit(1)

if __name__ == '__main__':
    if compare_files():
        print(1)
    else:
        print(0)

SEA-GHOST - SHELL CODING BY SEA-GHOST