Пример #1
0
 def steploop(self):
     """
     Continue stepi'ing in a loop until shouldRunAgain()
     returns false (like RunForever mode or something)
     """
     if self.getMode("NonBlocking", False):
         e_threads.firethread(self.doStepLoop)()
     else:
         self.doStepLoop()
Пример #2
0
 def steploop(self):
     """
     Continue stepi'ing in a loop until shouldRunAgain()
     returns false (like RunForever mode or something)
     """
     if self.getMode("NonBlocking", False):
         e_threads.firethread(self.doStepLoop)()
     else:
         self.doStepLoop()
Пример #3
0
 def wait(self):
     """
     Wait for the trace target to have
     something happen...   If the trace is in
     NonBlocking mode, this will fire a thread
     to wait for you and return control immediately.
     """
     if self.getMode("NonBlocking"):
         e_threads.firethread(self._doWait)()
         return
     self._doWait()
Пример #4
0
 def wait(self):
     """
     Wait for the trace target to have
     something happen...   If the trace is in
     NonBlocking mode, this will fire a thread
     to wait for you and return control immediately.
     """
     if self.getMode("NonBlocking"):
         e_threads.firethread(self._doWait)()
         return
     self._doWait()
Пример #5
0
 def actStepi(self, thing):
     firethread(self.trace.stepi)()
Пример #6
0
 def actBreak(self, thing):
     if self.trace.getMeta('PendingBreak'):
         return
     self.trace.setMeta('PendingBreak', True)
     firethread(self.trace.sendBreak)()
Пример #7
0
 def actContinue(self, thing):
     firethread(self.trace.run)()
Пример #8
0
 def actDetach(self, thing):
     if self.trace.isAttached():
         firethread(self.trace.detach)()
Пример #9
0
 def actAttach(self, *args, **kwargs):
     pid = getProcessPid(trace=self.trace)
     if pid != None:
         firethread(self.trace.attach)(pid)
Пример #10
0
def main():
    parser = argparse.ArgumentParser(prog='vivbin', usage='%(prog)s [options] <workspace|binaries...>')
    parser.add_argument('-M', '--module', dest='modname', default=None, action='store',
                        help='run the file listed as an analysis module in non-gui mode and exit')
    parser.add_argument('-A', '--skip-analysis', dest='doanalyze', default=True, action='store_false',
                        help='Do *not* do an initial auto-analysis pass')
    parser.add_argument('-B', '--bulk', dest='bulk', default=False, action='store_true',
                        help='Do *not* start the gui, just load, analyze and save')
    parser.add_argument('-C', '--cprofile', dest='cprof', default=False, action='store_true',
                        help='Output vivisect performace profiling (cProfile) info')
    parser.add_argument('-O', '--option', dest='option', default=None, action='store',
                        help='<secname>.<optname>=<optval> (optval must be json syntax)')
    parser.add_argument('-p', '--parser', dest='parsemod', default=None, action='store',
                        help='Manually specify the parser module (pe/elf/blob/...)')
    parser.add_argument('-s', '--storage', dest='storage_name', default=None, action='store',
                        help='Specify a storage module by name')
    parser.add_argument('-v', '--verbose', dest='verbose', default=False, action='store_true',
                        help='Enable verbose mode')
    parser.add_argument('-V', '--version', dest='version', default=None, action='store',
                        help='Add file version (if available) to save file name')
    parser.add_argument('file', nargs='*')
    args = parser.parse_args()

    vw = viv_cli.VivCli()
    vw.verbose = args.verbose

    if args.option is not None:
        vw.config.parseConfigOption(args.option)

    if args.storage_name is not None:
        vw.setMeta("StorageModule", args.storage_name)

    # If we're not gonna load files, no analyze
    if args.file is None:
        args.doanalyze = False

    # Load in any additional files...
    needanalyze = False
    if args.file is not None:
        for fname in args.file:
            if args.parsemod == None:
                args.parsemod = viv_parsers.guessFormatFilename(fname)

            start = time.time()
            if args.parsemod == 'viv':
                vw.loadWorkspace(fname)
            else:
                needanalyze = True
                vw.loadFromFile(fname, fmtname=args.parsemod)

            end = time.time()
            print('Loaded (%.4f sec) %s' % (end - start, fname))

    if args.bulk:
        if args.doanalyze:
            if args.cprof:
                cProfile.run("vw.analyze()")
            else:
                start = time.time()
                vw.analyze()
                end = time.time()
                print "ANALYSIS TIME: %s" % (end-start)

        if args.modname is not None:
            module = imp.load_module("custom_analysis", file(modname, "rb"), modname, ('.py', 'U', 1))
            module.analyze(vw)

        print('stats: %r' % (vw.getStats(),))
        print("Saving workspace: %s" % (vw.getMeta('StorageName')))

        vw.saveWorkspace()

    else:

        import vivisect.qt.main as viv_qt_main

        # If we are interactive, lets turn on extended output...
        vw.verbose = True
        if args.doanalyze and needanalyze:
            e_threads.firethread(vw.analyze)()

        viv_qt_main.main(vw)
