示例#1
0
def main(args):
    '''
        Main program.

        :param args: Arguments received in the command line.
    '''
    print banner.text

    sayingHello = """searchfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    results = performSearch(platformNames=args.platforms, queries=args.queries, process = args.process)

    # Generating summary files for each ...
    if args.extension:
        # Storing the file...
        #logger.info("Creating output files as requested.")
        if not args.maltego:
            # Verifying if the outputPath exists
            if not os.path.exists (args.output_folder):
                #logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                os.makedirs(args.output_folder)

        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)

        if not args.maltego:
            # Iterating through the given extensions to print its values
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

    # Generating the Maltego output
    if args.maltego:
        general.listToMaltego(results)

    # Printing the results if requested
    if not args.maltego:
        print "A summary of the results obtained are listed in the following table:"
        print unicode(general.usufyToTextExport(results))

        if args.web_browser:
            general.openResultsInBrowser(results)

        print "You will find all the information collected in the following files:"
        for ext in args.extension:
            # Generating output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.maltego:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#2
0
def main(args):
    '''
        Main program.

        :param args: Arguments received in the command line.
    '''
    print banner.text

    sayingHello = """searchfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    results = performSearch(platformNames=args.platforms, queries=args.queries, process = args.process)

    # Generating summary files for each ...
    if args.extension:
        # Storing the file...
        #logger.info("Creating output files as requested.")
        if not args.maltego:
            # Verifying if the outputPath exists
            if not os.path.exists (args.output_folder):
                #logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                os.makedirs(args.output_folder)

        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)

        if not args.maltego:
            # Iterating through the given extensions to print its values
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

    # Generating the Maltego output
    if args.maltego:
        general.listToMaltego(results)

    # Printing the results if requested
    if not args.maltego:
        print "A summary of the results obtained are listed in the following table:"
        print unicode(general.usufyToTextExport(results))

        if args.web_browser:
            general.openResultsInBrowser(results)

        print "You will find all the information collected in the following files:"
        for ext in args.extension:
            # Generating output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.maltego:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#3
0
def main(args):
    '''
        Main program.

        :param args: Arguments received in the command line.
    '''
    sayingHello = """mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    if sys.platform == 'win32':
        print "WARNING:"
        print "\tmailfy.py seems to be run in a Windows system."
        print "\tThe emailahoy libraries may NOT work properly."
        print

    if args.create_emails:
        results = grabEmails(nicksFile = args.create_emails, domains = ["gmail.com"])
    else:
        emails = grabEmails(emails=args.emails, emailsFile = args.emails_file, nicks=args.nicks, nicksFile = args.nicks_file, domains = args.domains)

        results = performSearch(emails)

    # Trying to store the information recovered
    if args.output_folder != None:
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print
示例#4
0
def main(args):
    '''
        Main program.

        :param args: Arguments received by parameter
    '''
    sayingHello = """phonefy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    results = processPhoneList(platformNames=args.platforms,
                               numbers=args.numbers,
                               excludePlatformNames=args.exclude)

    #print json.dumps(results, indent=2)

    # Trying to store the information recovered
    if args.output_folder != None:
        # Verifying an output folder was selected
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        if args.web_browser:
            general.openResultsInBrowser(results)

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#5
0
def main(args):
    '''
        Main program.

        :param args: Arguments received by parameter
    '''
    sayingHello = """phonefy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    results = processPhoneList(platformNames=args.platforms, numbers=args.numbers)

    #print json.dumps(results, indent=2)

    # Trying to store the information recovered
    if args.output_folder != None:
        # Verifying an output folder was selected
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        if args.web_browser:
            general.openResultsInBrowser(results)

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print
示例#6
0
def main(args):
    ''' 
        Main program.
        
        :param args: Arguments received in the command line.
    '''
    sayingHello = """searchfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""    
    results = performSearch(platformNames=args.platforms, queries=args.queries, process = args.process)

    # Generating summary files for each ...
    if args.extension:
        # Storing the file...
        #logger.info("Creating output files as requested.")
        if not args.maltego:
            # Verifying if the outputPath exists
            if not os.path.exists (args.output_folder):
                #logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                os.makedirs(args.output_folder)
                
        # Grabbing the results 
        fileHeader = os.path.join(args.output_folder, args.file_header)
        
        if not args.maltego:
            # Iterating through the given extensions to print its values
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)
                
    # Generating the Maltego output    
    if args.maltego:
        general.listToMaltego(results)

    # Printing the results if requested
    if not args.maltego:
        print "A summary of the results obtained are listed in the following table:"
        print unicode(general.usufyToTextExport(results))
        print "You will find all the information collected in the following files:"                                                     
        for ext in args.extension:
            # Generating output files
            print "\t-" + fileHeader + "." + ext
    return results
