from Spitzer.config import config
import subprocess

category = ['safe']

def exploit(nmap):
    print('screenshot!')
    hosts = ''
    for host in nmap:
        hosts += host + '\n'

    ports = '80,443'
    #print(nmap)
    for host, value in nmap.items(): 
        for port in value['tcp']:
            if 'http' in value['tcp'][port]['name'] and str(port) not in ports:
                ports += ',' + str(port)

    path = config.get_path() + 'hosts.txt'
    open(path, 'w+').write(hosts)

    subprocess.run('cat ' + path + ' | aquatone -out screens -ports ' + ports, check=True, text=True, shell=True)
    print('[*] Saved screenshots in screens')

    #move report named to current folder