Exemple #1
0
    def __init__(self, archname=None):
        # For the crazy thread-call-proxy-thing
        # (must come first for __getattribute__
        self.requires_thread = {}
        self.proxymeth = None  # FIXME hack for now...
        self._released = False

        # The universal place for all modes
        # that might be platform dependant...
        self.modes = {}
        self.modedocs = {}
        self.notifiers = {}

        # For all transient data (if notifiers want
        # to track stuff per-trace
        self.metadata = {}

        self.initMode("RunForever", False, "Run until RunForever = False")
        self.initMode("NonBlocking", False,
                      "A call to wait() fires a thread to wait *for* you")
        self.initMode(
            "ThreadProxy", True,
            "Proxy necessary requests through a single thread (can deadlock...)"
        )
        self.initMode(
            "SingleStep", False,
            "All calls to run() actually just step.  This allows RunForever + SingleStep to step forever ;)"
        )
        self.initMode("FastStep", False,
                      "All stepi() will NOT generate a step event")

        self.regcache = None
        self.regcachedirty = False
        self.sus_threads = {}  # A dictionary of suspended threads

        # Set if we're a server and this trace is proxied
        self.proxy = None

        # Set us up with an envi arch module
        # FIXME eventually we should just inherit one...
        if archname == None:
            archname = envi.getCurrentArch()

        arch = envi.getArchByName(archname)
        self.setMeta('Architecture', archname)
        self.arch = envi.getArchModule(name=archname)

        e_resolv.SymbolResolver.__init__(self,
                                         width=self.arch.getPointerSize())
        e_mem.IMemory.__init__(self, arch=arch)
        e_reg.RegisterContext.__init__(self)

        # Add event numbers to here for auto-continue
        self.auto_continue = [
            NOTIFY_LOAD_LIBRARY, NOTIFY_CREATE_THREAD, NOTIFY_UNLOAD_LIBRARY,
            NOTIFY_EXIT_THREAD, NOTIFY_DEBUG_PRINT
        ]
Exemple #2
0
    def __init__(self, archname=None):
        # For the crazy thread-call-proxy-thing
        # (must come first for __getattribute__
        self.requires_thread = {}
        self.proxymeth = None  # FIXME hack for now...
        self._released = False

        # The universal place for all modes
        # that might be platform dependant...
        self.modes = {}
        self.modedocs = {}
        self.notifiers = {}

        # For all transient data (if notifiers want
        # to track stuff per-trace
        self.metadata = {}

        self.initMode("RunForever", False, "Run until RunForever = False")
        self.initMode("NonBlocking", False, "A call to wait() fires a thread to wait *for* you")
        self.initMode("ThreadProxy", True, "Proxy necissary requests through a single thread (can deadlock...)")
        self.initMode("FastBreak", False, "Do *NOT* add/remove breakpoints per-run, but leave them there once active")
        self.initMode(
            "SingleStep",
            False,
            "All calls to run() actually just step.  This allows RunForever + SingleStep to step forever ;)",
        )
        self.initMode("FastStep", False, "All stepi() will NOT generate a step event")

        self.regcache = None
        self.regcachedirty = False
        self.fb_bp_done = False  # A little hack for FastBreak mode
        self.sus_threads = {}  # A dictionary of suspended threads

        # Set if we're a server and this trace is proxied
        self.proxy = None

        # Set us up with an envi arch module
        # FIXME eventually we should just inherit one...
        if archname == None:
            archname = envi.getCurrentArch()
        self.setMeta("Architecture", archname)
        self.arch = envi.getArchModule(name=archname)

        e_resolv.SymbolResolver.__init__(self, width=self.arch.getPointerSize())
        e_mem.IMemory.__init__(self, archmod=self.arch)
        e_reg.RegisterContext.__init__(self)

        # Add event numbers to here for auto-continue
        self.auto_continue = [
            NOTIFY_LOAD_LIBRARY,
            NOTIFY_CREATE_THREAD,
            NOTIFY_UNLOAD_LIBRARY,
            NOTIFY_EXIT_THREAD,
            NOTIFY_DEBUG_PRINT,
        ]
