def os_discovery():
hs = HostSearch()<EOL>hosts = hs.get_hosts(ports=[<NUM_LIT>], tags=['<STR_LIT>'])<EOL>hosts = [host for host in hosts if not host.os]<EOL>host_dict = {}<EOL>for host in hosts:<EOL><INDENT>host_dict[str(host.address)] = host<EOL><DEDENT>arguments = "<STR_LIT>".split('<STR_LIT:U+0020>')<EOL>if len(hosts):<EOL><INDENT>count = <NUM_LIT:0><EOL>print_notification("<STR_LIT>".format(len(hosts)))<EOL>result = nmap(arguments, [str(h.address) for h in hosts])<EOL>parser = NmapParser()<EOL>report = parser.parse_fromstring(result)<EOL>for nmap_host in report.hosts:<EOL><INDENT>for script_result in nmap_host.scripts_results:<EOL><INDENT>script_result = script_result.get('<STR_LIT>', {})<EOL>host = host_dict[str(nmap_host.address)]<EOL>if '<STR_LIT>' in script_result:<EOL><INDENT>host.hostname.append(script_result['<STR_LIT>'])<EOL><DEDENT>if '<STR_LIT>' in script_result:<EOL><INDENT>count += <NUM_LIT:1><EOL>host.os = script_result['<STR_LIT>']<EOL><DEDENT>host_dict[str(nmap_host.address)] = host<EOL><DEDENT><DEDENT>for host in hosts:<EOL><INDENT>host.add_tag('<STR_LIT>')<EOL>host.save()<EOL><DEDENT>print_notification("<STR_LIT>".format(count))<EOL><DEDENT>else:<EOL><INDENT>print_notification("<STR_LIT>")<EOL><DEDENT>
Performs os (and domain) discovery of smb hosts.