# Path: lib/settings.py
# def get_top_domains(dbname):


import threading
import time
import subprocess
import re
import lib.utils as utils
from lib.logger import *
from lib.objects import *
from lib.settings import homenet, lock
            for ip in rdp_targets:
                self.brute_force_service(ip, 'rdp')

            for ip in smb_targets:
                self.brute_force_service(ip, 'smb')

            for ip in vnc_targets:
                self.brute_force_service(ip, 'vnc')

            log.debug('FG-INFO: Default credentials assessment finished')

            time.sleep(86400)

    def brute_force_service(self, tip, service):

        proc = subprocess.Popen(['/usr/bin/hydra', '-t', '4', '-C', '/tmp/default_creds.csv', '-o', '/tmp/hydra_report', tip, service])
        proc.communicate()
        try:
            f = open('/tmp/hydra_report')
            lines = f.readlines()
            for line in lines:
                line = line.strip()
                groups = re.findall(self.hydra_regex1, line.strip())
                if groups:
                    with lock:
                        new_issue = DefaultCredentials()
                        new_issue.service = groups[0][1]
                        new_issue.port = groups[0][0]
                        new_issue.user = groups[0][3]
                        new_issue.password = groups[0][4]

# Path: lib/settings.py
# def get_top_domains(dbname):


# Path: lib/offensive.py
import threading
import time
import subprocess
import re
import lib.utils as utils
from lib.logger import *
from lib.objects import *
from lib.settings import homenet, lock

            for ip in rdp_targets:
                self.brute_force_service(ip, 'rdp')

            for ip in smb_targets:
                self.brute_force_service(ip, 'smb')

            for ip in vnc_targets:
                self.brute_force_service(ip, 'vnc')

            log.debug('FG-INFO: Default credentials assessment finished')

            time.sleep(86400)

    def brute_force_service(self, tip, service):

        proc = subprocess.Popen(['/usr/bin/hydra', '-t', '4', '-C', '/tmp/default_creds.csv', '-o', '/tmp/hydra_report', tip, service])
        proc.communicate()
        try:
            f = open('/tmp/hydra_report')
            lines = f.readlines()
            for line in lines:
                line = line.strip()
                groups = re.findall(self.hydra_regex1, line.strip())
                if groups:
                    with lock:
                        new_issue = DefaultCredentials()
                        new_issue.service = groups[0][1]
                        new_issue.port = groups[0][0]
                        new_issue.user = groups[0][3]
                        new_issue.password = groups[0][4]

                        homenet.hosts[tip].vuln_accounts.append(new_issue)