Exemple #3
0
def getCurrentDef(normname):
    bname, wver, stuff, whichkern = platform.win32_ver()
    wvertup = wver.split('.')
    arch = envi.getCurrentArch()
    if isSysWow64():
        arch = 'wow64'

    modname = 'vstruct.defs.windows.win_%s_%s_%s.%s' % (wvertup[0], wvertup[1], arch, normname)

    try:
        mod = __import__(modname, {}, {}, 1)
    except ImportError, e:
        mod = None
Exemple #4
0
def skip(*skips):
    arch = envi.getCurrentArch()
    plat = platform.system().lower()

    cur = set([arch,plat])
    skips = set(skips)

    def skipfunc(f):
        has = cur & skips
        if not has:
            return f

        def doskip(*args, **kwargs):
            raise unittest.SkipTest('Skipped For: %s' % (repr(has),))

        return doskip

    return skipfunc
Exemple #5
0
def skip(*skips):
    arch = envi.getCurrentArch()
    plat = platform.system().lower()

    cur = set([arch, plat])
    skips = set(skips)

    def skipfunc(f):
        has = cur & skips
        if not has:
            return f

        def doskip(*args, **kwargs):
            raise unittest.SkipTest('Skipped For: %s' % (repr(has), ))

        return doskip

    return skipfunc
Exemple #6
0
def getTrace():
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.
    ex. mytrace = vtrace.getTrace()
    """

    if remote: #We have a remote server!
        return getRemoteTrace()

    os_name = platform.system() # Like "Linux", "Darwin","Windows"
    arch = envi.getCurrentArch()

    if os_name == "Linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "FreeBSD":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.freebsd as v_freebsd
        #ilist.append(v_posix.PosixMixin)
        #ilist.append(v_posix.ElfMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_freebsd.FreeBSDMixin)
            #ilist.append(v_freebsd.FreeBSDIntelRegisters)
        #else:
            #raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_solaris.SolarisMixin)
            #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "Darwin":

        #if 9 not in os.getgroups():
            #print 'You MUST be in the procmod group....'
            #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
            #print '(put your username in there unless you want to put me in too... ;)'
            #raise Exception('procmod group membership required')
        if os.getuid() != 0:
            print 'For NOW you *must* be root.  There are some crazy MACH perms...'
            raise Exception('You must be root for now....')

        print 'Also... the darwin port is not even REMOTELY working yet.  Solid progress though...'

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin
        if arch == 'i386':
            return v_darwin.Darwini386Trace()
        elif arch == 'amd64':
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception('Darwin not supported on %s (only i386...)' % arch)

    elif os_name in ['Microsoft', 'Windows']:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #7
0
def getTrace(target=None, **kwargs):
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.

    ex. mytrace = vtrace.getTrace()


    NOTE: Use the release() method on the tracer once debugging
          is complete.  This releases the tracer thread and allows
          garbage collection to function correctly.

    Some specialized tracers may be constructed by specifying the "target"
    name from one of the following list.  Additionally, each "specialized"
    tracer may require additional kwargs (which are listed).


    Examples:
        # A tracer for *this* os
        t = vtrace.getTrace()

        # A tracer for the gdbstub debugging a vmware 32bit hypervisor
        t = vtrace.getTrace(target='vmware32', host='localhost', port=8832)

    Targets:

    Alpha Targets:

    vmware32    -
        host=<host>     ( probably 'localhost' )
        port=<port>     ( probably 8832 )

    """
    if target == 'gdbserver':

        host = reqTargOpt(kwargs, 'gdbserver', 'host', '<host>')
        port = reqTargOpt(kwargs, 'gdbserver', 'port', '<port>')
        arch = reqTargOpt(kwargs, 'gdbserver', 'arch', '<i386|amd64|arm>')
        plat = reqTargOpt(kwargs, 'gdbserver', 'plat', '<windows|linux>')

        if arch not in ('i386', 'amd64', 'arm'):
            raise Exception('Invalid arch specified for "gdbserver" target: %s' % arch)

        if plat not in ('windows', 'linux'):
            raise Exception('Invalid plat specified for "gdbserver" target: %s' % plat)

    if target == 'vmware32':

        import vtrace.platforms.vmware as vt_vmware

        host = reqTargOpt(kwargs, 'vmware32', 'host', '<host>')
        port = int( reqTargOpt(kwargs, 'vmware32', 'port', '<port>') )

        plat = 'windows'

        #plat = reqTargOpt(kwargs, 'vmware32', 'plat', '<windows|linux>')
        #if plat not in ('windows', 'linux'):
            #raise Exception('Invalid plat specified for "vmware32" target: %s' % plat)

        return vt_vmware.VMWare32WindowsTrace( host=host, port=port )

    if remote: #We have a remote server!
        return getRemoteTrace()

    # From here down, we're trying to build a trace for *this* platform!

    os_name = platform.system().lower() # Like "linux", "darwin","windows"
    arch = envi.getCurrentArch()

    if os_name == "linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        # Keep separate just in case
        elif arch == "armv7l":
            return v_linux.LinuxArmTrace()

        elif arch == "armv6l":
            return v_linux.LinuxArmTrace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "freebsd":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_solaris.SolarisMixin)
            #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "darwin":

        #if 9 not in os.getgroups():
            #print 'You MUST be in the procmod group....'
            #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
            #print '(put your username in there unless you want to put me in too... ;)'
            #raise Exception('procmod group membership required')
        if os.getuid() != 0:
            logger.error('For NOW you *must* be root.  There are some crazy MACH perms...')
            raise Exception('You must be root for now (on OSX)....')

        logger.warning('Also... the darwin port is not even REMOTELY working yet.  Solid progress though...')

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin
        if arch == 'i386':
            return v_darwin.Darwini386Trace()
        elif arch == 'amd64':
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception('Darwin not supported on %s (only i386...)' % arch)

    elif os_name in ['microsoft', 'windows']:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #8
