Example #1
0
def main(params=None):
    """Main function to launch searchfy

    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 `get_parser()`.

    Args:
        params (list): 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:
        list. A list of i3visio entities.
    """
    if params is None:
        parser = get_parser()
        args = parser.parse_args(params)
    else:
        args = params

    results = []

    print(general.title(banner.text))

    saying_hello = f"""
     Searchfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020

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}>.
"""
    print(general.info(saying_hello))

    if args.license:
        general.showLicense()
    else:
        # Showing the execution time...
        start_time = dt.datetime.now()
        print(
            f"{start_time}\tStarting search in different platform(s)... Relax!\n"
        )
        print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))
        # Performing the search
        try:
            results = perform_search(platformNames=args.platforms,
                                     queries=args.queries,
                                     exclude_platform_names=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.export_usufy(results, ext, fileHeader)

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

        if args.web_browser:
            general.open_results_in_browser(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...
        end_time = dt.datetime.now()
        print(f"\n{end_time}\tFinishing execution...\n")
        print("Total time used:\t" +
              general.emphasis(str(end_time - start_time)))
        print("Average seconds/query:\t" + general.emphasis(
            str((end_time - start_time).total_seconds() /
                len(args.platforms))) + " seconds\n")

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

    if params:
        return results
Example #2
0
def main(params=None):
    """Main function to launch mailfy

    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 `get_parser()`.

    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:
        list. A list of i3visio entities.
    """
    if params is None:
        parser = get_parser()
        args = parser.parse_args(params)
    else:
        args = params

    results = []

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

        saying_hello = f"""
          Mailfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020

    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}>.
    """
        print(general.info(saying_hello))
        # 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 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 = grab_emails(
                nicks_file=args.create_emails,
                domains=EMAIL_DOMAINS + extra_domains,
                exclude_domains=args.exclude)
            potentially_leaked_emails = grab_emails(
                nicks_file=args.create_emails,
                domains=LEAKED_DOMAINS + extra_domains,
                exclude_domains=args.exclude)
        else:
            potentially_existing_emails = grab_emails(
                emails=args.emails,
                emails_file=args.emails_file,
                nicks=args.nicks,
                nicks_file=args.nicks_file,
                domains=EMAIL_DOMAINS + extra_domains,
                exclude_domains=args.exclude)
            potentially_leaked_emails = grab_emails(
                emails=args.emails,
                emails_file=args.emails_file,
                nicks=args.nicks,
                nicks_file=args.nicks_file,
                domains=LEAKED_DOMAINS + extra_domains,
                exclude_domains=args.exclude)

        emails = list(
            set(potentially_leaked_emails + potentially_existing_emails))

        if not args.quiet:
            start_time = dt.datetime.now()
            print(
                f"\n{start_time}\t{general.emphasis('Step 1/5')}. Trying to determine if any of the following {general.emphasis(str(len(potentially_existing_emails)))} emails exist using emailahoy3...\n{general.emphasis(json.dumps(potentially_existing_emails, indent=2))}\n"
            )
            print(
                general.emphasis("\tPress <Ctrl + C> to skip this step...\n"))

        # Perform searches, using different Threads
        try:
            results = verify_with_emailahoy_step_1(potentially_existing_emails,
                                                   num_threads=args.threads)
        except KeyboardInterrupt:
            print(
                general.warning("\tStep 1 manually skipped by the user...\n"))
            results = []

        # Grabbing the <Platform> objects
        platforms = platform_selection.get_platforms_by_name(args.platforms,
                                                             mode="mailfy")
        names = [p.platformName for p in platforms]

        if not args.quiet:
            now = dt.datetime.now()
            print(
                f"\n{now}\t{general.emphasis('Step 2/5')}. Checking if the emails have been used to register accounts in {general.emphasis(str(len(platforms)))} platforms...\n{general.emphasis(json.dumps(names, indent=2))}\n"
            )
            print(
                general.emphasis("\tPress <Ctrl + C> to skip this step...\n"))

        try:
            registered = process_mail_list_step_2(platforms=platforms,
                                                  emails=emails)
        except KeyboardInterrupt:
            print(
                general.warning("\tStep 2 manually skipped by the user...\n"))
            registered = []

        results += registered

        if not args.quiet:
            if len(results) > 0:
                for r in registered:
                    print(
                        f"\t[*] Linked account found: {general.success(r['value'])}"
                    )
            else:
                print(f"\t[*] No account found.")

            now = dt.datetime.now()
            print(
                f"\n{now}\t{general.emphasis('Step 3/5')}. Verifying if the provided emails have been leaked somewhere using HaveIBeenPwned.com...\n"
            )
            print(
                general.emphasis("\tPress <Ctrl + C> to skip this step...\n"))

        all_keys = config_api_keys.get_list_of_api_keys()
        try:
            # Verify the existence of the mails found as leaked emails.
            for query in potentially_leaked_emails:
                # Iterate through the different leak platforms
                leaks = hibp.check_if_email_was_hacked(
                    query, api_key=all_keys["haveibeenpwned_com"]["api_key"])

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

                results += leaks
        except KeyError:
            # API_Key not found
            config_path = os.path.join(
                configuration.get_config_path()["appPath"], "api_keys.cfg")
            print(
                "\t[*] " + general.warning("No API found for HaveIBeenPwned") +
                f". Request one at <https://haveibeenpwned.com/API/Key> and add it to '{config_path}'."
            )
        except KeyboardInterrupt:
            print(
                general.warning("\tStep 3 manually skipped by the user...\n"))

        if not args.quiet:
            now = dt.datetime.now()
            print(
                f"\n{now}\t{general.emphasis('Step 4/5')}. Verifying if the provided emails have been leaked somewhere using Dehashed.com...\n"
            )
            print(
                general.emphasis("\tPress <Ctrl + C> to skip this step...\n"))

        try:
            # Verify the existence of the mails found as leaked emails.
            for query in emails:
                try:
                    # Iterate through the different leak platforms
                    leaks = dehashed.check_if_email_was_hacked(query)
                    if len(leaks) > 0:
                        if not args.quiet:
                            print(
                                f"\t[*] '{general.success(query)}' has been found in at least {general.success(len(leaks))} different leaks as shown by Dehashed.com."
                            )
                    else:
                        if not args.quiet:
                            print(
                                f"\t[*] '{general.error(query)}' has NOT been found on any leak yet."
                            )

                    results += leaks
                except Exception as e:
                    print(
                        general.warning(
                            f"Something happened when querying Dehashed.com about '{email}'. Omitting..."
                        ))
        except KeyboardInterrupt:
            print(
                general.warning("\tStep 4 manually skipped by the user...\n"))

        if not args.quiet:
            now = dt.datetime.now()
            print(
                f"\n{now}\t{general.emphasis('Step 5/5')}. Verifying if the provided emails have registered a domain using ViewDNS.info...\n"
            )
            print(
                general.emphasis("\tPress <Ctrl + C> to skip this step...\n"))

        try:
            # Verify the existence of the mails found as leaked emails.
            for query in potentially_leaked_emails:
                try:
                    # Iterate through the different leak platforms
                    domains = viewdns.check_reverse_whois(query)

                    if len(domains) > 0:
                        if not args.quiet:
                            print(
                                f"\t[*] '{general.success(query)}' has registered at least {general.success(len(domains))} different domains as shown by ViewDNS.info."
                            )
                    else:
                        if not args.quiet:
                            print(
                                f"\t[*] '{general.error(query)}' has NOT registered a domain yet."
                            )

                    results += domains
                except Exception as e:
                    print(
                        general.warning(
                            f"Something happened when querying Viewdns.info about '{query}'. Omitting..."
                        ))
        except KeyboardInterrupt:
            print(
                general.warning("\tStep 5 manually skipped by the user...\n"))

        # 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.export_usufy(results, ext, fileHeader)

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

            now = dt.datetime.now()
            print(
                f"\n{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:
            end_time = dt.datetime.now()
            print("\n{end_time}\tFinishing execution...\n")
            print("Total time used:\t" +
                  general.emphasis(str(end_time - start_time)))

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

    if params:
        return results
Example #3
0
def main(params=None):
    """ain 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 `get_parser()`.

    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:
        dict: A Json representing the matching results.
    """
    if params is None:
        parser = get_parser()
        args = parser.parse_args(params)
    else:
        args = params

    print(general.title(banner.text))

    saying_hello = f"""
      Usufy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020

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}>.

"""
    print(general.info(saying_hello))

    if args.fuzz:
        res = fuzzUsufy(args.fuzz, args.fuzz_config)
    else:
        # Recovering the list of platforms to be launched
        list_platforms = platform_selection.get_platforms_by_name(
            platform_names=args.platforms,
            tags=args.tags,
            mode="usufy",
            exclude_platform_names=args.exclude)

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

        # performing the test
        elif args.benchmark:
            platforms = platform_selection.get_all_platform_names("usufy")
            res = benchmark.do_benchmark(platforms)
            str_times = ""
            for e in sorted(res.keys()):
                str_times += str(e) + "\t" + str(res[e]) + "\n"
            return str_times

        # showing the tags of the usufy platforms
        elif args.show_tags:
            tags = platform_selection.get_all_platform_namesByTag("usufy")
            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...
            start_time = dt.datetime.now()
            print(
                f"{start_time}\tStarting search in {general.emphasis(str(len(list_platforms)))} platform(s)... Relax!\n"
            )
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

            # Defining the list of users to monitor
            nicks = []
            if args.nicks:
                for n in args.nicks:
                    nicks.append(n)
            else:
                # Reading the nick files
                try:
                    nicks = args.list.read().splitlines()
                except:
                    print(
                        general.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
                if not os.path.exists(args.output_folder):
                    os.makedirs(args.output_folder)
                # Launching the process...
                res = process_nick_list(nicks,
                                        list_platforms,
                                        args.output_folder,
                                        avoidProcessing=args.avoid_processing,
                                        avoidDownload=args.avoid_download,
                                        nThreads=args.threads,
                                        verbosity=args.verbose,
                                        logFolder=args.logfolder)

            else:
                try:
                    res = process_nick_list(nicks,
                                            list_platforms,
                                            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()))

            # We are going to iterate over the results...
            str_results = "\t"

            # Structure returned
            """
            [
                {
                  "attributes": [
                    {
                      "attributes": [],
                      "type": "com.i3visio.URI",
                      "value": "http://twitter.com/i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "com.i3visio.Alias",
                      "value": "i3visio"
                    },
                    {
                      "attributes": [],
                      "type": "com.i3visio.Platform",
                      "value": "Twitter"
                    }
                  ],
                  "type": "com.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"] == "com.i3visio.Platform":
                            platform = details["value"]
                        if details["type"] == "com.i3visio.URI":
                            uri = details["value"]
                    try:
                        str_results += (str(platform) + ":").ljust(
                            16, ' ') + " " + str(uri) + "\n\t\t"
                    except:
                        pass

            # 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
                file_header = 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.export_usufy(res, ext, file_header)

            now = dt.datetime.now()
            print(
                f"\n{now}\tResults obtained ({general.emphasis(len(res))}):\n")
            print(general.success(general.osrf_to_text_export(res)))

            if args.web_browser:
                general.open_results_in_browser(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(file_header + "." + ext))

            # Showing the execution time...
            end_time = dt.datetime.now()
            print(f"\n{end_time}\tFinishing execution...\n")
            print("Total time consumed:\t" +
                  general.emphasis(str(end_time - start_time)))
            print("Average seconds/query:\t" + general.emphasis(
                str((end_time - start_time).total_seconds() /
                    len(list_platforms))) + " seconds\n")

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

    if params:
        return res
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 `get_parser()`.

    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:
        list: Returns a list with i3visio entities.
    """
    if params is None:
        parser = get_parser()
        args = parser.parse_args(params)
    else:
        args = params

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

    saying_hello = f"""
    Domainfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020

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}>.
"""
    print(general.info(saying_hello))

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

        for new in args.user_defined:
            if new not in args.exclude:
                if new[0] == ".":
                    tlds.append({"tld": new, "type": "user_defined"})
                else:
                    tlds.append({"tld": "." + new, "type": "user_defined"})

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

        # Showing the execution time...
        if not args.quiet:
            startTime = dt.datetime.now()
            print(
                f"{startTime}\tTrying to get information about {general.emphasis(str(len(domains)))} domain(s)…\n"
            )
            if len(domains) > 200:
                print(
                    """        Note that a full '-t all' search may take around 3.5 mins. If that's too
        long for you, try narrowing the search using '-t cc' or similar arguments.
        Otherwise, just wait and keep calm!
                """)
            print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))

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

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

        # Showing the information gathered if requested
        if not args.quiet:
            now = dt.datetime.now()
            print(
                f"\n{now}\t{general.success(len(results))} results obtained:\n"
            )
            try:
                print(general.success(general.osrf_to_text_export(results)))
            except Exception:
                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(
                f"\n{now}\tYou can find all the information collected in the following files:"
            )
            for ext in args.extension:
                # Showing the output files
                print(f"\t{general.emphasis(file_header + '.' + ext)}")

        # Showing the execution time...
        if not args.quiet:
            # Showing the execution time...
            endTime = dt.datetime.now()
            print("\n{}\tFinishing execution...\n".format(endTime))
            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