diff --git a/pwn/__init__.py b/pwn/__init__.py index 70f34532e..3a87d1794 100644 --- a/pwn/__init__.py +++ b/pwn/__init__.py @@ -1,5 +1,7 @@ # Promote useful stuff to toplevel -from .toplevel import * +from __future__ import absolute_import + +from pwn.toplevel import * pwnlib.args.initialize() pwnlib.log.install_default_handler() diff --git a/pwnlib/__init__.py b/pwnlib/__init__.py index 59dccf9ff..f146bafa8 100644 --- a/pwnlib/__init__.py +++ b/pwnlib/__init__.py @@ -1,6 +1,8 @@ +from __future__ import absolute_import + import importlib -from .version import __version__ +from pwnlib.version import __version__ version = __version__ diff --git a/pwnlib/abi.py b/pwnlib/abi.py index a3e68db74..6d952314f 100644 --- a/pwnlib/abi.py +++ b/pwnlib/abi.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -from .context import LocalContext -from .context import context +from __future__ import absolute_import + +from pwnlib.context import LocalContext +from pwnlib.context import context class ABI(object): diff --git a/pwnlib/adb/__init__.py b/pwnlib/adb/__init__.py index d428c21f8..68f00cf89 100644 --- a/pwnlib/adb/__init__.py +++ b/pwnlib/adb/__init__.py @@ -1,2 +1,4 @@ -from .adb import * -from .protocol import Client +from __future__ import absolute_import + +from pwnlib.adb.adb import * +from pwnlib.adb.protocol import Client diff --git a/pwnlib/adb/adb.py b/pwnlib/adb/adb.py index 4adcd2aee..4122aff23 100644 --- a/pwnlib/adb/adb.py +++ b/pwnlib/adb/adb.py @@ -44,6 +44,8 @@ adb.write('/data/local/tmp/foo', 'my data') """ +from __future__ import absolute_import + import functools import glob import logging @@ -57,14 +59,14 @@ import dateutil.parser -from .. import atexit -from .. import tubes -from ..context import LocalContext -from ..context import context -from ..device import Device -from ..log import getLogger -from ..util import misc -from .protocol import Client +from pwnlib import atexit +from pwnlib import tubes +from pwnlib.adb.protocol import Client +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.device import Device +from pwnlib.log import getLogger +from pwnlib.util import misc log = getLogger(__name__) diff --git a/pwnlib/adb/protocol.py b/pwnlib/adb/protocol.py index a4fcefdf7..9beabf4c2 100644 --- a/pwnlib/adb/protocol.py +++ b/pwnlib/adb/protocol.py @@ -4,21 +4,23 @@ Documentation is available here: https://android.googlesource.com/platform/system/core/+/master/adb/protocol.txt """ +from __future__ import absolute_import + import functools import stat import time -from ..context import context -from ..log import Logger -from ..log import getLogger -from ..tubes.listen import listen -from ..tubes.process import process -from ..tubes.remote import remote -from ..util.lists import group -from ..util.misc import size -from ..util.packing import p32 -from ..util.proc import pidof -from ..util.sh_string import sh_string +from pwnlib.context import context +from pwnlib.log import Logger +from pwnlib.log import getLogger +from pwnlib.tubes.listen import listen +from pwnlib.tubes.process import process +from pwnlib.tubes.remote import remote +from pwnlib.util.lists import group +from pwnlib.util.misc import size +from pwnlib.util.packing import p32 +from pwnlib.util.proc import pidof +from pwnlib.util.sh_string import sh_string log = getLogger(__name__) diff --git a/pwnlib/args.py b/pwnlib/args.py index 11c176107..793fd9ae5 100644 --- a/pwnlib/args.py +++ b/pwnlib/args.py @@ -39,14 +39,16 @@ The full list of supported "magic arguments" and their effects are listed below. """ +from __future__ import absolute_import + import collections import logging import os import string import sys -from . import term -from .context import context +from pwnlib import term +from pwnlib.context import context term_mode = True args = collections.defaultdict(str) diff --git a/pwnlib/asm.py b/pwnlib/asm.py index ef60754a1..07dae62d0 100644 --- a/pwnlib/asm.py +++ b/pwnlib/asm.py @@ -39,6 +39,8 @@ ' 0: b8 0b 00 00 00 mov eax,0xb' """ +from __future__ import absolute_import + import errno import os import platform @@ -53,11 +55,11 @@ from os import environ from os import path -from . import atexit -from . import shellcraft -from .context import LocalContext -from .context import context -from .log import getLogger +from pwnlib import atexit +from pwnlib import shellcraft +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger log = getLogger(__name__) diff --git a/pwnlib/atexception.py b/pwnlib/atexception.py index d64978aab..1fba84a90 100644 --- a/pwnlib/atexception.py +++ b/pwnlib/atexception.py @@ -2,12 +2,13 @@ Analogous to atexit, this module allows the programmer to register functions to be run if an unhandled exception occurs. """ +from __future__ import absolute_import import sys import threading import traceback -from .context import context +from pwnlib.context import context __all__ = ['register', 'unregister'] diff --git a/pwnlib/atexit.py b/pwnlib/atexit.py index 0cdf3e68e..a46686bb2 100644 --- a/pwnlib/atexit.py +++ b/pwnlib/atexit.py @@ -7,12 +7,13 @@ This module also fixes a the issue that exceptions raised by an exit handler is printed twice when the standard :mod:`atexit` is used. """ +from __future__ import absolute_import import sys import threading import traceback -from .context import context +from pwnlib.context import context __all__ = ['register', 'unregister'] diff --git a/pwnlib/commandline/asm.py b/pwnlib/commandline/asm.py index 2fbe076fd..45e969304 100644 --- a/pwnlib/commandline/asm.py +++ b/pwnlib/commandline/asm.py @@ -1,10 +1,11 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'asm', diff --git a/pwnlib/commandline/checksec.py b/pwnlib/commandline/checksec.py index fdf90774d..5c5b544cd 100644 --- a/pwnlib/commandline/checksec.py +++ b/pwnlib/commandline/checksec.py @@ -1,10 +1,11 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'checksec', diff --git a/pwnlib/commandline/constgrep.py b/pwnlib/commandline/constgrep.py index 785fc9d74..1b0cc0d96 100644 --- a/pwnlib/commandline/constgrep.py +++ b/pwnlib/commandline/constgrep.py @@ -1,12 +1,12 @@ #!/usr/bin/env python2 +from __future__ import absolute_import import argparse import os import re from pwn import * - -from . import common +from pwnlib.commandline import common p = common.parser_commands.add_parser( 'constgrep', diff --git a/pwnlib/commandline/cyclic.py b/pwnlib/commandline/cyclic.py index 06507a119..894cd2bd6 100644 --- a/pwnlib/commandline/cyclic.py +++ b/pwnlib/commandline/cyclic.py @@ -1,11 +1,12 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import string import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'cyclic', diff --git a/pwnlib/commandline/disasm.py b/pwnlib/commandline/disasm.py index 1aa7c3f11..87850937c 100644 --- a/pwnlib/commandline/disasm.py +++ b/pwnlib/commandline/disasm.py @@ -1,11 +1,12 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import string import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'disasm', diff --git a/pwnlib/commandline/elfdiff.py b/pwnlib/commandline/elfdiff.py index 92183d0fe..c179cb71e 100644 --- a/pwnlib/commandline/elfdiff.py +++ b/pwnlib/commandline/elfdiff.py @@ -1,4 +1,6 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import shutil from argparse import ArgumentParser from subprocess import CalledProcessError @@ -6,8 +8,7 @@ from tempfile import NamedTemporaryFile from pwn import * - -from . import common +from pwnlib.commandline import common def dump(objdump, path): diff --git a/pwnlib/commandline/elfpatch.py b/pwnlib/commandline/elfpatch.py index 685504b62..563d57aeb 100644 --- a/pwnlib/commandline/elfpatch.py +++ b/pwnlib/commandline/elfpatch.py @@ -1,10 +1,11 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import sys from pwn import * - -from . import common +from pwnlib.commandline import common p = common.parser_commands.add_parser( 'elfpatch', diff --git a/pwnlib/commandline/errno.py b/pwnlib/commandline/errno.py index c0332c04d..f2dee0dda 100644 --- a/pwnlib/commandline/errno.py +++ b/pwnlib/commandline/errno.py @@ -1,7 +1,9 @@ +from __future__ import absolute_import + import argparse import os -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'errno', diff --git a/pwnlib/commandline/hex.py b/pwnlib/commandline/hex.py index 14dcdbd18..7dbba0156 100644 --- a/pwnlib/commandline/hex.py +++ b/pwnlib/commandline/hex.py @@ -1,8 +1,10 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import sys -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'hex', diff --git a/pwnlib/commandline/main.py b/pwnlib/commandline/main.py index d4fcd7747..a30b2196c 100644 --- a/pwnlib/commandline/main.py +++ b/pwnlib/commandline/main.py @@ -1,23 +1,25 @@ +from __future__ import absolute_import + import sys -from . import asm -from . import checksec -from . import common -from . import constgrep -from . import cyclic -from . import disasm -from . import elfdiff -from . import elfpatch -from . import errno -from . import hex -from . import phd -from . import pwnstrip -from . import scramble -from . import shellcraft -from . import unhex -from . import update -from ..context import context -from .common import parser +from pwnlib.commandline import asm +from pwnlib.commandline import checksec +from pwnlib.commandline import common +from pwnlib.commandline import constgrep +from pwnlib.commandline import cyclic +from pwnlib.commandline import disasm +from pwnlib.commandline import elfdiff +from pwnlib.commandline import elfpatch +from pwnlib.commandline import errno +from pwnlib.commandline import hex +from pwnlib.commandline import phd +from pwnlib.commandline import pwnstrip +from pwnlib.commandline import scramble +from pwnlib.commandline import shellcraft +from pwnlib.commandline import unhex +from pwnlib.commandline import update +from pwnlib.commandline.common import parser +from pwnlib.context import context commands = { 'asm': asm.main, diff --git a/pwnlib/commandline/phd.py b/pwnlib/commandline/phd.py index bb7ce5247..1749b2b5a 100644 --- a/pwnlib/commandline/phd.py +++ b/pwnlib/commandline/phd.py @@ -1,11 +1,12 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import os import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'phd', diff --git a/pwnlib/commandline/pwnstrip.py b/pwnlib/commandline/pwnstrip.py index cb5dfe1e7..180f829dd 100644 --- a/pwnlib/commandline/pwnstrip.py +++ b/pwnlib/commandline/pwnstrip.py @@ -1,8 +1,9 @@ +from __future__ import absolute_import + import argparse from pwn import * - -from . import common +from pwnlib.commandline import common p = common.parser_commands.add_parser( 'pwnstrip', diff --git a/pwnlib/commandline/scramble.py b/pwnlib/commandline/scramble.py index 309a2983a..746e70d5f 100644 --- a/pwnlib/commandline/scramble.py +++ b/pwnlib/commandline/scramble.py @@ -1,9 +1,10 @@ +from __future__ import absolute_import + import argparse import sys from pwn import * - -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'scramble', diff --git a/pwnlib/commandline/shellcraft.py b/pwnlib/commandline/shellcraft.py index 84b86f0e3..a216a7564 100644 --- a/pwnlib/commandline/shellcraft.py +++ b/pwnlib/commandline/shellcraft.py @@ -1,12 +1,13 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import os import sys import types from pwn import * - -from . import common +from pwnlib.commandline import common # ____ _ _ _ __ _ diff --git a/pwnlib/commandline/unhex.py b/pwnlib/commandline/unhex.py index fb7ab9b0e..d766768c1 100644 --- a/pwnlib/commandline/unhex.py +++ b/pwnlib/commandline/unhex.py @@ -1,9 +1,11 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import argparse import sys from string import whitespace -from . import common +from pwnlib.commandline import common parser = common.parser_commands.add_parser( 'unhex', diff --git a/pwnlib/commandline/update.py b/pwnlib/commandline/update.py index 46b464a45..f79658d24 100644 --- a/pwnlib/commandline/update.py +++ b/pwnlib/commandline/update.py @@ -1,9 +1,10 @@ #!/usr/bin/env python2 +from __future__ import absolute_import + import subprocess from pwn import * - -from . import common +from pwnlib.commandline import common p = common.parser_commands.add_parser( 'update', diff --git a/pwnlib/constants/__init__.py b/pwnlib/constants/__init__.py index 97d64fee9..88a5985f5 100644 --- a/pwnlib/constants/__init__.py +++ b/pwnlib/constants/__init__.py @@ -40,13 +40,15 @@ 4 """ +from __future__ import absolute_import + import importlib import sys from types import ModuleType -from ..context import context -from ..util import safeeval -from .constant import Constant +from pwnlib.constants.constant import Constant +from pwnlib.context import context +from pwnlib.util import safeeval class ConstantsModule(ModuleType): diff --git a/pwnlib/context/__init__.py b/pwnlib/context/__init__.py index 1c26bf874..1f69403d6 100644 --- a/pwnlib/context/__init__.py +++ b/pwnlib/context/__init__.py @@ -4,6 +4,8 @@ Implements context management so that nested/scoped contexts and threaded contexts work properly and as expected. """ +from __future__ import absolute_import + import collections import functools import logging @@ -19,8 +21,8 @@ import socks -from ..device import Device -from ..timeout import Timeout +from pwnlib.device import Device +from pwnlib.timeout import Timeout _original_socket = socket.socket @@ -756,7 +758,7 @@ def binary(self, binary): """ # Cyclic imports... sorry Idolf. - from ..elf import ELF + from pwnlib.elf import ELF if not isinstance(binary, ELF): binary = ELF(binary) diff --git a/pwnlib/dynelf.py b/pwnlib/dynelf.py index e50cb74e9..a7372b8f8 100644 --- a/pwnlib/dynelf.py +++ b/pwnlib/dynelf.py @@ -47,20 +47,22 @@ def leak(address): DynELF """ +from __future__ import absolute_import + import ctypes from elftools.elf.enums import ENUM_D_TAG -from . import elf -from . import libcdb -from .context import context -from .elf import ELF -from .elf import constants -from .log import getLogger -from .memleak import MemLeak -from .util.fiddling import enhex -from .util.packing import unpack -from .util.web import wget +from pwnlib import elf +from pwnlib import libcdb +from pwnlib.context import context +from pwnlib.elf import ELF +from pwnlib.elf import constants +from pwnlib.log import getLogger +from pwnlib.memleak import MemLeak +from pwnlib.util.fiddling import enhex +from pwnlib.util.packing import unpack +from pwnlib.util.web import wget log = getLogger(__name__) sizeof = ctypes.sizeof diff --git a/pwnlib/elf/__init__.py b/pwnlib/elf/__init__.py index 11857fd77..3af936142 100644 --- a/pwnlib/elf/__init__.py +++ b/pwnlib/elf/__init__.py @@ -1,6 +1,8 @@ -from .corefile import Core -from .datatypes import * -from .elf import ELF -from .elf import load +from __future__ import absolute_import + +from pwnlib.elf.corefile import Core +from pwnlib.elf.datatypes import * +from pwnlib.elf.elf import ELF +from pwnlib.elf.elf import load __all__ = ['load', 'ELF', 'Core'] + sorted(filter(lambda x: not x.startswith('_'), datatypes.__dict__.keys())) diff --git a/pwnlib/elf/corefile.py b/pwnlib/elf/corefile.py index 7090b0405..91a026b2a 100644 --- a/pwnlib/elf/corefile.py +++ b/pwnlib/elf/corefile.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import collections import ctypes @@ -7,11 +9,11 @@ from elftools.common.utils import struct_parse from elftools.construct import CString -from ..context import context -from ..log import getLogger -from ..tubes.tube import tube -from .datatypes import * -from .elf import ELF +from pwnlib.context import context +from pwnlib.elf.datatypes import * +from pwnlib.elf.elf import ELF +from pwnlib.log import getLogger +from pwnlib.tubes.tube import tube log = getLogger(__name__) diff --git a/pwnlib/elf/elf.py b/pwnlib/elf/elf.py index 8cd3fd3ff..8f6f38ed6 100644 --- a/pwnlib/elf/elf.py +++ b/pwnlib/elf/elf.py @@ -1,5 +1,7 @@ """Exposes functionality for manipulating ELF files """ +from __future__ import absolute_import + import codecs import mmap import os @@ -15,17 +17,17 @@ from elftools.elf.relocation import RelocationSection from elftools.elf.sections import SymbolTableSection -from .. import adb -from ..asm import * -from ..context import LocalContext -from ..context import context -from ..log import getLogger -from ..qemu import get_qemu_arch -from ..term import text -from ..tubes.process import process -from ..util import misc -from ..util import packing -from ..util import sh_string +from pwnlib import adb +from pwnlib.asm import * +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.qemu import get_qemu_arch +from pwnlib.term import text +from pwnlib.tubes.process import process +from pwnlib.util import misc +from pwnlib.util import packing +from pwnlib.util import sh_string log = getLogger(__name__) diff --git a/pwnlib/encoders/__init__.py b/pwnlib/encoders/__init__.py index ac42aee9f..7276f3d57 100644 --- a/pwnlib/encoders/__init__.py +++ b/pwnlib/encoders/__init__.py @@ -2,14 +2,16 @@ """ Encode shellcode to avoid input filtering and impress your friends! """ -from . import amd64 -from . import arm -from . import i386 -from . import mips -from .encoder import Encoder -from .encoder import alphanumeric -from .encoder import encode -from .encoder import line -from .encoder import null -from .encoder import printable -from .encoder import scramble +from __future__ import absolute_import + +from pwnlib.encoders import amd64 +from pwnlib.encoders import arm +from pwnlib.encoders import i386 +from pwnlib.encoders import mips +from pwnlib.encoders.encoder import Encoder +from pwnlib.encoders.encoder import alphanumeric +from pwnlib.encoders.encoder import encode +from pwnlib.encoders.encoder import line +from pwnlib.encoders.encoder import null +from pwnlib.encoders.encoder import printable +from pwnlib.encoders.encoder import scramble diff --git a/pwnlib/encoders/amd64/__init__.py b/pwnlib/encoders/amd64/__init__.py index f8ba46534..c38fca4d8 100644 --- a/pwnlib/encoders/amd64/__init__.py +++ b/pwnlib/encoders/amd64/__init__.py @@ -1 +1,3 @@ -from . import delta +from __future__ import absolute_import + +from pwnlib.encoders.amd64 import delta diff --git a/pwnlib/encoders/amd64/delta.py b/pwnlib/encoders/amd64/delta.py index 0bf378351..21959ea0e 100644 --- a/pwnlib/encoders/amd64/delta.py +++ b/pwnlib/encoders/amd64/delta.py @@ -1,4 +1,6 @@ -from ..i386.delta import i386DeltaEncoder +from __future__ import absolute_import + +from pwnlib.encoders.i386.delta import i386DeltaEncoder class amd64DeltaEncoder(i386DeltaEncoder): diff --git a/pwnlib/encoders/arm/__init__.py b/pwnlib/encoders/arm/__init__.py index 1411fa57d..b52d6a041 100644 --- a/pwnlib/encoders/arm/__init__.py +++ b/pwnlib/encoders/arm/__init__.py @@ -1,2 +1,4 @@ -from . import alphanumeric -from . import xor +from __future__ import absolute_import + +from pwnlib.encoders.arm import alphanumeric +from pwnlib.encoders.arm import xor diff --git a/pwnlib/encoders/arm/alphanumeric/__init__.py b/pwnlib/encoders/arm/alphanumeric/__init__.py index aa8cac26c..e25f5087f 100644 --- a/pwnlib/encoders/arm/alphanumeric/__init__.py +++ b/pwnlib/encoders/arm/alphanumeric/__init__.py @@ -1,12 +1,13 @@ +from __future__ import absolute_import + import binascii import random import string import sys -import builder - -from ....context import context -from ...encoder import Encoder +from pwnlib.context import context +from pwnlib.encoders.arm.alphanumeric import builder +from pwnlib.encoders.encoder import Encoder class ArmEncoder(Encoder): diff --git a/pwnlib/encoders/arm/xor.py b/pwnlib/encoders/arm/xor.py index b1020fefc..dcd9f60e4 100644 --- a/pwnlib/encoders/arm/xor.py +++ b/pwnlib/encoders/arm/xor.py @@ -1,10 +1,12 @@ -from ... import shellcraft -from ...asm import asm -from ...context import context -from ...util.fiddling import xor_key -from ...util.lists import group -from ...util.packing import u8 -from ..encoder import Encoder +from __future__ import absolute_import + +from pwnlib import shellcraft +from pwnlib.asm import asm +from pwnlib.context import context +from pwnlib.encoders.encoder import Encoder +from pwnlib.util.fiddling import xor_key +from pwnlib.util.lists import group +from pwnlib.util.packing import u8 class ArmXorEncoder(Encoder): diff --git a/pwnlib/encoders/encoder.py b/pwnlib/encoders/encoder.py index f43db5438..4bc6eaffc 100644 --- a/pwnlib/encoders/encoder.py +++ b/pwnlib/encoders/encoder.py @@ -1,13 +1,15 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import collections import random import re import string -from ..context import LocalContext -from ..context import context -from ..log import getLogger -from ..util.fiddling import hexdump +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util.fiddling import hexdump log = getLogger(__name__) diff --git a/pwnlib/encoders/i386/__init__.py b/pwnlib/encoders/i386/__init__.py index d4778bac6..126ac4efe 100644 --- a/pwnlib/encoders/i386/__init__.py +++ b/pwnlib/encoders/i386/__init__.py @@ -1,2 +1,4 @@ -from . import delta -from . import xor +from __future__ import absolute_import + +from pwnlib.encoders.i386 import delta +from pwnlib.encoders.i386 import xor diff --git a/pwnlib/encoders/i386/delta.py b/pwnlib/encoders/i386/delta.py index 99e1d1fca..21673b447 100644 --- a/pwnlib/encoders/i386/delta.py +++ b/pwnlib/encoders/i386/delta.py @@ -1,12 +1,14 @@ +from __future__ import absolute_import + import collections from random import choice from random import randint -from ...asm import asm -from ...asm import disasm -from ...context import context -from ...util.fiddling import hexdump -from ..encoder import Encoder +from pwnlib.asm import asm +from pwnlib.asm import disasm +from pwnlib.context import context +from pwnlib.encoders.encoder import Encoder +from pwnlib.util.fiddling import hexdump ''' diff --git a/pwnlib/encoders/i386/xor.py b/pwnlib/encoders/i386/xor.py index fccf86e04..c82e4a1f5 100644 --- a/pwnlib/encoders/i386/xor.py +++ b/pwnlib/encoders/i386/xor.py @@ -10,13 +10,14 @@ #; This program is distributed in the hope that it will be useful, #; but WITHOUT ANY WARRANTY; without even the implied warranty of #; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +from __future__ import absolute_import -from ... import shellcraft -from ...asm import asm -from ...context import context -from ...util.fiddling import xor_pair -from ...util.lists import group -from ..encoder import Encoder +from pwnlib import shellcraft +from pwnlib.asm import asm +from pwnlib.context import context +from pwnlib.encoders.encoder import Encoder +from pwnlib.util.fiddling import xor_pair +from pwnlib.util.lists import group # Note shellcode assumes it's based at ecx diff --git a/pwnlib/encoders/mips/__init__.py b/pwnlib/encoders/mips/__init__.py index 631ae05ec..c76cc2ece 100644 --- a/pwnlib/encoders/mips/__init__.py +++ b/pwnlib/encoders/mips/__init__.py @@ -1 +1,3 @@ -from . import xor +from __future__ import absolute_import + +from pwnlib.encoders.mips import xor diff --git a/pwnlib/encoders/mips/xor.py b/pwnlib/encoders/mips/xor.py index ca777ec65..9918cc1d9 100644 --- a/pwnlib/encoders/mips/xor.py +++ b/pwnlib/encoders/mips/xor.py @@ -23,12 +23,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from __future__ import absolute_import -from ... import shellcraft -from ...asm import asm -from ...context import context -from ...util.fiddling import xor_key -from ..encoder import Encoder +from pwnlib import asm +from pwnlib import shellcraft +from pwnlib.context import context +from pwnlib.encoders.encoder import Encoder +from pwnlib.util.fiddling import xor_key decoders = { 'little': ''.join([ diff --git a/pwnlib/flag/__init__.py b/pwnlib/flag/__init__.py index 6c07f8802..621851044 100644 --- a/pwnlib/flag/__init__.py +++ b/pwnlib/flag/__init__.py @@ -1,4 +1,6 @@ -from .flag import submit_flag +from __future__ import absolute_import + +from pwnlib.flag.flag import submit_flag __all__ = [ 'submit_flag', diff --git a/pwnlib/flag/flag.py b/pwnlib/flag/flag.py index 067b25075..b226c1352 100644 --- a/pwnlib/flag/flag.py +++ b/pwnlib/flag/flag.py @@ -1,10 +1,12 @@ """Describes a way to submit a key to a key server. """ +from __future__ import absolute_import + import os -from ..args import args -from ..log import getLogger -from ..tubes.remote import remote +from pwnlib.args import args +from pwnlib.log import getLogger +from pwnlib.tubes.remote import remote env_server = args.get('FLAG_HOST', 'flag-submission-server').strip() env_port = args.get('FLAG_PORT', '31337').strip() diff --git a/pwnlib/gdb.py b/pwnlib/gdb.py index ebae8d988..f00951b1e 100644 --- a/pwnlib/gdb.py +++ b/pwnlib/gdb.py @@ -1,22 +1,24 @@ +from __future__ import absolute_import + import os import random import re import shlex import tempfile -from . import adb -from . import atexit -from . import elf -from . import tubes -from .asm import _bfdname -from .asm import make_elf -from .asm import make_elf_from_assembly -from .context import LocalContext -from .context import context -from .log import getLogger -from .qemu import get_qemu_user -from .util import misc -from .util import proc +from pwnlib import adb +from pwnlib import atexit +from pwnlib import elf +from pwnlib import tubes +from pwnlib.asm import _bfdname +from pwnlib.asm import make_elf +from pwnlib.asm import make_elf_from_assembly +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.qemu import get_qemu_user +from pwnlib.util import misc +from pwnlib.util import proc log = getLogger(__name__) diff --git a/pwnlib/libcdb.py b/pwnlib/libcdb.py index 5ddbdfbdf..22b09829f 100644 --- a/pwnlib/libcdb.py +++ b/pwnlib/libcdb.py @@ -1,21 +1,23 @@ """ Fetch a LIBC binary based on some heuristics. """ +from __future__ import absolute_import + import codecs import json import os import tempfile import urlparse -from .context import context -from .elf import ELF -from .log import getLogger -from .util.fiddling import b64d -from .util.fiddling import hexdump -from .util.misc import read -from .util.misc import write -from .util.safeeval import const -from .util.web import wget +from pwnlib.context import context +from pwnlib.elf import ELF +from pwnlib.log import getLogger +from pwnlib.util.fiddling import b64d +from pwnlib.util.fiddling import hexdump +from pwnlib.util.misc import read +from pwnlib.util.misc import write +from pwnlib.util.safeeval import const +from pwnlib.util.web import wget log = getLogger(__name__) diff --git a/pwnlib/log.py b/pwnlib/log.py index 7d26257bc..88a12add6 100644 --- a/pwnlib/log.py +++ b/pwnlib/log.py @@ -40,7 +40,7 @@ ----------------- A module-specific logger can be imported into the module via:: - from .log import getLogger + from pwnlib.log import getLogger log = getLogger(__name__) This provides an easy way to filter logging programmatically @@ -91,10 +91,7 @@ will however see the extra log records generated by the ``'pwnlib.tubes.ssh'`` logger. """ - -__all__ = [ - 'getLogger', 'install_default_handler', 'rootlogger' -] +from __future__ import absolute_import import ConfigParser import logging @@ -105,12 +102,18 @@ import threading import time -from . import term -from .context import Thread -from .context import context -from .exception import PwnlibException -from .term import spinners -from .term import text +from pwnlib import term +from pwnlib.context import Thread +from pwnlib.context import context +from pwnlib.exception import PwnlibException +from pwnlib.term import spinners +from pwnlib.term import text + +__all__ = [ + 'getLogger', 'install_default_handler', 'rootlogger' +] + + # list of prefixes to use for the different message types. note that the `text` # module won't add any escape codes if `pwnlib.context.log_console.isatty()` is `False` diff --git a/pwnlib/memleak.py b/pwnlib/memleak.py index 3bc29c3d1..103ce472d 100644 --- a/pwnlib/memleak.py +++ b/pwnlib/memleak.py @@ -1,11 +1,13 @@ +from __future__ import absolute_import + import ctypes import functools import string -from .context import context -from .log import getLogger -from .util.packing import pack -from .util.packing import unpack +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util.packing import pack +from pwnlib.util.packing import unpack log = getLogger(__name__) diff --git a/pwnlib/qemu.py b/pwnlib/qemu.py index 0860fa89c..5e0767d0f 100644 --- a/pwnlib/qemu.py +++ b/pwnlib/qemu.py @@ -1,7 +1,9 @@ -from .context import LocalContext -from .context import context -from .log import getLogger -from .util import misc +from __future__ import absolute_import + +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util import misc log = getLogger(__name__) diff --git a/pwnlib/regsort.py b/pwnlib/regsort.py index 3e527b306..9f29c3565 100644 --- a/pwnlib/regsort.py +++ b/pwnlib/regsort.py @@ -2,13 +2,15 @@ """ Topographical sort """ +from __future__ import absolute_import + from collections import OrderedDict from collections import defaultdict from random import randint from random import shuffle -from .context import context -from .log import getLogger +from pwnlib.context import context +from pwnlib.log import getLogger log = getLogger(__name__) diff --git a/pwnlib/rop/__init__.py b/pwnlib/rop/__init__.py index 0c9b41285..cd1c25372 100644 --- a/pwnlib/rop/__init__.py +++ b/pwnlib/rop/__init__.py @@ -1 +1 @@ -from .rop import ROP +from pwnlib.rop.rop import ROP diff --git a/pwnlib/rop/call.py b/pwnlib/rop/call.py index e4aa210b8..5afb8f563 100644 --- a/pwnlib/rop/call.py +++ b/pwnlib/rop/call.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """Abstracting ROP calls """ -from ..abi import ABI -from ..context import context -from ..util import packing +from pwnlib.abi import ABI +from pwnlib.context import context +from pwnlib.util import packing class Unresolved(object): diff --git a/pwnlib/rop/rop.py b/pwnlib/rop/rop.py index 3b9960191..382ae8bb2 100644 --- a/pwnlib/rop/rop.py +++ b/pwnlib/rop/rop.py @@ -192,6 +192,8 @@ >>> p.recvline() 'hello\n' """ +from __future__ import absolute_import + import collections import copy import hashlib @@ -200,23 +202,23 @@ import sys import tempfile -from . import srop -from .. import abi -from .. import constants -from ..context import LocalContext -from ..context import context -from ..elf import ELF -from ..log import getLogger -from ..util import cyclic -from ..util import lists -from ..util import packing -from ..util.packing import * -from .call import AppendedArgument -from .call import Call -from .call import CurrentStackPointer -from .call import NextGadgetAddress -from .call import StackAdjustment -from .gadgets import Gadget +from pwnlib import abi +from pwnlib import constants +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.elf import ELF +from pwnlib.log import getLogger +from pwnlib.rop import srop +from pwnlib.rop.call import AppendedArgument +from pwnlib.rop.call import Call +from pwnlib.rop.call import CurrentStackPointer +from pwnlib.rop.call import NextGadgetAddress +from pwnlib.rop.call import StackAdjustment +from pwnlib.rop.gadgets import Gadget +from pwnlib.util import cyclic +from pwnlib.util import lists +from pwnlib.util import packing +from pwnlib.util.packing import * log = getLogger(__name__) __all__ = ['ROP'] diff --git a/pwnlib/rop/srop.py b/pwnlib/rop/srop.py index d08f67ea3..46699f20c 100644 --- a/pwnlib/rop/srop.py +++ b/pwnlib/rop/srop.py @@ -158,16 +158,17 @@ True """ +from __future__ import absolute_import from collections import namedtuple -from ..abi import ABI -from ..context import LocalContext -from ..context import context -from ..log import getLogger -from ..util.packing import flat -from ..util.packing import pack -from ..util.packing import unpack_many +from pwnlib.abi import ABI +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util.packing import flat +from pwnlib.util.packing import pack +from pwnlib.util.packing import unpack_many log = getLogger(__name__) diff --git a/pwnlib/runner.py b/pwnlib/runner.py index b74f868f8..f78ad687f 100644 --- a/pwnlib/runner.py +++ b/pwnlib/runner.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + import os import tempfile -from .context import LocalContext -from .elf import ELF -from .tubes.process import process +from pwnlib.context import LocalContext +from pwnlib.elf import ELF +from pwnlib.tubes.process import process __all__ = ['run_assembly', 'run_shellcode', 'run_assembly_exitcode', 'run_shellcode_exitcode'] diff --git a/pwnlib/shellcraft/__init__.py b/pwnlib/shellcraft/__init__.py index bb656f0eb..7137757d6 100644 --- a/pwnlib/shellcraft/__init__.py +++ b/pwnlib/shellcraft/__init__.py @@ -1,12 +1,14 @@ +from __future__ import absolute_import + import os import re import sys from types import ModuleType -from . import internal -from .. import constants -from ..context import context -from ..util import packing +from pwnlib import constants +from pwnlib.context import context +from pwnlib.shellcraft import internal +from pwnlib.util import packing class module(ModuleType): @@ -145,7 +147,7 @@ def okay(self, s, *a, **kw): s = packing.pack(s, *a, **kw) return '\0' not in s and '\n' not in s - import registers + from pwnlib.shellcraft import registers # To prevent garbage collection tether = sys.modules[__name__] diff --git a/pwnlib/shellcraft/internal.py b/pwnlib/shellcraft/internal.py index 871ffd7fd..887fb96a3 100644 --- a/pwnlib/shellcraft/internal.py +++ b/pwnlib/shellcraft/internal.py @@ -1,7 +1,9 @@ +from __future__ import absolute_import + import os from collections import defaultdict -from ..context import context +from pwnlib.context import context __all__ = ['make_function'] diff --git a/pwnlib/shellcraft/registers.py b/pwnlib/shellcraft/registers.py index 1dca7b33e..37d66f29e 100644 --- a/pwnlib/shellcraft/registers.py +++ b/pwnlib/shellcraft/registers.py @@ -1,7 +1,9 @@ +from __future__ import absolute_import + import re -from ..context import context -from ..util.misc import register_sizes +from pwnlib.context import context +from pwnlib.util.misc import register_sizes mips = { '$0' : 0, '$zero': 0, diff --git a/pwnlib/term/__init__.py b/pwnlib/term/__init__.py index d90776b9a..a19c6164b 100644 --- a/pwnlib/term/__init__.py +++ b/pwnlib/term/__init__.py @@ -1,12 +1,14 @@ +from __future__ import absolute_import + import sys -from . import completer -from . import key -from . import keymap -from . import readline -from . import term -from . import termcap -from . import text +from pwnlib.term import completer +from pwnlib.term import key +from pwnlib.term import keymap +from pwnlib.term import readline +from pwnlib.term import term +from pwnlib.term import termcap +from pwnlib.term import text # Re-exports (XXX: Are these needed?) output = term.output diff --git a/pwnlib/term/completer.py b/pwnlib/term/completer.py index 1b83042b4..9b41a75c4 100644 --- a/pwnlib/term/completer.py +++ b/pwnlib/term/completer.py @@ -1,7 +1,9 @@ +from __future__ import absolute_import + import os import re -from . import readline +from pwnlib.term import readline class Completer: diff --git a/pwnlib/term/key.py b/pwnlib/term/key.py index 9598bc19c..e98b07bd4 100644 --- a/pwnlib/term/key.py +++ b/pwnlib/term/key.py @@ -1,4 +1,4 @@ -__all__ = ['getch', 'getraw', 'get', 'unget'] +from __future__ import absolute_import import errno import os @@ -6,8 +6,12 @@ import string import sys -from . import keyconsts as kc -from . import termcap +from pwnlib.term import keyconsts as kc +from pwnlib.term import termcap + +__all__ = ['getch', 'getraw', 'get', 'unget'] + + try: _fd = sys.stdin.fileno() except Exception: _fd = file('/dev/null', 'r').fileno() diff --git a/pwnlib/term/keymap.py b/pwnlib/term/keymap.py index f78b7dfe8..376e1e59a 100644 --- a/pwnlib/term/keymap.py +++ b/pwnlib/term/keymap.py @@ -1,6 +1,9 @@ +from __future__ import absolute_import + +from pwnlib.term import key + __all__ = ['Keymap'] -from . import key class Keymap: diff --git a/pwnlib/term/readline.py b/pwnlib/term/readline.py index a1af00f51..ac25d2738 100644 --- a/pwnlib/term/readline.py +++ b/pwnlib/term/readline.py @@ -1,7 +1,9 @@ -from . import keyconsts as kc -from . import keymap as km -from . import term -from . import text +from __future__ import absolute_import + +from pwnlib.term import keyconsts as kc +from pwnlib.term import keymap as km +from pwnlib.term import term +from pwnlib.term import text cursor = text.reverse @@ -403,7 +405,7 @@ def readline(_size = None, prompt = '', float = True, priority = 10): def init(): # defer imports until initialization import sys, __builtin__ - from ..util import safeeval + from pwnlib.util import safeeval class Wrapper: def __init__(self, fd): diff --git a/pwnlib/term/term.py b/pwnlib/term/term.py index b252e2363..8c09daddf 100644 --- a/pwnlib/term/term.py +++ b/pwnlib/term/term.py @@ -1,3 +1,19 @@ +from __future__ import absolute_import + +import atexit +import fcntl +import os +import re +import signal +import struct +import sys +import termios +import threading +import traceback + +from pwnlib.context import ContextType +from pwnlib.term import termcap + __all__ = ['output', 'init'] # we assume no terminal can display more lines than this @@ -10,19 +26,7 @@ # list of callbacks triggered on SIGWINCH on_winch = [] -import atexit -import fcntl -import os -import re -import signal -import struct -import sys -import termios -import threading -import traceback -from . import termcap -from ..context import ContextType settings = None _graphics_mode = False diff --git a/pwnlib/term/text.py b/pwnlib/term/text.py index 48eeaa3c9..3032869fb 100644 --- a/pwnlib/term/text.py +++ b/pwnlib/term/text.py @@ -1,8 +1,10 @@ +from __future__ import absolute_import + import functools import sys import types -from . import termcap +from pwnlib.term import termcap def eval_when(when): diff --git a/pwnlib/tubes/__init__.py b/pwnlib/tubes/__init__.py index 5157fe10e..7aff6baf2 100644 --- a/pwnlib/tubes/__init__.py +++ b/pwnlib/tubes/__init__.py @@ -9,13 +9,14 @@ just enough for the class to work and possibly code pertaining only to that specific kind of tube. """ +from __future__ import absolute_import -__all__ = ['tube', 'sock', 'remote', 'listen', 'process', 'serialtube', 'ssh'] +from pwnlib.tubes import listen +from pwnlib.tubes import process +from pwnlib.tubes import remote +from pwnlib.tubes import serialtube +from pwnlib.tubes import sock +from pwnlib.tubes import ssh +from pwnlib.tubes import tube -from . import listen -from . import process -from . import remote -from . import serialtube -from . import sock -from . import ssh -from . import tube +__all__ = ['tube', 'sock', 'remote', 'listen', 'process', 'serialtube', 'ssh'] diff --git a/pwnlib/tubes/buffer.py b/pwnlib/tubes/buffer.py index 40ef41d2d..c103f2869 100644 --- a/pwnlib/tubes/buffer.py +++ b/pwnlib/tubes/buffer.py @@ -1,6 +1,7 @@ #!/usr/bin/env python2 +from __future__ import absolute_import -from ..context import context +from pwnlib.context import context class Buffer(Exception): diff --git a/pwnlib/tubes/listen.py b/pwnlib/tubes/listen.py index 98e0f7b21..5c0b6cae6 100644 --- a/pwnlib/tubes/listen.py +++ b/pwnlib/tubes/listen.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import + import errno import socket -from ..context import context -from ..log import getLogger -from ..timeout import Timeout -from .sock import sock +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.timeout import Timeout +from pwnlib.tubes.sock import sock log = getLogger(__name__) diff --git a/pwnlib/tubes/process.py b/pwnlib/tubes/process.py index 17b33e924..65650446c 100644 --- a/pwnlib/tubes/process.py +++ b/pwnlib/tubes/process.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import ctypes import errno import fcntl @@ -11,13 +13,13 @@ import subprocess import tty -from ..context import context -from ..log import getLogger -from ..qemu import get_qemu_user -from ..timeout import Timeout -from ..util.misc import parse_ldd_output -from ..util.misc import which -from .tube import tube +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.qemu import get_qemu_user +from pwnlib.timeout import Timeout +from pwnlib.tubes.tube import tube +from pwnlib.util.misc import parse_ldd_output +from pwnlib.util.misc import which log = getLogger(__name__) @@ -384,7 +386,7 @@ def __on_enoexec(self, exception): # Get the ELF binary for the target executable with context.quiet: # XXX: Cyclic imports :( - from ..elf import ELF + from pwnlib.elf import ELF binary = ELF(self.executable) # If we're on macOS, this will never work. Bail now. @@ -777,7 +779,7 @@ def libc(self): If possible, it is adjusted to the correct address automatically. """ - from ..elf import ELF + from pwnlib.elf import ELF for lib, address in self.libs().items(): if 'libc.so' in lib: diff --git a/pwnlib/tubes/remote.py b/pwnlib/tubes/remote.py index 9806d45e1..6f748aaac 100644 --- a/pwnlib/tubes/remote.py +++ b/pwnlib/tubes/remote.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + import socket import ssl as _ssl -from ..log import getLogger -from ..timeout import Timeout -from .sock import sock +from pwnlib.log import getLogger +from pwnlib.timeout import Timeout +from pwnlib.tubes.sock import sock log = getLogger(__name__) diff --git a/pwnlib/tubes/serialtube.py b/pwnlib/tubes/serialtube.py index 4c28f6380..15d07a036 100644 --- a/pwnlib/tubes/serialtube.py +++ b/pwnlib/tubes/serialtube.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import glob import platform import sys @@ -5,10 +7,8 @@ import serial -from . import tube -from .. import context -from .. import term -from ..log import getLogger +from pwnlib.log import getLogger +from pwnlib.tubes import tube log = getLogger(__name__) diff --git a/pwnlib/tubes/sock.py b/pwnlib/tubes/sock.py index 205d560ac..8f51d2eb4 100644 --- a/pwnlib/tubes/sock.py +++ b/pwnlib/tubes/sock.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + import errno import select import socket -from ..log import getLogger -from .tube import tube +from pwnlib.log import getLogger +from pwnlib.tubes.tube import tube log = getLogger(__name__) diff --git a/pwnlib/tubes/ssh.py b/pwnlib/tubes/ssh.py index 37d50ead2..7a34f0d26 100644 --- a/pwnlib/tubes/ssh.py +++ b/pwnlib/tubes/ssh.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import inspect import logging import os @@ -11,17 +13,17 @@ import time import types -from .. import term -from ..context import context -from ..log import Logger -from ..log import getLogger -from ..timeout import Timeout -from ..util import hashes -from ..util import misc -from ..util import safeeval -from ..util import sh_string -from .process import process -from .sock import sock +from pwnlib import term +from pwnlib.context import context +from pwnlib.log import Logger +from pwnlib.log import getLogger +from pwnlib.timeout import Timeout +from pwnlib.tubes.process import process +from pwnlib.tubes.sock import sock +from pwnlib.util import hashes +from pwnlib.util import misc +from pwnlib.util import safeeval +from pwnlib.util import sh_string # Kill the warning line: # No handlers could be found for logger "paramiko.transport" @@ -357,7 +359,7 @@ def libc(self): If possible, it is adjusted to the correct address automatically. """ - from ..elf import ELF + from pwnlib.elf import ELF for lib, address in self.libs().items(): if 'libc.so' in lib: diff --git a/pwnlib/tubes/tube.py b/pwnlib/tubes/tube.py index fe36fdd8e..334b3f8d8 100644 --- a/pwnlib/tubes/tube.py +++ b/pwnlib/tubes/tube.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import logging import re import string @@ -7,15 +9,15 @@ import threading import time -from .. import atexit -from .. import term -from ..context import context -from ..log import Logger -from ..timeout import Timeout -from ..util import fiddling -from ..util import misc -from ..util import packing -from .buffer import Buffer +from pwnlib import atexit +from pwnlib import term +from pwnlib.context import context +from pwnlib.log import Logger +from pwnlib.timeout import Timeout +from pwnlib.tubes.buffer import Buffer +from pwnlib.util import fiddling +from pwnlib.util import misc +from pwnlib.util import packing class tube(Timeout, Logger): diff --git a/pwnlib/ui.py b/pwnlib/ui.py index 5057346be..ecabf701a 100644 --- a/pwnlib/ui.py +++ b/pwnlib/ui.py @@ -1,8 +1,10 @@ +from __future__ import absolute_import + import time import types -from . import term -from .log import getLogger +from pwnlib import term +from pwnlib.log import getLogger log = getLogger(__name__) diff --git a/pwnlib/update.py b/pwnlib/update.py index 2d679b501..81211e162 100644 --- a/pwnlib/update.py +++ b/pwnlib/update.py @@ -12,6 +12,8 @@ $ echo never > ~/.pwntools-cache/update """ +from __future__ import absolute_import + import datetime import json import os @@ -20,12 +22,12 @@ import packaging.version -from .context import context -from .log import getLogger -from .util.misc import read -from .util.misc import write -from .util.web import wget -from .version import __version__ +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util.misc import read +from pwnlib.util.misc import write +from pwnlib.util.web import wget +from pwnlib.version import __version__ log = getLogger(__name__) diff --git a/pwnlib/util/__init__.py b/pwnlib/util/__init__.py index ced8b35f2..4b505baf1 100644 --- a/pwnlib/util/__init__.py +++ b/pwnlib/util/__init__.py @@ -1,19 +1,21 @@ +from __future__ import absolute_import + +from pwnlib.util import crc +from pwnlib.util import cyclic +from pwnlib.util import fiddling +from pwnlib.util import hashes +from pwnlib.util import iters +from pwnlib.util import lists +from pwnlib.util import misc +from pwnlib.util import net +from pwnlib.util import packing +from pwnlib.util import proc +from pwnlib.util import safeeval +from pwnlib.util import sh_string +from pwnlib.util import web + __all__ = [ 'crc', 'cyclic', 'fiddling', 'hashes', 'iters', 'lists', 'misc', 'net', 'packing', 'proc', 'safeeval', 'web' ] - -from . import crc -from . import cyclic -from . import fiddling -from . import hashes -from . import iters -from . import lists -from . import misc -from . import net -from . import packing -from . import proc -from . import safeeval -from . import sh_string -from . import web diff --git a/pwnlib/util/crc/__init__.py b/pwnlib/util/crc/__init__.py index 3944f8800..092e5c2bb 100644 --- a/pwnlib/util/crc/__init__.py +++ b/pwnlib/util/crc/__init__.py @@ -11,14 +11,15 @@ An obvious optimization would be to actually generate some lookup-tables. """ +from __future__ import absolute_import import sys import types -from . import known -from .. import fiddling -from .. import packing -from .. import safeeval +from pwnlib.util import fiddling +from pwnlib.util import packing +from pwnlib.util import safeeval +from pwnlib.util.crc import known class BitPolynom(object): diff --git a/pwnlib/util/cyclic.py b/pwnlib/util/cyclic.py index bcaff3726..d3f934566 100644 --- a/pwnlib/util/cyclic.py +++ b/pwnlib/util/cyclic.py @@ -1,8 +1,10 @@ +from __future__ import absolute_import + import string -from . import packing -from ..context import context -from ..log import getLogger +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util import packing log = getLogger(__name__) diff --git a/pwnlib/util/fiddling.py b/pwnlib/util/fiddling.py index ce00a131d..80ec173dd 100644 --- a/pwnlib/util/fiddling.py +++ b/pwnlib/util/fiddling.py @@ -1,17 +1,19 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import base64 import random import re import string import StringIO -from . import lists -from . import packing -from ..context import context -from ..log import getLogger -from ..term import text -from .cyclic import cyclic -from .cyclic import cyclic_find +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.term import text +from pwnlib.util import lists +from pwnlib.util import packing +from pwnlib.util.cyclic import cyclic +from pwnlib.util.cyclic import cyclic_find log = getLogger(__name__) diff --git a/pwnlib/util/getdents.py b/pwnlib/util/getdents.py index 2ac6a0d41..ef482e049 100644 --- a/pwnlib/util/getdents.py +++ b/pwnlib/util/getdents.py @@ -1,6 +1,8 @@ -from ..context import context -from .fiddling import hexdump -from .packing import unpack +from __future__ import absolute_import + +from pwnlib.context import context +from pwnlib.util.fiddling import hexdump +from pwnlib.util.packing import unpack class linux_dirent(object): diff --git a/pwnlib/util/iters.py b/pwnlib/util/iters.py index b5a68bf49..63691e554 100644 --- a/pwnlib/util/iters.py +++ b/pwnlib/util/iters.py @@ -1,6 +1,18 @@ """ This module includes and extends the standard module :mod:`itertools`. """ +from __future__ import absolute_import + +import collections +import copy +import multiprocessing +import operator +import random +import time +from itertools import * + +from pwnlib.context import context +from pwnlib.log import getLogger __all__ = [ 'bruteforce' , @@ -53,16 +65,7 @@ 'tee' ] -import collections -import copy -import multiprocessing -import operator -import random -import time -from itertools import * -from ..context import context -from ..log import getLogger log = getLogger(__name__) diff --git a/pwnlib/util/misc.py b/pwnlib/util/misc.py index 92bfba842..6d9a94717 100644 --- a/pwnlib/util/misc.py +++ b/pwnlib/util/misc.py @@ -7,10 +7,10 @@ import stat import string -from . import fiddling -from . import lists -from ..context import context -from ..log import getLogger +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.util import fiddling +from pwnlib.util import lists log = getLogger(__name__) diff --git a/pwnlib/util/packing.py b/pwnlib/util/packing.py index 7d849771c..514fe698c 100644 --- a/pwnlib/util/packing.py +++ b/pwnlib/util/packing.py @@ -30,12 +30,14 @@ >>> with context.local(endian='big'): print repr(p(0x1ff)) '\xff\x01' """ +from __future__ import absolute_import + import struct import sys -from . import iters -from ..context import LocalContext -from ..context import context +from pwnlib.context import LocalContext +from pwnlib.context import context +from pwnlib.util import iters mod = sys.modules[__name__] @@ -596,7 +598,7 @@ def fit(pieces=None, **kwargs): """ # HACK: To avoid circular imports we need to delay the import of `cyclic` - from . import cyclic + from pwnlib.util import cyclic filler = kwargs.pop('filler', cyclic.de_bruijn()) length = kwargs.pop('length', None) diff --git a/pwnlib/util/proc.py b/pwnlib/util/proc.py index a893246d3..c6ca6b8fb 100644 --- a/pwnlib/util/proc.py +++ b/pwnlib/util/proc.py @@ -1,11 +1,13 @@ +from __future__ import absolute_import + import errno import socket import time import psutil -from .. import tubes -from ..log import getLogger +from pwnlib import tubes +from pwnlib.log import getLogger log = getLogger(__name__) diff --git a/pwnlib/util/sh_string.py b/pwnlib/util/sh_string.py index 05bdeb4f5..7b5d4856b 100644 --- a/pwnlib/util/sh_string.py +++ b/pwnlib/util/sh_string.py @@ -222,14 +222,16 @@ [openbsd]: http://man.openbsd.org/cgi-bin/man.cgi?query=sh#SHELL_GRAMMAR [busybox]: https://en.wikipedia.org/wiki/BusyBox#Features """ +from __future__ import absolute_import + import string import subprocess -from . import fiddling -from ..context import context -from ..log import getLogger -from ..tubes.process import process -from .misc import which +from pwnlib.context import context +from pwnlib.log import getLogger +from pwnlib.tubes.process import process +from pwnlib.util import fiddling +from pwnlib.util.misc import which log = getLogger(__name__) diff --git a/pwnlib/util/splash.py b/pwnlib/util/splash.py index ca5005910..870c8d9af 100644 --- a/pwnlib/util/splash.py +++ b/pwnlib/util/splash.py @@ -1,10 +1,11 @@ """Silly module mostly meant as an easter-egg.""" +from __future__ import absolute_import import threading import time -from .. import term -from ..term import text +from pwnlib import term +from pwnlib.term import text _banner = r''' diff --git a/pwnlib/util/web.py b/pwnlib/util/web.py index 7c651d69c..ba6545cdb 100644 --- a/pwnlib/util/web.py +++ b/pwnlib/util/web.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import os import tempfile -from ..log import getLogger -from .misc import size +from pwnlib.log import getLogger +from pwnlib.util.misc import size log = getLogger(__name__)