Example #1
0
    def MainMenu(self):
        if len(self.currentmodule) > 0:
            g = int(self.currentmodule) - 1
            just_print = self.modules[int(g)][int(globals.vars.column_for_name)]
            cmd = raw_input(
                globals.bcolors.GREEN + 'mdb ' + globals.bcolors.RED + str(just_print) + globals.bcolors.GREEN + '#> ' + globals.bcolors.WHITE).strip()
        else:
            cmd = raw_input(globals.bcolors.GREEN + 'mdb ' + globals.bcolors.GREEN + '#> ' + globals.bcolors.WHITE).strip()

        try:
            while cmd == "":
                #print 'no cmd'
                self.MainMenu()

            if cmd == 'help':
                print " Available commands:\n"
                for (cmd, desc) in self.commands:
                    print "\t%s\t%s" % ('{0: <12}'.format(cmd), desc)
                print ''
                self.MainMenu()

            if cmd == 'search':
                ar = self.modules
                manySearch = manysearches.MuchSearch()

                # function to sort by arch
                if len(self.arch) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_arch, self.arch)
                # function to sort by plat
                if len(self.plat) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_plat, self.plat)
                # function to sort by lang
                if len(self.lang) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_pl, self.lang)
                if len(self.type) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_type, self.type)
                if len(self.vip) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_vip, self.vip)
                printController = manysearches.MuchSearch()
                printController.PrintPayloads(ar)
                self.MainMenu()

            if re.match('^set', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    print cmd[1] + ' => ' + cmd[2]
                    if cmd[1] == 'arch':
                        self.arch = cmd[2]
                    if cmd[1] == 'plat':
                        self.plat = cmd[2]
                    if cmd[1] == 'lang':
                        self.lang = cmd[2]
                    if cmd[1] == 'type':
                        self.type = cmd[2]
                except:
                    print 'Need to use the set method with two arguments.'
                cmd = ''
                self.MainMenu()

            if cmd == 'show':
                if len(self.currentmodule) == 0:
                    print "No modules have been chosen. Use 'use' command."
                if len(self.currentmodule) > 0:
                    print 'Currently selected Module: ' + self.currentmodule
                print '\tarch => ' + str(self.arch)
                print '\tplat => ' + str(self.plat)
                print '\tlang => ' + str(self.lang)
                print '\ttype => ' + str(self.type)
                print ''
                self.MainMenu()

            if cmd == 'exit':
                sys.exit(1)

            if cmd == 'update-db':
                updateHandler = Updater()
                updateHandler.get_maldb_ver()
                self.MainMenu()

            if cmd == 'get':
                updateHandler = Updater()
                try:
                    updateHandler.get_malware(self.currentmodule, self.modules)
                    self.MainMenu()
                except:
                    print globals.bcolors.RED + '[-]' + globals.bcolors.WHITE + 'Error getting malware.'
                    self.MainMenu()

            if re.match('^use', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    self.currentmodule = cmd[1]
                    cmd = ''
                except:
                    print 'The use method needs an argument.'
                self.MainMenu()

            if cmd == 'back':
                print 'im at back - WTF?'
                self.arch = ''
                self.plat = ''
                self.lang = ''
                self.type = ''
                self.currentmodule = ''
                self.MainMenu()

            if cmd == 'list all':
                print "\nAvailable Payloads:"
                array = self.modules
                i = 0
                print "ID\tName\tType"
                print '-----------------'
                for element in array:
                    answer = array[i][globals.vars.column_for_uid]
                    answer += '\t%s' % ('{0: <12}'.format(array[i][globals.vars.column_for_name]))
                    answer += '\t%s' % ('{0: <12}'.format(array[i][globals.vars.column_for_type]))
                    print answer
                    i=i+1
                self.MainMenu()

            if cmd == 'quit':
                print ":("
                sys.exit(1)

        except KeyboardInterrupt:
            print ("i'll just go now...")
            sys.exit()
Example #2
0
    def MainMenu(self):
        # This will give you the nice prompt you like so much
        if len(self.currentmodule) > 0:
            g = int(self.currentmodule) - 1
            just_print = self.modules[
                int(g)][int(globals.vars.column_for_name)]
            cmd = raw_input(
                globals.bcolors.GREEN + 'mdb ' + globals.bcolors.RED + str(
                    just_print) + globals.bcolors.GREEN + '#> ' + globals.bcolors.WHITE).strip()
        else:
            cmd = raw_input(
                globals.bcolors.GREEN + 'mdb ' + globals.bcolors.GREEN + '#> ' + globals.bcolors.WHITE).strip()
        try:
            while cmd == "":
                # print 'no cmd'
                self.MainMenu()

            if cmd == 'help':
                print " Available commands:\n"
                for (cmd, desc) in self.commands:
                    print "\t%s\t%s" % ('{0: <12}'.format(cmd), desc)
                print ''
                self.MainMenu()

            # Checks if normal or freestyle search
            if re.match('^search', cmd):
                manySearch = manysearches.MuchSearch()
                try:
                    args = cmd.rsplit(' ')[1:]
                    manySearch.sort(args)
                except:
                    print 'Uh oh, Invalid query.'
                self.MainMenu()

            if cmd == 'exit':
                sys.exit(1)

            if cmd == 'update-db':
                update_handler = Updater()
                db_ver = update_handler.get_maldb_ver()
                update_handler.update_db(db_ver)
                self.MainMenu()

            if cmd == 'report-mal':
                rprt_name = raw_input("Name of malware: ")
                rprt_type = raw_input("Type of malware: ")
                rprt_version = raw_input("Version: ")
                rprt_lang = raw_input("Language: ")
                rprt_src = raw_input("Source / Binary (s/b): ")
                rprt_arch = raw_input("Win32, ARM etc. ? ")
                rprt_reporter = raw_input(
                    "Your name for a thank you note on theZoo.\n"
                    "Please notice that this will be public!\n\nName: ")
                rprt_comments = raw_input("Comments? ")

                report = ("//%s//\n" % rprt_name)
                report += ("///type/%s///\n" % rprt_type)
                report += ("///ver/%s///\n" % rprt_version)
                report += ("///lang/%s///\n" % rprt_lang)
                report += ("///src/%s///\n" % rprt_src)
                report += ("///arch/%s///\n" % rprt_arch)
                report += ("//reporter/%s//\n" % rprt_reporter)
                report += ("//comments/%s//\n" % rprt_comments)

                # Just to avoid bots spamming us...
                email = "info"
                email += "\x40"
                email += "morirt\x2ecom"
                print "-------------- Begin of theZoo Report --------------"
                print report
                print "-------------- Ending of theZoo Report --------------"
                print "To avoid compromising your privacy we have chose this method of reporting."
                print "If you have not stated your name we will not write a thanks in our README."
                print "Your email will remain private in scenario and will not be published."
                print ""
                print "Please create an archive file with the structure described in the README file"
                print "And attach it to the email. "
                print("Please send this report to %s" % email)

                self.MainMenu()

            if cmd == 'get':
                update_handler = Updater()
                try:
                    update_handler.get_malware(self.currentmodule)
                except:
                    print globals.bcolors.RED + '[-] ' + globals.bcolors.WHITE + 'Error getting malware.'
                self.MainMenu()
            # If used the 'use' command
            if re.match('^use', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    self.currentmodule = cmd[1]
                    cmd = ''
                except:
                    print 'The use method needs an argument.'
                self.MainMenu()

            if cmd == 'list all':
                print "\nAvailable Payloads:"
                array = self.modules
                i = 0
                print "ID\tName\tType"
                print '-----------------'
                for element in array:
                    answer = str(array[i][globals.vars.column_for_uid])
                    answer += '\t%s' % (
                        '{0: <12}'.format(array[i][globals.vars.column_for_name]))
                    answer += '\t%s' % (
                        '{0: <12}'.format(array[i][globals.vars.column_for_type]))
                    print answer
                    i = i + 1
                self.MainMenu()

            if cmd == 'quit':
                print ":("
                sys.exit(1)

        except KeyboardInterrupt:
            print ("\n\nI'll just go now...")
            sys.exit()
Example #3
0
    def MainMenu(self):
        # This will give you the nice prompt you like to much
        if len(self.currentmodule) > 0:
            g = int(self.currentmodule) - 1
            just_print = self.modules[int(g)][int(
                globals.vars.column_for_name)]
            cmd = raw_input(globals.bcolors.GREEN + 'mdb ' +
                            globals.bcolors.RED + str(just_print) +
                            globals.bcolors.GREEN + '#> ' +
                            globals.bcolors.WHITE).strip()
        else:
            cmd = raw_input(globals.bcolors.GREEN + 'mdb ' +
                            globals.bcolors.GREEN + '#> ' +
                            globals.bcolors.WHITE).strip()

        try:
            while cmd == "":
                #print 'no cmd'
                self.MainMenu()

            if cmd == 'help':
                print " Available commands:\n"
                for (cmd, desc) in self.commands:
                    print "\t%s\t%s" % ('{0: <12}'.format(cmd), desc)
                print ''
                self.MainMenu()

            if cmd == 'search':
                ar = self.modules
                manySearch = manysearches.MuchSearch()

                # function to sort by arch
                if len(self.arch) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_arch,
                                         self.arch)
                # function to sort by plat
                if len(self.plat) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_plat,
                                         self.plat)
                # function to sort by lang
                if len(self.lang) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_pl,
                                         self.lang)
                if len(self.type) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_type,
                                         self.type)
                if len(self.vip) > 0:
                    ar = manySearch.sort(ar, globals.vars.column_for_vip,
                                         self.vip)
                printController = manysearches.MuchSearch()
                printController.print_payloads(ar)
                self.MainMenu()

            if re.match('^set', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    print cmd[1] + ' => ' + cmd[2]
                    if cmd[1] == 'arch':
                        self.arch = cmd[2]
                    if cmd[1] == 'plat':
                        self.plat = cmd[2]
                    if cmd[1] == 'lang':
                        self.lang = cmd[2]
                    if cmd[1] == 'type':
                        self.type = cmd[2]
                except:
                    print 'Need to use the set method with two arguments.'
                cmd = ''
                self.MainMenu()

            if cmd == 'show':
                if len(self.currentmodule) == 0:
                    print "No modules have been chosen. Use 'use' command."
                if len(self.currentmodule) > 0:
                    print 'Currently selected Module: ' + self.currentmodule
                print '\tarch => ' + str(self.arch)
                print '\tplat => ' + str(self.plat)
                print '\tlang => ' + str(self.lang)
                print '\ttype => ' + str(self.type)
                print ''
                self.MainMenu()

            if cmd == 'exit':
                sys.exit(1)

            if cmd == 'update-db':
                updateHandler = Updater()
                updateHandler.get_maldb_ver()
                self.MainMenu()

            if cmd == 'report-mal':
                rprt_name = raw_input("Name of malware: ")
                rprt_type = raw_input("Type of malware: ")
                rprt_version = raw_input("Version: ")
                rprt_lang = raw_input("Language: ")
                rprt_src = raw_input("Source / Binary (s/b): ")
                rprt_arch = raw_input("Win32, ARM etc. ? ")
                rprt_reporter = raw_input(
                    "Your name for a thanks note on theZoo.\nPlease notice that this will be public!\n\nName: "
                )
                rprt_comments = raw_input("Comments? ")

                report = ("//%s//\n" % rprt_name)
                report += ("///type/%s///\n" % rprt_type)
                report += ("///ver/%s///\n" % rprt_version)
                report += ("///lang/%s///\n" % rprt_lang)
                report += ("///src/%s///\n" % rprt_src)
                report += ("///arch/%s///\n" % rprt_arch)
                report += ("//reporter/%s//\n" % rprt_reporter)
                report += ("//comments/%s//\n" % rprt_comments)

                # Just to avoid bots spamming us...
                email = "info"
                email += "\x40"
                email += "morirt\x2ecom"
                print "-------------- Begin of theZoo Report --------------"
                print report
                print "-------------- Ending of theZoo Report --------------"
                print "To avoid compromising your privacy we have chose this method of reporting."
                print "If you have not stated your name we will not write a thanks in our README."
                print "Your email will remain private in scenario and will not be published."
                print ""
                print "Please create an archive file with the structure as in the README file"
                print "And attach it to the email. "
                print("Please send this report to %s" % email)

                self.MainMenu()

            # 'get' command. Not yet fully operational
            if cmd == 'get':
                updateHandler = Updater()
                try:
                    updateHandler.get_malware(self.currentmodule, self.modules)
                    self.MainMenu()
                except:
                    print globals.bcolors.RED + '[-]' + globals.bcolors.WHITE + 'Error getting malware.'
                    self.MainMenu()

            # If used the 'use' command
            if re.match('^use', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    self.currentmodule = cmd[1]
                    cmd = ''
                except:
                    print 'The use method needs an argument.'
                self.MainMenu()

            # Rests all current data
            if cmd == 'back':
                self.arch = ''
                self.plat = ''
                self.lang = ''
                self.type = ''
                self.currentmodule = ''
                self.MainMenu()

            if cmd == 'list all':
                print "\nAvailable Payloads:"
                array = self.modules
                i = 0
                print "ID\tName\tType"
                print '-----------------'
                for element in array:
                    answer = array[i][globals.vars.column_for_uid]
                    answer += '\t%s' % ('{0: <12}'.format(
                        array[i][globals.vars.column_for_name]))
                    answer += '\t%s' % ('{0: <12}'.format(
                        array[i][globals.vars.column_for_type]))
                    print answer
                    i = i + 1
                self.MainMenu()

            if cmd == 'quit':
                print ":("
                sys.exit(1)

        except KeyboardInterrupt:
            print("i'll just go now...")
            sys.exit()
Example #4
0
    def actOnCommand(self, cmd):
        try:
            while cmd == "":
                return

            if cmd == 'help':
                print(" Available commands:\n")
                for (cmd, desc) in self.commands:
                    print("\t%s\t%s" % ('{0: <12}'.format(cmd), desc))
                print('')
                return

            # Checks if normal or freestyle search
            if re.match('^search', cmd):
                manySearch = manysearches.MuchSearch()
                try:
                    args = cmd.rsplit(' ')[1:]
                    manySearch.sort(args)
                except:
                    print(red('[!]') + 'Uh oh, Invalid query.')
                return

            if cmd == 'exit':
                sys.exit(1)

            if cmd == 'update-db':
                update_handler = Updater()
                db_ver = update_handler.get_maldb_ver()
                update_handler.update_db(db_ver)
                return

            if cmd == 'report-mal':
                rprt_name = raw_input("Name of malware: ")
                rprt_type = raw_input("Type of malware: ")
                rprt_version = raw_input("Version: ")
                rprt_lang = raw_input("Language: ")
                rprt_src = raw_input("Source / Binary (s/b): ")
                rprt_arch = raw_input("Win32, ARM etc. ? ")
                rprt_reporter = raw_input(
                    "Your name for a thank you note on theZoo.\n"
                    "Please notice that this will be public!\n\nName: ")
                rprt_comments = raw_input("Comments? ")

                report = ("//%s//\n" % rprt_name)
                report += ("///type/%s///\n" % rprt_type)
                report += ("///ver/%s///\n" % rprt_version)
                report += ("///lang/%s///\n" % rprt_lang)
                report += ("///src/%s///\n" % rprt_src)
                report += ("///arch/%s///\n" % rprt_arch)
                report += ("//reporter/%s//\n" % rprt_reporter)
                report += ("//comments/%s//\n" % rprt_comments)

                # Just to avoid bots spamming us...
                email = "info"
                email += "\x40"
                email += "morirt\x2ecom"
                print("-------------- Begin of theZoo Report --------------")
                print(report)
                print("-------------- Ending of theZoo Report --------------")
                print(
                    "To avoid compromising your privacy we have chose this method of reporting."
                )
                print(
                    "If you have not stated your name we will not write a thanks in our README."
                )
                print(
                    "Your email will remain private in scenario and will not be published."
                )
                print("")
                print(
                    "Please create an archive file with the structure described in the README file"
                )
                print("And attach it to the email. ")
                print("Please send this report to %s" % email)

                return

            if cmd == 'get':
                update_handler = Updater()
                try:
                    update_handler.get_malware(self.currentmodule)
                except:
                    print(red('[-] ') + 'Error getting malware.')
                return
            # If used the 'use' command
            if re.match('^use', cmd):
                try:
                    cmd = re.split('\s+', cmd)
                    try:
                        self.currentmodule = int(cmd[1])
                    except IndexError:
                        print(
                            "You have chosen an index that is out of DB scale."
                        )
                    cmd = ''
                except TypeError:
                    print('Please enter malware ID')
                except:
                    print('The use method needs an argument [int].')
                return

            if cmd == 'list all':
                print("\nAvailable Payloads:")
                manySearch = manysearches.MuchSearch()
                manySearch.print_payloads(self.db.get_mal_list(),
                                          ["%", "Name", "Type"])
                return

            if cmd == 'info':
                if self.currentmodule is None:
                    print(
                        red("[!] ") +
                        "First select a malware using the \'use\' command")
                    return
                m = self.db.get_mal_info(self.currentmodule)
                manySearch = manysearches.MuchSearch()
                manySearch.print_payloads(m, [
                    "%", "Name", "Ver.", "Author", "Lang", "Date", "Arch.",
                    "Plat.", "Tags"
                ])
                return

            if cmd == 'quit':
                print(":(")
                sys.exit(1)

        except KeyboardInterrupt:
            print("\n\nI'll just go now...")
            sys.exit()
Example #5
0
def main():

    # Much much imports :)
    updateHandler = Updater
    eulaHandler = EULA()
    bannerHandler = muchmuchstrings.banners()
    db = db_handler.DBHandler()
    terminalHandler = Controller()

    def filter_array(array, colum, value):
        ret_array = [row for row in array if value in row[colum]]
        return ret_array

    def getArgvs():
        parser = OptionParser()
        parser = OptionParser()
        parser.add_option("-f", "--filter", dest="mal_filter", default=[],
                          help="Filter the malwares.", action="append")
        parser.add_option("-u", "--update", dest="update_bol", default=0,
                          help="Updates the DB of theZoo.", action="store_true")
        parser.add_option("-v", "--version", dest="ver_bol", default=0,
                          help="Shows version and licensing information.", action="store_true")
        parser.add_option("-w", "--license", dest="license_bol", default=0,
                          help="Prints the GPLv3 license information.", action="store_true")
        (options, args) = parser.parse_args()
        return options

    # Here actually starts Main()
    arguments = getArgvs()

    # Checking for EULA Agreement
    a = eulaHandler.check_eula_file()
    if a == 0:
        eulaHandler.prompt_eula()

    # Get arguments

    # Check if update flag is on
    if arguments.update_bol == 1:
        a = Updater()
        with open('conf/db.ver', 'r') as f:
            a.update_db(f.readline())
        sys.exit(1)

    # Check if version flag is on
    if arguments.ver_bol == 1:
        print(vars.maldb_banner)
        sys.exit(1)

    # Check if license flag is on
    if arguments.license_bol == 1:
        bannerHandler.print_license()
        sys.exit(1)

    if len(arguments.mal_filter) > 0:
        manySearch = manysearches.MuchSearch()
        print(vars.maldb_banner)
        manySearch.sort(arguments.mal_filter)
        sys.exit(1)

    # Initiate normal run. No arguments given.
    os.system('cls' if os.name == 'nt' else 'clear')
    print(vars.maldb_banner)
    while 1:
        terminalHandler.MainMenu()
    sys.exit(1)