Sort imports

This commit is contained in:
Zach Riggle 2015-04-13 16:22:08 -04:00
parent b6ac73a0e7
commit 1b36cbc5a3
49 changed files with 179 additions and 137 deletions

View File

@ -8,4 +8,3 @@ directory = path.abspath(directory)
sys.path.append(directory)
import pwndbg

View File

@ -1,7 +1,10 @@
import xmlrpclib
import threading
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
import idc, idautils, idaapi
import idaapi
import idautils
import idc
xmlrpclib.Marshaller.dispatch[type(0L)] = lambda _, v, w: w("<value><i8>%d</i8></value>" % v)
xmlrpclib.Marshaller.dispatch[type(0)] = lambda _, v, w: w("<value><i8>%d</i8></value>" % v)

View File

@ -1,8 +1,9 @@
import struct
import sys
import gdb
import pwndbg.memoize
import pwndbg.events
import pwndbg.memoize
import pwndbg.typeinfo
current = 'i386'
@ -39,4 +40,4 @@ def pack(integer):
return struct.pack(fmt, integer & ptrmask)
def unpack(data):
return struct.unpack(fmt, data)[0]
return struct.unpack(fmt, data)[0]

View File

@ -1,12 +1,12 @@
import gdb
import sys
import pwndbg.memory
import gdb
import pwndbg.arch
import pwndbg.events
import pwndbg.info
import pwndbg.memory
import pwndbg.regs
import pwndbg.typeinfo
import pwndbg.arch
example_info_auxv_linux = """
33 AT_SYSINFO_EHDR System-supplied DSO's ELF header 0x7ffff7ffa000

View File

@ -2,9 +2,9 @@ import gdb
import pwndbg.color
import pwndbg.enhance
import pwndbg.memory
import pwndbg.symbol
import pwndbg.typeinfo
import pwndbg.vmmap
import pwndbg.symbol
LIMIT = 5
@ -58,4 +58,4 @@ def format(value):
if len(chain) == 1:
return enhanced
return ' --> '.join(rest) + ' <-- ' + enhanced
return ' --> '.join(rest) + ' <-- ' + enhanced

View File

@ -1,2 +1,3 @@
import gdb
import subprocess
import gdb

View File

@ -1,7 +1,8 @@
import gdb
import pwndbg.commands
import pwndbg.chain
import pwndbg.auxv
import pwndbg.chain
import pwndbg.commands
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning

View File

@ -1,16 +1,17 @@
import gdb
import pwndbg.commands
import pwndbg.color
import pwndbg.vmmap
import pwndbg.symbol
import pwndbg.regs
import pwndbg.ui
import pwndbg.disasm
import pwndbg.chain
import pwndbg.commands.telescope
import pwndbg.color
import pwndbg.commands
import pwndbg.commands.nearpc
import pwndbg.commands.telescope
import pwndbg.disasm
import pwndbg.events
import pwndbg.ida
import pwndbg.regs
import pwndbg.symbol
import pwndbg.ui
import pwndbg.vmmap
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning

View File

@ -1,8 +1,9 @@
import gdb
import pwndbg.vmmap
import pwndbg.commands
import pwndbg.color
import pwndbg.commands
import pwndbg.dt
import pwndbg.vmmap
@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning

View File

@ -1,7 +1,8 @@
import pwndbg.regs
import pwndbg.commands
import pwndbg.memory
import pwndbg.hexdump
import pwndbg.memory
import pwndbg.regs
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
@ -24,4 +25,3 @@ def hexdump(address=None, count=64):
for line in pwndbg.hexdump.hexdump(data, address=address):
print(line)

View File

@ -1,8 +1,9 @@
import gdb
import pwndbg.ida
import pwndbg.commands
import pwndbg.ida
import pwndbg.regs
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
def j(*args):
@ -19,4 +20,4 @@ class ida(gdb.Function):
def invoke(self, name):
return pwndbg.ida.LocByName(name.string())
ida()
ida()

View File

@ -1,10 +1,11 @@
import pwndbg.regs
import pwndbg.ui
import pwndbg.symbol
import pwndbg.vmmap
import pwndbg.disasm
import pwndbg.color
import pwndbg.disasm
import pwndbg.ida
import pwndbg.regs
import pwndbg.symbol
import pwndbg.ui
import pwndbg.vmmap
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
@ -64,4 +65,4 @@ def nearpc(pc=None, lines=None, to_string=False):
if not to_string:
print('\n'.join(result))
return result
return result

View File

@ -1,4 +1,6 @@
import struct
import gdb
def pack(data, size=None):

View File

@ -6,10 +6,12 @@ import imp
import os
import sys
import types
import gdb
import pwndbg.events
import pwndbg.commands
import pwndbg
import pwndbg.commands
import pwndbg.events
def rreload(module, mdict=None):
"""Recursively reload modules."""
@ -35,4 +37,3 @@ def reload(*a):
pwndbg.events.on_reload()
rreload(pwndbg)
pwndbg.events.after_reload()

View File

@ -1,7 +1,9 @@
import os
import gdb
import pwndbg.commands
@pwndbg.commands.Command
def rop(start=None, stop=None):
"""
@ -17,4 +19,4 @@ def rop(start=None, stop=None):
'--rawMode=32',
'--binary=dump',
'--offset=0xdeadbeef']
os.system(' '.join(cmd))
os.system(' '.join(cmd))