示例#7
0
def main(args):
    ''' 
        Main program.
        
        :param args: Arguments received in the command line.
    ''' 
    sayingHello = """mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""    
    if not args.quiet:
        print sayingHello
        print
        
    if args.create_emails:
        results = grabEmails(nicksFile = args.create_emails, domains = ["gmail.com"])
    else:
        emails = grabEmails(emails=args.emails, emailsFile = args.emails_file, nicks=args.nicks, nicksFile = args.nicks_file, domains = args.domains)

        results = performSearch(emails)

    # Trying to store the information recovered
    if args.output_folder != None:    
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results 
        fileHeader = os.path.join(args.output_folder, args.file_header)                        
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)        

    # Showing the information gathered if requested                
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"                                                     
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext        
示例#8
0
def main(args):
    ''' 
        Main program.
        
        :param args: Arguments received by parameter
    '''
    sayingHello = """phonefy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""    
    if not args.quiet:
        print sayingHello
        print
        
    results = processPhoneList(platformNames=args.platforms, numbers=args.numbers)

    #print json.dumps(results, indent=2)

    # Trying to store the information recovered
    if args.output_folder != None:    
        # Verifying an output folder was selected
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results 
        fileHeader = os.path.join(args.output_folder, args.file_header)                        
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)        

    # Showing the information gathered if requested                
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"                                                     
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext        
示例#9
0
def main(params=None):
    """
    Main function to launch phonefy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point. If it is called by osrf
            the data is already parsed.

    Results:
    --------
        Returns a list with i3visio entities.
    """
    if params == None:
        parser = getParser()
        args = parser.parse_args(params)
    else:
        args = params

    results = []

    # Recovering the logger
    # Calling the logger when being imported
    logSet.setupLogger(loggerName="osrframework.entify",
                       verbosity=args.verbose,
                       logFolder=args.logfolder)
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.entify")

    logger.info("Selecting the regular expressions to be analysed...")

    if not args.quiet:
        print(general.title(banner.text))

    sayingHello = """
      Entify | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2018

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit <{}>.
""".format(general.LICENSE_URL)
    print(general.info(sayingHello))

    if args.license:
        general.showLicense()
    else:
        listRegexp = []
        if args.regexp:
            listRegexp = regexp_selection.getRegexpsByName(args.regexp)
        elif args.new_regexp:
            for i, r in enumerate(args.new_regexp):
                listRegexp.append(
                    RegexpObject(name="NewRegexp" + str(i),
                                 reg_exp=args.new_regexp))

        if not args.web:
            results = scanFolderForRegexp(folder=args.input_folder,
                                          listRegexp=listRegexp,
                                          recursive=args.recursive,
                                          verbosity=args.verbose,
                                          logFolder=args.logfolder,
                                          quiet=args.quiet)
        else:
            results = scanResource(uri=args.web,
                                   listRegexp=listRegexp,
                                   verbosity=args.verbose,
                                   logFolder=args.logfolder)
        logger.info("Logging the results:\n" +
                    json.dumps(results, indent=2, sort_keys=True))

        # Trying to store the information recovered
        if args.output_folder != None:
            # Verifying an output folder was selected
            logger.debug("Preparing the output folder...")
            if not os.path.exists(args.output_folder):
                logger.warning(
                    "The output folder \'" + args.output_folder +
                    "\' does not exist. The system will try to create it.")
                os.makedirs(args.output_folder)

            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Showing the information gathered if requested
        if not args.quiet:
            now = dt.datetime.now()
            print("\n{}\tResults obtained:\n".format(str(now)))
            print(general.success(general.usufyToTextExport(results)))

            now = dt.datetime.now()
            print(
                str(now) +
                "\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print("\t-" + general.emphasis(fileHeader + "." + ext))

            # Urging users to place an issue on Github...
            print(banner.footer)

    if params:
        return results
示例#10
0
def usufy_main(args):
    ''' 
        Main function. This function is created in this way so as to let other applications make use of the full configuration capabilities of the application.    
    '''
    # Recovering the logger
    # Calling the logger when being imported
    osrframework.utils.logger.setupLogger(loggerName="osrframework.usufy", verbosity=args.verbose, logFolder=args.logfolder)    
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.usufy")

    logger.info("""usufy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions.
For details, run:
\tpython usufy.py --license""")
    
    logger.info("Starting usufy.py...")

    if args.license:
        logger.info("Looking for the license...")
        # showing the license
        try:
            with open ("COPYING", "r") as iF:
                contenido = iF.read().splitlines()
                for linea in contenido:    
                    print linea
        except Exception:
            logger.error("ERROR: there has been an error when opening the COPYING file.\n\tThe file contains the terms of the GPLv3 under which this software is distributed.\n\tIn case of doubts, verify the integrity of the files or contact [email protected].")
    elif args.fuzz:
        logger.info("Performing the fuzzing tasks...")
        res = fuzzUsufy(args.fuzz, args.fuzz_config)
        logger.info("Recovered platforms:\n" + str(res))
    else:
        logger.debug("Recovering the list of platforms to be processed...")
        # Recovering the list of platforms to be launched
        listPlatforms = platform_selection.getPlatformsByName(platformNames=args.platforms, tags=args.tags, mode="usufy")
        logger.debug("Platforms recovered.")

        if args.info:
            # Information actions...
            if args.info == 'list_platforms':
                infoPlatforms="Listing the platforms:\n"
                for p in listPlatforms:
                    infoPlatforms += "\t\t" + (str(p) + ": ").ljust(16, ' ') + str(p.tags)+"\n"
                logger.info(infoPlatforms)
                return infoPlatforms
            elif args.info == 'list_tags':
                logger.info("Listing the tags:")
                tags = {}
                # Going through all the selected platforms to get their tags
                for p in listPlatforms:
                    for t in p.tags:
                        if t not in tags.keys():
                            tags[t] = 1
                        else:
                            tags[t] += 1
                infoTags = "List of tags:\n"
                # Displaying the results in a sorted list
                for t in tags.keys():
                    infoTags += "\t\t" + (t + ": ").ljust(16, ' ') + str(tags[t]) + "  time(s)\n"
                logger.info(infoTags)
                return infoTags
            else:
                pass
                
        # performing the test
        elif args.benchmark:
            logger.warning("The benchmark mode may last some minutes as it will be performing similar queries to the ones performed by the program in production. ")
            logger.info("Launching the benchmarking tests...")
            platforms = platform_selection.getAllPlatformNames("usufy")
            res = benchmark.doBenchmark(platforms)
            strTimes = ""
            for e in sorted(res.keys()):
                strTimes += str(e) + "\t" + str(res[e]) + "\n"
            logger.info(strTimes)
            return strTimes
        # Executing the corresponding process...
        else:
            # Defining the list of users to monitor
            nicks = []
            logger.debug("Recovering nicknames to be processed...")
            if args.nicks:
                for n in args.nicks:
                    # TO-DO
                    #     A trick to avoid having the processing of the properties when being queried by Maltego
                    if "properties.i3visio" not in n:
                        nicks.append(n)
            else:
                # Reading the nick files
                try:
                    nicks = args.list.read().splitlines()
                except:
                    logger.error("ERROR: there has been an error when opening the file that stores the nicks.\tPlease, check the existence of this file.")

            # Checking if performing any transform was required
            if args.squatting:
                logger.debug("Making basic transformations on the provided nicknames...")
                # Iterating to process _ and or .
                #nicks = profilesquatting.generatingProfiles(nicks, args.profilesquatting)
                nicks = profilesquatting.getNewNicks(nicks, logName = "usufy", modes = args.squatting, nonValidChars = args.nonvalid)
                logger.info("Obtained nicks:\n" + str(nicks))
                
                logger.debug("Profilesquatting nicknames recovered.")
                if args.info == 'list_users':            
                    strNicks = ""
                    for n in nicks:
                        strNicks += n + "\n"
                    logger.info("Generated nicks:\n----------------\n" + strNicks)
                    # Storing the file...
                    logger.info("Creating output files as requested.")
                    # Verifying if the outputPath exists
                    if not os.path.exists (args.output_folder):
                        logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                        os.makedirs(args.output_folder)
                            
                    strTime = general.getCurrentStrDatetime()
                    logger.info("Writing generated nicks to a text file.")
                    with open (os.path.join(args.output_folder, "nicks_" + strTime +".txt"), "w") as oF:
                        oF.write( strNicks )
                    # if this option was selected, we will jsut return this and exist
                    return nicks            

            if args.output_folder != None:    
                # if Verifying an output folder was selected
                logger.debug("Preparing the output folder...")
                if not os.path.exists(args.output_folder):
                    logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                    os.makedirs(args.output_folder)
                # Launching the process...
                res = processNickList(nicks, listPlatforms, args.output_folder, avoidProcessing = args.avoid_processing, avoidDownload = args.avoid_download, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)
            else:
                res = processNickList(nicks, listPlatforms, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)
                
            
            logger.info("Listing the results obtained...")
            # We are going to iterate over the results...
            strResults = "\t"   
            
            # Structure returned 
            """
            [
                {
                  "attributes": [
                    {
                      "attributes": [], 
                      "type": "i3visio.uri", 
                      "value": "http://twitter.com/i3visio"
                    }, 
                    {
                      "attributes": [], 
                      "type": "i3visio.alias", 
                      "value": "i3visio"
                    }, 
                    {
                      "attributes": [], 
                      "type": "i3visio.platform", 
                      "value": "Twitter"
                    }
                  ], 
                  "type": "i3visio.profile", 
                  "value": "Twitter - i3visio"
                }
                ,
                ...
            ]                    
            """    
            for r in res:               
                # The format of the results (attributes) for a given nick is a list as follows:
                for att in r["attributes"]:
                    # iterating through the attributes
                    platform = ""
                    uri = ""
                    for details in att["attributes"]:
                        if details["type"] == "i3visio.platform":
                            platform = details["value"]
                        if details["type"] == "i3visio.uri":
                            uri = details["value"]                                
                    try:
                        strResults+= (str(platform) + ":").ljust(16, ' ')+ " "+ str(uri)+"\n\t\t"
                    except:
                        pass

                logger.info(strResults)

                # Generating summary files for each ...
                if args.extension:
                    # Storing the file...
                    logger.info("Creating output files as requested.")
                    if not args.output_folder:
                        args.output_folder = "./"
                    else:
                        # Verifying if the outputPath exists
                        if not os.path.exists (args.output_folder):
                            logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                            os.makedirs(args.output_folder)
                            
                    # Grabbing the results 
                    fileHeader = os.path.join(args.output_folder, args.file_header + general.getCurrentStrDatetime())

                    # Iterating through the given extensions to print its values
                    for ext in args.extension:
                        # Generating output files
                        general.exportUsufy(res, ext, fileHeader)
                        
                # Generating the Maltego output    
                if args.maltego:
                    general.listToMaltego(res)

                # Printing the results if requested
                if not args.maltego:
                    print "A summary of the results obtained are the following table:"
                    print general.usufyToTextExport(res)
                    print "You can find all the information collected in the following files:"                    
                    for ext in args.extension:
                        # Generating output files
                        print "\t-" + fileHeader + "." + ext
                return res
示例#11
0
def main(params=None):
    """
    Main function to launch usufy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point. If it is called by osrf
            the data is already parsed.

    Returns:
    --------
        A list of i3visio entities.
    """
    if params == None:
        parser = getParser()
        args = parser.parse_args(params)
    else:
        args = params

    results = []

    print(general.title(banner.text))

    sayingHello = """
     Searchfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2018

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit <{}>.
""".format(general.LICENSE_URL)
    print(general.info(sayingHello))

    if args.license:
        general.showLicense()
    else:
        # Showing the execution time...
        startTime = dt.datetime.now()
        print(
            str(startTime) +
            "\tStarting search in different platform(s)... Relax!\n")
        print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))
        # Performing the search
        try:
            results = performSearch(platformNames=args.platforms,
                                    queries=args.queries,
                                    process=args.process,
                                    excludePlatformNames=args.exclude)
        except KeyboardInterrupt:
            print(
                general.error(
                    "\n[!] Process manually stopped by the user. Workers terminated without providing any result.\n"
                ))
            results = []

        # Generating summary files for each ...
        if args.extension:
            # Verifying if the outputPath exists
            if not os.path.exists(args.output_folder):
                os.makedirs(args.output_folder)

            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)

            # Iterating through the given extensions to print its values
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Printing the results if requested
        now = dt.datetime.now()
        print("\n{}\tResults obtained:\n".format(str(now)))
        print(general.success(general.usufyToTextExport(results)))

        if args.web_browser:
            general.openResultsInBrowser(results)

        now = dt.datetime.now()
        print(
            "\n{date}\tYou can find all the information collected in the following files:"
            .format(date=str(now)))
        for ext in args.extension:
            # Showing the output files
            print("\t" + general.emphasis(fileHeader + "." + ext))

        # Showing the execution time...
        endTime = dt.datetime.now()
        print("\n{date}\tFinishing execution...\n".format(date=str(endTime)))
        print("Total time used:\t" +
              general.emphasis(str(endTime - startTime)))
        print("Average seconds/query:\t" + general.emphasis(
            str((endTime - startTime).total_seconds() / len(args.platforms))) +
              " seconds\n")

        # Urging users to place an issue on Github...
        print(banner.footer)

    if params:
        return results
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))
示例#13
0
def main(args):
    '''Main program.

        :param args: Arguments received in the command line.
    '''
    sayingHello = """mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016-2017
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

        # Displaying a warning if this is being run in a windows system
        if sys.platform == 'win32':
            print "WARNING:"
            print "\tOSRFramework has detected that you are running mailfy.py in a Windows system."
            print "\tAs the emailahoy library is NOT working properly there, validate_email will be used."
            print "\tVerification may be slower though."
            print

    # Processing the options returned to remove the "all" option
    if "all" in args.domains:
        domains = EMAIL_DOMAINS
    else:
        # processing only the given domains and excluding the ones provided
        domains = []
        for d in args.domains:
            if d not in args.exclude:
                domains.append(d)

    if args.create_emails:
        emails = grabEmails(nicksFile=args.create_emails,
                            domains=domains,
                            excludeDomains=args.exclude)
    else:
        emails = grabEmails(emails=args.emails,
                            emailsFile=args.emails_file,
                            nicks=args.nicks,
                            nicksFile=args.nicks_file,
                            domains=domains,
                            excludeDomains=args.exclude)

    # Showing the execution time...
    if not args.quiet:
        startTime = dt.datetime.now()
        print str(startTime) + "\tStarting search of the following " + str(
            len(emails)) + " different emails: " + str(
                emails) + ". Be patient!"
        print
        print "\tPress <Ctrl + C> to stop..."
        print
    # Perform searches, using different Threads
    results = performSearch(emails, args.threads)

    # Trying to store the information recovered
    if args.output_folder != None:
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext
    # Showing the execution time...
    if not args.quiet:
        print
        endTime = dt.datetime.now()
        print str(endTime) + "\tFinishing execution..."
        print
        print "Total time used:\t" + str(endTime - startTime)
        print "Average seconds/query:\t" + str(
            (endTime - startTime).total_seconds() / len(emails)) + " seconds"
        print

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#14
0
def main(args):
    '''
        Main function. This function is created in this way so as to let other applications make use of the full configuration capabilities of the application.
    '''
    # Recovering the logger
    # Calling the logger when being imported
    osrframework.utils.logger.setupLogger(loggerName="osrframework.usufy", verbosity=args.verbose, logFolder=args.logfolder)
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.usufy")
    # Printing the results if requested
    if not args.maltego:
        print banner.text

        sayingHello = """usufy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
        logger.info(sayingHello)
        print sayingHello
        print
        logger.info("Starting usufy.py...")

    if args.license:
        logger.info("Looking for the license...")
        # showing the license
        try:
            with open ("COPYING", "r") as iF:
                contenido = iF.read().splitlines()
                for linea in contenido:
                    print linea
        except Exception:
            try:
                # Trying to recover the COPYING file...
                with open ("/usr/share/osrframework/COPYING", "r") as iF:
                    contenido = iF.read().splitlines()
                    for linea in contenido:
                        print linea
            except:
                logger.error("ERROR: there has been an error when opening the COPYING file.\n\tThe file contains the terms of the GPLv3 under which this software is distributed.\n\tIn case of doubts, verify the integrity of the files or contact [email protected].")
    elif args.fuzz:
        logger.info("Performing the fuzzing tasks...")
        res = fuzzUsufy(args.fuzz, args.fuzz_config)
        logger.info("Recovered platforms:\n" + str(res))
    else:
        logger.debug("Recovering the list of platforms to be processed...")
        # Recovering the list of platforms to be launched
        listPlatforms = platform_selection.getPlatformsByName(platformNames=args.platforms, tags=args.tags, mode="usufy")
        logger.debug("Platforms recovered.")

        if args.info:
            # Information actions...
            if args.info == 'list_platforms':
                infoPlatforms="Listing the platforms:\n"
                for p in listPlatforms:
                    infoPlatforms += "\t\t" + (str(p) + ": ").ljust(16, ' ') + str(p.tags)+"\n"
                logger.info(infoPlatforms)
                return infoPlatforms
            elif args.info == 'list_tags':
                logger.info("Listing the tags:")
                tags = {}
                # Going through all the selected platforms to get their tags
                for p in listPlatforms:
                    for t in p.tags:
                        if t not in tags.keys():
                            tags[t] = 1
                        else:
                            tags[t] += 1
                infoTags = "List of tags:\n"
                # Displaying the results in a sorted list
                for t in tags.keys():
                    infoTags += "\t\t" + (t + ": ").ljust(16, ' ') + str(tags[t]) + "  time(s)\n"
                logger.info(infoTags)
                return infoTags
            else:
                pass

        # performing the test
        elif args.benchmark:
            logger.warning("The benchmark mode may last some minutes as it will be performing similar queries to the ones performed by the program in production. ")
            logger.info("Launching the benchmarking tests...")
            platforms = platform_selection.getAllPlatformNames("usufy")
            res = benchmark.doBenchmark(platforms)
            strTimes = ""
            for e in sorted(res.keys()):
                strTimes += str(e) + "\t" + str(res[e]) + "\n"
            logger.info(strTimes)
            return strTimes
        # Executing the corresponding process...
        else:
            # Showing the execution time...
            if not args.maltego:
                startTime= dt.datetime.now()
                print str(startTime) +"\tStarting search in " + str(len(listPlatforms)) + " platform(s)... Be patient!\n"

            # Defining the list of users to monitor
            nicks = []
            logger.debug("Recovering nicknames to be processed...")
            if args.nicks:
                for n in args.nicks:
                    # TO-DO
                    #     A trick to avoid having the processing of the properties when being queried by Maltego
                    if "properties.i3visio" not in n:
                        nicks.append(n)
            else:
                # Reading the nick files
                try:
                    nicks = args.list.read().splitlines()
                except:
                    logger.error("ERROR: there has been an error when opening the file that stores the nicks.\tPlease, check the existence of this file.")

            if args.output_folder != None:
                # if Verifying an output folder was selected
                logger.debug("Preparing the output folder...")
                if not args.maltego:
                    if not os.path.exists(args.output_folder):
                        logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                        os.makedirs(args.output_folder)
                # Launching the process...
                res = processNickList(nicks, listPlatforms, args.output_folder, avoidProcessing = args.avoid_processing, avoidDownload = args.avoid_download, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)
            else:
                res = processNickList(nicks, listPlatforms, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)


            logger.info("Listing the results obtained...")
            # We are going to iterate over the results...
            strResults = "\t"

            # Structure returned
            """
            [
                {
                  "attributes": [
                    {
                      "attributes": [],
                      "type": "i3visio.uri",
                      "value": "http://twitter.com/i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.alias",
                      "value": "i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.platform",
                      "value": "Twitter"
                    }
                  ],
                  "type": "i3visio.profile",
                  "value": "Twitter - i3visio"
                }
                ,
                ...
            ]
            """
            for r in res:
                # The format of the results (attributes) for a given nick is a list as follows:

                for att in r["attributes"]:
                    # iterating through the attributes
                    platform = ""
                    uri = ""
                    for details in att["attributes"]:
                        if details["type"] == "i3visio.platform":
                            platform = details["value"]
                        if details["type"] == "i3visio.uri":
                            uri = details["value"]
                    try:
                        strResults+= (str(platform) + ":").ljust(16, ' ')+ " "+ str(uri)+"\n\t\t"
                    except:
                        pass

                logger.info(strResults)

            # Generating summary files for each ...
            if args.extension:
                # Storing the file...
                logger.info("Creating output files as requested.")
                if not args.maltego:
                    # Verifying if the outputPath exists
                    if not os.path.exists (args.output_folder):
                        logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                        os.makedirs(args.output_folder)

                # Grabbing the results
                fileHeader = os.path.join(args.output_folder, args.file_header)

                # Iterating through the given extensions to print its values
                if not args.maltego:
                    for ext in args.extension:
                        # Generating output files
                        general.exportUsufy(res, ext, fileHeader)

            # Generating the Maltego output
            if args.maltego:
                general.listToMaltego(res)

            # Printing the results if requested
            if not args.maltego:
                print "A summary of the results obtained are shown in the following table:"
                #print res
                print unicode(general.usufyToTextExport(res))

                print

                print "You can find all the information collected in the following files:"
                for ext in args.extension:
                    # Showing the output files
                    print "\t-" + fileHeader + "." + ext

            # Showing the execution time...
            if not args.maltego:
                print
                endTime= dt.datetime.now()
                print str(endTime) +"\tFinishing execution..."
                print
                print "Total time used:\t" + str(endTime-startTime)
                print "Average seconds/query:\t" + str((endTime-startTime).total_seconds()/len(listPlatforms)) +" seconds"
                print

            # Urging users to place an issue on Github...
            if not args.maltego:
                print
                print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
                print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
                print "Note that otherwise, we won't know about it!"
                print

            return res
