VDB Package

Warning

The documentation for VDB hasn’t been touched yet! If you want to contribute (or have ideas for better documentation), feel free to send me a pull request or email me.

VDB Package

class vdb.ScriptThread(cobj, locals)[source]

Bases: threading.Thread

run()[source]
class vdb.Vdb(trace=None)[source]

Bases: envi.cli.EnviMutableCli, vtrace.notifiers.Notifier, vtrace.util.TraceManager

A VDB object is a debugger object which may be used to embed full debugger like functionality into a python application. The Vdb object contains a CLI impelementation which extends envi.cli>

FIXME_do_remote(line)[source]

Act as a remote debugging client to the server running on the specified host/ip.

Usage: remote <host>

do_EOF(string)[source]
do_alloc(args)[source]

Allocate a chunk of memory in the target process. It will be allocated with rwx permissions.

Usage: alloc <size expr>

do_attach(args)[source]

Attach to a process by PID or by process name. In the event of more than one process by a given name, attach to the last (most recently created) one in the list.

Usage: attach [<pid>,<name>]

NOTE: This is not a regular expression. The given string must be found as a substring of the process name...

do_autocont(line)[source]

Manipulate the auto-continue behavior for the trace. This will cause particular event types to automagically continue execution.

Usage: autocont [event name]

do_bestname(args)[source]

Return the “best name” string for an address.

Usage: bestname <vtrace expression>

do_bp(line)[source]

Show, add, and enable/disable breakpoints USAGE: bp [-d <addr>] [-a <addr>] [-o <addr>] [[-c pycode] <address> [vdb cmds]] -C - Clear All Breakpoints -c “py code” - Set the breakpoint code to the given python string -d <id> - Disable Breakpoint -e <id> - Enable Breakpoint -r <id> - Remove Breakpoint -o <addr> - Create a OneTimeBreak -L <libname> - Add bp’s to all functions in <libname> -F <filename> - Load bpcode from file -W perms:size - Set a hardware Watchpoint with perms/size (ie -W rw:4) -f - Make added breakpoints from this command into “fastbreaks” -S <libname>:<regex> - Add bp’s to all matching funcs in <libname>

<address>... - Create Breakpoint

[vdb cmds].. - (optional) vdb cli comand to run on BP hit (seperate
multiple commands with ;; )
NOTE: -c adds python code to the breakpoint. The python code will

be run with the following objects mapped into it’s namespace automagically:

vtrace - the vtrace package trace - the tracer bp - the breakpoint object
do_bpedit(line)[source]

Manipulcate the python code that will be run for a given breakpoint by ID. (Also the way to view the code).

Usage: bpedit <id> [“optionally new code”]

NOTE: Your code must be surrounded by “s and may not contain any “s

do_bpfile(line)[source]

Set the python code for a breakpoint from the contents of a file.

Usage: bpfile <bpid> <filename>

do_break(args)[source]

Send the break signal to the target tracer to stop it’s execution.

Usage: break

do_bt(line)[source]

Show a stack backtrace for the currently selected thread.

Usage: bt

do_call(string)[source]

Allows a C-like syntax for calling functions inside the target process (from his context). Example: call printf(“yermom %d”, 10)

do_detach(args)[source]

Detach from the current tracer

do_dis(line)[source]

Print out the opcodes for a given address expression

Usage: dis <address expression> [<size expression>]

do_dope(line)[source]

Cli interface to the “stack doping” api inside recon. BETA

(Basically, set all un-initialized stack memory to V’s to tease out uninitialized stack bugs)

Usage: dope [ options ] -E Enable automagic thread stack doping on all continue events -D Disable automagic thread stack doping on all continue events -A Dope all current thread stacks

do_exec(cmd)[source]

Execute a program with the given command line and attach to it. Usage: exec </some/where and some args>

do_fds(args)[source]

Show all the open Handles/FileDescriptors for the target process. The “typecode” shown in []’s is the vtrace typecode for that kind of fd/handle.

Usage: fds

do_go(line)[source]

Continue the target tracer. -I go icount linear instructions forward (step over style) -U go out of fcount frames (step out style) <until addr> go until explicit address

Usage: go [-U <fcount> | -I <icount> | <until addr expression>]

do_gui(line)[source]

Attempt to spawn the VDB gui. Assuming GTK etc are all installed.

do_guid(line)[source]

Parse and display a Global Unique Identifier (GUID) from memory (eventually, use GUID db to lookup the name/meaning of the GUID).

Usage: guid <addr_exp>

do_ignore(args)[source]

Add the specified signal id (exception id for windows) to the ignored signals list for the current trace. This will make the smallest possible performance impact for that particular signal but will also not alert you that it has occured.

Usage: ignore [options] [-c | <sigcode>...] -d - Remove the specified signal codes. -c - Include the current signal in the sigcode list -C - Clear the list of ignored signals

Example: ignore -c # Ignore the currently posted signal
ignore -d 0x80000001 # Remove 0x80000001 from the ignores
do_lm(args)[source]

Show the loaded libraries and their base addresses.

Usage: lm [libname]

do_memdiff(line)[source]

Save and compare snapshots of memory to enumerate changes.

Usage: memdiff [options] -C Clear all current memory diff snapshots. -A <va:size> Add the given virtual address to the list. -M <va> Add the entire memory map which contains VA to the list. -D Compare currently tracked memory with the target process

and show any differences.
do_memload(line)[source]

Load a file into memory. (straight mapping, no parsing)

Usage: memload <filename>

do_meta(line)[source]

Show the metadata for the current trace.

