Example #1
0
    def menu_system(self):

        # Reinitialize colorama as sys.stdout/stderr may have changed since program started
        colorama.reinit()

        while self.user_command == "":

            try:

                if self.cli_args is not None:

                    if self.cli_args.list is not None:
                        self.run_list_command(self.cli_args.list)

                    if self.cli_args.load is not None:
                        try:
                            self.load_ips(self.cli_args.load)
                        except IndexError:
                            print helpers.color(
                                "\n\n[*] Error: Load command requires a path to a file!",
                                warning=True)
                            print helpers.color("[*] Ex: load /root/file.txt",
                                                warning=True)
                            sys.exit()

                    if self.cli_args.file_import is not None:
                        self.run_import_command(self.cli_args.file_import)

                    if self.cli_args.gather is not None:
                        self.run_gather_command(self.cli_args.gather)

                    if self.cli_args.save:
                        self.save_state()

                    if self.cli_args.analyze is not None:
                        self.run_analyze_command(self.cli_args.analyze)

                    if self.cli_args.ip_info is not None:
                        self.run_ipinfo_command(self.cli_args.ip_info)

                    if self.cli_args.export:
                        self.export_info()

                    sys.exit()

                else:

                    while True:
                        self.user_command = raw_input(
                            ' \n\n[>] Please enter a command: ').strip()
                        helpers.print_header()

                        if self.user_command is not "":
                            # Check if command is to load IP addresses into framework
                            if self.user_command.startswith('load'):
                                try:
                                    self.load_ips(self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "\n\n[*] Error: Load command requires a path to a file!",
                                        warning=True)
                                    print helpers.color(
                                        "[*] Ex: load /root/file.txt",
                                        warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('gather'):
                                try:
                                    self.run_gather_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "\n\n[*] Error: Module command requires a module to load!",
                                        warning=True)
                                    print helpers.color(
                                        "[*] Ex: gather geoinfo", warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('help'):
                                self.print_commands()
                                self.user_command = ""

                            elif self.user_command.startswith('exit'):
                                print helpers.color(
                                    "\n\n[!] Exiting Just Metadata..\n",
                                    warning=True)
                                sys.exit()

                            # Code for saving current state to disk
                            elif self.user_command.startswith('save'):
                                self.save_state()
                                self.user_command = ""

                            # Code for loading state from disk
                            elif self.user_command.startswith('import'):
                                try:
                                    self.run_import_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "[*] Error: Please provide path to file that will be imported.",
                                        warning=True)
                                    print helpers.color(
                                        "[*] Ex: import metadata1111_1111.state",
                                        warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('ip_info'):
                                try:
                                    self.run_ipinfo_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "[*] Error: The \"ip_info\" command requires an IP address!",
                                        warning=True)
                                    self.check_cli()
                                self.user_command = ""

                            # This will be the export command, used to export
                            # all information into a csv file
                            elif self.user_command.startswith('export'):
                                self.export_info()
                                self.user_command = ""

                            elif self.user_command.startswith('analyze'):
                                try:
                                    self.run_analyze_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "\n\n[*] Error: Analyze command requires a module to load!",
                                        warning=True)
                                    print helpers.color(
                                        "[*] Ex: analyze GeoInfo",
                                        warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('list'):
                                try:
                                    self.run_list_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color(
                                        "\n\n[*] Error: You did not provide a module type to display!",
                                        warning=True)
                                    print helpers.color(
                                        "[*] Ex: list analysis", warning=True)
                                self.user_command = ""

                            else:
                                print helpers.color(
                                    "\n\n[*] Error: You did not provide a valid command!",
                                    warning=True)
                                print helpers.color(
                                    "[*] Type \"help\" to view valid commands",
                                    warning=True)

            except KeyboardInterrupt:
                print helpers.color("\n\n[!] You just rage quit...",
                                    warning=True)
                sys.exit()

            except Exception as e:
                print helpers.color("\n\n[!] Encountered Error!", warning=True)
                print helpers.color(e)
                print helpers.color("[!] Saving state to disk...",
                                    warning=True)
                print helpers.color(
                    "[!] Please report this info to the developer!",
                    warning=True)
                self.save_state()

        return
Example #2
0
    def menu_system(self):

        # Reinitialize colorama as sys.stdout/stderr may have changed since program started
        colorama.reinit()

        while self.user_command == "":

            try:

                if self.cli_args is not None:

                    if self.cli_args.list is not None:
                        self.run_list_command(self.cli_args.list)

                    if self.cli_args.load is not None:
                        try:
                            self.load_ips(self.cli_args.load)
                        except IndexError:
                            print helpers.color("\n\n[*] Error: Load command requires a path to a file!", warning=True)
                            print helpers.color("[*] Ex: load /root/file.txt", warning=True)
                            sys.exit()

                    if self.cli_args.file_import is not None:
                        self.run_import_command(self.cli_args.file_import)

                    if self.cli_args.gather is not None:
                        self.run_gather_command(self.cli_args.gather)

                    if self.cli_args.save:
                        self.save_state()

                    if self.cli_args.analyze is not None:
                        self.run_analyze_command(self.cli_args.analyze)

                    if self.cli_args.ip_info is not None:
                        self.run_ipinfo_command(self.cli_args.ip_info)

                    if self.cli_args.export:
                        self.export_info()

                    sys.exit()

                else:

                    while True:
                        self.user_command = raw_input(' \n\n[>] Please enter a command: ').strip()
                        helpers.print_header()

                        if self.user_command is not "":
                            # Check if command is to load IP addresses into framework
                            if self.user_command.startswith('load'):
                                try:
                                    self.load_ips(self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("\n\n[*] Error: Load command requires a path to a file!", warning=True)
                                    print helpers.color("[*] Ex: load /root/file.txt", warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('gather'):
                                try:
                                    self.run_gather_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("\n\n[*] Error: Module command requires a module to load!", warning=True)
                                    print helpers.color("[*] Ex: gather geoinfo", warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('help'):
                                self.print_commands()
                                self.user_command = ""

                            elif self.user_command.startswith('exit'):
                                print helpers.color(
                                    "\n\n[!] Exiting Just Metadata..\n",
                                    warning=True)
                                sys.exit()

                            # Code for saving current state to disk
                            elif self.user_command.startswith('save'):
                                self.save_state()
                                self.user_command = ""

                            # Code for loading state from disk
                            elif self.user_command.startswith('import'):
                                try:
                                    self.run_import_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("[*] Error: Please provide path to file that will be imported.", warning=True)
                                    print helpers.color("[*] Ex: import metadata1111_1111.state", warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('ip_info'):
                                try:
                                    self.run_ipinfo_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("[*] Error: The \"ip_info\" command requires an IP address!", warning=True)
                                    self.check_cli()
                                self.user_command = ""

                            # This will be the export command, used to export
                            # all information into a csv file
                            elif self.user_command.startswith('export'):
                                self.export_info()
                                self.user_command = ""

                            elif self.user_command.startswith('analyze'):
                                try:
                                    self.run_analyze_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("\n\n[*] Error: Analyze command requires a module to load!", warning=True)
                                    print helpers.color("[*] Ex: analyze GeoInfo", warning=True)
                                self.user_command = ""

                            elif self.user_command.startswith('list'):
                                try:
                                    self.run_list_command(
                                        self.user_command.split()[1])
                                except IndexError:
                                    print helpers.color("\n\n[*] Error: You did not provide a module type to display!", warning=True)
                                    print helpers.color("[*] Ex: list analysis", warning=True)
                                self.user_command = ""

                            else:
                                print helpers.color("\n\n[*] Error: You did not provide a valid command!", warning=True)
                                print helpers.color("[*] Type \"help\" to view valid commands", warning=True)

            except KeyboardInterrupt:
                print helpers.color("\n\n[!] You just rage quit...", warning=True)
                sys.exit()

            except Exception as e:
                print helpers.color("\n\n[!] Encountered Error!", warning=True)
                print helpers.color(e)
                print helpers.color("[!] Saving state to disk...", warning=True)
                print helpers.color("[!] Please report this info to the developer!", warning=True)
                self.save_state()

        return
Example #3
0
This tool is designed to be used to gather information about a large number
of IP addresses and perform some analytics against them.  Ideally, it will
be extensible to easily add new functionality.
'''

import argparse
import sys
from common import helpers
from common import orchestra
from colorama import init
init()

if __name__ == '__main__':

    # print the title screen for the first "run"
    helpers.print_header()

    # Default CLI Options, should be none unless specified
    args = None

    if len(sys.argv) > 1:
        parser = argparse.ArgumentParser(
            add_help=False, description="EyeWitness is a tool used to capture\
            screenshots from a list of URLs")
        parser.add_argument(
            '-h', '-?', '--h', '-help', '--help', action="store_true",
            help=argparse.SUPPRESS)

        load_options = parser.add_argument_group('IP load/import options')
        load_options.add_argument(
            '-l', '--load', metavar='Filename', default=None,
Example #4
0
    def menu_system(self):

        while self.user_command == "":

            try:

                while True:

                    self.user_command = raw_input(' \n\n[>] Please enter a command: ').strip()
                    helpers.print_header()

                    if self.user_command is not "":

                        # Check if command is to load IP addresses into framework
                        if self.user_command.startswith('load'):
                            try:
                                self.load_ips(self.user_command.split()[1])
                            except IndexError:
                                print helpers.color("\n\n[*] Error: Load command requires a path to a file!", warning=True)
                                print helpers.color("[*] Ex: load /root/file.txt", warning=True)
                            self.user_command = ""

                        elif self.user_command.startswith('gather'):
                            gather_module_found = False
                            try:
                                for path, ig_obj in self.intelgathering_transforms.iteritems():
                                    if self.user_command.split()[1].lower() == ig_obj.cli_name.lower():
                                        ig_obj.gather(self.ip_objects)
                                        self.user_command = ""
                                        gather_module_found = True
                                        break
                                if not gather_module_found:
                                    print helpers.color("\n\n[*] Error: You didn't provide a valid gather module!", warning=True)
                                    print helpers.color("[*] Please re-run and use a valid module.", warning=True)
                                    self.user_command = ""
                            except IndexError:
                                print helpers.color("\n\n[*] Error: Module command requires a module to load!", warning=True)
                                print helpers.color("[*] Ex: gather geoinfo", warning=True)
                            except KeyboardInterrupt:
                                print helpers.color("\n\n[*] You Rage quit your intel gathering!", warning=True)
                            self.user_command = ""

                        elif self.user_command.startswith('help'):
                            self.print_commands()
                            self.user_command = ""

                        elif self.user_command.startswith('exit'):
                            print helpers.color("\n\n[!] Exiting Just Metadata..", warning=True)
                            sys.exit()

                        # Code for saving current state to disk
                        elif self.user_command.startswith('save'):
                            current_date = time.strftime("%m/%d/%Y").replace("/", "")
                            current_time = time.strftime("%H:%M:%S").replace(":", "")

                            # Save state to disk
                            pickle.dump(self.ip_objects, open(
                                'metadata' + current_date + "_" + current_time
                                + '.state', 'wb'))
                            print helpers.color("\nState saved to disk at metadata" + current_date + "_" + current_time + ".state")
                            self.user_command = ""

                        # Code for loading state from disk
                        elif self.user_command.startswith('import'):
                            try:
                                if os.path.isfile(self.user_command.split()[1]):
                                    try:
                                        self.ip_objects = pickle.load(open(self.user_command.split()[1], 'rb'))
                                        print helpers.color("[*] Successfully imported " + self.user_command.split()[1])
                                    except IndexError:
                                        print helpers.color("[*] Error: Invalid state file.", warning=True)
                                        print helpers.color("[*] Please provide the path to a valid state file.", warning=True)
                                    except KeyError:
                                        print helpers.color("[*] Error: Problem parsing your state file.", warning=True)
                                        print helpers.color("[*] Error: Has it been tampered with...?", warning=True)
                                else:
                                    print helpers.color("[*] Error: Please provide path to file that will be imported.", warning=True)
                            except IndexError:
                                print helpers.color("[*] Error: Please provide path to file that will be imported.", warning=True)
                                print helpers.color("[*] Ex: import metadata1111_1111.state", warning=True)
                            self.user_command = ""

                        elif self.user_command.startswith('ip_info'):
                            ip_found = False
                            try:
                                for path, ip_objd in self.ip_objects.iteritems():
                                    if ip_objd[0].ip_address == self.user_command.split()[1]:
                                        attrs = vars(ip_objd[0])
                                        print ip_objd[0].ip_address
                                        print "*" * 25
                                        for key, value in attrs.iteritems():
                                            print helpers.color(key) + ": " + self.collapse(value)
                                        ip_found = True
                                if not ip_found:
                                    print helpers.color("[*] Error: The provided IP address is not loaded in the framework!", warning=True)
                                    print helpers.color("[*] Error: Please provide a new IP.", warning=True)
                            except IndexError:
                                print helpers.color("[*] Error: The \"ip_info\" command requires an IP address!", warning=True)
                            self.user_command = ""

                        elif self.user_command.startswith('analyze'):
                            try:
                                hit_module = False
                                for path, analytics_obj in self.analytical_transforms.iteritems():
                                    if self.user_command.split()[1].lower() == analytics_obj.cli_name.lower():
                                        analytics_obj.analyze(self.ip_objects)
                                        hit_module = True
                                        break
                            except IndexError:
                                print helpers.color("\n\n[*] Error: Analyze command requires a module to load!", warning=True)
                                print helpers.color("[*] Ex: analyze GeoInfo", warning=True)
                            if not hit_module:
                                print helpers.color("\n\n[*] Error: You didn't provide a valid module!", warning=True)
                                print helpers.color("[*] Please re-run and use a valid module.", warning=True)
                            self.user_command = ""

                        elif self.user_command.startswith('list'):
                            try:
                                list_command = self.user_command.split()[1]
                                if list_command.lower() == 'analysis':
                                    for path, object_name in self.analytical_transforms.iteritems():
                                        print object_name.cli_name + " => " + object_name.description
                                elif list_command.lower() == 'gather':
                                    for path, object_name in self.intelgathering_transforms.iteritems():
                                        print object_name.cli_name + " => " + object_name.description
                                self.user_command = ""
                            except IndexError:
                                print helpers.color("\n\n[*] Error: You did not provide module type to display!", warning=True)
                                print helpers.color("[*] Ex: list analysis", warning=True)

                        else:
                            print helpers.color("\n\n[*] Error: You did not provide a valid command!", warning=True)
                            print helpers.color("[*] Type \"help\" to view valid commands", warning=True)

            except KeyboardInterrupt:
                print helpers.color("\n\n[!] You just rage quit...", warning=True)
                sys.exit()

            #except Exception as e:
            #    print helpers.color("\n\n[!] Encountered Error!", warning=True)
            #    print helpers.color(e)
            #    print helpers.color("[!] Saving state to disk...", warning=True)
            #    print helpers.color("[!] Please report this info to the developer!", warning=True)
            #    current_date = time.strftime("%m/%d/%Y").replace("/", "")
            #    current_time = time.strftime("%H:%M:%S").replace(":", "")

                # Save state to disk
            #    pickle.dump(self.ip_objects, open(
            #        'metadata' + current_date + "_" + current_time
            #        + '.state', 'wb'))
            #    print helpers.color("\nState saved to disk at metadata" + current_date + "_" + current_time + ".state")

        return