Пример #11
0
 def actContinue(self, thing):
     firethread(self.trace.run)()
Пример #12
0
 def actDetach(self, thing):
     if self.trace.isAttached():
         firethread(self.trace.detach)()
Пример #13
0
 def actAttach(self, *args, **kwargs):
     pid = getProcessPid(trace=self.trace)
     if pid != None:
         firethread(self.trace.attach)(pid)
Пример #14
0
 def returnPressedSlot(self):
     cmd = str(self.input.text())
     self.input.clear()
     self.addHistory(cmd)
     self.output.addText('> %s\n' % cmd)
     firethread(self.onecmd)(cmd)
Пример #15
0
            module = imp.load_module("custom_analysis", file(modname, "rb"), modname, ('.py', 'U', 1))
            module.analyze(vw)

        print('stats: %r' % (vw.getStats(),))
        print("Saving workspace: %s" % (vw.getMeta('StorageName')))

        vw.saveWorkspace()

    else:

        import vivisect.qt.main as viv_qt_main

        # If we are interactive, lets turn on extended output...
        vw.verbose = True
        if args.doanalyze and needanalyze:
            e_threads.firethread(vw.analyze)()

        viv_qt_main.main(vw)

if __name__ == '__main__':
    try:
        # psyco makes disasm much faster (2-3X)
        import psyco
        #psyco.log()
        psyco.full()
    except ImportError:
        pass

    main()

Пример #16
0
def main():
    parser = argparse.ArgumentParser(
        prog='vivbin', usage='%(prog)s [options] <workspace|binaries...>')
    parser.add_argument(
        '-M',
        '--module',
        dest='modname',
        default=None,
        action='store',
        help=
        'run the file listed as an analysis module in non-gui mode and exit')
    parser.add_argument('-A',
                        '--skip-analysis',
                        dest='doanalyze',
                        default=True,
                        action='store_false',
                        help='Do *not* do an initial auto-analysis pass')
    parser.add_argument(
        '-B',
        '--bulk',
        dest='bulk',
        default=False,
        action='store_true',
        help='Do *not* start the gui, just load, analyze and save')
    parser.add_argument(
        '-C',
        '--cprofile',
        dest='cprof',
        default=False,
        action='store_true',
        help='Output vivisect performace profiling (cProfile) info')
    parser.add_argument(
        '-O',
        '--option',
        dest='option',
        default=None,
        action='store',
        help='<secname>.<optname>=<optval> (optval must be json syntax)')
    parser.add_argument(
        '-p',
        '--parser',
        dest='parsemod',
        default=None,
        action='store',
        help='Manually specify the parser module (pe/elf/blob/...)')
    parser.add_argument('-s',
                        '--storage',
                        dest='storage_name',
                        default=None,
                        action='store',
                        help='Specify a storage module by name')
    parser.add_argument('-v',
                        '--verbose',
                        dest='verbose',
                        default=False,
                        action='count',
                        help='Enable verbose mode (multiples matter: -vvvv)')
    parser.add_argument(
        '-V',
        '--version',
        dest='version',
        default=None,
        action='store',
        help='Add file version (if available) to save file name')
    parser.add_argument('-c',
                        '--config',
                        dest='config',
                        default=None,
                        action='store_true',
                        help='Path to a directory to use for config data')
    parser.add_argument('-a',
                        '--autosave',
                        dest='autosave',
                        default=False,
                        action='store_true',
                        help='Autosave configuration data')
    parser.add_argument('file', nargs='*')
    args = parser.parse_args()

    vw = viv_cli.VivCli(confdir=args.config, autosave=args.autosave)

    # setup logging
    vw.verbose = min(args.verbose, 4)
    logger.setLevel(loglevels[vw.verbose])

    if args.option is not None:
        if args.option in ('-h', '?'):
            logger.critical(vw.config.reprConfigPaths())
            sys.exit(-1)

        try:
            vw.config.parseConfigOption(args.option)
        except e_config.ConfigNoAssignment as e:
            logger.critical(vw.config.reprConfigPaths() + "\n")
            logger.critical(e)
            logger.critical(
                "syntax: \t-O <secname>.<optname>=<optval> (optval must be json syntax)"
            )
            sys.exit(-1)

        except Exception as e:
            logger.critical(vw.config.reprConfigPaths())
            logger.critical("With entry: %s", args.option)
            logger.critical(e)
            sys.exit(-1)

    if args.storage_name is not None:
        vw.setMeta("StorageModule", args.storage_name)

    # If we're not gonna load files, no analyze
    if args.file is None:
        args.doanalyze = False

    # Load in any additional files...
    needanalyze = False
    if args.file is not None:
        for fname in args.file:
            if args.parsemod is None:
                args.parsemod = viv_parsers.guessFormatFilename(fname)

            start = time.time()
            if args.parsemod == 'viv':
                vw.loadWorkspace(fname)
            else:
                needanalyze = True
                vw.loadFromFile(fname, fmtname=args.parsemod)

            end = time.time()
            logger.info('Loaded (%.4f sec) %s', (end - start), fname)

    if args.bulk:
        if args.doanalyze:
            if args.cprof:
                cProfile.run("vw.analyze()")
            else:
                start = time.time()
                vw.analyze()
                end = time.time()
                logger.debug("ANALYSIS TIME: %s", (end - start))

        if args.modname is not None:
            with open(args.modname, 'rb') as f:
                module = imp.load_module("custom_analysis", f, args.modname,
                                         ('.py', 'U', 1))
                module.analyze(vw)

        logger.info('stats: %r', vw.getStats())
        logger.info("Saving workspace: %s", vw.getMeta('StorageName'))

        vw.saveWorkspace()

    else:

        import vivisect.qt.main as viv_qt_main

        # If we are interactive, lets turn on extended output...
        if args.doanalyze and needanalyze:
            e_threads.firethread(vw.analyze)()

        viv_qt_main.main(vw)