示例#15
0
def main(args):
    '''
        Main program of domainfy.

        :param args: Arguments received in the command line.
    '''
    sayingHello = """domainfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016-2017
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    # Processing the options returned to remove the "all" option
    tlds = []
    if "all" in args.tlds:
        for typeTld in TLD.keys():
            for tld in TLD[typeTld]:
                if tld not in args.exclude:
                    tlds.append({"tld": tld, "type": typeTld})
    elif "none" in args.tlds:
        pass
    else:
        for typeTld in TLD.keys():
            if typeTld in args.tlds:
                for tld in TLD[typeTld]:
                    if tld not in args.exclude:
                        tlds.append({"tld": tld, "type": typeTld})

    for new in args.user_defined:
        if tld not in args.exclude:
            tlds.append({"tld": new, "type": "user_defined"})

    if args.nicks:
        domains = createDomains(tlds, nicks=args.nicks)
    else:
        # nicks_file
        domains = createDomains(tlds, nicksFile=args.nicks_file)

    # Showing the execution time...
    if not args.quiet:
        startTime = dt.datetime.now()
        print str(startTime) + "\tStarting the lookup in up to " + str(
            len(tlds)) + " different domains. Be patient!"
        print
        print "\tPress <Ctrl + C> to stop..."
        print
    # Perform searches, using different Threads
    results = performSearch(domains, args.threads)

    # Trying to store the information recovered
    if args.output_folder != None:
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        try:
            print str(general.usufyToTextExport(results))
        except:
            print results
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext
    # Showing the execution time...
    if not args.quiet:
        print
        endTime = dt.datetime.now()
        print str(endTime) + "\tFinishing execution..."
        print
        print "Total time used:\t" + str(endTime - startTime)
        print "Average seconds/query:\t" + str(
            (endTime - startTime).total_seconds() / len(domains)) + " seconds"
        print

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#16
0
def main(params=None):
    """
    Main function to launch phonefy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point.

    Returns:
    --------
        A list of i3visio entities.
    """
    # Grabbing the parser
    parser = getParser()

    if params != None:
        args = parser.parse_args(params)
    else:
        args = parser.parse_args()

    results = []

    if not args.quiet:
        print(general.title(banner.text))

        sayingHello = """
