def main(): global config #print('DEBUG', set(['-v', '--version']), sys.argv) parser = argparse.ArgumentParser() parser.add_argument( 'input_file', type=fileexists, help='Input File Location EX: /Desktop/Somewhere/input.txt', nargs="?") parser.add_argument('-l', '--log-output', default=False, action='store_true', help='Log output to json file') parser.add_argument('-v', '--version', help='Version', action='store_true') parser.add_argument('-c', '--config', help='Version', action='store_true') args = parser.parse_args() if args.version: print("%s version %s" % (__title__, __version__)) return elif args.config: config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print( "Cound't read config values, please start the program again using --config parameter" ) return if config == None or config['api_key'] == "": a = """VirusTotal API key is empty. To obtain an API Key: [1] Register an account on https://www.virustotal.com if you haven't. [2] Sign in and get your API Key from community profile. [3] Enter configuration values below. (Refer this link for more help: https://www.virustotal.com/en/documentation/public-api/)""" print(a) config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print( "Cound't read config values, please start the program again using --config parameter" ) return print("") #check if filename is valid if args.input_file == None: print("Filename can't be empty") return #calculate hash of file print("calculating sha1 hash...") hash = hashlib.sha1() with open(args.input_file, 'rb') as fp: for chunk in iter(lambda: fp.read(4096), b""): hash.update(chunk) strhash = hash.hexdigest() print("done. sending scan request...\n") scan(strhash.strip(), args.log_output) #args.verbose print("done")
def main(): global config banner = """%s version %s %s Copyright (c) 2019 Prahlad Yeri. This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>. """ % (__title__, __version__, __description__) parser = argparse.ArgumentParser() parser.add_argument('-v', '--version', default=False, action='store_true', help='display the version number') parser.add_argument('-c', '--config', default=False, action='store_true', help='setup the app configuration') args = parser.parse_args() if args.version: print(banner) return if args.config: config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print("Cound't read config values, please start the program again using --config parameter") return if config == None or config['github_username'] == '': config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print("Cound't read config values, please start the program again using --config parameter") return # if config["github_username"] == "": # print("Configuration file is empty. Please put the appropriate values in this config file:\n") # print(conf_file) # return # else: check_activity()
def main(): global config #print('DEBUG', set(['-v', '--version']), sys.argv) if '-v' in sys.argv or '--version' in sys.argv: print( "%s version %s" % (__title__, __version__) ) return parser = argparse.ArgumentParser() parser.add_argument('input_file', type=fileexists, help='Input File Location EX: /Desktop/Somewhere/input.txt') parser.add_argument('-l', '--log-output', default=False, action='store_true', help='Log output to json file') parser.add_argument('-v', '--version', help='Version', action='store_true') parser.add_argument('-c', '--config', help='Version', action='store_true') args = parser.parse_args() if args.config: config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print("Cound't read config values, please start the program again using --config parameter") return if config == None or config['api_key'] == "": config = cfgsaver.get_from_cmd(pkg_name, config_keys) if config == None: print("Cound't read config values, please start the program again using --config parameter") return #calculate hash of file hash = hashlib.sha1() with open(args.input_file,'rb') as fp: for chunk in iter(lambda: fp.read(4096), b""): hash.update(chunk) strhash = hash.hexdigest() scan(strhash.strip(), args.log_output) #args.verbose
def announce(args=[]): global config, dry_run, refresh_tags if '-v' in args or '--version' in args: print("%s version %s" % (__title__, __version__)) return parser = argparse.ArgumentParser() parser.add_argument('-v', '--version', help='Version', action='store_true') parser.add_argument('-c', '--config', default=False, action='store_true', help='setup the app configuration') parser.add_argument('-n', '--dry-run', default=False, action='store_true', help='dry run mode') parser.add_argument('-r', '--refresh-tags', default=False, action='store_true', help='refresh tags') args = parser.parse_args(args) if args.config or config == None: print("""You need to add some configuration data. Things you'll need: [1] Your github username (eg: prahladyeri) [2] Your twitter API credentials. To get those, visit https://developer.twitter.com/en/apps and register an app for yourself. After that, visit the "Keys and tokens" section and note down the following four kinds of keys: (i) Consumer API Key. (ii) Consumer Secret. (iii) Access Token. (iv) Access Token Secret. Once you have the above information, you can enter the configuration values below. """) config = cfgsaver.get_from_cmd(pkg_name, config_keys, opt_keys) if config == None: print( "Cound't read config values, please start the program again using --config parameter" ) return elif args.config: return dry_run = args.dry_run if dry_run: print("running in %s mode" % ("dry run" if dry_run else "normal")) if args.refresh_tags: refresh_tags = True do_refresh_tags() else: check_activity()