View File

@ -1,13 +1,16 @@
from __future__ import print_function
import gdb
import os
import struct
import pwndbg.commands
import pwndbg.search
import pwndbg.enhance
import gdb
import pwndbg.color
import pwndbg.commands
import pwndbg.enhance
import pwndbg.search
import pwndbg.vmmap
@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def search(value):
@ -26,4 +29,4 @@ def search(value):
region = pwndbg.color.get(address, region)
addr = pwndbg.color.get(address)
display = pwndbg.enhance.enhance(address)
print(region,addr,display)
print(region,addr,display)

View File

@ -1,5 +1,6 @@
import gdb
import os
import gdb
import pwndbg.commands
shellcmds = [

View File

@ -2,6 +2,7 @@ import gdb
import pwndbg.commands
import pwndbg.symbol
@pwndbg.commands.ParsedCommand
def start():
symbols = ["main",

View File

@ -1,8 +1,9 @@
import pwndbg.chain
import pwndbg.commands
import pwndbg.memory
import pwndbg.regs
import pwndbg.typeinfo
import pwndbg.commands
import pwndbg.chain
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning

View File

@ -1,7 +1,8 @@
import gdb
import pwndbg.vmmap
import pwndbg.commands
import pwndbg.color
import pwndbg.commands
import pwndbg.vmmap
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning

View File

@ -1,11 +1,13 @@
import codecs
import gdb
import math
import gdb
import pwndbg.arch
import pwndbg.commands
import pwndbg.memory
import pwndbg.typeinfo
import pwndbg.strings
import pwndbg.typeinfo
def get_type(size):
return {

View File

@ -1,10 +1,11 @@
import gdb
import collections
import gdb
import pwndbg.arch
import pwndbg.color
import pwndbg.disasm_powerpc
import pwndbg.memory
import pwndbg.arch
import pwndbg.ida
import pwndbg.memory
import pwndbg.symbol
Instruction = collections.namedtuple('Instruction', ['address', 'length', 'asm'])
@ -130,4 +131,4 @@ def color(ins):
if mnem in branches:
asm = pwndbg.color.yellow(asm)
asm += '\n'
return asm
return asm

View File

@ -97,4 +97,4 @@ powerpc = """
bzlr+ bzlr- bzlrl+ bzlrl-
""".strip().split()
branches = set(map(lambda x: x.rstrip('+-'), powerpc))
branches = set(map(lambda x: x.rstrip('+-'), powerpc))

View File

@ -1,15 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gdb
import glob
import os
import re
import subprocess
import tempfile
import gdb
import pwndbg.memory
import pwndbg.typeinfo
def get_type(v):
t = v.type
while not t.name:

View File

@ -8,18 +8,19 @@ This is necessary for when access to /proc is restricted, or when
working on a BSD system which simply does not have /proc.
"""
from __future__ import print_function
import gdb
import os
import re
import subprocess
import tempfile
import gdb
import pwndbg.auxv
import pwndbg.events
import pwndbg.info
import pwndbg.memory
import pwndbg.memoize
import pwndbg.memory
import pwndbg.stack
import pwndbg.auxv
import pwndbg.typeinfo
# ELF constants
@ -283,4 +284,4 @@ def map_inner(ei_class, ehdr, objfile):
@pwndbg.events.stop
def update_main_exe():
addr = int(exe().address)
map(addr)
map(addr)

View File

@ -1,14 +1,14 @@
import gdb
import string
import pwndbg.symbol
import pwndbg.memory
import gdb
import pwndbg.arch
import pwndbg.color
import pwndbg.typeinfo
import pwndbg.strings
import pwndbg.disasm
import pwndbg.memoize
import pwndbg.arch
import string
import pwndbg.memory
import pwndbg.strings
import pwndbg.symbol
import pwndbg.typeinfo
bad_instrs = [
'.byte',
@ -134,4 +134,4 @@ def enhance(value):
if len(retval) == 1:
return retval[0]
return retval[0] + ' /* {} */'.format('; '.join(retval[1:]))
return retval[0] + ' /* {} */'.format('; '.join(retval[1:]))

View File

@ -1,6 +1,7 @@
import gdb
import traceback
import gdb
debug = False
pause = 0
@ -52,4 +53,4 @@ def on_reload():
for event, functions in registered.items():
for function in functions:
event.disconnect(function)
registered[event] = []
registered[event] = []

View File

@ -1,8 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tempfile
import gdb
import pwndbg.remote
import tempfile
def get(path):
"""
@ -25,5 +27,3 @@ def get(path):
with open(local_path,'rb') as f:
return f.read()

View File

@ -1,9 +1,9 @@
import gdb
import pwndbg.typeinfo
import pwndbg.arch
import pwndbg.typeinfo
import pwndbg.regs
import pwndbg.memory
import pwndbg.regs
import pwndbg.typeinfo
def arguments():
"""
@ -33,4 +33,4 @@ def argument(n):
sp = pwndbg.regs.sp + (n * pwndbg.arch.ptrsize)
return int(pwndbg.memory.poi(pwndbg.typeinfo.ppvoid, sp))
return int(pwndbg.memory.poi(pwndbg.typeinfo.ppvoid, sp))

View File

@ -1,9 +1,10 @@
import gdb
import platform
import pwndbg.arch
import collections
import glob
import os
import collections
import platform
import gdb
import pwndbg.arch
def flags():
@ -72,5 +73,3 @@ def which_binutils(util, **kwargs):
res = sorted(glob.glob(os.path.join(dir, pattern)))
if res:
return res[0]

View File

@ -1,5 +1,6 @@
import copy
import string
import pwndbg.color
@ -80,4 +81,3 @@ def hexdump(data, address = 0, width = 16, skip = True):
hexline.append("%#08x " % (base + len(data)))
yield ''.join(hexline)

View File

@ -1,13 +1,14 @@
import gdb
import pwndbg.memory
import pwndbg.events
import pwndbg.regs
import pwndbg.memoize
import pwndbg.elf
import pwndbg.arch
import socket
from contextlib import closing
import gdb
import pwndbg.arch
import pwndbg.elf
import pwndbg.events
import pwndbg.memoize
import pwndbg.memory
import pwndbg.regs
try:
import xmlrpc.client as xmlrpclib
except:
@ -214,4 +215,4 @@ def isASCII(flags):
@withIDA
@pwndbg.memoize.reset_on_objfile
def isFunc(flags):
return _ida.isASCII(flags)
return _ida.isASCII(flags)

View File

@ -1,7 +1,7 @@
import gdb
import pwndbg.memoize
@pwndbg.memoize.reset_on_exit
def proc_mapping():
try:

View File

@ -1,8 +1,9 @@
# This hook is necessary for compatibility with Python2.7 versions of GDB
# since they cannot directly cast to integer a gdb.Value object that is
# not already an integer type.
import gdb
import sys
import gdb
import pwndbg.typeinfo
if sys.version_info < (3,0):

View File

@ -1,9 +1,10 @@
from __future__ import print_function
import gdb
import pwndbg.elf
import pwndbg.events
import pwndbg.memoize
import pwndbg.memory
import pwndbg.elf
@pwndbg.events.new_objfile
@ -24,4 +25,4 @@ def find():
# pwntools/binjitsu. See the documentation there:
#
# - https://github.com/binjitsu/binjitsu/blob/master/pwnlib/dynelf.py
#
#

View File

@ -15,4 +15,4 @@ def chunk2mem(p):
def mem2chunk(mem):
"conversion from user pointer to malloc header"
return p + (2-pwndbg.arch.ptrsize)
return p + (2-pwndbg.arch.ptrsize)

View File

@ -1,12 +1,14 @@
from __future__ import print_function
import copy
import collections
import gdb
import copy
import functools
import sys
import gdb
import pwndbg.events
class memoize(object):
def __call__(self, *args):
if not isinstance(args, collections.Hashable):
@ -80,4 +82,3 @@ class reset_on_objfile(memoize):
def __reset():
for obj in reset_on_objfile.caches:
obj.clear()

View File

@ -149,4 +149,4 @@ class Page(object):
def __lt__(self, other):
return self.vaddr < getattr(other, 'vaddr', other)
def __hash__(self):
return hash((self.vaddr, self.memsz, self.flags, self.offset, self.objfile))
return hash((self.vaddr, self.memsz, self.flags, self.offset, self.objfile))

View File

@ -2,10 +2,11 @@ import gdb
import pwndbg.disasm
import pwndbg.regs
def next_branch(callback, address=None):
if address is None:
address = pwndbg.regs.pc
# Disassemble forward until we find *any* branch instruction
# Set a temporary, internal breakpoint on it so the user is
# not bothered.
# not bothered.

View File

@ -1,9 +1,10 @@
import gdb
import sys
from types import ModuleType
import gdb
import pwndbg.memoize
class module(ModuleType):
@property
def pid(self):
@ -19,4 +20,4 @@ class module(ModuleType):
# To prevent garbage collection
tether = sys.modules[__name__]
sys.modules[__name__] = module(__name__, '')
sys.modules[__name__] = module(__name__, '')

View File

@ -1,10 +1,12 @@
import gdb
import sys
import re
import sys
from types import ModuleType
import pwndbg.memoize
import gdb
import pwndbg.arch
import pwndbg.memoize
class RegisterSet(object):
def __init__(self, pc, stack, frame, retaddr, flags, gpr, misc, args):
self.pc = pc
@ -228,4 +230,4 @@ class module(ModuleType):
# To prevent garbage collection
tether = sys.modules[__name__]
sys.modules[__name__] = module(__name__, '')
sys.modules[__name__] = module(__name__, '')

View File

@ -2,5 +2,6 @@
# -*- coding: utf-8 -*-
import gdb
def is_remote():
return 'serial line' in gdb.execute('info program',to_string=True)
return 'serial line' in gdb.execute('info program',to_string=True)

View File

@ -1,8 +1,10 @@
import gdb
import struct
import gdb
import pwndbg.memory
import pwndbg.vmmap
import pwndbg.typeinfo
import pwndbg.vmmap
def search(searchfor):
value = searchfor
@ -34,4 +36,4 @@ def search(searchfor):
break
hits.append(start)
start += len(searchfor)
return hits
return hits

View File

@ -1,8 +1,7 @@
import gdb
import pwndbg.events
import pwndbg.memory
import pwndbg.memoize
import pwndbg.memory
# Dictionary of stack ranges.
# Key is the gdb thread ptid
@ -90,4 +89,3 @@ def is_executable():
nx = True
return not nx

View File

@ -1,7 +1,8 @@
import gdb
import string
import pwndbg.typeinfo
import gdb
import pwndbg.events
import pwndbg.typeinfo
length = 15
@ -34,4 +35,4 @@ def get(address):
if len(sz) < length:
return sz
return sz[:length] + '...'
return sz[:length] + '...'

View File

@ -1,9 +1,10 @@
import gdb
import pwndbg.elf
import pwndbg.ida
import pwndbg.memoize
import pwndbg.memory
import pwndbg.stack
import pwndbg.ida
import pwndbg.elf
@pwndbg.memoize.reset_on_objfile
def get(address):
@ -56,4 +57,4 @@ def address(symbol):
address = next(r for r in result if r.startswith('0x'))
return int(address, 0)
except gdb.error:
return None
return None

View File

@ -1,12 +1,12 @@
import os
import sys
import gdb
import glob
import tempfile
import os
import subprocess
import sys
import tempfile
import pwndbg.gcc
import gdb
import pwndbg.events
import pwndbg.gcc
import pwndbg.memoize
module = sys.modules[__name__]
@ -116,4 +116,4 @@ def load(name):
with pwndbg.events.Pause():
gdb.execute('add-symbol-file %s.o 0' % filename, from_tty=False, to_string=True)
return gdb.lookup_type(name)
return gdb.lookup_type(name)

View File

@ -1,6 +1,11 @@
import struct, termios, fcntl, sys
import fcntl
import struct
import sys
import termios
import pwndbg.arch
def banner(title):
title = title.upper()
try:

View File

@ -7,19 +7,19 @@ address ranges with various ELF files and permissions.
The reason that we need robustness is that not every operating
system has /proc/$$/maps, which backs 'info proc mapping'.
"""
import gdb
import sys
import pwndbg.remote
import pwndbg.memory
import pwndbg.typeinfo
import pwndbg.file
import pwndbg.proc
import gdb
import pwndbg.compat
import pwndbg.memoize
import pwndbg.stack
import pwndbg.events
import pwndbg.file
import pwndbg.memoize
import pwndbg.memory
import pwndbg.proc
import pwndbg.regs
import pwndbg.remote
import pwndbg.stack
import pwndbg.typeinfo
# List of manually-explored pages which were discovered
# by analyzing the stack or register context.
@ -326,4 +326,4 @@ def check_aslr():
if "is off." in output:
vmmap.aslr = True
return vmmap.aslr
return vmmap.aslr