Phonefy | Copyright (C) F. Brezo and Y. Rubio (i3visio) 2014-2018

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit """ + general.LICENSE_URL + "\n"
        print(general.title(sayingHello))

    if args.license:
        general.showLicense()
    else:
        # Showing the execution time...
        startTime = dt.datetime.now()
        #TODO: Get the number searchable platforms in this context
        print(
            str(startTime) +
            "\tStarting search in different platform(s)... Relax!\n")
        print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))
        try:
            results = processPhoneList(platformNames=args.platforms,
                                       numbers=args.numbers,
                                       excludePlatformNames=args.exclude)
        except KeyboardInterrupt:
            print(
                general.error(
                    "\n[!] Process manually stopped by the user. Workers terminated without providing any result.\n"
                ))

        # Trying to store the information recovered
        if args.output_folder != None:
            # Verifying an output folder was selected
            if not os.path.exists(args.output_folder):
                os.makedirs(args.output_folder)
            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Showing the information gathered if requested
        if not args.quiet:
            now = dt.datetime.now()
            print(
                str(now) +
                "\tA summary of the results obtained is shown in the following table:\n"
            )
            print(general.success(general.usufyToTextExport(results)))

            if args.web_browser:
                general.openResultsInBrowser(results)

            now = dt.datetime.now()
            print(
                "\n" + str(now) +
                "\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print("\t" + general.emphasis(fileHeader + "." + ext))

            # Showing the execution time...
            endTime = dt.datetime.now()
            print("\n" + str(endTime) + "\tFinishing execution...\n")
            print("Total time consumed:\t" +
                  general.emphasis(str(endTime - startTime)) + "\n")
            #TODO: Get the number searchable platforms in this context
            #print("Average seconds/query:\t" + general.emphasis(str((endTime-startTime).total_seconds()/len(listPlatforms))) +" seconds\n")

            # Urging users to place an issue on Github...
            print(banner.footer)

    if params:
        return results
示例#17
0
def main(args):
    '''
        Main function. This function is created in this way so as to let other applications make use of the full configuration capabilities of the application.
    '''
    # Recovering the logger
    # Calling the logger when being imported
    logSet.setupLogger(loggerName="osrframework.entify", verbosity=args.verbose, logFolder=args.logfolder)
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.entify")

    logger.info("""entify.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015-2017
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit to <http://www.gnu.org/licenses/gpl-3.0.txt>.""")

    logger.info("Selecting the regular expressions to be analysed...")

    sayingHello = """entify.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015-2017
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print
        logger.info("Starting entify.py")

    listRegexp = []
    if args.regexp:
        listRegexp = regexp_selection.getRegexpsByName(args.regexp)
    elif args.new_regexp:
        for i, r in enumerate(args.new_regexp):
            listRegexp.append(RegexpObject(name = "NewRegexp"+str(i), reg_exp = args.new_regexp))

    if not args.web:
        results = scanFolderForRegexp(folder = args.input_folder, listRegexp= listRegexp, recursive = args.recursive, verbosity=args.verbose, logFolder= args.logfolder, quiet=args.quiet)
    else:
        results = scanResource(uri = args.web, listRegexp= listRegexp, verbosity=args.verbose, logFolder= args.logfolder)
    logger.info("Logging the results:\n" + json.dumps(results, indent=2, sort_keys=True))

    # Trying to store the information recovered
    if args.output_folder != None:
        # Verifying an output folder was selected
        logger.debug("Preparing the output folder...")
        if not os.path.exists(args.output_folder):
            logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
            os.makedirs(args.output_folder)

        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print

    return results
示例#18
0
def main(params=None):
    """
    Main function to launch phonefy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point. If it is called by osrf
            the data is already parsed.

    Returns:
    --------
        A list of i3visio entities.
    """
    if params == None:
        parser = getParser()
        args = parser.parse_args(params)
    else:
        args = params

    results = []

    if not args.quiet:
        print(general.title(banner.text))

        sayingHello = """
          Mailfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2018

    This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
    are welcome to redistribute it under certain conditions. For additional info,
    visit <{}>.
    """.format(general.LICENSE_URL)
        print(general.info(sayingHello))
        # Displaying a warning if this is being run in a windows system
        if sys.platform == 'win32':
            print(
                general.warning(
                    """OSRFramework has detected that you are running mailfy.py in a Windows system.
