def cp_file2file(source_file, target_file, should_be_notice_files): if source_file.rsplit('.', 1)[1] not in allowedFileTypes: return if is_file_modified(source_file, target_file): if source_file in should_be_notice_files: if notice_if_cover_file(source_file, target_file): shutil.copy(source_file, target_file) with indent(6, quote=colored.clean('#')): puts( colored.cyan('Update %s -> %s' % (cleaner_path(source_file), cleaner_path(target_file)))) else: shutil.copy(source_file, target_file) with indent(6, quote=colored.clean('#')): puts( colored.cyan('Auto update %s -> %s' % (cleaner_path(source_file), cleaner_path(target_file)))) elif is_file_modified(source_file, target_file) is None: shutil.copy(source_file, target_file) with indent(6, quote=colored.clean('#')): puts( colored.cyan( 'Copy %s -> %s' % (cleaner_path(source_file), cleaner_path(target_file))))
def handle_noargs(self, **options): # Inspired by Postfix's "postconf -n". from django.conf import settings, global_settings # Because settings are imported lazily, we need to explicitly load them. settings._setup() user_settings = module_to_dict(settings._wrapped) default_settings = module_to_dict(global_settings) opts = Options() from clint.textui import puts, colored pformat = "%30s: %-30s %-30s %-30s" puts('') puts(pformat % (colored.white('Option'), colored.cyan('APP Value'), colored.cyan('INI Value'), colored.green('APP Default'))) puts('') for section in opts.sections: puts(pformat % (colored.green("[%s]" % section), '', '', '')) for key, kaio_value in opts.items(section): keycolor = colored.magenta(key) if key in user_settings: value = colored.green(user_settings[key]) keycolor = colored.blue(key) else: value = colored.green( opts.options[key].get_value_or_default()) default_value = opts.options[key].default_value kaio_value = kaio_value if kaio_value else repr(kaio_value) puts(pformat % (keycolor, clint_encode(value), colored.white(clint_encode(kaio_value)), clint_encode(default_value))) puts('') puts( colored.white( "No configurables directamente en INI (estáticos o compuestos por otros):" )) puts() not_configured = set(user_settings.keys()) - set(opts.keys()) # not_configured = not_configured - set([ # 'INSTALLED_APPS', # 'MIDDLEWARE_CLASSES', # 'CONTEXT_PROCESSORS', # ]) pformat = "%30s: %-50s" puts(pformat % (colored.white('Option'), colored.cyan('Value'))) for key in sorted(not_configured): if key not in default_settings: puts(pformat % (colored.blue(key), user_settings[key])) elif user_settings[key] != default_settings[key]: puts(pformat % ( colored.blue(key), colored.green(user_settings[key]) # colored.white(default_settings[key]) ))
def status(arguments): output = StringIO() verbose = initialise(arguments) environments = arguments['<environment>'] if environments: puts(columns( [(colored.green('Nickname')), 15], [(colored.green('Instance Type')), 10], [(colored.green('Status')), 20], [(colored.green('Instance href')), 60], ), stream=output.write) for environment in environments: server = righteous.find_server(environment) if server: settings = righteous.server_settings(server['href']) if verbose: server_info = righteous.server_info(server['href']) puts('Server Info:\n' + colored.cyan(pformat(server_info))) puts('Server Settings:\n' + colored.cyan(pformat(settings))) puts(columns( [environment, 15], [settings['ec2-instance-type'], 10], [server['state'] if server else 'Found', 20], [server['href'] if server else 'Not', 60], ), stream=output.write) else: puts(colored.red('%s: Not Found' % environment), stream=output.write) print output.getvalue()
def send_ena_action(ena_acc, action, test=False, date=None, samples=False): file_path = create_xml(ena_acc, action, date, samples) url = settings.ENA_SRA_URL if test: url = settings.ENA_SRA_DEV_URL print colored.magenta('This submission is going to ENA Dev Server') content = '<html>' requests.packages.urllib3.disable_warnings(InsecureRequestWarning) while '<html>' in content: files = {'SUBMISSION': open(file_path, 'rb')} r = requests.post(url, files=files, verify=False, timeout=1000) content = r.content if '<html>' not in content: break else: time.sleep(20) print content server = 'production' if test: server = 'test' if 'success="true' not in content: print colored.cyan('FAILURE: Failed submission to ENA. with the following errors ') errors = content.split('<ERROR>') for e in errors[1:]: print colored.red(e.split('</ERROR>')[0]) return False, [i.split('</ERROR>')[0] for i in errors] else: print colored.green("%s was applied successfully on %s in the %s server" % (action, ena_acc, server)) return True, []
def handle(self, *args, **options): # Load dynamic configs - the middleware is not working here, so do this manually config.load_app_configs() self.stdout.write(colored.cyan('Retrieving Olap datasets...')) self.stdout.write(colored.cyan('__________________________________________________________________')) self.stdout.write(colored.cyan('Olap datasets defined in the Vique configuration:')) self.stdout.write('') try: for key, values in config.OLAP_DATASETS.iteritems(): olap_datasource = config.OLAP_DATASOURCES[values['olap_datasource']] olap_server = config.OLAP_SERVERS[olap_datasource['olap_server']] try: connection_succesfull = test_olap_dataset(olap_server['url'], olap_server['username'], olap_server['password'], olap_datasource['datasource_info'], values['cube']) except: connection_succesfull = False self.stdout.write(colored.cyan('Name : ') + key) self.stdout.write(colored.cyan('Olap server : ') + olap_datasource['olap_server']) self.stdout.write(colored.cyan('Datasource info : ') + olap_datasource['datasource_info']) self.stdout.write(colored.cyan('Cube : ') + values['cube']) self.stdout.write(colored.cyan('Connection succesfull : ') + connection_succesfull) self.stdout.write('') self.stdout.write(colored.cyan('__________________________________________________________________')) self.stdout.write(colored.cyan('Finished retrieving Olap datasets')) except Exception: self.stdout.write(colored.red('An error occured when retrieving Olap datasets from Vique'))
def rejar(jarpth, fresh_content_map={}, compression=zipfile.ZIP_DEFLATED): if not isfile(jarpth): raise IOError("No jar: %s" % jarpth) puts(colored.cyan("Re-jarring '%s' with %d possible replacements:" % (basename(jarpth), len(fresh_content_map)))) with indent(3, quote=" *"): for fresh_key in fresh_content_map.keys(): puts(colored.cyan(fresh_key)) print() oldjar = zipfile.ZipFile(jarpth, mode="r") newjar = zipfile.ZipFile(tempfile.mktemp(suffix=".zip"), mode="w", compression=compression) for item in progress.bar(oldjar.infolist(), label=colored.cyan("Re-jar: %s" % basename(jarpth))): replace = basename(item.filename) in fresh_content_map content = replace and fresh_content_map[basename(item.filename)] or oldjar.read(item.filename) replace and puts(colored.yellow("Replaced %s" % item.filename)) newjar.writestr(item, content) print() oldjarpth = oldjar.filename newjarpth = newjar.filename oldjar.testzip() oldjar.close() shutil.move(oldjar.filename, oldjar.filename + ".backup") newjar.testzip() newjar.close() _copy(newjarpth, oldjarpth) puts(colored.yellow("Finished restructuring jar: %s" % oldjarpth)) print()
def send_chooser(wallet_obj): puts('What do you want to do?:') if not USER_ONLINE: puts("(since you are NOT connected to BlockCypher, many choices are disabled)") with indent(2): puts(colored.cyan('1: Basic send (generate transaction, sign, & broadcast)')) puts(colored.cyan('2: Sweep funds into bcwallet from a private key you hold')) puts(colored.cyan('3: Offline transaction signing (more here)')) choice = choice_prompt( user_prompt=DEFAULT_PROMPT, acceptable_responses=range(0, 5+1), quit_ok=True, default_input='1', show_default=True, ) verbose_print('Choice: %s' % choice) if choice in ('q', 'Q'): return elif choice == '1': return send_funds(wallet_obj=wallet_obj) elif choice == '2': return sweep_funds_from_privkey(wallet_obj=wallet_obj) elif choice == '3': offline_tx_chooser(wallet_obj=wallet_obj)
def check_requirements(): requirements_met = True required = UTILS['required'] optional = UTILS['optional'][platform.system().lower()] puts(colored.cyan('\nChecking requirements')) with indent(4, quote='>>>'): for util in required: try: check_output('which %s' % util, shell=True).strip() puts(colored.cyan('%s is installed' % util)) except Exception: puts(colored.red('ERROR: %s is required but not found.' % util)) requirements_met = False for util in optional: try: check_output('which %s' % util['call'], shell=True).strip() puts(colored.cyan('%s is installed' % util['call'])) except Exception: warning = 'WARNING: %s is recommended but not found.' % util[ 'call'] if util['req']: warning = warning + ' Try \'%s\'' % util['req'] puts(colored.yellow(warning)) requirements_met = False print return requirements_met
def send_chooser(wallet_obj): puts('What do you want to do?:') if not USER_ONLINE: puts("(since you are NOT connected to BlockCypher, many choices are disabled)") with indent(2): puts(colored.cyan('1: Basic send (generate transaction, sign, & broadcast)')) puts(colored.cyan('2: Sweep funds into bcwallet from a private key you hold')) puts(colored.cyan('3: Offline transaction signing (more here)')) puts(colored.cyan('\nb: Go Back\n')) choice = choice_prompt( user_prompt=DEFAULT_PROMPT, acceptable_responses=range(0, 5+1), quit_ok=True, default_input='1', show_default=True, ) verbose_print('Choice: %s' % choice) if choice is False: return elif choice == '1': return send_funds(wallet_obj=wallet_obj) elif choice == '2': return sweep_funds_from_privkey(wallet_obj=wallet_obj) elif choice == '3': offline_tx_chooser(wallet_obj=wallet_obj)
def apply(self): self.puts(colored.blue("Applying project...")) context = self.get_initial_context() context.update(self.collect_parameters()) for (number, name, filename, template_type) in self.steps(): with indent(2): puts(colored.cyan("{} ({})".format(filename, template_type))) with indent(4): if self.debug: puts( colored.white( u"✸ Applying template {} with context {}".format( filename, context))) getattr(self, 'apply_{}_template'.format(template_type))(name, filename, context) self.puts(colored.blue("Project Outputs:")) for k, v in six.iteritems(context): if k.startswith('Clioutput'): with indent(2): puts(colored.cyan(k[9:])) with indent(4): puts(colored.green(v))
def run_command(cls, *args): requested_keys = { k: True for k in args[0]}.keys() all_supported_keys = [x for x in requested_keys if x in supported_commands] if len(all_supported_keys): # command(s) specified, print help for specified command valid_help_keys = all_supported_keys print colored.magenta('Parameters can be specified in order they should appear') print colored.magenta('Arguments can be specified with "=" between key and value') print colored.magenta('\te.g.\tevents 12 venue.state=NY') print colored.magenta('\t[PARAMS]: 12 \t [ARGS]: { "venue.state": "NY" }') for key in valid_help_keys: if key == "help": print colored.cyan(' [%s] takes any of the following arguments' % key) all_args = [x for x in supported_commands.keys() if x != "help"] pprint(all_args, indent=8) elif supported_commands[key]: supported_commands[key].get_help_text(name=key) else: # print supported commands valid_help_keys = supported_commands.keys() print colored.blue(' Type `help [command1] [command2] ...` to get more information.\n The following commands are supported:') for key in valid_help_keys: print colored.cyan(' [%s] - %s' % (key, supported_commands[key].get_info_text()))
def show_logo3(self): print colored.cyan(""" .-. {{@}} <> 8@8 .::::. 888 @\\\/W\/\/W\//@ 8@8 \\\/^\/\/^\// _ )8( _ \_O_<>_O_/ (@)__/8@8\__(@) ____________________ `~"-=):(=-"~` |<><><> | | <><><>| |@| |<> | | <>| |f| |<> | | <>| |4| |<> .--------. <>| |l| | | () | | |s| |_____| (O\/O) |_____| |3| | \ /\ / | |_| |------\ \/ /------| ||| | '.__.' | |'| | | | | |.| : | | : ||| \<> | | <>/ |'| \<> | | <>/ |.| \<> | | <>/ ||| `\<> | | <>/' |'| `-.| |.-` \ / '--' ^ """)
def greeting_text_and_guide(): f = Figlet(font='slant') puts(colored.green(f.renderText('MangaDLer'))) puts(colored.green("The mangareader.net Downloader\n")) with indent(2, quote=' | '): puts(colored.cyan("How to Use MangaDLer\n")) puts( colored.cyan(""" Go to a mangareader.net link, for example: \n https://www.mangareader.net/naruto/11 You see the url says 'naruto' for the manga name? Copy/paste the manga name 'naruto' into the manga prompt. (case insensitive)\n """)) puts(colored.magenta("Example:")) puts(colored.green("Manga Name?: naruto\n")) with indent(2, quote=' | '): puts( colored.cyan(""" Then when asked what chapters, you can respond one of three ways: *) Give a number like 374 for the 374th chapter of naruto.\n *) Give a range like 374-390 for the chapters 374, 375, .. 390\n *) Write 'all' to download all chapters.\n """)) puts(colored.magenta("Examples:")) puts(colored.green("Which chapters?: 2")) puts(colored.green("Which chapters?: 2-10")) puts(colored.green("Which chapters?: all\n"))
def print_shell(self, *args): try: for arg in args: arg = str(arg) if isinstance(type(args), types.NoneType): continue if self.color == 'true': if str(arg).count(self.ruler) == len(str(arg)): print colored.green(arg), elif ":\n=" in arg: print colored.red(arg), elif ':' in arg: print colored.blue(arg), elif 'type' in arg: print colored.green(arg), elif 'state' in arg or 'count' in arg: print colored.yellow(arg), elif 'id =' in arg: print colored.cyan(arg), elif 'name =' in arg: print colored.magenta(arg), elif 'Error' in arg: print colored.red(arg), else: print arg, else: print arg, print except Exception, e: print colored.red("Error: "), e
def check_requirements(): requirements_met = True required = UTILS['required'] optional = UTILS['optional'][platform.system().lower()] puts(colored.cyan('\nChecking requirements')) with indent(4, quote='>>>'): for util in required: try: check_output('which %s' % util, shell=True).strip() puts(colored.cyan('%s is installed' % util)) except Exception: puts(colored.red('ERROR: %s is required but not found.' % util)) requirements_met = False for util in optional: try: check_output('which %s' % util['call'], shell=True).strip() puts(colored.cyan('%s is installed' % util['call'])) except Exception: warning = 'WARNING: %s is recommended but not found.' % util['call'] if util['req']: warning = warning + ' Try \'%s\'' % util['req'] puts(colored.yellow(warning)) requirements_met = False print return requirements_met
def mainmenu(): print("\b\b\bPlease select an option below and type '0' to exit the program.") puts(colored.cyan("----------------------------------------")) print("\t\tMain Menu") puts(colored.cyan("----------------------------------------")) with indent(4): puts('1. Book Information') puts('2. Author Information') puts('3. Average Rating of Book') puts("4. Graph Author's Hometowns") puts(colored.cyan("----------------------------------------")) while True: try: option = int(input("\nWhat data would you like to explore?\n")) except ValueError: puts(colored.red("Please enter a valid number between 1 and 4.")) continue if option < 0: puts(colored.red("Please enter a number between 1 and 4.")) continue elif option > 4: puts(colored.red("Please enter a number between 1 and 4.")) continue elif option == 0: raise SystemExit else: break submenu(option) return None
def __format_gist(gist): """ Formats the output for a Gist metadata object. :param gist: :class: `Gist <Gist>` instance. """ url_title = unicode(colored.green('Url:\t\t')) html_title = unicode(colored.green('Html Url:\t')) public_title = unicode(colored.green('Private:\t')) file_title = unicode(colored.green('Files:\t\t')) # Calculate the number of columns of the current terminal window rows, columns = os.popen('stty size', 'r').read().split() # Prepare the Header gists_string = colored.cyan('-' * int(columns)) + "\n" gists_string += colored.cyan("Gist [" + gist.identifier + "]") + '\n' gists_string += colored.cyan('-' * int(columns)) + "\n" # Format Gist data gists_string += colored.green('Description:\t') if gist.description: gists_string += gist.description + '\n' gists_string += url_title + gist.url + '\n' gists_string += html_title + gist.html_url + '\n' gists_string += public_title + str(not gist.public) + '\n' gist_names = [gistfile.filename for gistfile in gist.files] stringfiles = "[" + ", ".join(gist_names) + "]" gists_string += file_title + colored.red(stringfiles) + '\n' # Prepare the Footer gists_string += colored.cyan('-' * int(columns)) + "\n" return gists_string
def call_api_with_results(url): print colored.cyan("Making request: %s" % (url)) r = requests.get(url, stream=True, timeout=5) if r.headers.get('content-length'): total_length = int(r.headers.get('content-length')) content = '' for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1, label=colored.green(" KB received: ")): content += chunk else: content = r.content if (r.status_code >= 200 and r.status_code < 300): print 'Status Code: %s' % colored.green(str(r.status_code)) else: print 'Status Code: %s' % colored.red(str(r.status_code)) print colored.cyan('Headers:') pretty_dict(r.headers) parsed_content = json.loads(content) print colored.magenta('Content:') print json.dumps(parsed_content, indent=2, sort_keys=True)
def run(): stemmer = Stemmer("english") pages = db.en.find() print colored.yellow("statistic words") wordstatistic = {} for page in progress.bar(pages,size=db.en.count()): data = page.get("data") if not data:continue content = data.get("content") if not content: db.en.remove({"_id":page["_id"]}) continue words = EN_WORD_CUT.split(content) for word in words: w=stemmer.stemWord(word.strip()).lower() if w and len(w)<20 and not w in EN_IGNORE: if wordstatistic.get(w): wordstatistic[w]+=1 else: wordstatistic[w]=1 print colored.yellow("save to en_words_freq") savequene = [] for k,v in progress.bar(wordstatistic.iteritems(),size=len(wordstatistic)): savequene.append({"_id":k,"freq":v}) if len(savequene) >=1000: db.en_words_freq.insert(savequene) savequene=[] if savequene:db.en_words_freq.insert(savequene) print colored.cyan( "count of en_words_freq: %d" % db.en_words_freq.count())
def release(jshare_db, args): print(colored.magenta("Grabbing open notebooks...")) time.sleep(2) raw_notebooks = get_notebooks(jshare_db) notebooks = {} for port in raw_notebooks: if not is_in_db(jshare_db, port): notebooks[port] = raw_notebooks[port] if len(notebooks) == 0: print(colored.green('NO NOTEBOOKS OPEN')) sys.exit(0) print(colored.green('\nWhich notebook are you referring to?')) for i, key in enumerate(notebooks): try: jshare_db[key] except Exception as e: print(' {} {}'.format(colored.cyan('| {} |'.format(key)), notebooks[key][0])) while (1): if (sys.version_info > (3, 0)): port_chosen = input(colored.cyan('NOTEBOOK PORT: ')) else: port_chosen = raw_input(colored.cyan('NOTEBOOK PORT: ')) if port_chosen == 'q' or port_chosen == 'quit' or port_chosen == ':q': sys.exit(0) if port_chosen in notebooks: break else: print(colored.red('ERROR: MUST ENTER A VALID NOTEBOOK PORT')) continue os.system('ngrok http {} > ngrok.log &'.format(port_chosen)) print( colored.magenta( "Opening notebook on port {} up...".format(port_chosen))) time.sleep(10) r = requests.get('http://127.0.0.1:4040/api/tunnels') r.raise_for_status() ngrok_url = r.json()['tunnels'][0]['public_url'] notebook_url = ngrok_url + '/' + '?token=' + notebooks[port_chosen][1] jshare_db[port_chosen] = [notebooks[port_chosen][0], notebook_url] print( colored.green( "Opened! To see a list of open notebooks try running jupyshare show" )) print(colored.green("Your notebook is found on {}".format(notebook_url))) webbrowser.get(args.browser).open_new_tab(notebook_url)
def translations(self, mods=None, lang=None): request.disable_db = False uid = openerp.SUPERUSER_ID print colored.cyan("HOLAAAAA") if mods is None: m = request.registry.get('ir.module.module') mods = [x['name'] for x in m.search_read(request.cr, uid, [('state','=','installed')], ['name'])] if lang is None: lang = request.context["lang"] res_lang = request.registry.get('res.lang') ids = res_lang.search(request.cr, uid, [("code", "=", lang)]) lang_params = None if ids: lang_params = res_lang.read(request.cr, uid, ids[0], ["direction", "date_format", "time_format", "grouping", "decimal_point", "thousands_sep", "view_decimal"]) # Regional languages (ll_CC) must inherit/override their parent lang (ll), but this is # done server-side when the language is loaded, so we only need to load the user's lang. ir_translation = request.registry.get('ir.translation') translations_per_module = {} messages = ir_translation.search_read(request.cr, uid, [('module','in',mods),('lang','=',lang), ('comments','like','openerp-web'),('value','!=',False), ('value','!=','')], ['module','src','value','lang'], order='module') for mod, msg_group in itertools.groupby(messages, key=operator.itemgetter('module')): translations_per_module.setdefault(mod,{'messages':[]}) translations_per_module[mod]['messages'].extend({'id': m['src'], 'string': m['value']} \ for m in msg_group) return {"modules": translations_per_module, "lang_parameters": lang_params}
def Run(graph, timetable, report): print colored.yellow( "[*] Adding Modules Loaded Threat Intel From Bit9.") for item in report['process']['modload_complete']: #print item if item.split("|")[1] != '': hashvalue = item.split('|')[1] intelresult = CheckHash.Run(hashvalue) #print intelresult #print type(intelresult[0]['threat']) if len(intelresult) >= 1 and intelresult[0]['threat'] == 100: print colored.magenta("[+] Bit9 Threat Intel Hit! " + str(hashvalue)) threatlabel = intelresult[0]['fileName'] + str( "-Threat=") + str(intelresult[0]['threat']) time = item.split("|")[0][:-4] modload_name = item.split("|")[2] time_node = GetNode.Run(graph, time, "time", float(1.0)) threat_node = GetNode.Run(graph, threatlabel, "threat", float(5.0)) modload_node = GetNode.Run(graph, modload_name, "modload", float(1.0)) ConnectNodes.Run(graph, time_node, modload_node) ConnectNodes.Run(graph, modload_node, threat_node) else: print colored.cyan("[?] Hash not a threat, " + str(hashvalue)) pass print colored.green("[+] Completed.\n")
def __format_file(file_gist): """ Formats the output for a GistFile object. :param gist: :class: `GistFile <GistFile>` instance. """ # Calculate the number of columns of the current terminal window rows, columns = os.popen('stty size', 'r').read().split() # Prepare the Header gist_string = colored.cyan('-' * int(columns)) + "\n" gist_string += colored.cyan("File [" + file_gist.filename + "]\n") gist_string += colored.cyan('-' * int(columns)) + "\n" # Format Gist data gist_string += (colored.green("Language:") + " " + colored.red(file_gist.language) + "\n") gist_string += (colored.green("Size:") + " " + colored.red(file_gist.size) + "\n") gist_string += (colored.green("Raw Url:") + " " + colored.red(file_gist.raw_url + "\n")) gist_string += (colored.green("Content:\n\n") + file_gist.content + "\n\n") # Prepare the Footer gist_string += colored.cyan('-' * int(columns)) + "\n" return gist_string
def _imprime_output_formateado(line): """ Metodo: Imprime la salida en consola formateada en base al tipo de salida Error o Stream """ import re import json n_linea = None # Remueve caracteres no deseados regex_indeseados = re.compile("[\n\t\r]") line = line.replace('\n', '').replace('{}', '"None"') # Conversion a JSON para mejor manejo try: line = json.loads(line) except ValueError: return False if line.get('stream', ''): n_linea = colored.cyan( \ regex_indeseados.sub("", line.get('stream', ''))) if line.get('status', ''): n_linea = colored.cyan( \ regex_indeseados.sub("", line.get('status', ''))) elif line.get('error', ''): n_linea = colored.red( \ regex_indeseados.sub("", line.get('error', ''))) else: return False print n_linea
def __format_gist(gist): """ Formats the output for a Gist metadata object. :param gist: :class: `Gist <Gist>` instance. """ # Calculate the number of columns of the current terminal window rows, columns = os.popen('stty size', 'r').read().split() # Prepare the Header gists_string = colored.cyan('-' * int(columns)) + "\n" gists_string += colored.cyan("Gist [" + gist.identifier + "]") + '\n' gists_string += colored.cyan('-' * int(columns)) + "\n" # Format Gist data gists_string += colored.green('Description:\t') if gist.description: gists_string += gist.description + '\n' gists_string += colored.green('Url:\t\t') gists_string += gist.url + '\n' gists_string += colored.green('Html Url:\t') gists_string += gist.html_url + '\n' gists_string += colored.green('Private:\t') gists_string += str(not gist.public) + '\n' gists_string += colored.green('Files:\t\t') gist_names = [gistfile.filename for gistfile in gist.files] stringfiles = "[" + ", ".join(gist_names) + "]" gists_string += colored.red(stringfiles) + '\n' # Prepare the Footer gists_string += colored.cyan('-' * int(columns)) + "\n" return gists_string
def view_entry(entry, password): # pylint: disable=inconsistent-return-statements title = entry.title data = crypto.decrypt(entry.content, password) if entry.sync: clear_screen() print("Checking for updates on note with Google Drive......") download_drive(entry, title, data, password) # entry = m.Note.get(m.Note.title == title) # data = decrypt(entry.content, password) clear_screen() puts(colored.yellow(title)) puts(colored.blue("=" * len(title))) puts(colored.yellow(data)) puts(colored.cyan('e) edit entry')) puts(colored.cyan('d) delete entry')) puts(colored.cyan('v) view previous versions')) puts(colored.cyan('q) to return to view entries')) next_action = input('Action: [e/d/v/q] : ').lower().strip() if next_action == 'd': return delete_entry(entry) if next_action == 'e': return edit_entry_view(entry, password) if next_action == 'v': return view_previous_versions(entry, password) if next_action == 'q': return False
def aws_sign_in(aws_profile, duration_minutes=DEFAULT_SIGN_IN_DURATION_MINUTES, force_new=False): """ Create a temp session through MFA for a given aws profile :param aws_profile: The name of an existing aws profile to create a temp session for :param duration_minutes: How long to set the session expiration if a new one is created :param force_new: If set to True, creates new credentials even if valid ones are found :return: The name of temp session profile. (Always the passed in profile followed by ':session') """ aws_session_profile = '{}:session'.format(aws_profile) if not force_new \ and _has_valid_session_credentials(aws_session_profile): return aws_session_profile default_username = get_default_username() if default_username.is_guess: username = input("Enter username associated with credentials [{}]: ".format( default_username)) or default_username print_help_message_about_the_commcare_cloud_default_username_env_var(username) else: username = default_username mfa_token = input("Enter your MFA token: ") generate_session_profile(aws_profile, username, mfa_token, duration_minutes) puts(colored.green(u"✓ Sign in accepted")) puts(colored.cyan( "You will be able to use AWS from the command line for the next {} minutes." .format(duration_minutes))) puts(colored.cyan( "To use this session outside of commcare-cloud, " "prefix your command with AWS_PROFILE={}:session".format(aws_profile))) return aws_session_profile
def loadUser(): headers = {'User-Agent': config.tvtime["auth"]['user-agent']} request = requests.get(config.tvtime["urls"]['user'] + "?access_token=" + access_token, headers=headers) request_json = request.json() if (request_json["result"] == "OK"): global username username = request_json["user"]["name"] puts( colored.yellow('[Plex-TvTime-Agent]') + colored.magenta('[General]') + "###############################################################################" ) puts( colored.yellow('[Plex-TvTime-Agent]') + colored.magenta('[General]') + " Welcome " + username) puts( colored.yellow('[Plex-TvTime-Agent]') + colored.magenta('[General]') + "###############################################################################" ) puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 1]') + " Loading Tv Time Data ") loadTvTimeShows() else: puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 1]') + colored.red('[Error]') + " Token Expired, reauthenticate!") authenticate()
def handle(self, *args, **options): # Load dynamic configs - the middleware is not working here, so do this manually config.load_app_configs() self.stdout.write(colored.cyan('Retrieving Olap servers...')) self.stdout.write(colored.cyan('__________________________________________________________________')) self.stdout.write(colored.cyan('Olap servers defined in the Vique configuration:')) self.stdout.write('') try: for key, values in config.OLAP_SERVERS.iteritems(): connection_succesfull = test_olap_server_connection(values['url'], values['username'], values['password']) self.stdout.write(colored.cyan('Name : ') + key) self.stdout.write(colored.cyan('URL : ') + values['url']) self.stdout.write(colored.cyan('Username : '******'username']) self.stdout.write(colored.cyan('Password : '******'password']) self.stdout.write(colored.cyan('Connection succesfull : ') + connection_succesfull) self.stdout.write('') self.stdout.write(colored.cyan('__________________________________________________________________')) self.stdout.write(colored.cyan('Finished retrieving Olap servers')) except Exception: self.stdout.write(colored.red('An error occured when retrieving Olap servers from Vique'))
def loadPlexShows(): global shows headers = {'User-Agent': config.tvtime["auth"]['user-agent']} url_params = "?X-Plex-Token=" + config.plex["auth"]['token'] request = requests.get(config.plex["auth"]['server'] + config.plex["urls"]['library'] + url_params, headers=headers) tree = ElementTree.fromstring(request.content) for show in tree.findall('Directory'): showId = str(show.get("guid").split('//')[1].split('?')[0]) if (showId in shows): shows[showId]["plex"] = int(show.get("viewedLeafCount")) shows[showId]["plex_id"] = int(show.get("ratingKey")) else: shows[showId] = { "plex": int(show.get("viewedLeafCount")), "plex_id": int(show.get("ratingKey")) } puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 1]') + colored.green('[Success]') + " Finished Loading Plex (total: " + str(len(shows)) + ")") if (len(shows) > 0): processShows() else: puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 1]') + colored.red('[Error]') + " No shows found, stopping")
def setup_jvm(): puts(colored.yellow("Starting JVM...")) print() import jnius javasys = jnius.autoclass("java.lang.System") classpath = javasys.getProperty("java.class.path") puts(colored.cyan("Classpath:")) puts(colored.cyan(classpath)) print() amended_cp = ":".join( [ classpath, jarpath("ae-awt.jar"), jarpath("javax-imageio.jar"), jarpath("commons-codec-1.9.jar"), jarpath("lire.jar"), ] ) javasys.setProperty("java.class.path", amended_cp) puts(colored.cyan("Classpath (amended):")) puts(colored.cyan(amended_cp)) print() return jnius
def addToTvTime(tvId, showData): puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 2]') + " Adding show (" + tvId + ") to TvTime") global shows shows[tvId]["tvtime"] = 0 showData["tvtime"] = 0 # add to TvTime headers = {'User-Agent': config.tvtime["auth"]['user-agent']} url_params = "?access_token=" + access_token + "&show_id=" + tvId data = {'show_id': str(tvId)} request = requests.post(config.tvtime["urls"]['follow'] + url_params, data=data, headers=headers) request_json = request.json() if (request_json["result"] == "OK"): puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 2]') + colored.green('[Success]') + " Added show (" + tvId + ")") #add episodes time.sleep(config.tvtime["auth"]['rate_time']) # Rate limit safety addTvTimeWatched(tvId, showData) else: puts( colored.yellow('[Plex-TvTime-Agent]') + colored.cyan('[Phase 2]') + colored.red('[Error]') + " Failed to add show (" + tvId + ")")
def help(): function = {" -h ": " To display help menu.", " -i <contest> ": " To initialize a contest directory.", " -f ": " To create only files in a directory.", " -i -b <contest> ": " To initialize a contest directory for practice and beginner level.", " -i <args> -t2 <contest> ": " To initialize a contest directory and use 2nd template.", " -i -n <file> ": " To initialize only a single file.", " -v ": " To print version number."} print('\n') print(colored.red(""" ██████╗ ██████╗ ██████╗ ███████╗ ██╗ ████████╗ ██╔════╝ ██╔═══██╗ ██╔══██╗ ██╔════╝ ██║ ╚══██╔══╝ ██║ ██║ ██║ ██║ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ██╔══╝ ██║ ██║ ╚██████╗ ╚██████╔╝ ██████╔╝ ███████╗ ██║ ██║ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ """)) print(colored.cyan( "\n The CLI Script tool to help you initialize CPP files for any contest.")) print(colored.red('\n Command: ')) print(colored.cyan(" codeit <args> <filename/contestname>")) print(colored.red('\n Args list: ')) for arg, func in function.items(): print(colored.yellow(arg) + '-'*(30-len(arg)) + '>' + colored.cyan(func)) print('\n')
def get_info(droplet, ip, args): return "{0} => {1}{2}{3}".format( colored.green(droplet.name), colored.cyan(args.user), colored.cyan("@"), colored.cyan(ip) )
def editShow(args): name = " ".join(args) animeExists = searchEntry(name, ANIME_DB, True) serieExists = searchEntry(name, SERIES_DB, True) if animeExists == False and serieExists == False: message = colored.red("%s doesn't exist in the database" % (name)) exit(message) conn = sqlite3.connect(DATABASE_URL) c = conn.cursor() if (serieExists): season = input(colored.cyan("Season: ")) episode = input(colored.cyan("Episode: ")) t = ( season, episode, name, ) sql = "UPDATE {tn} SET Season = ?, Episode = ? WHERE Name = ?".format( tn=SERIES_DB) else: episode = input(colored.cyan("Episode: ")) t = ( episode, name, ) sql = "UPDATE {tn} SET Episode = ? WHERE Name = ?".format(tn=ANIME_DB) c.execute(sql, t) conn.commit() conn.close() message = colored.cyan("%s was updated" % (name)) print(message)
def update_repo(key): repo = '/'.join(key.split('/')[:2]) ref = '/'.join(key.split('/')[2:]) if not '_clone' in key: try: if not os.path.exists(path_for_key(key)): debugger(colored.cyan('Cloning repo %s' % repo)) check_output([ 'git', 'clone', '-b', ref, '[email protected]:%s.git' % repo, path_for_key(key) ]) os.chdir(path_for_key(key)) else: os.chdir(path_for_key(key)) debugger(colored.cyan('Updating repo for %s' % key)) check_output(['git', 'pull', 'origin', '%s' % ref]) except CalledProcessError: debugger( colored.red( 'Looks like we got an error from a called git process. Assuming repo is gone.' )) raise RepoGoneError # Gravatar regardless of condition download_gravatars(path_for_key(key)) # Yay sound. play_sound()
def print_shell(self, *args): try: for arg in args: arg = str(arg) if isinstance(type(args), types.NoneType): continue if self.color == 'true': if str(arg).count(self.ruler) == len(str(arg)): print colored.green(arg), elif 'Error' in arg: print colored.red(arg), elif ":\n=" in arg: print colored.red(arg), elif ':' in arg: print colored.blue(arg), elif 'type' in arg: print colored.green(arg), elif 'state' in arg or 'count' in arg: print colored.magenta(arg), elif 'id =' in arg: print colored.yellow(arg), elif 'name =' in arg: print colored.cyan(arg), else: print arg, else: print arg, print except Exception, e: print colored.red("Error: "), e
def dump_private_keys_or_addrs_chooser(wallet_obj): ''' Offline-enabled mechanism to dump everything ''' if wallet_obj.private_key: puts('Which private keys and addresses do you want?') else: puts('Which addresses do you want?') with indent(2): puts(colored.cyan('1: Active - have funds to spend')) puts(colored.cyan('2: Spent - no funds to spend (because they have been spent)')) puts(colored.cyan('3: Unused - no funds to spend (because the address has never been used)')) puts(colored.cyan('0: All (works offline) - regardless of whether they have funds to spend (super advanced users only)')) puts(colored.cyan('\nb: Go Back\n')) choice = choice_prompt( user_prompt=DEFAULT_PROMPT, acceptable_responses=[0, 1, 2, 3], default_input='1', show_default=True, quit_ok=True, ) if choice is False: return if choice == '1': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=False, used=True) elif choice == '2': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=True, used=True) elif choice == '3': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=None, used=False) elif choice == '0': return dump_all_keys_or_addrs(wallet_obj=wallet_obj)
def get_boston_weather(boston_lat, boston_long): weather_api_key = '3faebebd5dd5b4b45f1280a39eec2e55' # This code handles the url endpoint for the api weather_api_endpoint = 'https://api.darksky.net/forecast/' destination = '{}/{},{}'.format(weather_api_key, boston_lat, boston_long) weather_url = weather_api_endpoint + destination # makes a request to api and responds with json weather_request = urllib.urlopen(weather_url) weather_response = json.load(weather_request) # sorting json for temperature and weather summary weather_temp = weather_response["currently"]["temperature"] weather_summary = weather_response["minutely"]["summary"] # change text color depending on temperature if (weather_temp <= 32.5): weather_temp = colored.cyan(weather_temp) elif (weather_temp >= 33): weather_temp = colored.cyan(weather_temp) else: weather_temp = colored.yellow(weather_temp) return ("Bostons weather is %sF and %s" % (weather_temp, weather_summary.lower()))
def print_shell(self, *args): try: for arg in args: arg = str(arg) if isinstance(type(args), types.NoneType): continue if self.color == "true": if str(arg).count(self.ruler) == len(str(arg)): print colored.green(arg), elif "Error" in arg: print colored.red(arg), elif ":\n=" in arg: print colored.red(arg), elif ":" in arg: print colored.blue(arg), elif "type" in arg: print colored.green(arg), elif "state" in arg or "count" in arg: print colored.magenta(arg), elif "id =" in arg: print colored.yellow(arg), elif "name =" in arg: print colored.cyan(arg), else: print arg, else: print arg, print except Exception, e: print colored.red("Error: "), e
def dump_private_keys_or_addrs_chooser(wallet_obj): ''' Offline-enabled mechanism to dump everything ''' if wallet_obj.private_key: puts('Which private keys and addresses do you want?') else: puts('Which addresses do you want?') with indent(2): puts(colored.cyan(' 1: Active - have funds to spend')) puts(colored.cyan(' 2: Spent - no funds to spend (because they have been spent)')) puts(colored.cyan(' 3: Unused - no funds to spend (because the address has never been used)')) puts(colored.cyan(' 0: All (works offline) - regardless of whether they have funds to spend (super advanced users only)')) choice = choice_prompt( user_prompt=DEFAULT_PROMPT, acceptable_responses=[0, 1, 2, 3], default_input='1', show_default=True, quit_ok=True, ) if choice in ('q', 'Q'): return if choice == '1': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=False, used=True) elif choice == '2': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=True, used=True) elif choice == '3': return dump_selected_keys_or_addrs(wallet_obj=wallet_obj, zero_balance=None, used=False) elif choice == '0': return dump_all_keys_or_addrs(wallet_obj=wallet_obj)
def kill(jshare_db): ngrok_processes, ngrok_dict = get_live_processes() notebooks = get_notebooks(jshare_db) if len(ngrok_processes) == 0: print(colored.green('NO NOTEBOOKS ARE IN THE CLOUD')) sys.exit(0) print( colored.green( "\nWhich tunnel do you want to kill? Type 'all' if you want to shut everything down" )) for i, key in enumerate(ngrok_dict): if is_in_db(jshare_db, key): if key not in notebooks: os.system('kill {}'.format(ngrok_dict[key])) print( colored.magenta( "Didn't find any notebooks on port {}. Killing ngrok connection." .format(key))) del jshare_db[key] else: print(' {} {}'.format(colored.cyan('| {} |'.format(key)), jshare_db[key][0])) print(' {}'.format( colored.magenta(jshare_db[key][1]))) else: jshare_db[key] = ["Location unknown", "Url unknown"] print(' {} {}'.format(colored.cyan('| {} |'.format(key)), jshare_db[key][0])) print(' {}'.format(colored.magenta( jshare_db[key][1]))) while (1): port_chosen = raw_input(colored.cyan('NOTEBOOK PORT: ')) if port_chosen in ('q', 'quit', ':q'): sys.exit(0) if port_chosen == 'all': for key in ngrok_dict: os.system('kill {}'.format(ngrok_dict[key])) print( colored.green( "Killed notebook listening on port {}".format(key))) jshare_db.clear() sys.exit(0) if port_chosen in ngrok_dict: break else: print(colored.red('ERROR: MUST ENTER A VALID NOTEBOOK PORT')) continue os.system('kill {}'.format(ngrok_dict[port_chosen])) del jshare_db[port_chosen] print( colored.green( "Killed notebook listening on port {}".format(port_chosen))) sys.exit(0)
def main(): args = parse_arguments() downloader = KippoMalware(args) downloader.get_urls() downloader.download_malware() print colored.cyan( "\nINFO => Downloading ended. The files have been stored at: %s" % args.directory)
def unzip_tar(file, path): print('tar -xvf {}'.format(file)) expected_name = file.replace(".tar", "") if not os.path.isfile(path + expected_name): puts(colored.cyan('* unzipping Tar')) command('tar -xvf {}'.format(file), path) else: puts(colored.cyan('defaulting to local {}'.format(expected_name)))
def prompt_task(): title = '=' + ' ' * 10 + 'onedrive-d Preference Wizard' + ' ' * 10 + '=' puts(colored.cyan('=' * len(title))) puts(colored.cyan(title)) puts(colored.cyan('=' * len(title))) print_system_info() while True: dispatch_task()
def prompt_task(): title = "=" + " " * 10 + "onedrive-d Preference Wizard" + " " * 10 + "=" puts(colored.cyan("=" * len(title))) puts(colored.cyan(title)) puts(colored.cyan("=" * len(title))) print_system_info() while True: dispatch_task()
def unzip_7z(file, path): print('7z x {} -aos'.format(file)) expected_name = file.replace(".7z", "") if not os.path.isfile(path + expected_name): puts(colored.cyan('* unzipping 7z')) command('7z x {} -aos'.format(file), path) else: puts(colored.cyan('defaulting to local {}'.format(expected_name)))
def scrape_images(self): """ Method to download images found in the page """ if not os.path.exists(self.download_directory): try: os.makedirs(self.download_directory) except: raise DirectoryCreateError() with indent(4, quote='>>>'): puts( colored.cyan('Getting html page source from ') + colored.yellow(str(self.page_url))) if self.is_dynamic_site or self.use_gui: import asyncio self.dom = asyncio.get_event_loop().run_until_complete( self.getdynamichtmlsource(self.page_url)) else: self.dom = self.gethtmlsource(self.page_url) with indent(4, quote='>>>'): puts(colored.cyan("Processing html")) self.img_links = self.acquire_links(self.dom, self.page_url) total_count = len(self.img_links) if self.download_first_n: self.img_links = self.img_links[:self.download_first_n] self.img_count = len(self.img_links) with indent(4, quote='>>>'): puts( colored.cyan("Found") + " " + colored.yellow( str(total_count) + " " + colored.cyan("images"))) puts( colored.cyan("Downloading " + str(self.img_count) + " images to " + self.download_directory)) pool_size = max(self.img_count, self.max_threads) pool = ThreadPool(pool_size) pb = ProgressBar(maxval=self.img_count).start() for link in self.img_links: file_location = self.download_directory+"/" + \ link.split('/')[len(link.split('/'))-1] pool.add_task(self.download_img, link, file_location, pb) pool.wait_completion() pb.finish() puts( colored.green("\nSuccessfull downloads: " + str(len(self.downloaded_links)))) puts(colored.red("Failed downloads: " + str(len(self.failed_links))))
def get_help_text(cls, **kwargs): all_possible_args = sorted(cls.get_all_default_args().keys()) name = kwargs.get('name', cls.__name__) if len(all_possible_args) > 0: print colored.cyan("Possible arguments for %s: " % name) for k in sorted(cls.get_all_default_args().keys()): print "\t <%s>" % k else: print colored.cyan("No arguments needed for %s" % name)
def register(self, app_id, name, link): if app_id in self.registry: raise AlreadyRegistered print "Registering {} at {}".format(colored.cyan(name), colored.cyan(link)) self.registry[app_id] = { 'name': name, 'link': link, }
def print_search(query): # Scraping vibeclouds url = 'http://www.vibeclouds.net/tracks/{}.html'.format(format_query(query)) results = requests.get(url) html = BeautifulSoup(results.text) ul = html.find('ul', class_='results') lis = ul.find_all('li') if not lis: puts(colored.red('\tNo matches found.')) sys.exit() options = {} for i, v in enumerate(lis, 1): artist = v.find('a', rel='nofollow').text.strip() title = v.find('span', class_='songName').text unparsed_link = v.find('p', class_='downloadButton').get('onclick') dl_link_search = re.search("location.href='(.*)'", unparsed_link) if dl_link_search: dl_link = dl_link_search.group(1) options[i] = (artist, title, dl_link) for k, v in options.items(): puts(colored.green('\t{}: {}{}'.format(k, v[0], v[1]))) # User-input to choose song opt = 'N' while opt != 'Y': choice = int(input('Enter index of song: ')) try: chosen_link = options[choice][2] except KeyError: print('Invalid index; try again.') continue size, count = 0.000165, 0 while size == 0.000165: if count >= 30: break r = requests.head(chosen_link) size = int(r.headers['content-length']) / 1000000 count += 1 puts(colored.cyan('The file is {} MB. Proceed? (Y/N) '.format(size))) opt = input('> ') default_name = re.search('track/.*/(.*.mp3)', chosen_link).group(1) puts(colored.cyan('Name your file (default: {}):'.format(default_name))) file_name = input('> ') file_name = file_name or default_name return chosen_link, file_name
def Simulate(): try: ndays = int(sys.argv[4]) except IndexError: print colored.red("Number of days missing missing: python main.py simulate [ndays]") print colored.yellow("Asumming 1 day simulation:") ndays = 1 for i in ndays: print colored.cyan("Simulating day "), print colored.cyan(i)
def release(jshare_db, args): print(colored.magenta("Grabbing open notebooks...")) time.sleep(2) raw_notebooks = get_notebooks(jshare_db) notebooks = {} for port in raw_notebooks: if not is_in_db(jshare_db, port): notebooks[port] = raw_notebooks[port] if len(notebooks) == 0: print(colored.green('NO NOTEBOOKS OPEN')) sys.exit(0) print(colored.green('\nWhich notebook are you referring to?')) for i, key in enumerate(notebooks): try: jshare_db[key] except Exception as e: print(' {} {}'.format(colored.cyan('| {} |'.format(key)), notebooks[key][0])) while(1): if (sys.version_info > (3, 0)): port_chosen = input(colored.cyan('NOTEBOOK PORT: ')) else: port_chosen = raw_input(colored.cyan('NOTEBOOK PORT: ')) if port_chosen == 'q' or port_chosen == 'quit' or port_chosen == ':q': sys.exit(0) if port_chosen in notebooks: break else: print(colored.red('ERROR: MUST ENTER A VALID NOTEBOOK PORT')) continue os.system('ngrok http {} > ngrok.log &'.format(port_chosen)) print(colored.magenta("Opening notebook on port {} up...".format(port_chosen))) time.sleep(10) r = requests.get('http://127.0.0.1:4040/api/tunnels') r.raise_for_status() ngrok_url = r.json()['tunnels'][0]['public_url'] notebook_url = ngrok_url + '/' + '?token=' + notebooks[port_chosen][1] jshare_db[port_chosen] = [notebooks[port_chosen][0], notebook_url] print(colored.green("Opened! To see a list of open notebooks try running jupyshare show")) print(colored.green("Your notebook is found on {}".format(notebook_url))) webbrowser.get(args.browser).open_new_tab(notebook_url)
def hash_lookup(hashvalue): #used for getting hash state info #if it exists, prompt to ban, if it does not, prompt to ban pre-emptively if len(hashvalue)==32: print colored.yellow("[*] MD5 Detected.") hashtype="md5" if len(hashvalue)==40: print colored.yellow("[*] SHA-1 Detected.") hashtype="sha1" if len(hashvalue)==64: print colored.yellow("[*] SHA-256 Detected.") hashtype="sha256" print colored.yellow("[*] Checking "+str(hashvalue)) hashstate=bit9.check_hash(hashtype, hashvalue) if len(hashstate)==0: print colored.cyan("[?] Hash not found in Bit9.") cb.check_execution(str(hashvalue)) pass else: if hashstate[0]['effectiveState']!='Banned': print colored.yellow("[*] Hash is not Banned") cb.check_execution(hashstate[0]['md5']) print colored.cyan("https://www.virustotal.com/latest-report.html?resource="+str(hashstate[0]['sha256'])) print colored.cyan("[i] Prevalence: "+str(hashstate[0]['prevalence'])) print colored.cyan("[?] File Name: "+str(hashstate[0]['fileName'])) print colored.cyan("[?] Path: "+str(hashstate[0]['pathName'])) try: print colored.magenta("[?] "+str(hashstate[0]['fileName'])+" is not Banned, shall we?") except: print colored.yellow("[*] Can't print filename, strange characters.") pass userinput=get_user_input() if userinput==True: bit9.ban_hash(hashstate[0]['sha256'], hashstate[0]['fileName']) if userinput==False: print colored.yellow("[*] Okay then, not banning the hash.") if hashstate[0]['publisherState']>0: print colored.magenta("[?] "+hashstate[0]['fileName']+" also has a publisher, "+hashstate[0]['publisher']+" shall we Ban it?") userinput=get_user_input() if userinput==True: bit9.ban_certificate(hashstate) if userinput==False: print colored.yellow("[*] Okay then, not banning the Certificate.") else: print colored.yellow("[*] Hash is banned.") print colored.magenta("[?] Check Carbon Black?") userinput=get_user_input() if userinput==True: cb.check_execution(hashstate[0]['md5'])
def show_logo2(self): print colored.cyan(""" |`-._/\_.-`| 1 = 'Malicious File' | || | 2 = 'Potential Risk File' |___o()o___| 3 = FireEye 'Malicious File' (not finished) |__((<>))__| 4 = Hash \ o\/o / 5 = Certificate (not finished) \ || / 0 = Quit \ || / '.||.' `` """)
def show_logo2(): print colored.cyan(""" |`-._/\_.-`| 1 = 'Malicious File' | || | 2 = 'Potential Risk File' |___o()o___| 3 = FireEye 'Malicious File' |__((<>))__| 4 = Hash \ o\/o / 5 = Certificate (not finished) \ || / 6 = Computer lookup \ || / 0 = Exit '.||.' `` """)
def showProcess(): print colored.yellow("\nViewing proccesses currently running: ") print colored.cyan("Output will be OVERWRITTEN to logs/showprovess.txt") subprocess.call(["ps", "aux"]) print ##LOG UPDATER os.system("echo >> logs/log.txt") os.system("echo `date` >> logs/log.txt") os.system("echo \"Show system processes via MANDY, entry \"process\".\" >> logs/log.txt") os.system("echo \"Commands Executed: ps aux\" >> logs/log.txt") os.system("echo >> logs/log.txt")