Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin pyelftools to 0.2.4 #1196

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5c4def0
Start working on 3.13.0dev
TethysSvensson Jan 3, 2018
7860eec
Prevent Python3 installation via "pip3 install pwntools" (#1093)
zachriggle Jan 4, 2018
9859f54
Remove pypandoc as a dependency (#1098)
kristoff3r Jan 25, 2018
3ff283c
unify `flat` and `fit` (#1096)
br0ns Jan 25, 2018
c7c5019
Improved hexdump output (#1094)
dimos Jan 25, 2018
63dfed7
Do not throw an exception if the Corefile cannot be deleted after copy
zachriggle Jan 24, 2018
f3b5a14
Don't accidentally debug init, which causes a kernel panic
zachriggle Jan 24, 2018
5fdc084
Workaround broken "pidof" on older Android emulators
zachriggle Jan 25, 2018
6808501
Merge branch 'stable' into beta
zachriggle Jan 25, 2018
14b2f29
Merge branch 'beta' into dev
zachriggle Jan 25, 2018
aadf409
Enable setting context.os via context.binary (#1101)
zachriggle Jan 25, 2018
a208251
Fix typo (#1099)
zachriggle Jan 27, 2018
90f23df
Implemented the dump() feature in the DynELF. (#1104)
eyalitki Feb 6, 2018
8a3a577
Add BUILD_SET to const opcodes (#1103)
Arusekk Feb 7, 2018
cd8f8d3
Removed useragentstring.com as user agents source, fixed BeautifulSou…
tandriamil Feb 13, 2018
2255b7f
Update asm.py
zachriggle Feb 19, 2018
758a954
Update CHANGELOG
zachriggle Feb 20, 2018
b507bd7
Merge branch 'beta' into dev
zachriggle Feb 20, 2018
1e6f207
Release 3.13.0beta0
TethysSvensson Feb 22, 2018
aa1f792
Begin working on 3.14.0
TethysSvensson Feb 22, 2018
d67cb15
Fix input encoding parsing (#1111)
dimos Feb 23, 2018
6e1e96d
Update packages to Artful
zachriggle Feb 28, 2018
a28ae52
Update autoprogram version
zachriggle Feb 28, 2018
b53ec5e
Merge remote-tracking branch 'upstream/stable' into beta
zachriggle Feb 28, 2018
799f9a4
Expose BootloaderImage in ADB
zachriggle Mar 2, 2018
75b422a
Fix magic bytes check in pwnlib.adb.bootloader
zachriggle Mar 2, 2018
1f8f294
Expose BootloaderImage.header fields through __getattr__
zachriggle Mar 2, 2018
76413fc
Add pwnlib.adb.bootimg for 'ANDROID!' format boot.img images
zachriggle Mar 2, 2018
1854095
Expose adb.BootImage
zachriggle Mar 2, 2018
c14f1a4
Update bootimg.py
zachriggle Mar 2, 2018
532f910
Update bootimg.py
zachriggle Mar 2, 2018
e1b3c27
Update bootimg.py
zachriggle Mar 2, 2018
6cb9c1f
Fix grammar for mips doc (#1123)
mscherer Mar 19, 2018
6c79402
Remove tuple parameters unpacking due to PEP-3113 (#1119)
Arusekk Mar 19, 2018
9308062
Fix compatibility with newer version of sphinx (#1124)
mscherer Apr 2, 2018
fc31b51
Fix MIPS shell shellcraft not working properly (#1129)
Arusekk Apr 2, 2018
ac67b97
Add doctests for shellcraft.mips.sh()
zachriggle Apr 2, 2018
3d03a75
Replace division with floor division as of PEP-238 (#1135)
Arusekk Apr 11, 2018
2a4a633
Merge remote-tracking branch 'upstream/stable' into beta
zachriggle Apr 23, 2018
20cb049
Replaced except X,Y: with except X as Y: as of PEP-3110 (#1137)
Arusekk Apr 30, 2018
eeedb2c
Merge remote-tracking branch 'upstream/stable' into beta
zachriggle May 25, 2018
1fbff01
Merge branch 'beta' into dev
zachriggle May 25, 2018
8da0827
Replaced it.next() with next(it) as of PEP-3114 (#1136)
Arusekk May 30, 2018
338fbeb
Improve pwnup template, gdbserver detection (#1148)
ambiso May 30, 2018
c090910
Merge remote-tracking branch 'upstream/stable' into beta
zachriggle May 31, 2018
8e704e7
Fix #1164 (#1165)
Jun 11, 2018
8970156
Revert "Fix #1164 (#1165)" (#1167)
Jun 12, 2018
b7609ae
Update changelog for 3.12.1
zachriggle Jun 19, 2018
7dc76c7
Merge branch 'stable' into beta
zachriggle Jul 2, 2018
0d25ca3
Merge branch 'beta' into dev
zachriggle Jul 2, 2018
9023b38
corefile: also expose page_offset (#1169)
Mic92 Jul 3, 2018
b666e9e
mips: Enable XOR encoder
zachriggle Jul 19, 2018
75857fd
pin pyelftools to 0.2.4 until 0.2.5 can be fixed
crclark96 Sep 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ To be released on Mar 31, 2018.
[5fdc08]: https://github.com/Gallopsled/pwntools/commit/5fdc08
[63dfed]: https://github.com/Gallopsled/pwntools/commit/63dfed

## 3.12.1

- [#1159][1159] Fix check for `/proc/.../status`
- [#1162][1162] Fix broken package versions
- [#1150][1150] Fix exception raised when a cache file is missing
- [#1156][1156] Fix ROP gadget selection logic involving `int` and `syscall` instructions
- [#1152][1152] Fix QEMU LD_PREFIX calculation (wrong parameter passed)
- [#1155][1155] Use Ubuntu Trusty for all CI builds
- [#1131][1131] Add "libc-" to libc prefixes in `process` tubes
- [#1125][1125] Fix a typo
- [#1121][1121] Fix tests which were broken by an upstream Sphinx change

[1159]: https://github.com/Gallopsled/pwntools/pull/1159
[1162]: https://github.com/Gallopsled/pwntools/pull/1162
[1150]: https://github.com/Gallopsled/pwntools/pull/1150
[1156]: https://github.com/Gallopsled/pwntools/pull/1156
[1152]: https://github.com/Gallopsled/pwntools/pull/1152
[1155]: https://github.com/Gallopsled/pwntools/pull/1155
[1131]: https://github.com/Gallopsled/pwntools/pull/1131
[1125]: https://github.com/Gallopsled/pwntools/pull/1125
[1121]: https://github.com/Gallopsled/pwntools/pull/1121

## 3.12.0

- [#1083][1083] Better error messages for `gdb` when `LD_PRELOAD` is incorrect
Expand Down
2 changes: 1 addition & 1 deletion docs/dashbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main(args):
doc2dash.__main__.main.main( \
[ os.path.join(dstdir, "html"), "-d", dstdir, "-n", name, \
"-f", "-I", "index.html"], "doc2dash", False)
except SystemExit,e:
except SystemExit as e:
pass

# Insert a link to the online version.
Expand Down
1 change: 1 addition & 0 deletions pwnlib/abi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division

from pwnlib.context import LocalContext
from pwnlib.context import context
Expand Down
2 changes: 2 additions & 0 deletions pwnlib/adb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

from pwnlib.adb.adb import *
from pwnlib.adb.protocol import Client
from pwnlib.adb.bootimg import BootImage
from pwnlib.adb.bootloader import BootloaderImage
14 changes: 11 additions & 3 deletions pwnlib/adb/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

"""
from __future__ import absolute_import
from __future__ import division

import functools
import glob
Expand Down Expand Up @@ -881,9 +882,16 @@ def logcat(stream=False):
def pidof(name):
"""Returns a list of PIDs for the named process."""
with context.quiet:
io = process(['pidof', name])
data = io.recvall().split()
return list(map(int, data))
# Older devices have a broken 'pidof', apparently.
# Try pgrep first.
io = process(['pgrep', name])
data = io.recvall()

if 'not found' in data:
io = process(['pidof', name])
data = io.recvall()

return list(map(int, data.split()))

@with_device
def proc_exe(pid):
Expand Down
52 changes: 52 additions & 0 deletions pwnlib/adb/bootimg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from __future__ import division

import ctypes

BOOT_MAGIC = b"ANDROID!"
BOOT_MAGIC_SIZE = 8
BOOT_NAME_SIZE = 16
BOOT_ARGS_SIZE = 512
BOOT_EXTRA_ARGS_SIZE = 1024


class boot_img_hdr(ctypes.Structure):
_fields_ = [
('magic', ctypes.c_char * BOOT_MAGIC_SIZE),

('kernel_size', ctypes.c_uint32),
('kernel_addr', ctypes.c_uint32),

('ramdisk_size', ctypes.c_uint32),
('ramdisk_addr', ctypes.c_uint32),

('second_size', ctypes.c_uint32),
('second_addr', ctypes.c_uint32),

('tags_addr', ctypes.c_uint32),
('page_size', ctypes.c_uint32),
('unused', ctypes.c_uint32),

('os_version', ctypes.c_uint32),

('name', ctypes.c_char * BOOT_NAME_SIZE),
('cmdline', ctypes.c_char * BOOT_ARGS_SIZE),
('id', ctypes.c_char * 8),

('extra_cmdline', ctypes.c_char * BOOT_EXTRA_ARGS_SIZE),
]

class BootImage(object):
def __init__(self, data):
self.data = data
self.header = boot_img_hdr.from_buffer_copy(data)

PAGE = self.page_size

# The kernel starts at the beginning of the second page.
self.kernel = self.data[PAGE:PAGE+self.kernel_size]

def __getattr__(self, name):
value = getattr(self.header, name, None)
if value is not None:
return value
return getattr(super(BootImage, self), name)
43 changes: 32 additions & 11 deletions pwnlib/adb/bootloader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from __future__ import unicode_literals
from __future__ import division

import ctypes
import io
import os
import sys

from pwnlib.log import getLogger

log = getLogger(__name__)

class img_info(ctypes.Structure):
_fields_ = [
('name', ctypes.c_char * 64),
Expand All @@ -19,11 +24,7 @@ class bootloader_images_header(ctypes.Structure):
('bootldr_size', ctypes.c_uint32),
]

def __init__(self, *a, **kw):
super(bootloader_images_header, self).__init__(*a, **kw)
if self.magic != self.MAGIC:
raise ValueError("Incorrect magic (%r, expected %r)" % (self.magic, self.MAGIC))
MAGIC = 'BOOTLDR!'
BOOTLDR_MAGIC = bytes('BOOTLDR!')

class BootloaderImage(object):
def __init__(self, data):
Expand All @@ -35,7 +36,21 @@ def __init__(self, data):
self.data = data
self.header = bootloader_images_header.from_buffer_copy(data)

imgarray = ctypes.ARRAY(img_info, self.header.num_images)
if self.magic != BOOTLDR_MAGIC:
log.error("Incorrect magic (%r, expected %r)" % (self.magic, BOOTLDR_MAGIC))

if(self.bootldr_size > len(data)):
log.warn_once("Bootloader is supposed to be %#x bytes, only have %#x",
self.bootldr_size,
len(data))

if(self.num_images >= 0x100):
old = self.num_images
self.num_images = 1
log.warn_once("Bootloader num_images (%#x) appears corrupted, truncating to 1",
old)

imgarray = ctypes.ARRAY(img_info, self.num_images)
self.img_info = imgarray.from_buffer_copy(data, ctypes.sizeof(self.header))

def extract(self, index_or_name):
Expand All @@ -62,7 +77,7 @@ def extract(self, index_or_name):
if index >= len(self.img_info):
raise ValueError("index out of range (%s, max %s)" % (index, len(self.img_info)))

offset = self.header.start_offset
offset = self.start_offset

for i in range(index):
offset += self.img_info[i].size
Expand All @@ -87,16 +102,22 @@ def extract_all(self, path):
def __str__(self):
rv = []
rv.append("Bootloader")
rv.append(" Magic: %r" % self.header.magic)
rv.append(" Offset: %#x" % self.header.start_offset)
rv.append(" Size: %#x" % self.header.bootldr_size)
rv.append(" Images: %s" % self.header.num_images)
rv.append(" Magic: %r" % self.magic)
rv.append(" Offset: %#x" % self.start_offset)
rv.append(" Size: %#x" % self.bootldr_size)
rv.append(" Images: %s" % self.num_images)
for img in self.img_info:
rv.append(" Name: %s" % img.name)
rv.append(" Size: %#x" % img.size)
rv.append(" Data: %r..." % self.extract(img.name)[:32])
return '\n'.join(rv)

def __getattr__(self, name):
value = getattr(self.header, name, None)
if value is not None:
return value
return getattr(super(BootImage, self), name)

if __name__ == '__main__':
# Easy sanity checking
b = BootloaderImage(open(sys.argv[1]).read())
Expand Down
1 change: 1 addition & 0 deletions pwnlib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

"""
from __future__ import absolute_import
from __future__ import division

import collections
import logging
Expand Down
3 changes: 2 additions & 1 deletion pwnlib/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

"""
from __future__ import absolute_import
from __future__ import division

import errno
import os
Expand Down Expand Up @@ -614,7 +615,7 @@ def asm(shellcode, vma = 0, extract = True, shared = False):
Runs :func:`cpp` over a given shellcode and then assembles it into bytes.

To see which architectures or operating systems are supported,
look in :mod:`pwnlib.contex`.
look in :mod:`pwnlib.context`.

Assembling shellcode requires that the GNU assembler is installed
for the target architecture.
Expand Down
1 change: 1 addition & 0 deletions pwnlib/atexception.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
be run if an unhandled exception occurs.
"""
from __future__ import absolute_import
from __future__ import division

import sys
import threading
Expand Down
1 change: 1 addition & 0 deletions pwnlib/atexit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
printed twice when the standard :mod:`atexit` is used.
"""
from __future__ import absolute_import
from __future__ import division

import sys
import threading
Expand Down
10 changes: 6 additions & 4 deletions pwnlib/commandline/asm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down Expand Up @@ -45,22 +46,22 @@
parser.add_argument(
'-v', '--avoid',
action='append',
help = 'Encode the shellcode to avoid the listed bytes (provided as hex; default: 000a)'
help = 'Encode the shellcode to avoid the listed bytes (provided as hex)'
)

parser.add_argument(
'-n', '--newline',
dest='avoid',
action='append_const',
const='\n',
const='0a',
help = 'Encode the shellcode to avoid newlines'
)

parser.add_argument(
'-z', '--zero',
dest='avoid',
action='append_const',
const='\x00',
const='00',
help = 'Encode the shellcode to avoid NULL bytes'
)

Expand Down Expand Up @@ -106,7 +107,8 @@ def main(args):
formatters = {'r':str, 'h':enhex, 's':repr}

if args.avoid:
output = encode(output, args.avoid)
avoid = unhex(''.join(args.avoid))
output = encode(output, avoid)

if args.debug:
proc = gdb.debug_shellcode(output, arch=context.arch)
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/checksec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/constgrep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import os
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/cyclic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import string
Expand Down
6 changes: 6 additions & 0 deletions pwnlib/commandline/debug.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down Expand Up @@ -78,7 +79,12 @@ def main(args):
# pidof() returns a list
if not target:
log.error("Could not find a PID for %r", args.process)

target = target[0]

# pidof will sometimes return all PIDs, including init
if target == 1:
log.error("Got PID 1 from pidof. Check the process name, or use --pid 1 to debug init")
else:
parser.print_usage()
return 1
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/disablenx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

from pwn import *
from pwnlib.commandline import common
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/disasm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import string
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/elfdiff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import shutil
from argparse import ArgumentParser
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/elfpatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/hex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/phd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import
from __future__ import division

import argparse
import os
Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/pwnstrip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import
from __future__ import division

import argparse

Expand Down
1 change: 1 addition & 0 deletions pwnlib/commandline/scramble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import
from __future__ import division

import argparse
import sys
Expand Down
Loading