def run_comb_perm_search(search): #Create progressbar to show how many searches have been done, removing eta search.progressbar = ProgressBar(total_items=get_num_comb_perm( string_options=search.string_options, num_chars=search.num_chars)) search.progressbar(num_compelted=0) #Get all public butets that have been found so far search.buckets_found = get_buckets_found(search.output_file) #Create a string generator search.string_generator = createStringGenerator(search.string_options, search.num_chars) #Check and see if a start after value was provided if search.start_after_value: search.start_after_found = False else: search.start_after_found = True #See if a stop at value is seen if search.stop_at_value: search.stop_at_found = False else: search.stop_at_found = False my_queue = Queue.Queue() for i in range(search.threads): t = threading.Thread(target=search_instance, args=(search, )) my_queue.put(t) #Run all of the threads while not my_queue.empty(): my_queue.get().start()
def run_random_search(search): #Create progressbar to show how many searches have been done, removing eta search.progressbar = ProgressBar(0) search.progressbar.fmt = '''%(percent)3d%% %(bar)s %(current)s/%(total_items)s %(items_per_sec)s Run time: %(run_time)s Bucket: %(bucket_name)s''' buckets_found = get_buckets_found(search.output_file) #Get all public butets that have been found so far search.buckets_found = get_buckets_found(search.output_file) #Create a string generator search.string_generator = createStringGenerator(search) my_queue = Queue.Queue() for i in range(search.threads): t = threading.Thread(target=search_instance, args=(search, )) my_queue.put(t) #Run all of the threads while not my_queue.empty(): my_queue.get().start()
try: clear_amount = (len(PROGRESS_BARS) - 1) * 2 for plugin in manager.getAllPlugins(): clear_amount += 2 clear_lines(clear_amount) # TODO: change to list comprehension to make it more pythonic # all static writers included in every static analysis writers = [common.Writer((0, height-8)), common.Writer((0, height-6)), common.Writer((0, height-4)), common.Writer((0, height-2)), common.Writer((0, height-10)), common.Writer((0, height-12)), common.Writer((0, height-14))] pbars = {} # create dictionary for progress bars, pbars = { name: ProgressBar } for barNum in range(len(PROGRESS_BARS)-1): pbars[PROGRESS_BARS[barNum]] = ProgressBar(widgets=[PROGRESS_BARS[barNum], Percentage(), Bar()], maxval=100, fd=writers[barNum]).start() # create writer and progress bar for each plugin placer = 0 for plugin in manager.getAllPlugins(): writer = common.Writer((0, height-(16+placer))) writers.append(writer) if 'Plugin issues' not in pbars: pbars['Plugin issues'] = {} pbars['Plugin issues'][plugin.plugin_object.getName()] = ProgressBar(widgets=[plugin.plugin_object.getName(), Percentage(), Bar()], maxval=100, fd=writer).start() placer += 2 pub.subscribe(progress_bar_update, 'progress') #Create static analysis threads
def metric_downloader(workbench, outputfolder): log = Logger("Measurement Downloader") conn = sqlite3.connect(workbench) curs = conn.cursor() visits = {} for row in curs.execute( 'SELECT WatershedName, SiteName, VisitYear, V.VisitID' ' FROM CHaMP_Visits V' ' INNER JOIN CHaMP_Sites S ON V.SiteID = S.SiteID' ' INNER JOIN CHaMP_Watersheds W ON S.WatershedID = W.WatershedID' ' WHERE V.ProgramID IN (1, 5, 6)' ' AND W.WatershedID IN (15, 32)' # NOT IN ("Asotin", "Big-Navarro-Garcia (CA)", "CHaMP Training")' ' ORDER BY WatershedName, visitYear'): if not row[0] in visits: visits[row[0]] = [] visits[row[0]].append({ 'VisitID': row[3], 'Year': row[2], 'Site': row[1] }) watersheds = list(visits.keys()) watersheds.sort() curs.close() for watershed in watersheds: visitCount = len(visits[watershed]) p = ProgressBar(end=len(visits[watershed]), width=20, fill='=', blank='.', format='[%(fill)s>%(blank)s] %(progress)s%%') for visit in visits[watershed]: p + 1 print p visit_path = os.path.join(outputfolder, str(visit['Year']), watershed.replace(' ', ''), visit['Site'].replace(' ', ''), 'VISIT_{}'.format(visit['VisitID'])) measurements = APIGet("visits/{0}/measurements".format( visit['VisitID'])) for meas in measurements: if not os.path.isdir(visit_path): os.makedirs(visit_path) meas_path = os.path.join( visit_path, '{}.json'.format(meas['name'].replace(' ', ''))) data = APIGet(meas['url'], True) json_string = json.dumps(data['values']) with open(meas_path, 'w') as outfile: json.dump(data, outfile) print('Process completed')
common.keyFiles=common.findKeys(common.sourceDirectory) ''' #Look for improper use of checkCallingPermission, rather than enforceCallingPermission try: useCheckPermission() except Exception as e: common.logger.error("Unable to run checks for improper use of checkCallingPermission: " + str(e)) ''' clearlines(14) height = common.term.height try: writer1 = common.Writer((0, height-8)) pbar1 = ProgressBar(widgets=['X.509 Validation ', Percentage(), Bar()], maxval=100, fd=writer1).start() writer2 = common.Writer((0, height-6)) pbar2 = ProgressBar(widgets=['Pending Intents ', Percentage(), Bar()], maxval=100, fd=writer2).start() writer3 = common.Writer((0, height-4)) pbar3 = ProgressBar(widgets=['File Permissions (check 1) ', Percentage(), Bar()], maxval=100, fd=writer3).start() writer4 = common.Writer((0, height-2)) pbar4 = ProgressBar(widgets=['File Permissions (check 2) ', Percentage(), Bar()], maxval=100, fd=writer4).start() writer5 = common.Writer((0, height-10)) pbar5 = ProgressBar(widgets=['Webview checks ', Percentage(), Bar()], maxval=100, fd=writer5).start() writer6 = common.Writer((0, height-12)) pbar6 = ProgressBar(widgets=['Broadcast issues ', Percentage(), Bar()], maxval=100, fd=writer6).start() writer7 = common.Writer((0, height-14)) pbar7 = ProgressBar(widgets=['Crypto issues ', Percentage(), Bar()], maxval=100, fd=writer7).start() pub.subscribe(progress_bar_update, 'progress')