Usage: meta

do_mode(args)[source]

Set modes in the tracers... mode Foo=True/False

do_ps(args)[source]

Show the current process list.

Usage: ps

do_quit(args)[source]

Quit VDB

use “quit force” to hard-force a quit regardless of everything.

do_recon(line)[source]

Cli front end to the vdb recon subsystem which allows runtime analysis of known API calls.

Usage: recon [options] -A <sym_expr>:<recon_fmt> - Add a recon breakpoint with the given format -C - Clear the current list of recon breakpoint hits. -H - Print the current list of recon breakpoint hits. -Q - Toggle “quiet” mode which prints nothing on bp hits. -S <sym_expr>:<argidx> - Add a sniper break for arg index

NOTE: A “recon format” is a special format sequence which tells the
recon subsystem how to present the argument data for a given breakpoint hit.

Recon Format: C - A character I - A decimal integer P - A pointer (display symbol if possible) S - An ascii string (up to 260 chars) U - A unicode string (up to 260 chars) X - A hex number

do_reg(args)[source]

Show the current register values. Additionally, you may specify name=<expression> to set a register

Usage: reg [regname=vtrace_expression]

do_restart(line)[source]

Restart the current process.

Usage: restart

NOTE: This only works if the process was exec’d to begin with!

TODO: Plumb options for persisting bp’s etc...

do_resume(line)[source]

Resume a thread.

Usage: resume <-A | <tid>[ <tid>...]>

do_server(port)[source]

Start a vtrace server on the local box. If the server is already running, show which processes are being remotely debugged.

Usage: server

do_signal(args)[source]

Show the current pending signal/exception code.

Usage: signal

do_snapshot(line)[source]

Take a process snapshot of the current (stopped) trace and save it to the specified file.

Usage: snapshot <filename>

do_stalker(line)[source]

Cli front end to the VDB code coverage subsystem. FIXME MORE DOCS!

Usage: stalker [options] -C - Cleanup stalker breaks and hit info -c - Clear the current hits (so you can make more ;) -E <addr_expr> - Add the specified entry point for tracking -H - Show the current hits -L <lib>:<regex> - Add stalker breaks to all matching library symbols -R - Reset all breakpoints to enabled and clear hit info

do_status(line)[source]

Print out the status of the debugger / trace...

do_stepi(line)[source]

Single step the target tracer. Usage: stepi [ options ]

-A <addr>
  • Step to <addr>
-B
  • Step past the next branch instruction

-C <count> - Step <count> instructions -R - Step to return from this function -V - Show operand values during single step (verbose!)

do_struct(args)[source]

Break out a strcuture from memory. You may use the command “vstruct” to show the known structures in vstruct.

Usage: struct <StructName> <vtrace expression>

do_suspend(line)[source]

Suspend a thread.

Usage: suspend <-A | <tid>[ <tid>...]>

do_syms(line)[source]

List symbols and by file.

Usage: syms [-s <pattern>] [filename]

With no arguments, syms will self.vprint(the possible libraries with symbol resolvers. Specify a library to see all the symbols for it.

do_threads(line)[source]

List the current threads in the target process or select the current thread context for the target tracer. Usage: threads [thread id]

do_var(line)[source]

Set a variable in the expression parsing context. This allows for scratchspace names (python compatable names) to be used in expressions.

Usage: var <name> <addr_expression>

NOTE: The address expression must resolve at the time you set it.

do_vstruct(line)[source]

List the available structure modules and optionally structure definitions from a particular module in the current vstruct.

Usage: vstruct [modname]

do_waitlib(line)[source]

Run the target process until the specified library (by normalized name such as ‘kernel32’ or ‘libc’) is loaded. Disable waiting with -D.

Usage: waitlib [ -D | <libname> ]

emptyline()[source]
getExpressionLocals()[source]
getSignal(sig)[source]

If given an int, return the name, for a name, return the int ;)

getTrace()[source]
loadConfig()[source]
loadDefaultRenderers(trace)[source]
loadExtensions(trace)[source]

Load up any extensions which are relevant for the current tracer’s platform/arch/etc...

newTrace()[source]

Generate a new trace for this vdb instance. This fixes many of the new attach/exec data munging issues because tracer re-use is very sketchy...

notify(event, trace)[source]
parseExpression(exprstr)[source]
reprPointer(address)[source]

Return a string representing the best known name for the given address

script(filename, args=[])[source]

Execute a vdb script.

scriptstring(script, filename, args=[])[source]

Do the actual compile and execute for the script data contained in script which was read from filename.

setupSignalLookups()[source]
verror(msg, addnl=True)[source]
class vdb.VdbLookup(initdict={})[source]

Bases: UserDict.UserDict

class vdb.VdbTrace(db)[source]

Used to hand thing that need a persistant reference to a trace when using vdb to manage tracers.

attach(pid)[source]
deregisterNotifier(event, notif)[source]
registerNotifier(event, notif)[source]
selectThread(threadid)[source]

Renderers Module

A home for the vdb specific memory renderers.

class vdb.renderers.DerefRenderer(trace)[source]

Bases: envi.memcanvas.MemoryRenderer

isAscii(bytes)[source]
isBasicUnicode(bytes)[source]
render(mcanv, va)[source]
class vdb.renderers.OpcodeRenderer(trace)[source]

Bases: envi.memcanvas.MemoryRenderer

render(mcanv, va)[source]
class vdb.renderers.SymbolRenderer(trace)[source]

Bases: envi.memcanvas.MemoryRenderer

render(mcanv, va)[source]

Table Of Contents

This Page