Пример #17
0
def main():
    parser = argparse.ArgumentParser(
        prog='vivbin', usage='%(prog)s [options] <workspace|binaries...>')
    parser.add_argument(
        '-M',
        '--module',
        dest='modname',
        default=None,
        action='store',
        help=
        'run the file listed as an analysis module in non-gui mode and exit')
    parser.add_argument('-A',
                        '--skip-analysis',
                        dest='doanalyze',
                        default=True,
                        action='store_false',
                        help='Do *not* do an initial auto-analysis pass')
    parser.add_argument(
        '-B',
        '--bulk',
        dest='bulk',
        default=False,
        action='store_true',
        help='Do *not* start the gui, just load, analyze and save')
    parser.add_argument(
        '-C',
        '--cprofile',
        dest='cprof',
        default=False,
        action='store_true',
        help='Output vivisect performace profiling (cProfile) info')
    parser.add_argument(
        '-O',
        '--option',
        dest='option',
        default=None,
        action='store',
        help='<secname>.<optname>=<optval> (optval must be json syntax)')
    parser.add_argument(
        '-p',
        '--parser',
        dest='parsemod',
        default=None,
        action='store',
        help='Manually specify the parser module (pe/elf/blob/...)')
    parser.add_argument('-s',
                        '--storage',
                        dest='storage_name',
                        default=None,
                        action='store',
                        help='Specify a storage module by name')
    parser.add_argument('-v',
                        '--verbose',
                        dest='verbose',
                        default=False,
                        action='store_true',
                        help='Enable verbose mode')
    parser.add_argument(
        '-V',
        '--version',
        dest='version',
        default=None,
        action='store',
        help='Add file version (if available) to save file name')
    parser.add_argument('file', nargs='*')
    args = parser.parse_args()

    vw = viv_cli.VivCli()
    vw.verbose = args.verbose

    if args.option is not None:
        vw.config.parseConfigOption(args.option)

    if args.storage_name is not None:
        vw.setMeta("StorageModule", args.storage_name)

    # If we're not gonna load files, no analyze
    if args.file is None:
        args.doanalyze = False

    # Load in any additional files...
    needanalyze = False
    if args.file is not None:
        for fname in args.file:
            if args.parsemod == None:
                args.parsemod = viv_parsers.guessFormatFilename(fname)

            start = time.time()
            if args.parsemod == 'viv':
                vw.loadWorkspace(fname)
            else:
                needanalyze = True
                vw.loadFromFile(fname, fmtname=args.parsemod)

            end = time.time()
            print('Loaded (%.4f sec) %s' % (end - start, fname))

    if args.bulk:
        if args.doanalyze:
            if args.cprof:
                cProfile.run("vw.analyze()")
            else:
                start = time.time()
                vw.analyze()
                end = time.time()
                print "ANALYSIS TIME: %s" % (end - start)

        if args.modname is not None:
            module = imp.load_module("custom_analysis", file(modname, "rb"),
                                     modname, ('.py', 'U', 1))
            module.analyze(vw)

        print('stats: %r' % (vw.getStats(), ))
        print("Saving workspace: %s" % (vw.getMeta('StorageName')))

        vw.saveWorkspace()

    else:

        import vivisect.qt.main as viv_qt_main

        # If we are interactive, lets turn on extended output...
        vw.verbose = True
        if args.doanalyze and needanalyze:
            e_threads.firethread(vw.analyze)()

        viv_qt_main.main(vw)
Пример #18
0
 def actBreak(self, thing):
     if self.trace.getMeta('PendingBreak'):
         return
     self.trace.setMeta('PendingBreak', True)
     firethread(self.trace.sendBreak)()
Пример #19
0
 def actStepi(self, thing):
     firethread(self.trace.stepi)()
Пример #20
0
 def returnPressedSlot(self):
     cmd = str(self.input.text())
     self.input.clear()
     self.addHistory(cmd)
     self.output.addText('> %s\n' % cmd)
     firethread(self.onecmd)(cmd)