As the "emailahoy" library is NOT working properly there, "validate_email" will
be used instead. Verification may be slower though."""))

    if args.license:
        general.showLicense()
    else:
        # processing only the given domains and excluding the ones provided
        extra_domains = []

        for d in args.domains:
            if d not in args.exclude and not d == "all":
                extra_domains.append(d)

        # Two different arrays are mantained since there are some domains that cannot be safely verified
        if args.create_emails:
            potentially_existing_emails = grabEmails(
                nicksFile=args.create_emails,
                domains=EMAIL_DOMAINS + extra_domains,
                excludeDomains=args.exclude)
            potentially_leaked_emails = grabEmails(
                nicksFile=args.create_emails,
                domains=LEAKED_DOMAINS + extra_domains,
                excludeDomains=args.exclude)
        else:
            potentially_existing_emails = grabEmails(
                emails=args.emails,
                emailsFile=args.emails_file,
                nicks=args.nicks,
                nicksFile=args.nicks_file,
                domains=EMAIL_DOMAINS + extra_domains,
                excludeDomains=args.exclude)
            potentially_leaked_emails = grabEmails(emails=args.emails,
                                                   emailsFile=args.emails_file,
                                                   nicks=args.nicks,
                                                   nicksFile=args.nicks_file,
                                                   domains=LEAKED_DOMAINS +
                                                   extra_domains,
                                                   excludeDomains=args.exclude)

        emails = list(
            set(potentially_leaked_emails + potentially_existing_emails))

        # Showing the execution time...
        if not args.quiet:
            startTime = dt.datetime.now()
            print("{}\tStarting search of {} different emails:\n{}\n".format(
                str(startTime), general.emphasis(str(len(emails))),
                json.dumps(emails, indent=2, sort_keys=True)))

        if not args.quiet:
            now = dt.datetime.now()
            print(
                "\n{}\tStep 1. Trying to determine if the emails provided do exist...\n"
                .format(str(now)))
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

        # Perform searches, using different Threads
        results = performSearch(potentially_existing_emails,
                                nThreads=args.threads)

        if not args.quiet:
            now = dt.datetime.now()
            print(
                "\n{}\tStep 2. Checking if the emails have been used to register socialmedia accounts...\n"
                .format(str(now)))
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

        registered = processMailList(platformNames=args.platforms,
                                     emails=potentially_existing_emails)
        results += registered

        if not args.quiet:
            if len(results) > 0:
                for r in registered:
                    print("\t[*] Registered account found: {}".format(
                        general.success(r["value"])))
            else:
                print("\t[*] Registered account found: {}".format(
                    general.error("None")))

            now = dt.datetime.now()
            print(
                "\n{}\tStep 3. Verifying if the provided emails have  been leaked somewhere?\n"
                .format(str(now)))
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

        # Verify the existence of the mails found as leaked emails.
        for query in potentially_leaked_emails:
            # Iterate through the different leak platforms
            leaks = hibp.checkIfEmailWasHacked(query)

            if len(leaks) > 0:
                if not args.quiet:
                    if len(leaks) > 0:
                        print(
                            "\t[*] '{}' has been found in at least {} different leaks."
                            .format(general.success(query),
                                    general.success(str(len(leaks)))))
                    else:
                        print("\t[*] '{}' has NOT been found in any leak.".
                              format(general.error(query)))
            else:
                if not args.quiet:
                    print("\t[*] '{}' has NOT been found on any leak yet.".
                          format(general.error(query)))

            results += leaks

        # Trying to store the information recovered
        if args.output_folder != None:
            if not os.path.exists(args.output_folder):
                os.makedirs(args.output_folder)
            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Showing the information gathered if requested
        if not args.quiet:
            now = dt.datetime.now()
            print("\n{}\tResults obtained:\n".format(str(now)))
            print(general.success(general.usufyToTextExport(results)))

            now = dt.datetime.now()
            print(
                "\n" + str(now) +
                "\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print(general.emphasis("\t" + fileHeader + "." + ext))

        # Showing the execution time...
        if not args.quiet:
            endTime = dt.datetime.now()
            print("\n" + str(endTime) + "\tFinishing execution...\n")
            print("Total time used:\t" +
                  general.emphasis(str(endTime - startTime)))
            print("Average seconds/query:\t" + general.emphasis(
                str((endTime - startTime).total_seconds() / len(emails))) +
                  " seconds\n")

        if not args.quiet:
            # Urging users to place an issue on Github...
            print(banner.footer)

    if params:
        return results
示例#19
0
def main(params=None):
    """
    Main function to launch usufy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point.

    Returns:
    --------
        dict: A Json representing the matching results.
    """
    # Grabbing the parser
    parser = getParser()

    if params != None:
        args = parser.parse_args(params)
    else:
        args = parser.parse_args()

    # Recovering the logger
    # Calling the logger when being imported
    osrframework.utils.logger.setupLogger(loggerName="osrframework.usufy",
                                          verbosity=args.verbose,
                                          logFolder=args.logfolder)
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.usufy")

    print(general.title(banner.text))

    sayingHello = """
