code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
aProcess = self.system.get_process(pid)
aModule = aProcess.get_module_by_name(modName)
if not aModule:
aProcess.scan_modules()
aModule = aProcess.get_module_by_name(modName)
if aModule:
address = aModule.resolve(procName)
return ad... | def resolve_exported_function(self, pid, modName, procName) | Resolves the exported DLL function for the given process.
@type pid: int
@param pid: Process global ID.
@type modName: str
@param modName: Name of the module that exports the function.
@type procName: str
@param procName: Name of the exported function to resolve.
... | 2.61669 | 3.063517 | 0.854146 |
'''Processes a command received from the Java side
@param cmd_id: the id of the command
@param seq: the sequence of the command
@param text: the text received in the command
'''
meaning = ID_TO_MEANING[str(cmd_id)]
# print('Handling %s (%s)' % (meaning, text))
... | def process_net_command(self, py_db, cmd_id, seq, text) | Processes a command received from the Java side
@param cmd_id: the id of the command
@param seq: the sequence of the command
@param text: the text received in the command | 3.132749 | 2.900964 | 1.079899 |
if self.PATTERN is not None:
PC = PatternCompiler()
self.pattern, self.pattern_tree = PC.compile_pattern(self.PATTERN,
with_tree=True) | def compile_pattern(self) | Compiles self.PATTERN into self.pattern.
Subclass may override if it doesn't want to use
self.{pattern,PATTERN} in .match(). | 7.273639 | 5.764741 | 1.261746 |
self.filename = filename
self.logger = logging.getLogger(filename) | def set_filename(self, filename) | Set the filename, and a logger derived from it.
The main refactoring tool should call this. | 5.231021 | 3.292988 | 1.588533 |
results = {"node": node}
return self.pattern.match(node, results) and results | def match(self, node) | Returns match for a given parse tree node.
Should return a true or false object (not necessarily a bool).
It may return a non-empty dict of matching sub-nodes as
returned by a matching pattern.
Subclass may override. | 11.814081 | 11.3139 | 1.044209 |
name = template
while name in self.used_names:
name = template + unicode(self.numbers.next())
self.used_names.add(name)
return name | def new_name(self, template=u"xxx_todo_changeme") | Return a string suitable for use as an identifier
The new name is guaranteed not to conflict with other identifiers. | 3.339953 | 3.345183 | 0.998437 |
lineno = node.get_lineno()
for_output = node.clone()
for_output.prefix = u""
msg = "Line %d: could not convert: %s"
self.log_message(msg % (lineno, for_output))
if reason:
self.log_message(reason) | def cannot_convert(self, node, reason=None) | Warn the user that a given chunk of code is not valid Python 3,
but that it cannot be converted automatically.
First argument is the top-level node for the code in question.
Optional second argument is why it can't be converted. | 5.240683 | 5.266394 | 0.995118 |
lineno = node.get_lineno()
self.log_message("Line %d: %s" % (lineno, reason)) | def warning(self, node, reason) | Used for warning the user about possible uncertainty in the
translation.
First argument is the top-level node for the code in question.
Optional second argument is why it can't be converted. | 5.568516 | 6.83004 | 0.815298 |
self.used_names = tree.used_names
self.set_filename(filename)
self.numbers = itertools.count(1)
self.first_log = True | def start_tree(self, tree, filename) | Some fixers need to maintain tree-wide state.
This method is called once, at the start of tree fix-up.
tree - the root node of the tree to be processed.
filename - the name of the file the tree came from. | 7.546579 | 8.295987 | 0.909666 |
if not arg:
Cmd.do_help(self, arg)
elif arg in ('?', 'help'):
# An easter egg :)
print(" Help! I need somebody...")
print(" Help! Not just anybody...")
print(" Help! You know, I need someone...")
print(" Heeelp!")
... | def do_help(self, arg) | ? - show the list of available commands
? * - show help for all commands
? <command> [command...] - show help for the given command(s)
help - show the list of available commands
help * - show help for all commands
help <command> [command...] - show help for the given command(s) | 4.176261 | 4.165642 | 1.002549 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
# Try to use the environment to locate cmd.exe.
# If not found, it's usually OK to just use the filename,
# since cmd.exe is one of those "magic" programs that
# can be automatically found by CreateProc... | def do_shell(self, arg) | ! - spawn a system shell
shell - spawn a system shell
! <command> [arguments...] - execute a single shell command
shell <command> [arguments...] - execute a single shell command | 7.189196 | 7.357313 | 0.97715 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
# When given a Python statement, execute it directly.
if arg:
try:
compat.exec_(arg, globals(), locals())
except Exception:
traceback.print_exc()
# When ... | def do_python(self, arg) | # - spawn a python interpreter
python - spawn a python interpreter
# <statement> - execute a single python statement
python <statement> - execute a single python statement | 4.993934 | 4.559108 | 1.095375 |
pos = arg.find(' ')
if pos < 0:
name = arg
arg = ''
else:
name = arg[:pos]
arg = arg[pos:].strip()
if not name:
raise CmdError("missing plugin name")
for c in name:
if c not in self.valid_plugin_na... | def do_plugin(self, arg) | [~prefix] .<name> [arguments] - run a plugin command
[~prefix] plugin <name> [arguments] - run a plugin command | 2.67499 | 2.646421 | 1.010796 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
if self.confirm_quit:
count = self.debug.get_debugee_count()
if count > 0:
if count == 1:
msg = "There... | def do_quit(self, arg) | quit - close the debugging session
q - close the debugging session | 4.5814 | 4.462795 | 1.026577 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
targets = self.input_process_list( self.split_tokens(arg, 1) )
if not targets:
print("Error: missing parameters")
else:
debug = self.debug
for pid in targets:
... | def do_attach(self, arg) | attach <target> [target...] - attach to the given process(es) | 6.068107 | 5.193901 | 1.168314 |
debug = self.debug
token_list = self.split_tokens(arg)
if self.cmdprefix:
token_list.insert(0, self.cmdprefix)
targets = self.input_process_list(token_list)
if not targets:
if self.lastEvent is None:
raise CmdError("no current pr... | def do_detach(self, arg) | [~process] detach - detach from the current process
detach - detach from the current process
detach <target> [target...] - detach from the given process(es) | 4.937323 | 4.754168 | 1.038525 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
cmdline = self.input_command_line(arg)
try:
process = self.debug.execl(arg,
bConsole = False,
bFollow = self.o... | def do_windowed(self, arg) | windowed <target> [arguments...] - run a windowed program for debugging | 11.351127 | 11.351222 | 0.999992 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
if self.debug.get_debugee_count() > 0:
return True | def do_continue(self, arg) | continue - continue execution
g - continue execution
go - continue execution | 8.737535 | 8.444255 | 1.034731 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
if self.lastEvent:
self.lastEvent.continueStatus = win32.DBG_EXCEPTION_HANDLED
return self.do_go(arg) | def do_gh(self, arg) | gh - go with exception handled | 9.382115 | 8.611788 | 1.08945 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
if self.lastEvent:
self.lastEvent.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED
return self.do_go(arg) | def do_gn(self, arg) | gn - go with exception not handled | 8.305348 | 7.447639 | 1.115165 |
if arg:
raise CmdError("too many arguments")
if self.cmdprefix:
process = self.get_process_from_prefix()
process.scan()
else:
self.debug.system.scan() | def do_refresh(self, arg) | refresh - refresh the list of running processes and threads
[~process] refresh - refresh the list of running threads | 12.473623 | 12.271358 | 1.016483 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
system = self.debug.system
pid_list = self.debug.get_debugee_pids()
if pid_list:
print("Process ID File name")
for pid... | def do_processlist(self, arg) | pl - show the processes being debugged
processlist - show the processes being debugged | 4.622039 | 4.412172 | 1.047566 |
if arg:
raise CmdError("too many arguments")
if self.cmdprefix:
process = self.get_process_from_prefix()
for thread in process.iter_threads():
tid = thread.get_tid()
name = thread.get_name()
print("%-12d %s" % ... | def do_threadlist(self, arg) | tl - show the threads being debugged
threadlist - show the threads being debugged | 2.952986 | 2.903291 | 1.017117 |
if arg:
if arg == '*':
target_pids = self.debug.get_debugee_pids()
target_tids = list()
else:
target_pids = set()
target_tids = set()
if self.cmdprefix:
pid, tid = self.get_proces... | def do_kill(self, arg) | [~process] kill - kill a process
[~thread] kill - kill a thread
kill - kill the current process
kill * - kill all debugged processes
kill <processes and/or threads...> - kill the given processes and threads | 2.0465 | 1.994722 | 1.025957 |
filename = self.split_tokens(arg, 1, 1)[0]
process = self.get_process_from_prefix()
try:
process.inject_dll(filename, bWait=False)
except RuntimeError:
print("Can't inject module: %r" % filename) | def do_modload(self, arg) | [~process] modload <filename.dll> - load a DLL module | 7.241227 | 6.228147 | 1.162662 |
if arg: # XXX TODO add depth parameter
raise CmdError("too many arguments")
pid, tid = self.get_process_and_thread_ids_from_prefix()
process = self.get_process(pid)
thread = process.get_thread(tid)
try:
stack_trace = th... | def do_stack(self, arg) | [~thread] k - show the stack trace
[~thread] stack - show the stack trace | 4.902039 | 4.79972 | 1.021318 |
debug = self.debug
system = debug.system
targets = self.input_process_list( self.split_tokens(arg) )
if not targets:
targets = debug.get_debugee_pids()
targets.sort()
if self.lastEvent:
current = self.lastEvent.get_pid()
els... | def do_break(self, arg) | break - force a debug break in all debugees
break <process> [process...] - force a debug break | 6.054867 | 4.795518 | 1.26261 |
if self.cmdprefix:
raise CmdError("prefix not allowed")
if self.lastEvent is None:
raise CmdError("no current process set")
if arg: # XXX this check is to be removed
raise CmdError("too many arguments")
pid = self.lastEvent.get_pid()
... | def do_step(self, arg) | p - step on the current assembly instruction
next - step on the current assembly instruction
step - step on the current assembly instruction | 6.036909 | 6.068768 | 0.99475 |
if arg: # XXX this check is to be removed
raise CmdError("too many arguments")
if self.lastEvent is None:
raise CmdError("no current thread set")
self.lastEvent.get_thread().set_tf()
return True | def do_trace(self, arg) | t - trace at the current assembly instruction
trace - trace at the current assembly instruction | 11.629194 | 11.671625 | 0.996365 |
pid = self.get_process_id_from_prefix()
if not self.debug.is_debugee(pid):
raise CmdError("target process is not being debugged")
process = self.get_process(pid)
token_list = self.split_tokens(arg, 1, 1)
try:
address = self.input_address(toke... | def do_bp(self, arg) | [~process] bp <address> - set a code breakpoint | 3.832656 | 3.616575 | 1.059747 |
debug = self.debug
thread = self.get_thread_from_prefix()
pid = thread.get_pid()
tid = thread.get_tid()
if not debug.is_debugee(pid):
raise CmdError("target thread is not being debugged")
token_list = self.split_tokens(arg, 3, 3... | def do_ba(self, arg) | [~thread] ba <a|w|e> <1|2|4|8> <address> - set hardware breakpoint | 2.390684 | 2.174804 | 1.099264 |
pid = self.get_process_id_from_prefix()
if not self.debug.is_debugee(pid):
raise CmdError("target process is not being debugged")
process = self.get_process(pid)
token_list = self.split_tokens(arg, 1, 2)
address, size = self.input_address_range(token... | def do_bm(self, arg) | [~process] bm <address-address> - set memory breakpoint | 6.260767 | 5.780157 | 1.083148 |
debug = self.debug
if arg == '*':
if self.cmdprefix:
raise CmdError("prefix not supported")
breakpoints = debug.get_debugee_pids()
else:
targets = self.input_process_list( self.split_tokens(arg) )
if self.cmdprefix:
... | def do_bl(self, arg) | bl - list the breakpoints for the current process
bl * - list the breakpoints for all processes
[~process] bl - list the breakpoints for the given process
bl <process> [process...] - list the breakpoints for each given process | 3.166676 | 3.066181 | 1.032775 |
token_list = self.split_tokens(arg, 1, 2)
pid, tid, address, size = self.input_breakpoint(token_list)
debug = self.debug
found = False
if size is None:
if tid is not None:
if debug.has_hardware_breakpoint(tid, address):
deb... | def do_bo(self, arg) | [~process] bo <address> - make a code breakpoint one-shot
[~thread] bo <address> - make a hardware breakpoint one-shot
[~process] bo <address-address> - make a memory breakpoint one-shot
[~process] bo <address> <size> - make a memory breakpoint one-shot | 3.223808 | 2.773718 | 1.162269 |
token_list = self.split_tokens(arg, 1, 2)
pid, tid, address, size = self.input_breakpoint(token_list)
debug = self.debug
found = False
if size is None:
if tid is not None:
if debug.has_hardware_breakpoint(tid, address):
deb... | def do_be(self, arg) | [~process] be <address> - enable a code breakpoint
[~thread] be <address> - enable a hardware breakpoint
[~process] be <address-address> - enable a memory breakpoint
[~process] be <address> <size> - enable a memory breakpoint | 3.173481 | 2.820529 | 1.125137 |
token_list = self.split_tokens(arg, 1, 2)
pid, tid, address, size = self.input_breakpoint(token_list)
debug = self.debug
found = False
if size is None:
if tid is not None:
if debug.has_hardware_breakpoint(tid, address):
deb... | def do_bd(self, arg) | [~process] bd <address> - disable a code breakpoint
[~thread] bd <address> - disable a hardware breakpoint
[~process] bd <address-address> - disable a memory breakpoint
[~process] bd <address> <size> - disable a memory breakpoint | 3.180134 | 2.773592 | 1.146576 |
token_list = self.split_tokens(arg, 1, 2)
pid, tid, address, size = self.input_breakpoint(token_list)
debug = self.debug
found = False
if size is None:
if tid is not None:
if debug.has_hardware_breakpoint(tid, address):
deb... | def do_bc(self, arg) | [~process] bc <address> - clear a code breakpoint
[~thread] bc <address> - clear a hardware breakpoint
[~process] bc <address-address> - clear a memory breakpoint
[~process] bc <address> <size> - clear a memory breakpoint | 3.939215 | 3.525669 | 1.117296 |
if not arg:
arg = self.default_disasm_target
token_list = self.split_tokens(arg, 1, 1)
pid, tid = self.get_process_and_thread_ids_from_prefix()
process = self.get_process(pid)
address = self.input_address(token_list[0], pid, tid)
... | def do_disassemble(self, arg) | [~thread] u [register] - show code disassembly
[~process] u [address] - show code disassembly
[~thread] disassemble [register] - show code disassembly
[~process] disassemble [address] - show code disassembly | 4.719364 | 4.813554 | 0.980432 |
token_list = self.split_tokens(arg, 1, 3)
pid, tid = self.get_process_and_thread_ids_from_prefix()
process = self.get_process(pid)
if len(token_list) == 1:
pattern = token_list[0]
minAddr = None
maxAddr = None
else:
pa... | def do_search(self, arg) | [~process] s [address-address] <search string>
[~process] search [address-address] <search string> | 4.560144 | 4.473945 | 1.019267 |
token_list = self.split_tokens(arg, 1, 3)
pid, tid = self.get_process_and_thread_ids_from_prefix()
process = self.get_process(pid)
if len(token_list) == 1:
pattern = token_list[0]
minAddr = None
maxAddr = None
else:
pa... | def do_searchhex(self, arg) | [~process] sh [address-address] <hexadecimal pattern>
[~process] searchhex [address-address] <hexadecimal pattern> | 4.232282 | 4.13778 | 1.022839 |
self.print_memory_display(arg, HexDump.hexblock)
self.last_display_command = self.do_db | def do_db(self, arg) | [~thread] db <register> - show memory contents as bytes
[~thread] db <register-register> - show memory contents as bytes
[~thread] db <register> <size> - show memory contents as bytes
[~process] db <address> - show memory contents as bytes
[~process] db <address-address> - show memory co... | 22.260674 | 17.993042 | 1.237182 |
self.print_memory_display(arg, HexDump.hexblock_word)
self.last_display_command = self.do_dw | def do_dw(self, arg) | [~thread] dw <register> - show memory contents as words
[~thread] dw <register-register> - show memory contents as words
[~thread] dw <register> <size> - show memory contents as words
[~process] dw <address> - show memory contents as words
[~process] dw <address-address> - show memory co... | 21.69585 | 19.154648 | 1.132668 |
self.print_memory_display(arg, HexDump.hexblock_dword)
self.last_display_command = self.do_dd | def do_dd(self, arg) | [~thread] dd <register> - show memory contents as dwords
[~thread] dd <register-register> - show memory contents as dwords
[~thread] dd <register> <size> - show memory contents as dwords
[~process] dd <address> - show memory contents as dwords
[~process] dd <address-address> - show memor... | 24.371901 | 20.700834 | 1.177339 |
self.print_memory_display(arg, HexDump.hexblock_qword)
self.last_display_command = self.do_dq | def do_dq(self, arg) | [~thread] dq <register> - show memory contents as qwords
[~thread] dq <register-register> - show memory contents as qwords
[~thread] dq <register> <size> - show memory contents as qwords
[~process] dq <address> - show memory contents as qwords
[~process] dq <address-address> - show memor... | 22.768003 | 17.927227 | 1.270024 |
if not arg:
arg = self.default_display_target
token_list = self.split_tokens(arg, 1, 2)
pid, tid, address, size = self.input_display(token_list, 256)
process = self.get_process(pid)
data = process.peek_string(ad... | def do_du(self, arg) | [~thread] du <register> - show memory contents as Unicode string
[~process] du <address> - show memory contents as Unicode string | 7.459835 | 7.048138 | 1.058412 |
arg = arg.strip()
if not arg:
self.print_current_location()
else:
equ = arg.find('=')
if equ >= 0:
register = arg[:equ].strip()
value = arg[equ+1:].strip()
if not value:
value = '0... | def do_register(self, arg) | [~thread] r - print(the value of all registers
[~thread] r <register> - print(the value of a register
[~thread] r <register>=<value> - change the value of a register
[~thread] register - print(the value of all registers
[~thread] register <register> - print(the value of a register
... | 3.196847 | 3.048238 | 1.048752 |
# TODO
# data parameter should be optional, use a child Cmd here
pid = self.get_process_id_from_prefix()
token_list = self.split_tokens(arg, 2)
address = self.input_address(token_list[0], pid)
data = HexInput.hexadecimal(' '.join(token_list[1:]))
... | def do_eb(self, arg) | [~process] eb <address> <data> - write the data to the specified address | 9.543846 | 8.000341 | 1.19293 |
if not arg:
raise CmdError("missing parameter: string")
process = self.get_process_from_prefix()
self.find_in_memory(arg, process) | def do_find(self, arg) | [~process] f <string> - find the string in the process memory
[~process] find <string> - find the string in the process memory | 8.864985 | 6.248042 | 1.418842 |
if arg: # TODO: take min and max addresses
raise CmdError("too many arguments")
process = self.get_process_from_prefix()
try:
memoryMap = process.get_memory_map()
mappedFilenames = process.get_mapped_filenames()
print('')
... | def do_memory(self, arg) | [~process] m - show the process memory map
[~process] memory - show the process memory map | 6.453087 | 6.109145 | 1.0563 |
regexp = r"[\s\w\!\@\#\$\%%\^\&\*\(\)\{\}\[\]\~\`\'\"\:\;\.\,\\\/\-\+\=\_\<\>]{%d,%d}\0" % (minSize, maxSize)
pattern = RegExpPattern(regexp, 0, maxSize)
return cls.search_process(process, pattern, overlapping = False) | def extract_ascii_strings(cls, process, minSize = 4, maxSize = 1024) | Extract ASCII strings from the process memory.
@type process: L{Process}
@param process: Process to search.
@type minSize: int
@param minSize: (Optional) Minimum size of the strings to search for.
@type maxSize: int
@param maxSize: (Optional) Maximum size of the str... | 8.457902 | 8.465055 | 0.999155 |
token = token.strip()
neg = False
if token.startswith(compat.b('-')):
token = token[1:]
neg = True
if token.startswith(compat.b('0x')):
result = int(token, 16) # hexadecimal
elif token.startswith(compat.b('0b')):
result... | def integer(token) | Convert numeric strings into integers.
@type token: str
@param token: String to parse.
@rtype: int
@return: Parsed integer value. | 2.179963 | 2.358345 | 0.924361 |
token = ''.join([ c for c in token if c.isalnum() ])
if len(token) % 2 != 0:
raise ValueError("Missing characters in hex data")
data = ''
for i in compat.xrange(0, len(token), 2):
x = token[i:i+2]
d = int(x, 16)
s = struct.pack('<B... | def hexadecimal(token) | Convert a strip of hexadecimal numbers into binary data.
@type token: str
@param token: String to parse.
@rtype: str
@return: Parsed string value. | 3.111413 | 3.412826 | 0.911682 |
token = ''.join([ c for c in token if c == '?' or c.isalnum() ])
if len(token) % 2 != 0:
raise ValueError("Missing characters in hex data")
regexp = ''
for i in compat.xrange(0, len(token), 2):
x = token[i:i+2]
if x == '??':
re... | def pattern(token) | Convert an hexadecimal search pattern into a POSIX regular expression.
For example, the following pattern::
"B8 0? ?0 ?? ??"
Would match the following data::
"B8 0D F0 AD BA" # mov eax, 0xBAADF00D
@type token: str
@param token: String to parse.
@... | 2.487922 | 2.567324 | 0.969072 |
count = 0
result = list()
fd = open(filename, 'r')
for line in fd:
count = count + 1
if '#' in line:
line = line[ : line.find('#') ]
line = line.strip()
if line:
try:
value =... | def integer_list_file(cls, filename) | Read a list of integers from a file.
The file format is:
- # anywhere in the line begins a comment
- leading and trailing spaces are ignored
- empty lines are ignored
- integers can be specified as:
- decimal numbers ("100" is 100)
- hexadecimal numb... | 2.361027 | 2.328337 | 1.01404 |
count = 0
result = list()
fd = open(filename, 'r')
for line in fd:
count = count + 1
if '#' in line:
line = line[ : line.find('#') ]
line = line.strip()
if line:
result.append(line)
retu... | def string_list_file(cls, filename) | Read a list of string values from a file.
The file format is:
- # anywhere in the line begins a comment
- leading and trailing spaces are ignored
- empty lines are ignored
- strings cannot span over a single line
@type filename: str
@param filename: Name o... | 2.808658 | 2.92806 | 0.959222 |
count = 0
result = list()
fd = open(filename, 'r')
for line in fd:
count = count + 1
if '#' in line:
line = line[ : line.find('#') ]
line = line.strip()
if line:
try:
value =... | def mixed_list_file(cls, filename) | Read a list of mixed values from a file.
The file format is:
- # anywhere in the line begins a comment
- leading and trailing spaces are ignored
- empty lines are ignored
- strings cannot span over a single line
- integers can be specified as:
- decimal... | 2.82292 | 2.710015 | 1.041662 |
fd = open(filename, 'w')
for integer in values:
print >> fd, cls.integer(integer, bits)
fd.close() | def integer_list_file(cls, filename, values, bits = None) | Write a list of integers to a file.
If a file of the same name exists, it's contents are replaced.
See L{HexInput.integer_list_file} for a description of the file format.
@type filename: str
@param filename: Name of the file to write.
@type values: list( int )
@param... | 3.447653 | 4.932597 | 0.698953 |
fd = open(filename, 'w')
for string in values:
print >> fd, string
fd.close() | def string_list_file(cls, filename, values) | Write a list of strings to a file.
If a file of the same name exists, it's contents are replaced.
See L{HexInput.string_list_file} for a description of the file format.
@type filename: str
@param filename: Name of the file to write.
@type values: list( int )
@param v... | 3.34281 | 4.366379 | 0.765579 |
fd = open(filename, 'w')
for original in values:
try:
parsed = cls.integer(original, bits)
except TypeError:
parsed = repr(original)
print >> fd, parsed
fd.close() | def mixed_list_file(cls, filename, values, bits) | Write a list of mixed values to a file.
If a file of the same name exists, it's contents are replaced.
See L{HexInput.mixed_list_file} for a description of the file format.
@type filename: str
@param filename: Name of the file to write.
@type values: list( int )
@par... | 4.370362 | 4.897726 | 0.892325 |
if bits is None:
integer_size = cls.integer_size
else:
integer_size = bits / 4
return ('%%.%dX' % integer_size) % integer | def integer(cls, integer, bits = None) | @type integer: int
@param integer: Integer.
@type bits: int
@param bits:
(Optional) Number of bits of the target architecture.
The default is platform dependent. See: L{HexDump.integer_size}
@rtype: str
@return: Text output. | 4.508957 | 4.369969 | 1.031805 |
if bits is None:
address_size = cls.address_size
bits = win32.bits
else:
address_size = bits / 4
if address < 0:
address = ((2 ** bits) - 1) ^ ~address
return ('%%.%dX' % address_size) % address | def address(cls, address, bits = None) | @type address: int
@param address: Memory address.
@type bits: int
@param bits:
(Optional) Number of bits of the target architecture.
The default is platform dependent. See: L{HexDump.address_size}
@rtype: str
@return: Text output. | 4.539839 | 5.13328 | 0.884393 |
result = ''
for c in data:
if 32 < ord(c) < 128:
result += c
else:
result += '.'
return result | def printable(data) | Replace unprintable characters with dots.
@type data: str
@param data: Binary data.
@rtype: str
@return: Printable text. | 2.639295 | 2.769842 | 0.952868 |
if len(data) & 1 != 0:
data += '\0'
return separator.join( [ '%.4x' % struct.unpack('<H', data[i:i+2])[0] \
for i in compat.xrange(0, len(data), 2) ] ) | def hexa_word(data, separator = ' ') | Convert binary data to a string of hexadecimal WORDs.
@type data: str
@param data: Binary data.
@type separator: str
@param separator:
Separator between the hexadecimal representation of each WORD.
@rtype: str
@return: Hexadecimal representation. | 3.553702 | 3.95213 | 0.899187 |
if width is None:
fmt = '%s %s'
else:
fmt = '%%-%ds %%-%ds' % ((len(separator)+2)*width-1, width)
return fmt % (cls.hexadecimal(data, separator), cls.printable(data)) | def hexline(cls, data, separator = ' ', width = None) | Dump a line of hexadecimal numbers from binary data.
@type data: str
@param data: Binary data.
@type separator: str
@param separator:
Separator between the hexadecimal representation of each character.
@type width: int
@param width:
(Optional... | 4.150184 | 4.524233 | 0.917323 |
return cls.hexblock_cb(cls.hexline, data, address, bits, width,
cb_kwargs = {'width' : width, 'separator' : separator}) | def hexblock(cls, data, address = None,
bits = None,
separator = ' ',
width = 8) | Dump a block of hexadecimal numbers from binary data.
Also show a printable text version of the data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
... | 7.491674 | 12.590785 | 0.595012 |
result = ''
if address is None:
for i in compat.xrange(0, len(data), width):
result = '%s%s\n' % ( result, \
callback(data[i:i+width], *cb_args, **cb_kwargs) )
else:
for i in compat.xrange(0, len(data), width):
... | def hexblock_cb(cls, callback, data, address = None,
bits = None,
width = 16,
cb_args = (),
... | Dump a block of binary data using a callback function to convert each
line of text.
@type callback: function
@param callback: Callback function to convert each line of data.
@type data: str
@param data: Binary data.
@type address: str
@param address:
... | 2.370048 | 2.350421 | 1.00835 |
return cls.hexblock_cb(cls.hexadecimal, data,
address, bits, width,
cb_kwargs = {'separator': separator}) | def hexblock_byte(cls, data, address = None,
bits = None,
separator = ' ',
width = 16) | Dump a block of hexadecimal BYTEs from binary data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
(Optional) Number of bits of the target architectur... | 9.890942 | 19.332741 | 0.511616 |
return cls.hexblock_cb(cls.hexa_word, data,
address, bits, width * 2,
cb_kwargs = {'separator': separator}) | def hexblock_word(cls, data, address = None,
bits = None,
separator = ' ',
width = 8) | Dump a block of hexadecimal WORDs from binary data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
(Optional) Number of bits of the target architectur... | 7.881301 | 15.234759 | 0.517324 |
return cls.hexblock_cb(cls.hexa_dword, data,
address, bits, width * 4,
cb_kwargs = {'separator': separator}) | def hexblock_dword(cls, data, address = None,
bits = None,
separator = ' ',
width = 4) | Dump a block of hexadecimal DWORDs from binary data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
(Optional) Number of bits of the target architectu... | 8.293122 | 15.262896 | 0.543352 |
return cls.hexblock_cb(cls.hexa_qword, data,
address, bits, width * 8,
cb_kwargs = {'separator': separator}) | def hexblock_qword(cls, data, address = None,
bits = None,
separator = ' ',
width = 2) | Dump a block of hexadecimal QWORDs from binary data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
(Optional) Number of bits of the target architectu... | 7.721819 | 14.163063 | 0.545208 |
"Make the current foreground color the default."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_GREY
wAttributes &= ~win32.FOREGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def default(cls) | Make the current foreground color the default. | 5.486552 | 3.938318 | 1.393121 |
"Make the current foreground color light."
wAttributes = cls._get_text_attributes()
wAttributes |= win32.FOREGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def light(cls) | Make the current foreground color light. | 7.223266 | 5.326673 | 1.356056 |
"Make the current foreground color dark."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def dark(cls) | Make the current foreground color dark. | 6.190283 | 4.914375 | 1.259628 |
"Make the text foreground color black."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
#wAttributes |= win32.FOREGROUND_BLACK
cls._set_text_attributes(wAttributes) | def black(cls) | Make the text foreground color black. | 6.137335 | 4.545821 | 1.350105 |
"Make the text foreground color white."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_GREY
cls._set_text_attributes(wAttributes) | def white(cls) | Make the text foreground color white. | 6.617305 | 4.762043 | 1.389594 |
"Make the text foreground color red."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_RED
cls._set_text_attributes(wAttributes) | def red(cls) | Make the text foreground color red. | 5.606267 | 4.372968 | 1.282028 |
"Make the text foreground color green."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_GREEN
cls._set_text_attributes(wAttributes) | def green(cls) | Make the text foreground color green. | 5.649049 | 4.440978 | 1.272028 |
"Make the text foreground color blue."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_BLUE
cls._set_text_attributes(wAttributes) | def blue(cls) | Make the text foreground color blue. | 5.770201 | 4.453809 | 1.295565 |
"Make the text foreground color cyan."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_CYAN
cls._set_text_attributes(wAttributes) | def cyan(cls) | Make the text foreground color cyan. | 5.168585 | 4.106375 | 1.258673 |
"Make the text foreground color magenta."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_MAGENTA
cls._set_text_attributes(wAttributes) | def magenta(cls) | Make the text foreground color magenta. | 4.82505 | 3.789796 | 1.273169 |
"Make the text foreground color yellow."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_YELLOW
cls._set_text_attributes(wAttributes) | def yellow(cls) | Make the text foreground color yellow. | 5.43057 | 4.277057 | 1.269698 |
"Make the current background color the default."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
#wAttributes |= win32.BACKGROUND_BLACK
wAttributes &= ~win32.BACKGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def bk_default(cls) | Make the current background color the default. | 7.473096 | 5.602285 | 1.333937 |
"Make the current background color light."
wAttributes = cls._get_text_attributes()
wAttributes |= win32.BACKGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def bk_light(cls) | Make the current background color light. | 10.845073 | 7.983802 | 1.358384 |
"Make the current background color dark."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_INTENSITY
cls._set_text_attributes(wAttributes) | def bk_dark(cls) | Make the current background color dark. | 9.710561 | 7.614404 | 1.275288 |
"Make the text background color black."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
#wAttributes |= win32.BACKGROUND_BLACK
cls._set_text_attributes(wAttributes) | def bk_black(cls) | Make the text background color black. | 7.930103 | 6.031274 | 1.314831 |
"Make the text background color white."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_GREY
cls._set_text_attributes(wAttributes) | def bk_white(cls) | Make the text background color white. | 8.390385 | 6.510009 | 1.288844 |
"Make the text background color red."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_RED
cls._set_text_attributes(wAttributes) | def bk_red(cls) | Make the text background color red. | 7.796091 | 5.916282 | 1.317735 |
"Make the text background color green."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_GREEN
cls._set_text_attributes(wAttributes) | def bk_green(cls) | Make the text background color green. | 7.530281 | 5.82849 | 1.291978 |
"Make the text background color blue."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_BLUE
cls._set_text_attributes(wAttributes) | def bk_blue(cls) | Make the text background color blue. | 7.689205 | 5.960921 | 1.289936 |
"Make the text background color cyan."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_CYAN
cls._set_text_attributes(wAttributes) | def bk_cyan(cls) | Make the text background color cyan. | 6.927915 | 5.343414 | 1.296533 |
"Make the text background color magenta."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_MAGENTA
cls._set_text_attributes(wAttributes) | def bk_magenta(cls) | Make the text background color magenta. | 6.62059 | 5.261853 | 1.258224 |
"Make the text background color yellow."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_YELLOW
cls._set_text_attributes(wAttributes) | def bk_yellow(cls) | Make the text background color yellow. | 7.587292 | 5.742587 | 1.321233 |
row = [ str(item) for item in row ]
len_row = [ len(item) for item in row ]
width = self.__width
len_old = len(width)
len_new = len(row)
known = min(len_old, len_new)
missing = len_new - len_old
if missing > 0:
width.extend( le... | def addRow(self, *row) | Add a row to the table. All items are converted to strings.
@type row: tuple
@keyword row: Each argument is a cell in the table. | 3.294915 | 3.701823 | 0.890079 |
if direction == -1:
self.__width[column] = abs(self.__width[column])
elif direction == 1:
self.__width[column] = - abs(self.__width[column])
else:
raise ValueError("Bad direction value.") | def justify(self, column, direction) | Make the text in a column left or right justified.
@type column: int
@param column: Index of the column.
@type direction: int
@param direction:
C{-1} to justify left,
C{1} to justify right.
@raise IndexError: Bad column index.
@raise ValueErro... | 3.393101 | 3.396641 | 0.998958 |
width = 0
if self.__width:
width = sum( abs(x) for x in self.__width )
width = width + len(self.__width) * len(self.__sep) + 1
return width | def getWidth(self) | Get the width of the text output for the table.
@rtype: int
@return: Width in characters for the text output,
including the newline character. | 4.97542 | 5.349918 | 0.929999 |
width = self.__width
if width:
num_cols = len(width)
fmt = ['%%%ds' % -w for w in width]
if width[-1] > 0:
fmt[-1] = '%s'
fmt = self.__sep.join(fmt)
for row in self.__cols:
row.extend( [''] * (num_cols -... | def yieldOutput(self) | Generate the text output for the table.
@rtype: generator of str
@return: Text output. | 4.037352 | 4.120397 | 0.979845 |
if efl is None:
return ''
efl_dump = 'iopl=%1d' % ((efl & 0x3000) >> 12)
if efl & 0x100000:
efl_dump += ' vip'
else:
efl_dump += ' '
if efl & 0x80000:
efl_dump += ' vif'
else:
efl_dump += ' '
... | def dump_flags(efl) | Dump the x86 processor flags.
The output mimics that of the WinDBG debugger.
Used by L{dump_registers}.
@type efl: int
@param efl: Value of the eFlags register.
@rtype: str
@return: Text suitable for logging. | 2.140775 | 2.166593 | 0.988083 |
if registers is None:
return ''
if arch is None:
if 'Eax' in registers:
arch = win32.ARCH_I386
elif 'Rax' in registers:
arch = win32.ARCH_AMD64
else:
arch = 'Unknown'
if arch not in cls.reg_t... | def dump_registers(cls, registers, arch = None) | Dump the x86/x64 processor register values.
The output mimics that of the WinDBG debugger.
@type registers: dict( str S{->} int )
@param registers: Dictionary mapping register names to their values.
@type arch: str
@param arch: Architecture of the machine whose registers were... | 3.737981 | 3.377694 | 1.106667 |
if None in (registers, data):
return ''
names = compat.keys(data)
names.sort()
result = ''
for reg_name in names:
tag = reg_name.lower()
dumped = HexDump.hexline(data[reg_name], separator, width)
result += '%s -> %s\n'... | def dump_registers_peek(registers, data, separator = ' ', width = 16) | Dump data pointed to by the given registers, if any.
@type registers: dict( str S{->} int )
@param registers: Dictionary mapping register names to their values.
This value is returned by L{Thread.get_context}.
@type data: dict( str S{->} str )
@param data: Dictionary mapp... | 5.085072 | 5.825955 | 0.872831 |
if data is None:
return ''
pointers = compat.keys(data)
pointers.sort()
result = ''
for offset in pointers:
dumped = HexDump.hexline(data[offset], separator, width)
address = HexDump.address(base + offset, bits)
result += ... | def dump_data_peek(data, base = 0,
separator = ' ',
width = 16,
bits = None) | Dump data from pointers guessed within the given binary data.
@type data: str
@param data: Dictionary mapping offsets to the data they point to.
@type base: int
@param base: Base offset.
@type bits: int
@param bits:
(Optional) Number of bits of the targe... | 4.806454 | 4.154575 | 1.156906 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.