def scan(subnets, seed, cooldown, nrounds, zmap_binary): scan_files = [] # First, find which devices are online (give some time for the replies to arrive) logger.info('searching for online devices') add_result_file(scan_files) ZMap.zmap(binary = zmap_binary, output_file = scan_files[-1], subnets = subnets, seed = seed, cooldown = cooldown) online_devices = ZMap.read_results_from_file(scan_files[-1]) ZMap.populate_whitelist(online_devices, filename = ZMap.WHITELIST_TMP) logger.info('%s devices found to be online' % len(online_devices)) # Then scan just the online devices for i in xrange(nrounds): add_result_file(scan_files) ZMap.zmap(binary = zmap_binary, output_file = scan_files[-1], whitelist = ZMap.WHITELIST_TMP, seed = seed, cooldown = cooldown) logger.info('ping number %s done' % (i + 1)) logger.info('ZMap rounds finished') ZMap.clean(ZMap.WHITELIST_TMP) return scan_files
def identify(zmap_binary, subnets, nrounds, cooldown, pattern_generator): # First, find which devices are online (give some time for the replies to arrive) logger.info('searching for online devices') online_devices = ZMap.zmap(binary = zmap_binary, subnets = subnets, cooldown = 8) ZMap.populate_whitelist(online_devices, filename = ZMap.WHITELIST_TMP) logger.info('%s devices found to be online' % len(online_devices)) # Start generating the pattern logger.info('starting the pattern generator') pattern_generator.start() # Then scan just the online devices scans = [online_devices] for i in xrange(nrounds): devices = ZMap.zmap(binary = zmap_binary, whitelist = ZMap.WHITELIST_TMP, cooldown = cooldown) logger.info('%s devices replied to the ping number %s' % (len(devices), i + 1)) scans.append(devices) logger.info('ZMap rounds finished') ZMap.clean(ZMap.WHITELIST_TMP) # Compute the round-trip times map(ZMap.add_rtts, scans) # Wait for the generator to finish logger.info('stopping the pattern generator') pattern_generator.join() result = {} result['type'] = TYPENAME result['scans'] = scans return result
def do_scan(zmap_binary, subnets, nrounds, cooldown): # First, find which devices are online (give some time for the replies to arrive) logger.info('searching for online devices') online_devices = ZMap.zmap(binary = zmap_binary, subnets = subnets, cooldown = 8) ZMap.populate_whitelist(online_devices, filename = ZMap.WHITELIST_TMP) logger.info('%s devices found to be online' % len(online_devices)) # Then scan just the online devices scans = [online_devices] for i in xrange(nrounds): devices = ZMap.zmap(binary = zmap_binary, whitelist = ZMap.WHITELIST_TMP, cooldown = cooldown) logger.info('%s devices replied to the ping number %s' % (len(devices), i + 1)) scans.append(devices) logger.info('ZMap rounds finished') ZMap.clean(ZMap.WHITELIST_TMP) # Compute the round-trip times map(ZMap.add_rtts, scans) return scans