Usufy | Copyright (C) F. Brezo and Y. Rubio (i3visio) 2014-2018

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit """ + general.LICENSE_URL + "\n"
    logger.info(sayingHello)
    print(general.title(sayingHello))
    logger.info("Starting usufy...")

    if args.license:
        general.showLicense()
    elif args.fuzz:
        logger.info("Performing the fuzzing tasks...")
        res = fuzzUsufy(args.fuzz, args.fuzz_config)
        logger.info("Recovered platforms:\n" + str(res))
    else:
        logger.debug("Recovering the list of platforms to be processed...")
        # Recovering the list of platforms to be launched
        listPlatforms = platform_selection.getPlatformsByName(
            platformNames=args.platforms,
            tags=args.tags,
            mode="usufy",
            excludePlatformNames=args.exclude)
        logger.debug("Platforms recovered.")

        if args.info:
            # Information actions...
            if args.info == 'list_platforms':
                infoPlatforms = "Listing the platforms:\n"
                for p in listPlatforms:
                    infoPlatforms += "\t\t" + (str(p) + ": ").ljust(
                        16, ' ') + str(p.tags) + "\n"
                logger.info(infoPlatforms)
                return infoPlatforms
            elif args.info == 'list_tags':
                logger.info("Listing the tags:")
                tags = {}
                # Going through all the selected platforms to get their tags
                for p in listPlatforms:
                    for t in p.tags:
                        if t not in tags.keys():
                            tags[t] = 1
                        else:
                            tags[t] += 1
                infoTags = "List of tags:\n"
                # Displaying the results in a sorted list
                for t in tags.keys():
                    infoTags += "\t\t" + (t + ": ").ljust(16, ' ') + str(
                        tags[t]) + "  time(s)\n"
                logger.info(infoTags)
                return infoTags
            else:
                pass

        # performing the test
        elif args.benchmark:
            logger.warning(
                "The benchmark mode may last some minutes as it will be performing similar queries to the ones performed by the program in production. "
            )
            logger.info("Launching the benchmarking tests...")
            platforms = platform_selection.getAllPlatformNames("usufy")
            res = benchmark.doBenchmark(platforms)
            strTimes = ""
            for e in sorted(res.keys()):
                strTimes += str(e) + "\t" + str(res[e]) + "\n"
            logger.info(strTimes)
            return strTimes

        # showing the tags of the usufy platforms
        elif args.show_tags:
            logger.info("Collecting the list of tags...")
            tags = platform_selection.getAllPlatformNamesByTag("usufy")
            logger.info(json.dumps(tags, indent=2))
            print(
                general.info(
                    "This is the list of platforms grouped by tag.\n"))
            print(json.dumps(tags, indent=2, sort_keys=True))
            print(
                general.info(
                    "[Tip] Remember that you can always launch the platform using the -t option followed by any of the aforementioned.\n"
                ))
            return tags

        # Executing the corresponding process...
        else:
            # Showing the execution time...
            startTime = dt.datetime.now()
            print(
                str(startTime) + "\tStarting search in " +
                general.emphasis(str(len(listPlatforms))) +
                " platform(s)... Relax!\n")
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

            # Defining the list of users to monitor
            nicks = []
            logger.debug("Recovering nicknames to be processed...")
            if args.nicks:
                for n in args.nicks:
                    # TO-DO
                    #     A trick to avoid having the processing of the properties when being queried by Maltego
                    if "properties.i3visio" not in n:
                        nicks.append(n)
            else:
                # Reading the nick files
                try:
                    nicks = args.list.read().splitlines()
                except:
                    logger.error(
                        "ERROR: there has been an error when opening the file that stores the nicks.\tPlease, check the existence of this file."
                    )

            # Definning the results
            res = []

            if args.output_folder != None:
                # if Verifying an output folder was selected
                logger.debug("Preparing the output folder...")
                if not os.path.exists(args.output_folder):
                    logger.warning(
                        "The output folder \'" + args.output_folder +
                        "\' does not exist. The system will try to create it.")
                    os.makedirs(args.output_folder)
                # Launching the process...
                res = processNickList(nicks,
                                      listPlatforms,
                                      args.output_folder,
                                      avoidProcessing=args.avoid_processing,
                                      avoidDownload=args.avoid_download,
                                      nThreads=args.threads,
                                      verbosity=args.verbose,
                                      logFolder=args.logfolder)

            else:
                try:
                    res = processNickList(nicks,
                                          listPlatforms,
                                          nThreads=args.threads,
                                          verbosity=args.verbose,
                                          logFolder=args.logfolder)
                except Exception as e:
                    print(
                        general.error(
                            "Exception grabbed when processing the nicks: " +
                            str(e)))
                    print(general.error(traceback.print_stack()))

            logger.info("Listing the results obtained...")
            # We are going to iterate over the results...
            strResults = "\t"

            # Structure returned
            """
            [
                {        print

                  "attributes": [
                    {
                      "attributes": [],
                      "type": "i3visio.uri",
                      "value": "http://twitter.com/i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.alias",
                      "value": "i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.platform",
                      "value": "Twitter"
                    }
                  ],
                  "type": "i3visio.profile",
                  "value": "Twitter - i3visio"
                }
                ,
                ...
            ]
            """
            for r in res:
                # The format of the results (attributes) for a given nick is a list as follows:

                for att in r["attributes"]:
                    # iterating through the attributes
                    platform = ""
                    uri = ""
                    for details in att["attributes"]:
                        if details["type"] == "i3visio.platform":
                            platform = details["value"]
                        if details["type"] == "i3visio.uri":
                            uri = details["value"]
                    try:
                        strResults += (str(platform) + ":").ljust(
                            16, ' ') + " " + str(uri) + "\n\t\t"
                    except:
                        pass

                logger.info(strResults)

            # Generating summary files for each ...
            if args.extension:
                # Storing the file...
                logger.info("Creating output files as requested.")
                # Verifying if the outputPath exists
                if not os.path.exists(args.output_folder):
                    logger.warning(
                        "The output folder \'" + args.output_folder +
                        "\' does not exist. The system will try to create it.")
                    os.makedirs(args.output_folder)

                # Grabbing the results
                fileHeader = os.path.join(args.output_folder, args.file_header)

                # Iterating through the given extensions to print its values
                for ext in args.extension:
                    # Generating output files
                    general.exportUsufy(res, ext, fileHeader)

            now = dt.datetime.now()
            print(
                str(now) +
                "\tA summary of the results obtained is shown below:\n")
            print(general.success(general.usufyToTextExport(res)))

            if args.web_browser:
                general.openResultsInBrowser(res)

            now = dt.datetime.now()
            print("\n" + str(now) + "\tYou can find all the information here:")
            for ext in args.extension:
                # Showing the output files
                print("\t" + general.emphasis(fileHeader + "." + ext))

            # Showing the execution time...
            endTime = dt.datetime.now()
            print("\n" + str(endTime) + "\tFinishing execution...\n")
            print("Total time consumed:\t" +
                  general.emphasis(str(endTime - startTime)))
            print("Average seconds/query:\t" + general.emphasis(
                str((endTime - startTime).total_seconds() /
                    len(listPlatforms))) + " seconds\n")

            # Urging users to place an issue on Github...
            print(banner.footer)

    if params:
        return res
示例#20
0
def main(args):
    '''
        Main program.

        :param args: Arguments received in the command line.
    '''
    sayingHello = """mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    if sys.platform == 'win32':
        print "WARNING:"
        print "\tmailfy.py seems to be run in a Windows system."
        print "\tThe emailahoy libraries may NOT work properly. We are trying to find a fix for this issue."
        print

    # Processing the options returned to remove the "all" option
    if "all" in args.domains:
        domains = EMAIL_DOMAINS
    else:
        # processing only the given domains
        domains = args.domains

    if args.create_emails:  
        emails = grabEmails(nicksFile = args.create_emails, domains = domains)
    else:
        emails = grabEmails(emails=args.emails, emailsFile = args.emails_file, nicks=args.nicks, nicksFile = args.nicks_file, domains = domains)


    # Showing the execution time...
    if not args.quiet:
        startTime= dt.datetime.now()
        print str(startTime) +"\tStarting search of the following " + str(len(emails))+ " different emails: "+ str(emails) + ". Be patient!\n"

    # Perform searches, using different Threads
    results = performSearch(emails, args.threads)

    # Trying to store the information recovered
    if args.output_folder != None:
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext
    # Showing the execution time...
    if not args.quiet:
        print
        endTime= dt.datetime.now()
        print str(endTime) +"\tFinishing execution..."
        print
        print "Total time used:\t" + str(endTime-startTime)
        print "Average seconds/query:\t" + str((endTime-startTime).total_seconds()/len(emails)) +" seconds"
        print

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print
示例#21
0
def main(params=None):
    """
    Main function to launch phonefy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        params: A list with the parameters as grabbed by the terminal. It is
            None when this is called by an entry_point.

    Results:
    --------
        list: Returns a list with i3visio entities.
    """
    # Grabbing the parser
    parser = getParser()

    if params != None:
        args = parser.parse_args(params)
    else:
        args = parser.parse_args()

    results = []
    if not args.quiet:
        print(general.title(banner.text))

        sayingHello = """
Domainfy | Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016-2018

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit """ + general.LICENSE_URL + "\n"
        print(general.title(sayingHello))

    if args.license:
        general.showLicense()
    else:
        # Processing the options returned to remove the "all" option
        tlds = []
        if "all" in args.tlds:
            for typeTld in TLD.keys():
                for tld in TLD[typeTld]:
                    if tld not in args.exclude:
                        tlds.append({"tld": tld, "type": typeTld})
        elif "none" in args.tlds:
            pass
        else:
            for typeTld in TLD.keys():
                if typeTld in args.tlds:
                    for tld in TLD[typeTld]:
                        if tld not in args.exclude:
                            tlds.append({"tld": tld, "type": typeTld})

        for new in args.user_defined:
            if new not in args.exclude:
                tlds.append({"tld": new, "type": "user_defined"})

        if args.nicks:
            domains = createDomains(tlds, nicks=args.nicks)
        else:
            # nicks_file
            domains = createDomains(tlds, nicksFile=args.nicks_file)

        # Showing the execution time...
        if not args.quiet:
            startTime = dt.datetime.now()
            print(
                str(startTime) + "\tTrying to identify the existence of " +
                general.emphasis(str(len(domains))) + " domain(s)... Relax!\n")
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

        # Perform searches, using different Threads
        results = performSearch(domains, args.threads, args.whois)

        # Trying to store the information recovered
        if args.output_folder != None:
            if not os.path.exists(args.output_folder):
                os.makedirs(args.output_folder)
            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Showing the information gathered if requested
        if not args.quiet:
            print(
                "A summary of the results obtained are shown in the following table:\n"
            )
            try:
                print(general.success(general.usufyToTextExport(results)))
            except:
                print(
                    general.warning(
                        "\nSomething happened when exporting the results. The Json will be shown instead:\n"
                    ))
                print(general.warning(json.dumps(results, indent=2)))

            now = dt.datetime.now()
            print(
                "\n" + str(now) +
                "\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print("\t" + general.emphasis(fileHeader + "." + ext))

        # Showing the execution time...
        if not args.quiet:
            # Showing the execution time...
            endTime = dt.datetime.now()
            print("\n" + str(endTime) + "\tFinishing execution...\n")
            print("Total time used:\t" +
                  general.emphasis(str(endTime - startTime)))
            print("Average seconds/query:\t" + general.emphasis(
                str((endTime - startTime).total_seconds() / len(domains))) +
                  " seconds\n")

            # Urging users to place an issue on Github...
            print(banner.footer)

    if params:
        return results
示例#22
0
def main(args):
    ''' 
        Main function. This function is created in this way so as to let other applications make use of the full configuration capabilities of the application.    
    '''
    # Recovering the logger
    # Calling the logger when being imported
    logSet.setupLogger(loggerName="osrframework.entify", verbosity=args.verbose, logFolder=args.logfolder)    
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.entify")

    logger.info("""entify.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2014
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit to <http://www.gnu.org/licenses/gpl-3.0.txt>.""")

    logger.info("Selecting the regular expressions to be analysed...")

    sayingHello = """entify.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""    
    if not args.quiet:
        print sayingHello
        print
        logger.info("Starting entify.py")

    listRegexp = []
    if args.regexp:
        listRegexp = regexp_selection.getRegexpsByName(args.regexp)
    elif args.new_regexp:
        for i, r in enumerate(args.new_regexp):
            listRegexp.append(RegexpObject(name = "NewRegexp"+str(i), reg_exp = args.new_regexp))

    if not args.web:
        results = scanFolderForRegexp(folder = args.input_folder, listRegexp= listRegexp, recursive = args.recursive, verbosity=args.verbose, logFolder= args.logfolder, quiet=args.quiet)
    else:
        results = scanResource(uri = args.web, listRegexp= listRegexp, verbosity=args.verbose, logFolder= args.logfolder)
    logger.info("Logging the results:\n" + general.dictToJson(results))

    # Trying to store the information recovered
    if args.output_folder != None:    
        # Verifying an output folder was selected
        logger.debug("Preparing the output folder...")
        if not os.path.exists(args.output_folder):
            logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
            os.makedirs(args.output_folder)

        # Grabbing the results 
        fileHeader = os.path.join(args.output_folder, args.file_header)            
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)        

    # Showing the information gathered if requested                
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"                                                     
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext         

    return results
示例#23
0
def main(args):
    '''
        Main program.

        :param args: Arguments received in the command line.
    '''
    sayingHello = """mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2015
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
    if not args.quiet:
        print banner.text

        print sayingHello
        print

    if sys.platform == 'win32':
        print "WARNING:"
        print "\tmailfy.py seems to be run in a Windows system."
        print "\tThe emailahoy libraries may NOT work properly."
        print

    if args.create_emails:
        results = grabEmails(nicksFile=args.create_emails,
                             domains=["gmail.com"])
    else:
        emails = grabEmails(emails=args.emails,
                            emailsFile=args.emails_file,
                            nicks=args.nicks,
                            nicksFile=args.nicks_file,
                            domains=args.domains)

        results = performSearch(emails)

    # Trying to store the information recovered
    if args.output_folder != None:
        if not os.path.exists(args.output_folder):
            os.makedirs(args.output_folder)
        # Grabbing the results
        fileHeader = os.path.join(args.output_folder, args.file_header)
        for ext in args.extension:
            # Generating output files
            general.exportUsufy(results, ext, fileHeader)

    # Showing the information gathered if requested
    if not args.quiet:
        print "A summary of the results obtained are shown in the following table:"
        print unicode(general.usufyToTextExport(results))
        print

        print "You can find all the information collected in the following files:"
        for ext in args.extension:
            # Showing the output files
            print "\t-" + fileHeader + "." + ext

    # Urging users to place an issue on Github...
    if not args.quiet:
        print
        print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
        print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
        print "Note that otherwise, we won't know about it!"
        print
示例#24
0
def main(args):
    '''
        Main function. This function is created in this way so as to let other applications make use of the full configuration capabilities of the application.
    '''
    # Recovering the logger
    # Calling the logger when being imported
    osrframework.utils.logger.setupLogger(loggerName="osrframework.usufy", verbosity=args.verbose, logFolder=args.logfolder)
    # From now on, the logger can be recovered like this:
    logger = logging.getLogger("osrframework.usufy")
    # Printing the results if requested
    if not args.maltego:
        print banner.text

        sayingHello = """usufy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2014-2017
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. For additional info, visit <http://www.gnu.org/licenses/gpl-3.0.txt>."""
        logger.info(sayingHello)
        print sayingHello
        print
        logger.info("Starting usufy.py...")

    if args.license:
        logger.info("Looking for the license...")
        # showing the license
        try:
            with open ("COPYING", "r") as iF:
                contenido = iF.read().splitlines()
                for linea in contenido:
                    print linea
        except Exception:
            try:
                # Trying to recover the COPYING file...
                with open ("/usr/share/osrframework/COPYING", "r") as iF:
                    contenido = iF.read().splitlines()
                    for linea in contenido:
                        print linea
            except:
                logger.error("ERROR: there has been an error when opening the COPYING file.\n\tThe file contains the terms of the GPLv3 under which this software is distributed.\n\tIn case of doubts, verify the integrity of the files or contact [email protected].")
    elif args.fuzz:
        logger.info("Performing the fuzzing tasks...")
        res = fuzzUsufy(args.fuzz, args.fuzz_config)
        logger.info("Recovered platforms:\n" + str(res))
    else:
        logger.debug("Recovering the list of platforms to be processed...")
        # Recovering the list of platforms to be launched
        listPlatforms = platform_selection.getPlatformsByName(platformNames=args.platforms, tags=args.tags, mode="usufy", excludePlatformNames=args.exclude)
        logger.debug("Platforms recovered.")

        if args.info:
            # Information actions...
            if args.info == 'list_platforms':
                infoPlatforms="Listing the platforms:\n"
                for p in listPlatforms:
                    infoPlatforms += "\t\t" + (str(p) + ": ").ljust(16, ' ') + str(p.tags)+"\n"
                logger.info(infoPlatforms)
                return infoPlatforms
            elif args.info == 'list_tags':
                logger.info("Listing the tags:")
                tags = {}
                # Going through all the selected platforms to get their tags
                for p in listPlatforms:
                    for t in p.tags:
                        if t not in tags.keys():
                            tags[t] = 1
                        else:
                            tags[t] += 1
                infoTags = "List of tags:\n"
                # Displaying the results in a sorted list
                for t in tags.keys():
                    infoTags += "\t\t" + (t + ": ").ljust(16, ' ') + str(tags[t]) + "  time(s)\n"
                logger.info(infoTags)
                return infoTags
            else:
                pass

        # performing the test
        elif args.benchmark:
            logger.warning("The benchmark mode may last some minutes as it will be performing similar queries to the ones performed by the program in production. ")
            logger.info("Launching the benchmarking tests...")
            platforms = platform_selection.getAllPlatformNames("usufy")
            res = benchmark.doBenchmark(platforms)
            strTimes = ""
            for e in sorted(res.keys()):
                strTimes += str(e) + "\t" + str(res[e]) + "\n"
            logger.info(strTimes)
            return strTimes

        # showing the tags of the usufy platforms
        elif args.show_tags:
            logger.info("Collecting the list of tags...")
            tags = platform_selection.getAllPlatformNamesByTag("usufy")
            logger.info(json.dumps(tags, indent=2))
            print "This is the list of platforms grouped by tag."
            print
            print json.dumps(tags, indent=2, sort_keys=True)
            print
            print "[Tip] Remember that you can always launch the platform using the -t option followed by any of the aforementioned."
            print
            return tags

        # Executing the corresponding process...
        else:
            # Showing the execution time...
            if not args.maltego:
                startTime= dt.datetime.now()
                print str(startTime) +"\tStarting search in " + str(len(listPlatforms)) + " platform(s)... Relax!"
                print
                print "\tPress <Ctrl + C> to stop..."
                print

            # Defining the list of users to monitor
            nicks = []
            logger.debug("Recovering nicknames to be processed...")
            if args.nicks:
                for n in args.nicks:
                    # TO-DO
                    #     A trick to avoid having the processing of the properties when being queried by Maltego
                    if "properties.i3visio" not in n:
                        nicks.append(n)
            else:
                # Reading the nick files
                try:
                    nicks = args.list.read().splitlines()
                except:
                    logger.error("ERROR: there has been an error when opening the file that stores the nicks.\tPlease, check the existence of this file.")

            # Definning the results
            res = []

            if args.output_folder != None:
                # if Verifying an output folder was selected
                logger.debug("Preparing the output folder...")
                if not args.maltego:
                    if not os.path.exists(args.output_folder):
                        logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                        os.makedirs(args.output_folder)
                # Launching the process...
                ###try:
                res = processNickList(nicks, listPlatforms, args.output_folder, avoidProcessing = args.avoid_processing, avoidDownload = args.avoid_download, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)
                ###except Exception as e:
                    ###print "Exception grabbed when processing the nicks: " + str(e)
                    ###print traceback.print_stack()
            else:
                try:
                    res = processNickList(nicks, listPlatforms, nThreads=args.threads, verbosity= args.verbose, logFolder=args.logfolder)
                except Exception as e:
                    print "Exception grabbed when processing the nicks: " + str(e)
                    print traceback.print_stack()

            logger.info("Listing the results obtained...")
            # We are going to iterate over the results...
            strResults = "\t"

            # Structure returned
            """
            [
                {
                  "attributes": [
                    {
                      "attributes": [],
                      "type": "i3visio.uri",
                      "value": "http://twitter.com/i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.alias",
                      "value": "i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "i3visio.platform",
                      "value": "Twitter"
                    }
                  ],
                  "type": "i3visio.profile",
                  "value": "Twitter - i3visio"
                }
                ,
                ...
            ]
            """
            for r in res:
                # The format of the results (attributes) for a given nick is a list as follows:

                for att in r["attributes"]:
                    # iterating through the attributes
                    platform = ""
                    uri = ""
                    for details in att["attributes"]:
                        if details["type"] == "i3visio.platform":
                            platform = details["value"]
                        if details["type"] == "i3visio.uri":
                            uri = details["value"]
                    try:
                        strResults+= (str(platform) + ":").ljust(16, ' ')+ " "+ str(uri)+"\n\t\t"
                    except:
                        pass

                logger.info(strResults)

            # Generating summary files for each ...
            if args.extension:
                # Storing the file...
                logger.info("Creating output files as requested.")
                if not args.maltego:
                    # Verifying if the outputPath exists
                    if not os.path.exists (args.output_folder):
                        logger.warning("The output folder \'" + args.output_folder + "\' does not exist. The system will try to create it.")
                        os.makedirs(args.output_folder)

                    # Grabbing the results
                    fileHeader = os.path.join(args.output_folder, args.file_header)

                    # Iterating through the given extensions to print its values
                    for ext in args.extension:
                        # Generating output files
                        general.exportUsufy(res, ext, fileHeader)

            # Generating the Maltego output
            if args.maltego:
                general.listToMaltego(res)
            # Printing the results if requested
            else:
                print "A summary of the results obtained are shown in the following table:"
                #print res
                print unicode(general.usufyToTextExport(res))

                print

                if args.web_browser:
                    general.openResultsInBrowser(res)

                print "You can find all the information collected in the following files:"
                for ext in args.extension:
                    # Showing the output files
                    print "\t-" + fileHeader + "." + ext

                # Showing the execution time...
                print
                endTime= dt.datetime.now()
                print str(endTime) +"\tFinishing execution..."
                print
                print "Total time used:\t" + str(endTime-startTime)
                print "Average seconds/query:\t" + str((endTime-startTime).total_seconds()/len(listPlatforms)) +" seconds"
                print

                # Urging users to place an issue on Github...
                print
                print "Did something go wrong? Is a platform reporting false positives? Do you need to integrate a new one?"
                print "Then, place an issue in the Github project: <https://github.com/i3visio/osrframework/issues>."
                print "Note that otherwise, we won't know about it!"
                print

            return res
示例#25
0
def main(args):
    """
    Main function to launch phonefy.

    The function is created in this way so as to let other applications make
    use of the full configuration capabilities of the application. The
    parameters received are used as parsed by this modules `getParser()`.

    Args:
    -----
        args: The parameters as processed by this modules `getParser()`.

    Results:
    --------
        Returns a list with i3visio entities.
    """
    results = []

    if not args.quiet:
        print(general.title(banner.text))

        sayingHello = """
mailfy.py Copyright (C) F. Brezo and Y. Rubio (i3visio) 2016-2017

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. For additional info,
visit """ + general.LICENSE_URL + "\n"
        print(general.title(sayingHello))

        # Displaying a warning if this is being run in a windows system
        if sys.platform == 'win32':
            print(
                general.warning(
                    """OSRFramework has detected that you are running mailfy.py in a Windows system.
As the "emailahoy" library is NOT working properly there, "validate_email" will
be used instead. Verification may be slower though."""))

    if args.license:
        general.showLicense()
    else:
        # Grabbing the list of global domains
        if args.is_leaked:
            domains = LEAKED_DOMAINS
            # Processing the options returned to remove the "all" option
        elif "all" in args.domains:
            domains = EMAIL_DOMAINS
        else:
            # processing only the given domains and excluding the ones provided
            domains = []
            for d in args.domains:
                if d not in args.exclude:
                    domains.append(d)

        if args.create_emails:
            emails = grabEmails(nicksFile=args.create_emails,
                                domains=domains,
                                excludeDomains=args.exclude)
        else:
            emails = grabEmails(emails=args.emails,
                                emailsFile=args.emails_file,
                                nicks=args.nicks,
                                nicksFile=args.nicks_file,
                                domains=domains,
                                excludeDomains=args.exclude)

        startTime = dt.datetime.now()

        if not args.is_leaked:
            # Showing the execution time...
            if not args.quiet:
                print(
                    str(startTime) + "\tStarting search in " +
                    general.emphasis(str(len(emails))) +
                    " different emails:\n" +
                    json.dumps(emails, indent=2, sort_keys=True) + "\n")
                print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))
            # Perform searches, using different Threads
            tmp = performSearch(emails, args.threads)

            # We make a strict copy of the object
            results = list(tmp)

            if not args.quiet:
                now = dt.datetime.now()
                print(
                    str(now) + "\tMailfy has found " +
                    general.emphasis(str(len(results))) +
                    " existing email(s). Has it been leaked somewhere?")

            # Verify the existence of the mails found as leaked emails.
            for r in tmp:
                # We assume that the first attribute is always the email
                query = r["attributes"][0]["value"]
                leaks = hibp.checkIfEmailWasHacked(query)
                if len(leaks) > 0:
                    if not args.quiet:
                        print(
                            general.success("\t" + query +
                                            " has been found in at least " +
                                            str(len(leaks)) +
                                            " different leaks."))
                    email, alias, domain = getMoreInfo(query)

                    for leak in leaks:
                        # Creating a new full entity from scratch
                        new = {}
                        new["type"] = "i3visio.profile"
                        new["value"] = leak["value"] + " - " + alias["value"]
                        new["attributes"] = []
                        new["attributes"].append(email)
                        new["attributes"].append(alias)
                        new["attributes"].append(domain)

                        # leak contains a i3visio.platform built by HIBP
                        new["attributes"].append(leak)
                        results.append(new)
                else:
                    if not args.quiet:
                        print(
                            general.warning(
                                "\t" + query +
                                " has NOT been found on any leak yet."))
        else:
            if not args.quiet:
                print(
                    "\n" + str(startTime) + "\tStarting search of " +
                    general.emphasis(str(len(emails))) +
                    " different emails in leaked databases.\nNote that this will take between 1 and 2 seconds per query due to HIBP API restrictions:\n"
                    + json.dumps(emails, indent=2, sort_keys=True) + "\n")
                print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

            # Perform is_leaked function
            results = []
            for i, e in enumerate(emails):
                if not args.quiet:
                    print("\t" + str(i + 1) + "/" + str(len(emails)) +
                          " - Searching if " + e +
                          " has been leaked somewhere...")
                leaks = hibp.checkIfEmailWasHacked(e)

                if len(leaks) > 0:
                    if not args.quiet:
                        print(
                            general.success("\t" + e +
                                            " has been found in at least " +
                                            str(len(leaks)) +
                                            " different leaks."))

                    email, alias, domain = getMoreInfo(e)
                    for leak in leaks:
                        # Creating a new full entity from scratch
                        new = {}
                        new["type"] = "i3visio.profile"
                        new["value"] = leak["value"] + " - " + alias["value"]
                        new["attributes"] = []
                        new["attributes"].append(email)
                        new["attributes"].append(alias)
                        new["attributes"].append(domain)

                        # leak contains a i3visio.platform built by HIBP
                        new["attributes"].append(leak)
                        results.append(new)

        # Trying to store the information recovered
        if args.output_folder != None:
            if not os.path.exists(args.output_folder):
                os.makedirs(args.output_folder)
            # Grabbing the results
            fileHeader = os.path.join(args.output_folder, args.file_header)
            for ext in args.extension:
                # Generating output files
                general.exportUsufy(results, ext, fileHeader)

        # Showing the information gathered if requested
        if not args.quiet:
            now = dt.datetime.now()
            print(
                "\n" + str(now) +
                "\tA summary of the results obtained are shown in the following table:\n"
            )
            print(general.success(general.usufyToTextExport(results)))

            now = dt.datetime.now()
            print(
                "\n" + str(now) +
                "\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print(general.emphasis("\t" + fileHeader + "." + ext))

        # Showing the execution time...
        if not args.quiet:
            endTime = dt.datetime.now()
            print("\n" + str(endTime) + "\tFinishing execution...\n")
            print("Total time used:\t" +
                  general.emphasis(str(endTime - startTime)))
            print("Average seconds/query:\t" + general.emphasis(
                str((endTime - startTime).total_seconds() / len(emails))) +
                  " seconds\n")

        if not args.quiet:
            # Urging users to place an issue on Github...
            print(banner.footer)

    return results