from Spitzer import command
from Spitzer.config import config
from Spitzer.result import result
from Spitzer.print import print_error

import subprocess

category = ['heavy']

def bust(url, nmap):
    print('[*] starting gobuster')
    pages = []

    lists = config.get_config('wordlist').split(',')
    for list in lists:
        cmd = ['gobuster', 'dir', '-w', config.get_data('busterlist')[list], '-u', url, '-q', '-n']

        extensions = config.get_data('extensions')
        for extension, value in extensions.items():
            if extension in nmap['product']:
                cmd += ['-x', value]
                break
        completed = command.run(cmd, True)
        if completed is None:
            return

        print(completed)

        for line in iter(completed.splitlines()):
                print(line)
                pages.append(line)

    return pages