def you_get_signal_scan(host): ip = host['ipv4_addr'] url_h = urllib2.urlopen(YOU_GET_SIGNAL_URL, "remoteAddress={0}&key=".format(ip)) try: data = json.load(url_h) except: kraken.log(kraken.LOG_LVL_WARNING, "failed to get yougetsignal data") raise kraken.error("failed to get yougetsignal data") if data['status'].lower() != 'success': kraken.log(kraken.LOG_LVL_WARNING, data['message']) raise kraken.error(" ".join(data['message'].split()[:6])) if str(data.get('domainCount', '0')) == '0': kraken.log(kraken.LOG_LVL_DEBUG, 'you_get_signal returned 0 domains for ' + ip) return domainArray = map(lambda x: x[0], data['domainArray']) if not len(domainArray): return known_hostnames = kraken.host_manager.get_hostnames(ip) for name in known_hostnames: if name in domainArray: domainArray.remove(name) if not len(domainArray): return for name in domainArray: try: dnsresp = socket.gethostbyname_ex(name) except: return # probably a "herror: [Errno 4] No address associated with name" error if ip in dnsresp[2]: kraken.host_manager.add_hostname(ip, name)
def main(args): if not len(args): return 0 for name in args.split(' '): try: kraken.host_manager.quick_add_by_name(name) except ValueError as err: raise kraken.error(err.message) return 0