def display(self):
        db = Database()
        if 'file_id' in self.request.POST:
            file_id = self.request.POST['file_id']
            # Check to see if we already have strings stored.
            new_strings = db.get_strings(file_id)
            if new_strings:
                string_id = new_strings._id
            else:
                string_id = False
        print string_id

        self.render_data = {'ExtractStrings': {'string_id': string_id}}
Exemple #2
0
    def display(self):
        db = Database()
        if 'file_id' in self.request.POST:
            file_id = self.request.POST['file_id']
            # Check to see if we already have strings stored.
            new_strings = db.get_strings(file_id)
            if new_strings:
                string_id = new_strings._id
            else:
                string_id = False
        print string_id

        self.render_data = {'ExtractStrings': {'string_id': string_id}}
    def run(self):
        db = Database()
        # Get Options

        if "min_length" in self.request.POST:
            min_len = self.request.POST['min_length']
        else:
            min_len = 4

        if 'file_id' in self.request.POST:
            file_id = self.request.POST['file_id']
            # Check to see if we already have strings stored.
            new_strings = db.get_strings(file_id)
            if new_strings:
                string_id = new_strings._id
            else:

                file_object = db.get_filebyid(file_id)

                # Always get ASCII and Unicode

                file_data = file_object.read()

                ascii_strings = self.ascii_strings(file_data, 4)
                unicode_strings = self.unicode_strings(file_data, 4)

                if HAVE_FLOSS:

                    # Advacned Floss needs a file on disk
                    with tempfile.NamedTemporaryFile() as tmp:
                        tmp.write(file_data)

                        file_path = tmp.name

                        if self.is_supported_file_type(file_path):
                            try:
                                vw = viv_utils.getWorkspace(file_path, should_save=False)
                            except Exception:
                                print "ahhhhhhhhhhhhhh"
                                raise

                            # Decode Strings
                            #decoding_functions_candidates = im.identify_decoding_functions(vw, selected_plugins, selected_functions)
                            #function_index = viv_utils.InstructionFunctionIndex(vw)

                            #decoded_strings = decode_strings(vw, function_index, decoding_functions_candidates)

                            # Stack Strings

                # Generate the final output file

                string_list = '##### ASCII Strings #####\n {0} \n ##### Unicode Strings #####\n {1}'.format(ascii_strings, unicode_strings)

                '''
                String lists can get larger than the 16Mb bson limit
                Need to store in GridFS
                '''
                store_data = {'file_id': file_id, 'string_list': string_list}
                string_id = db.create_file(string_list, 'session_id', 'sha256', '{0}_strings.txt'.format(file_id))
                print string_id

            self.render_type = 'html'
            self.render_data = '<td><a class="btn btn-success" role="button" href="/download/file/{0}">Download</a></td>'.format(
                        string_id)
Exemple #4
0
    def run(self):
        db = Database()
        # Get Options

        if "min_length" in self.request.POST:
            min_len = self.request.POST['min_length']
        else:
            min_len = 4

        if 'file_id' in self.request.POST:
            file_id = self.request.POST['file_id']
            # Check to see if we already have strings stored.
            new_strings = db.get_strings(file_id)
            if new_strings:
                string_id = new_strings._id
            else:

                file_object = db.get_filebyid(file_id)

                # Always get ASCII and Unicode

                file_data = file_object.read()

                ascii_strings = self.ascii_strings(file_data, 4)
                unicode_strings = self.unicode_strings(file_data, 4)

                if HAVE_FLOSS:

                    # Advacned Floss needs a file on disk
                    with tempfile.NamedTemporaryFile() as tmp:
                        tmp.write(file_data)

                        file_path = tmp.name

                        if self.is_supported_file_type(file_path):
                            try:
                                vw = viv_utils.getWorkspace(file_path,
                                                            should_save=False)
                            except Exception:
                                print "ahhhhhhhhhhhhhh"
                                raise

                            # Decode Strings
                            #decoding_functions_candidates = im.identify_decoding_functions(vw, selected_plugins, selected_functions)
                            #function_index = viv_utils.InstructionFunctionIndex(vw)

                            #decoded_strings = decode_strings(vw, function_index, decoding_functions_candidates)

                            # Stack Strings

                # Generate the final output file

                string_list = '##### ASCII Strings #####\n {0} \n ##### Unicode Strings #####\n {1}'.format(
                    ascii_strings, unicode_strings)
                '''
                String lists can get larger than the 16Mb bson limit
                Need to store in GridFS
                '''
                store_data = {'file_id': file_id, 'string_list': string_list}
                string_id = db.create_file(string_list, 'session_id', 'sha256',
                                           '{0}_strings.txt'.format(file_id))
                print string_id

            self.render_type = 'html'
            self.render_data = '<td><a class="btn btn-success" role="button" href="/download/file/{0}">Download</a></td>'.format(
                string_id)