0
def getTrace():
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.
    ex. mytrace = vtrace.getTrace()
    """

    if remote:  # We have a remote server!
        return getRemoteTrace()

    os_name = platform.system()  # Like "Linux", "Darwin","Windows"
    arch = envi.getCurrentArch()

    if os_name == "Linux":
        import vtrace.platforms.linux as v_linux

        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "FreeBSD":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

        # import vtrace.platforms.posix as v_posix
        # import vtrace.platforms.freebsd as v_freebsd
        # ilist.append(v_posix.PosixMixin)
        # ilist.append(v_posix.ElfMixin)
        # if arch == "i386":
        # import vtrace.archs.intel as v_intel
        # ilist.append(v_intel.i386Mixin)
        # ilist.append(v_freebsd.FreeBSDMixin)
        # ilist.append(v_freebsd.FreeBSDIntelRegisters)
        # else:
        # raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        # import vtrace.platforms.posix as v_posix
        # import vtrace.platforms.solaris as v_solaris
        # ilist.append(v_posix.PosixMixin)
        # if arch == "i386":
        # import vtrace.archs.intel as v_intel
        # ilist.append(v_intel.i386Mixin)
        # ilist.append(v_solaris.SolarisMixin)
        # ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "Darwin":

        # if 9 not in os.getgroups():
        # print 'You MUST be in the procmod group....'
        # print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        # print '(put your username in there unless you want to put me in too... ;)'
        # raise Exception('procmod group membership required')
        if os.getuid() != 0:
            print "For NOW you *must* be root.  There are some crazy MACH perms..."
            raise Exception("You must be root for now....")

        print "Also... the darwin port is not even REMOTELY working yet.  Solid progress though..."

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin

        if arch == "i386":
            return v_darwin.Darwini386Trace()
        elif arch == "amd64":
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception("Darwin not supported on %s (only i386...)" % arch)

    elif os_name in ["Microsoft", "Windows"]:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #9
0
def getTrace(target=None, **kwargs):
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.

    ex. mytrace = vtrace.getTrace()


    NOTE: Use the release() method on the tracer once debugging
          is complete.  This releases the tracer thread and allows
          garbage collection to function correctly.

    Some specialized tracers may be constructed by specifying the "target"
    name from one of the following list.  Additionally, each "specialized"
    tracer may require additional kwargs (which are listed).


    Examples:
        # A tracer for *this* os
        t = vtrace.getTrace()

        # A tracer for the gdbstub debugging a vmware 32bit hypervisor
        t = vtrace.getTrace(target='vmware32', host='localhost', port=8832)

    Targets:

    Alpha Targets:

    vmware32    -
        host=<host>     ( probably 'localhost' )
        port=<port>     ( probably 8832 )

    """
    if target == 'gdbserver':

        host = reqTargOpt(kwargs, 'gdbserver', 'host', '<host>')
        port = reqTargOpt(kwargs, 'gdbserver', 'port', '<port>')
        arch = reqTargOpt(kwargs, 'gdbserver', 'arch', '<i386|amd64|arm>')
        plat = reqTargOpt(kwargs, 'gdbserver', 'plat', '<windows|linux>')

        if arch not in ('i386', 'amd64', 'arm'):
            raise Exception('Invalid arch specified for "gdbserver" target: %s' % arch)

        if plat not in ('windows', 'linux'):
            raise Exception('Invalid plat specified for "gdbserver" target: %s' % plat)

    if target == 'vmware32':

        import vtrace.platforms.vmware as vt_vmware

        host = reqTargOpt(kwargs, 'vmware32', 'host', '<host>')
        port = int( reqTargOpt(kwargs, 'vmware32', 'port', '<port>') )

        plat = 'windows'

        #plat = reqTargOpt(kwargs, 'vmware32', 'plat', '<windows|linux>')
        #if plat not in ('windows', 'linux'):
            #raise Exception('Invalid plat specified for "vmware32" target: %s' % plat)

        return vt_vmware.VMWare32WindowsTrace( host=host, port=port )

    if remote: #We have a remote server!
        return getRemoteTrace()

    # From here down, we're trying to build a trace for *this* platform!

    os_name = platform.system().lower() # Like "linux", "darwin","windows"
    arch = envi.getCurrentArch()

    if os_name == "linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        # Keep separate just in case
        elif arch == "armv7l":
            return v_linux.LinuxArmTrace()

        elif arch == "armv6l":
            return v_linux.LinuxArmTrace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "freebsd":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_solaris.SolarisMixin)
            #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "darwin":

        #if 9 not in os.getgroups():
            #print 'You MUST be in the procmod group....'
            #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
            #print '(put your username in there unless you want to put me in too... ;)'
            #raise Exception('procmod group membership required')
        if os.getuid() != 0:
            print 'For NOW you *must* be root.  There are some crazy MACH perms...'
            raise Exception('You must be root for now (on OSX)....')

        print 'Also... the darwin port is not even REMOTELY working yet.  Solid progress though...'

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin
        if arch == 'i386':
            return v_darwin.Darwini386Trace()
        elif arch == 'amd64':
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception('Darwin not supported on %s (only i386...)' % arch)

    elif os_name in ['microsoft', 'windows']:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #10
