def do_run(self, line): """Running the current application. This method should be redefined for each util.""" print # Checking if all the required parameters have been set if self._checkIfRequiredAreSet(): print(general.info("Collecting the options set by the user...")) # Getting the parser... parser = entify.getParser() # Generating the parameters params = self._getParams() args = parser.parse_args(params) print(general.info("Launching " + self.UNAME + " with the following parameters: ") + general.emphashis(str(params))) try: usufy.main(args) except Exception as e: print(gemeral.error("[!] ERROR. Something happened when launching the utility. Type 'show options' to check the parameters. ")) print(general.error("Traceback: " + str(e))) else: print(general.error("[!] ERROR. There are required parameters which have not been set.")) self.do_show("options") print(general.success("Execution ended successfully."))
def do_run(self, line): """ Running the current application. This method should be redefined for each util. """ print # Checking if all the required parameters have been set if self._checkIfRequiredAreSet(): print "Collecting the options set by the user..." # Getting the parser... parser = entify.getParser() # Generating the parameters params = self._getParams() args = parser.parse_args(params) print "Launching the util with the following parameters:\n\t" + str( params) print try: entify.main(args) except Exception as e: print "[!] ERROR. Something happenned when launching the utility. Type 'show options' to check the parameters. " print "Traceback: " + str(e) else: print "[!] ERROR. There are required parameters which have not been set." self.do_show("options") print
def do_run(self, line): """ Command that send the order to the framework to launch this util Args: ----- line: The string of the line typed. """ # Checking if all the required parameters have been set if self._checkIfRequiredAreSet(): print(general.info("\nCollecting the options set by the user...\n")) # Getting the parser... parser = entify.getParser() # Generating the parameters params = self._getParams() args = parser.parse_args(params) print(general.info("\nLaunching " + self.UNAME + " with the following parameters:") + general.emphasis("\t$ " + self.UNAME + " " + utils.listToString(params) + "\n")) try: entify.main(args) except Exception as e: print(general.error("\n[!!] ERROR. Something happened when launching the utility. Type 'show options' to check the parameters.\n")) print(general.error("Traceback: " + str(e))) else: print(general.error("\n[!!] ERROR. There are required parameters which have not been set.")) self.do_show("options") print(general.success("Execution ended successfully."))
def api_v1(command, query): """Loading API v1.0 executions... :param command: the command to be launched. :param query: the user name to be searched. This application can received a random number set by the administrator that may allow the one who performs the query to run code. Use it with caution. """ # Splitting the query splittedQuery = shlex.split(query) # Get info froo OSRFramework configuration files if SECRET_TOKEN and SECRET_TOKEN == request.args.get('secret_token'): params = splittedQuery else: params = [splittedQuery[0]] # Selecting the appropriate program if command == "domainfy": args = domainfy.getParser().parse_args(['-n'] + params) elif command == "entify": args = entify.getParser().parse_args(['-w'] + params) elif command == "mailfy": args = mailfy.getParser().parse_args(['-n'] + params) elif command == "phonefy": args = phonefy.getParser().parse_args(['-n'] + params) elif command == "searchfy": args = searchfy.getParser().parse_args(['-q'] + params) elif command == "usufy": args = usufy.getParser().parse_args(['-n'] + params) answer = runQuery(command, args) # Grabbing current Time osrfTimestamp, osrfDate = _getServerTime() if answer != None: return flask.Response( json.dumps({ "code": 200, "content": answer, 'date': osrfDate, "description": "200 OK. The response contains an entity corresponding to the requested resource.", 'timestamp': osrfTimestamp }, indent=2, sort_keys=True ), status=200, mimetype="application/json" ) else: abort(400)
def run(program): """Loading OSRFramework output... """ platOptions = platform_selection.getAllPlatformNames(program) # Loading the stored global data global loaded_data global DATA_FOLDER output_folder = DATA_FOLDER answer = [] form = request.form if "terminal-form" in form.keys(): strParams = request.form['tex_command'] # Splitting the query params = shlex.split(strParams) # Manually adding the data folder if NOT provided if "-o " not in strParams: params += ["-o", output_folder] elif "windowed-form" in form.keys(): # Manually building params params = [] # Iterating through all the attributes. We will use its name to identify them for key in form.keys(): if key == "tex_query": # Adding the queries from the first text file if program != "searchfy": params += ["-n"] else: params += ["-q"] # Splitting the query splittedQuery = shlex.split(request.form[key]) # Adding the parameters params += splittedQuery elif key == "select_platforms": # Adding the parameter depending on the platform if program == "domainfy": params += ["-t"] elif program == "mailfy": params += ["-d"] else: params += ["-p"] # This is a MultiDict. We have to ad an iteration for pName in form.getlist(key): params += [pName] elif "export_" in key: params += ["-e"] params += [key.split("_")[1]] elif key == "open_url": params += ["-w"] elif key == "tex_filename": params += ["-F"] params += [request.form[key]] params += ["-o", DATA_FOLDER] # Selecting the appropriate program if program == "domainfy": args = domainfy.getParser().parse_args(params) elif program == "entify": args = entify.getParser().parse_args(params) elif program == "mailfy": args = mailfy.getParser().parse_args(params) elif program == "phonefy": args = phonefy.getParser().parse_args(params) elif program == "searchfy": args = searchfy.getParser().parse_args(params) elif program == "usufy": args = usufy.getParser().parse_args(params) # Return output. text/html is required for most browsers to show the text try: answer = runQuery(program=program, args=args) except: abort(400) # Reading CSV try: with open(os.path.join(args.output_folder, args.file_header + ".csv")) as iF: everything = iF.read().splitlines() loaded_data["csv"] = "" for i, line in enumerate(everything): loaded_data["csv"] += line # Checking if it is the last line. This is done to avoid extra lines. if i + 1 != len(everything): loaded_data["csv"] += "\n" except: pass return render_template('research-' + program + '.html', mt_research='class=current', plat_options=platOptions, text_results=general.usufyToTextExport(answer), command=buildCommandFromParams(program, params))
def getParser(): parser = OSRFParser(description='OSRFramework CLI', prog='osrf', epilog=EPILOG, conflict_handler='resolve') # Add subcommands as subparsers subcommands = parser.add_subparsers( title="SUBCOMMANDS", description= "List of available commands that can be invoked using OSRFramework CLI.", metavar="<sub_command> <sub_command_options>", dest='command_name') subparser_alias_generator = subcommands.add_parser( "alias_generator", help= "Generates a list of candidate usernames based on known information.", parents=[alias_generator.getParser()]) subparser_domainfy = subcommands.add_parser( "domainfy", help= "Checks whether domain names using words and nicknames are available.", parents=[domainfy.getParser()]) subparser_entify = subcommands.add_parser( "entify", help="Extracts entities using regular expressions from provided URIs.", parents=[entify.getParser()]) subparser_mailfy = subcommands.add_parser( "mailfy", help="Gets information about email accounts. ", parents=[mailfy.getParser()]) subparser_phonefy = subcommands.add_parser( "phonefy", help= "Looks for information linked to spam practices by a phone number.", parents=[phonefy.getParser()]) subparser_searchfy = subcommands.add_parser( "searchfy", help="Performs queries on several platforms", parents=[searchfy.getParser()]) subparser_usufy = subcommands.add_parser( "usufy", help="Looks for registered accounts with given nicknames", parents=[usufy.getParser()]) # About options groupAbout = parser.add_argument_group( 'ABOUT ARGUMENTS', 'Showing additional information about this program.') groupAbout.add_argument('-h', '--help', action='help', help='shows this help and exists.') groupAbout.add_argument('--license', action='store_true', default=False, help='shows the AGPLv3+ license and exists.') groupAbout.add_argument( '--version', action='version', version='[%(prog)s] OSRFramework ' + osrframework.__version__, help='shows the version of the program and exists.') return parser