0
def getTrace(plat=None, **kwargs):
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.
    ex. mytrace = vtrace.getTrace()


    NOTE: Use the release() method on the tracer once debugging
          is complete.  This releases the tracer thread and allows
          garbage collection to function correctly.

    Some specialized tracers may be constructed by specifying the "plat"
    name from one of the following list.  Additionally, each "specialized"
    tracer may require additional kwargs (which are listed).

    android - Debug android apps through adb (adb must be in your path)
        avd=<name> (None will let adb decide)

    vmware32  - Debug a 32bit VMWare target.
        host=<host> - Where is the gdb server listening? (default 127.0.0.1)
        port=<port> - What port (default: 8832)
        os=<osname> - On of "Windows", "Linux" (that's all we support now...)

    vmware64  - Debug a 64bit VMWare target.
        host=<host> - Where is the gdb server listening? (default 127.0.0.1)
        port=<port> - What port (default: 8864)
        os=<osname> - On of "Windows", "Linux" (that's all we support now...)

    Examples:
        t = vtrace.getTrace() # A tracer for *this* os

        t = vtrace.getTrace(plat='android') # The default ADB device

        t = vtrace.getTrace(plat='vmware32', host='localhost', port=31337)
    """
    # FIXME make "remote" traces use plat="remote"!
    if plat == 'android':
        import vtrace.platforms.android as v_android
        return v_android.getTrace(**kwargs)

    if remote:  #We have a remote server!
        return getRemoteTrace()

    # From here down, we're trying to build a trace for *this* platform!

    os_name = platform.system()  # Like "Linux", "Darwin","Windows"
    arch = envi.getCurrentArch()

    if os_name == "Linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "FreeBSD":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.freebsd as v_freebsd
        #ilist.append(v_posix.PosixMixin)
        #ilist.append(v_posix.ElfMixin)
        #if arch == "i386":
        #import vtrace.archs.intel as v_intel
        #ilist.append(v_intel.i386Mixin)
        #ilist.append(v_freebsd.FreeBSDMixin)
        #ilist.append(v_freebsd.FreeBSDIntelRegisters)
        #else:
        #raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
        #import vtrace.archs.intel as v_intel
        #ilist.append(v_intel.i386Mixin)
        #ilist.append(v_solaris.SolarisMixin)
        #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "Darwin":

        #if 9 not in os.getgroups():
        #print 'You MUST be in the procmod group....'
        #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #print '(put your username in there unless you want to put me in too... ;)'
        #raise Exception('procmod group membership required')
        if os.getuid() != 0:
            print 'For NOW you *must* be root.  There are some crazy MACH perms...'
            raise Exception('You must be root for now (on OSX)....')

        print 'Also... the darwin port is not even REMOTELY working yet.  Solid progress though...'

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin
        if arch == 'i386':
            return v_darwin.Darwini386Trace()
        elif arch == 'amd64':
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception('Darwin not supported on %s (only i386...)' % arch)

    elif os_name in ['Microsoft', 'Windows']:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #11
0
def getTrace():
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.
    ex. mytrace = vtrace.getTrace()
    """

    if remote: #We have a remote server!
        return getRemoteTrace()

    os_name = platform.system() # Like "Linux", "Darwin","Windows"
    arch = envi.getCurrentArch()

    if os_name == "Linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "FreeBSD":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.freebsd as v_freebsd
        #ilist.append(v_posix.PosixMixin)
        #ilist.append(v_posix.ElfMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_freebsd.FreeBSDMixin)
            #ilist.append(v_freebsd.FreeBSDIntelRegisters)
        #else:
            #raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_solaris.SolarisMixin)
            #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "Darwin":
        raise Exception("Darwin needs porting!")
        #print "DARWIN SUPPORT ISNT DONE"
        #if 9 not in os.getgroups():
            #raise Exception("You must be in the procmod group!")
        #import vtrace.platforms.darwin as v_darwin
        #import vtrace.platforms.posix as v_posix
        #ilist.append(v_posix.PosixMixin)
        #ilist.append(v_posix.PtraceMixin)
        #ilist.append(v_darwin.DarwinMixin)
        #ilist.append(v_darwin.MachoMixin)
        #if arch == "i386":
            #import vtrace.archs.i386 as v_i386
            #ilist.append(v_i386.i386Mixin)
            #ilist.append(v_darwin.DarwinIntel32Registers)
        #elif arch == "powerpc":
            #import vtrace.archs.ppc as v_ppc
            #ilist.append(v_ppc.PpcMixin)
            #ilist.append(v_darwin.DarwinPpc32Registers)
        #else:
            #raise Exception("WTF?!?!  You got Darwin running on %s?!?>!?" % arch)

    elif os_name == "Windows":

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)
Exemple #12
0
def getTrace(plat=None, **kwargs):
    """
    Return a tracer object appropriate for this platform.
    This is the function you will use to get a tracer object
    with the appropriate ancestry for your host.
    ex. mytrace = vtrace.getTrace()


    NOTE: Use the release() method on the tracer once debugging
          is complete.  This releases the tracer thread and allows
          garbage collection to function correctly.

    Some specialized tracers may be constructed by specifying the "plat"
    name from one of the following list.  Additionally, each "specialized"
    tracer may require additional kwargs (which are listed).

    android - Debug android apps through adb (adb must be in your path)
        avd=<name> (None will let adb decide)

    vmware32  - Debug a 32bit VMWare target.
        host=<host> - Where is the gdb server listening? (default 127.0.0.1)
        port=<port> - What port (default: 8832)
        os=<osname> - On of "Windows", "Linux" (that's all we support now...)

    vmware64  - Debug a 64bit VMWare target.
        host=<host> - Where is the gdb server listening? (default 127.0.0.1)
        port=<port> - What port (default: 8864)
        os=<osname> - On of "Windows", "Linux" (that's all we support now...)

    Examples:
        t = vtrace.getTrace() # A tracer for *this* os

        t = vtrace.getTrace(plat='android') # The default ADB device

        t = vtrace.getTrace(plat='vmware32', host='localhost', port=31337)
    """
    # FIXME make "remote" traces use plat="remote"!
    if plat == 'android':
        import vtrace.platforms.android as v_android
        return v_android.getTrace(**kwargs)

    if remote: #We have a remote server!
        return getRemoteTrace()

    # From here down, we're trying to build a trace for *this* platform!

    os_name = platform.system() # Like "Linux", "Darwin","Windows"
    arch = envi.getCurrentArch()

    if os_name == "Linux":
        import vtrace.platforms.linux as v_linux
        if arch == "amd64":
            return v_linux.LinuxAmd64Trace()

        elif arch == "i386":
            return v_linux.Linuxi386Trace()

        else:
            raise Exception("Sorry, no linux support for %s" % arch)

    elif os_name == "FreeBSD":

        import vtrace.platforms.freebsd as v_freebsd

        if arch == "i386":
            return v_freebsd.FreeBSDi386Trace()

        elif arch == "amd64":
            return v_freebsd.FreeBSDAmd64Trace()

        else:
            raise Exception("Sorry, no FreeBSD support for %s" % arch)

        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.freebsd as v_freebsd
        #ilist.append(v_posix.PosixMixin)
        #ilist.append(v_posix.ElfMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_freebsd.FreeBSDMixin)
            #ilist.append(v_freebsd.FreeBSDIntelRegisters)
        #else:
            #raise Exception("Sorry, no FreeBSD support for %s" % arch)

    elif os_name == "sunos5":
        raise Exception("Solaris needs porting!")
        #import vtrace.platforms.posix as v_posix
        #import vtrace.platforms.solaris as v_solaris
        #ilist.append(v_posix.PosixMixin)
        #if arch == "i386":
            #import vtrace.archs.intel as v_intel
            #ilist.append(v_intel.i386Mixin)
            #ilist.append(v_solaris.SolarisMixin)
            #ilist.append(v_solaris.Solarisi386Mixin)

    elif os_name == "Darwin":

        #if 9 not in os.getgroups():
            #print 'You MUST be in the procmod group....'
            #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth'
            #print '(put your username in there unless you want to put me in too... ;)'
            #raise Exception('procmod group membership required')
        if os.getuid() != 0:
            print 'For NOW you *must* be root.  There are some crazy MACH perms...'
            raise Exception('You must be root for now (on OSX)....')

        print 'Also... the darwin port is not even REMOTELY working yet.  Solid progress though...'

        #'sudo dscl . append /Groups/procmod GroupMembership invisigoth'
        #'sudo dscl . read /Groups/procmod GroupMembership'
        import vtrace.platforms.darwin as v_darwin
        if arch == 'i386':
            return v_darwin.Darwini386Trace()
        elif arch == 'amd64':
            return v_darwin.DarwinAmd64Trace()
        else:
            raise Exception('Darwin not supported on %s (only i386...)' % arch)

    elif os_name in ['Microsoft', 'Windows']:

        import vtrace.platforms.win32 as v_win32

        if arch == "i386":
            return v_win32.Windowsi386Trace()

        elif arch == "amd64":
            return v_win32.WindowsAmd64Trace()

        else:
            raise Exception("Windows with arch %s is not supported!" % arch)

    else:

        raise Exception("ERROR - OS %s not supported yet" % os_name)