Compare commits

...
40 Commits
Author SHA1 Message Date
Mathias Svensson 894b17e74a Release 3.1.1 2016-10-23 11:11:39 +02:00
Mathias Svensson 33b734cbc6 Added a doctest for MemLeak.struct 2016-10-23 11:11:32 +02:00
Morten Brøns-Pedersen 3e8454412e Bugfix in MemLeak.struct. (#768)
The function didn't work due to `sizeof` not being defined.  This PR imports
`ctypes` and uses `ctypes.sizeof`.
2016-10-23 10:53:04 +02:00
Zach Riggle 0c4d1365e9 Fix documentation generation since autoprogram broke Python2 2016-10-18 22:57:32 +02:00
Mathias Svensson fc097f3446 Fixed a link in the CHANGELOG 2016-10-02 20:27:51 +02:00
Mathias Svensson eb92a95134 Release 3.1.0 2016-10-02 20:12:51 +02:00
Zach Riggle c706461f10 Add branch table 2016-10-02 20:07:12 +02:00
Mathias Svensson 9cca9c989b Merge branch 'stable' into beta 2016-09-19 23:07:53 +02:00
Mathias Svensson f42c291fef Release 3.0.4 2016-09-19 22:57:54 +02:00
Zach Riggle dacdd397ab Merge remote-tracking branch 'upstream/stable' into beta 2016-09-19 13:10:34 -07:00
Zach Riggle c0f02d453a Merge pull request #752 from zachriggle/fix-setup
Add all MD and TXT files to binary distribution; include correct file…
2016-09-19 21:52:55 +02:00
Mathias Svensson 254958bae9 Merge branch 'stable' into beta 2016-09-19 00:28:50 +02:00
Mathias Svensson 1cb47220f1 Fixed this binutils-multiarch path 2016-09-19 00:27:56 +02:00
Mathias Svensson d9be4f9ce0 Made the wget timeout longer 2016-09-19 00:18:37 +02:00
Mathias Svensson 6ebcc6f3a2 Merge branch 'stable' into beta 2016-09-18 22:31:34 +02:00
Mathias Svensson 21ce572dd6 Make CHANGELOG.md closer follow dev for easier forwardporting in the future 2016-09-18 22:30:23 +02:00
Mathias Svensson 89fc74facf Merge branch 'stable' into beta 2016-09-18 21:35:21 +02:00
Mathias Svensson 5a79a5e609 Release 3.0.3 2016-09-18 21:21:42 +02:00
Mathias Svensson c92f9bed42 I was being stupid when I did #744, since @zachriggle was not done. This is (hopefully) a more proper fix. 2016-09-18 21:09:29 +02:00
Mathias Svensson bfb534378b Removed verbosity from travis files 2016-09-18 19:35:28 +02:00
Mathias Svensson 0ddcf8b129 Add a test that we will *not* update when we have a never local version 2016-09-18 19:35:06 +02:00
Mathias Svensson a66376b8a0 Merge branch 'faster-update-import' of https://github.com/zachriggle/pwntools into merge-738 2016-09-18 15:23:25 +02:00
Mathias Svensson 9cb53d90fe Merge branch 'corefile-pyelftools' of https://github.com/binjitsu/binjitsu into release-3.0.3 2016-09-18 15:00:37 +02:00
Mathias Svensson a31cec5e81 Removed aarch64 install as it is broken and not currently needed and stopped bailing out even if .ssh exists 2016-09-18 14:50:52 +02:00
Zach Riggle 5367a3528d Promote binutils installation 2016-09-18 14:49:59 +02:00
Zach Riggle 669e7295c6 Auto-detect the current URL for QEMU rather than relying on a hard-coded URL 2016-09-18 14:49:03 +02:00
Zach Riggle a7f32d1b0f Bail on any error 2016-09-18 14:48:05 +02:00
Zach Riggle d5fbb21f72 Switch from pkg_resources to packaging, for performance reasons
Also backports the PyPi documentation changes to stable.

Fixes #736
2016-09-17 18:13:57 -07:00
Zach Riggle cd0ba369b8 Fix bug introduced by internal changes to pyelftools v0.2.4 2016-09-14 12:23:47 -07:00
Mathias Svensson 5fe024838b Release 3.1.0beta1 2016-09-06 11:36:27 -10:00
Mathias Svensson b60103b839 Merge branch 'stable' into beta 2016-09-06 11:30:58 -10:00
Mathias Svensson a5c2b9276a Merge branch 'stable' into beta 2016-09-06 10:07:33 -10:00
Mathias Svensson efaea581a1 Merge branch 'stable' into beta 2016-08-24 20:04:06 -07:00
Mathias Svensson 300ef0b462 Merge branch 'Idolf-beta-changelog' into beta 2016-08-24 14:20:02 -07:00
Mathias Svensson 6e79272e8d Updated the changelog 2016-08-24 14:17:46 -07:00
Mathias Svensson e4c2a48696 Merge pull request #679 from Gallopsled/stable
Even more documentation (#678)
2016-08-22 15:22:39 -07:00
Mathias Svensson abd08a94ea Fixed the logo path to be closer to stable 2016-08-22 14:48:26 -07:00
Mathias Svensson e877f7455a Merge branch 'stable' into beta 2016-08-22 14:37:33 -07:00
Mathias Svensson 12b60447da Merging #674 into beta 2016-08-20 18:39:00 -07:00
Mathias Svensson 2663762a9a Prepare the beta branch 2016-08-20 17:48:37 -07:00
10 changed files with 223 additions and 67 deletions

No files matched your search

+20 -18
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash -e
set -e
local_deb_extract()
{
wget $1
@@ -17,7 +18,8 @@ get_binutils()
get_qemu()
{
echo "Installing qemu"
QEMU_URL='https://mirrors.kernel.org/ubuntu/pool/universe/q/qemu/qemu-user-static_2.6%2bdfsg-3ubuntu1_amd64.deb'
QEMU_INDEX='http://packages.ubuntu.com/en/yakkety/amd64/qemu-user-static/download'
QEMU_URL=$(curl "$QEMU_INDEX" | grep kernel.org | grep -Eo 'http.*\.deb')
local_deb_extract "$QEMU_URL"
}
@@ -26,35 +28,35 @@ setup_travis()
export PATH=$PWD/usr/bin:$PATH
export LD_LIBRARY_PATH=$PWD/usr/lib
if [ ! -d usr/bin ];
# Install libbfd-multiarch and libopcodes-multiarch if not found in the cache
if [ ! -f usr/lib/libbfd-2.22-multiarch.so ];
then
# Install our custom binutils
which arm-linux-as || get_binutils arm
which mips-linux-as || get_binutils mips
which powerpc-linux-as || get_binutils powerpc
which aarch64-linux-as || get_binutils aarch64
# Install the multiarch binutils
local_deb_extract http://mirrors.mit.edu/ubuntu/ubuntu/pool/universe/b/binutils/binutils-multiarch_2.22-6ubuntu1_amd64.deb
local_deb_extract http://mirrors.mit.edu/ubuntu/pool/universe/b/binutils/binutils-multiarch_2.22-6ubuntu1_amd64.deb
pushd usr/lib
ln -sf libbfd-2.22-multiarch.so libbfd-2.22.so
ln -sf libopcodes-2.22-multiarch.so libopcodes-2.22.so
popd
fi
if ! (which qemu-arm-static && qemu-arm-static -version | grep 2.6.0); then
# Install/upgrade qemu
if ! (which qemu-arm-static && qemu-arm-static -version | grep 2.6.1); then
get_qemu
fi
# Get rid of files we don't want cached
rm -rf usr/share
pushd usr/lib
ln -sf libbfd-2.22-multiarch.so libbfd-2.22.so
ln -sf libopcodes-2.22-multiarch.so libopcodes-2.22.so
popd
# Install our custom binutils
which arm-linux-gnu-as || get_binutils arm
which mips-linux-gnu-as || get_binutils mips
which powerpc-linux-gnu-as || get_binutils powerpc
# Test that the installs worked
which arm-linux-gnu-as
which mips-linux-gnu-as
which powerpc-linux-gnu-as
which aarch64-linux-gnu-as
which qemu-arm-static
# Get rid of files we don't want cached
rm -rf usr/share
}
setup_linux()
+3 -1
View File
@@ -4,6 +4,8 @@
#
# All of the "conditional sudo" is to do container-based builds on
# Travis which are much, much faster.
set -e
U=travis
H=/home/$U
@@ -36,7 +38,7 @@ pubkey=$(cat ~/.ssh/$U.pub)
# Set the authorized_keys entry to only permit login from localhost,
# and only with
USUDO mkdir $H/.ssh
USUDO mkdir $H/.ssh || true
USUDO tee -a $H/.ssh/authorized_keys <<EOF
from="127.0.0.1" $pubkey
EOF
+40 -4
View File
@@ -3,17 +3,53 @@
This changelog only includes added major features and changes. Bugfixes and
minor changes are omitted.
## 3.0.2 (September 6 2016)
## Release History
The table below shows which release corresponds to each branch, and what date the version was released.
| Version | Branch | Release Date |
| ---------------- | -------- | ---------------------- |
| [3.3.0](#330) | `dev` | Dec 24, 2016 (planned)
| [3.2.0](#320) | `beta` | Nov 12, 2016 (planned)
| [3.1.1](#311) | `stable` | Oct 23, 2016
| [3.1.0](#310) | | Oct 2, 2016
| [3.0.4](#304) | | Sept 19, 2016
| [3.0.3](#303) | | Sept 18, 2016
| [3.0.2](#302) | | Sept 6, 2016
| [3.0.1](#301) | | Aug 20, 2016
| [3.0.0](#300) | | Aug 20, 2016
| [2.2.0](#220) | | Jan 5, 2015
## 3.1.1
Fixed a bug in `MemLeak.struct` (PR: #768).
## 3.1.0
A number of smaller bugfixes and documentation tweaks.
## 3.0.4
- Fixed a bug that made 3.0.3 uninstallable (Issue: #751, PR: #752)
## 3.0.3
- Fixed some performance and usability problems with the update system (Issues:
#723, #724, #736. PRs: #729, #738, #747).
- Fixed a bug related to internals in pyelftools (PRs: #730, #746).
- Fixed an issue with travis (Issue: #741, PRs: #743, #744, #745).
## 3.0.2
- Cherry-pick #695, as this was a regression-fix.
- Added a fix for the update checker, as it would suggest prereleases as updates to stable releases.
- Various documentation fixes.
## 3.0.1 (August 20 2016)
## 3.0.1
A small bugfix release. There were a lot of references to the `master`-branch, however after 3.0.0 we use the names `stable`, `beta` and `dev` for our branches.
## 3.0.0 (August 20 2016)
## 3.0.0
This was a large release (1305 commits since 2.2.0) with a lot of bugfixes and changes. The Binjitsu project, a fork of Pwntools, was merged back into Pwntools. As such, its features are now available here.
@@ -49,7 +85,7 @@ Android support via a new `adb` module, `context.device`, `context.adb_host`, an
- Added `context.noptrace` setting for disabling actions which require `ptrace` support. This is useful for turning all `gdb.debug` and `gdb.attach` options into no-ops, and can be set via the `NOPTRACE` magic command-line option.
- Added `context.proxy` which hooks all connections and sends them to a SOCKS4/SOCKS5. This can be set via the `PROXY` magic command-line option.
- Added `context.randomize` to control randommization of settings like XOR keys and register ordering (default off).
- Added `context.termianl` for setting how to launch commands in a new terminal.
- Added `context.terminal` for setting how to launch commands in a new terminal.
#### DynELF and MemLeak Module
+7 -1
View File
@@ -1 +1,7 @@
include *.txt
graft examples
graft extra
include *.md *.txt *.sh *.yml MANIFEST.in
recursive-include docs *.rst *.png Makefile *.py *.txt
recursive-include pwnlib *.py *.asm *.rst *.md *.txt *.sh
recursive-include pwn *.py *.asm *.rst *.md *.txt *.sh
recursive-exclude *.pyc
+1 -1
View File
@@ -1,5 +1,5 @@
sphinxcontrib-napoleon
sphinxcontrib-autoprogram
sphinxcontrib-autoprogram==0.1.2
isort
paramiko>=1.15.2
mako>=1.0.0
+2 -3
View File
@@ -6,7 +6,6 @@ from elftools.common.py3compat import bytes2str
from elftools.common.utils import roundup
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
@@ -30,11 +29,11 @@ def iter_notes(self):
end = self['p_offset'] + self['p_filesz']
while offset < end:
note = struct_parse(
self._elfstructs.Elf_Nhdr,
self.elffile.structs.Elf_Nhdr,
self.stream,
stream_pos=offset)
note['n_offset'] = offset
offset += self._elfstructs.Elf_Nhdr.sizeof()
offset += self.elffile.structs.Elf_Nhdr.sizeof()
self.stream.seek(offset)
# n_namesz is 4-byte aligned.
disk_namesz = roundup(note['n_namesz'], 2)
+12 -1
View File
@@ -1,3 +1,4 @@
import ctypes
import functools
import string
@@ -96,8 +97,18 @@ class MemLeak(object):
struct(class): A ctypes structure to be instantiated with leaked data
Return Value:
An instance of the provided struct class, with the leaked data decoded
Examples:
>>> @pwnlib.memleak.MemLeak
... def leaker(addr):
... return "A"
>>> e = leaker.struct(0, pwnlib.elf.Elf32_Phdr)
>>> hex(e.p_paddr)
'0x41414141'
"""
size = sizeof(struct)
size = ctypes.sizeof(struct)
data = self.n(address, size)
obj = struct.from_buffer_copy(data)
return obj
+100 -28
View File
@@ -1,54 +1,83 @@
"""
# Pwntools Update
In order to ensure that Pwntools users always have the latest and
greatest version, Pwntools automatically checks for updates.
Since this update check takes a moment, it is only performed once
every week. It can be permanently disabled via:
.. code-block:: bash
$ echo never > ~/.pwntools-cache/update
"""
import datetime
import json
import pip
import pkg_resources
import os
import time
import xmlrpclib
import packaging.version
from .context import context
from .log import getLogger
from .version import __version__
from .util.misc import read
from .util.misc import write
from .util.web import wget
from .version import __version__
log = getLogger(__name__)
current_version = pkg_resources.parse_version(__version__)
current_version = packaging.version.Version(__version__)
package_name = 'pwntools'
package_repo = 'Gallopsled/pwntools'
update_freq = datetime.timedelta(days=7).total_seconds()
def available_on_github(prerelease=False):
"""Return True if an update is available on Github."""
def available_on_github(prerelease=current_version.is_prerelease):
"""Return True if an update is available on Github.
>>> available_on_github() # doctest: +ELLIPSIS
<Version('...')>
>>> available_on_github(prerelease=False).is_prerelease
False
"""
url = 'https://api.github.com/repos/%s/tags' % package_repo
with context.quiet:
tags = json.loads(wget(url))
tags = json.loads(wget(url, timeout = 60))
versions = map(pkg_resources.parse_version, [t['name'] for t in tags])
# 'pwntools-ancient' is a tag, but not a valid version.
# Handle this here, and for all potential tags which cause
# issues.
versions = []
for tag in [t['name'] for t in tags]:
try:
versions.append(packaging.version.Version(tag))
except Exception:
pass
if not prerelease:
versions = filter(lambda v: not v.is_prerelease, versions)
return max(versions)
def available_on_pypi(prerelease=False):
"""Return True if an update is available on PyPI."""
search_command = pip.commands.search.SearchCommand()
options, _ = search_command.parse_args([package_name])
pypi_hits = search_command.search(package_name, options)
for hit in pip.commands.search.transform_hits(pypi_hits):
if hit['name'] != 'pwntools':
continue
def available_on_pypi(prerelease=current_version.is_prerelease):
"""Return True if an update is available on PyPI.
versions = map(pkg_resources.parse_version, hit['versions'])
>>> available_on_pypi() # doctest: +ELLIPSIS
<Version('...')>
>>> available_on_pypi(prerelease=False).is_prerelease
False
"""
client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
versions = client.package_releases('pwntools', True)
versions = map(packaging.version.Version, versions)
if not prerelease:
versions = filter(lambda v: not v.is_prerelease, versions)
if not prerelease:
versions = filter(lambda v: not v.is_prerelease, versions)
return max(versions)
return max(versions)
def cache_file():
"""Returns the path of the file used to cache update data, and ensures that it exists."""
@@ -73,18 +102,50 @@ def should_check():
return False
return time.time() > (last_check() + update_freq)
def perform_check(prerelease=False):
"""Perform the update check, and report to the user."""
def perform_check(prerelease=current_version.is_prerelease):
"""Perform the update check, and report to the user.
Arguments:
prerelease(bool): Whether or not to include pre-release versions.
Returns:
A list of arguments to the update command.
>>> from packaging.version import Version
>>> pwnlib.update.current_version = Version("999.0.0")
>>> print perform_check()
None
>>> pwnlib.update.current_version = Version("0.0.0")
>>> perform_check() # doctest: +ELLIPSIS
['pip', 'install', '-U', ...]
>>> def bail(*a): raise Exception()
>>> github = pwnlib.update.available_on_github
>>> pypi = pwnlib.update.available_on_pypi
>>> pwnlib.update.available_on_github = bail
>>> perform_check(prerelease=False)
['pip', 'install', '-U', 'pwntools']
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
['pip', 'install', '-U', 'pwntools...']
>>> pwnlib.update.available_on_github = github
>>> pwnlib.update.available_on_pypi = bail
>>> perform_check(prerelease=False)
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
"""
pypi = current_version
try:
pypi = available_on_pypi(prerelease)
except:
except Exception:
log.warning("An issue occurred while checking PyPI")
github = current_version
try:
github = available_on_github(prerelease)
except:
except Exception:
log.warning("An issue occurred while checking Github")
best = max(pypi, github, current_version)
@@ -97,15 +158,26 @@ def perform_check(prerelease=False):
log.info("You have the latest version of Pwntools (%s)" % best)
return
command = [
'pip',
'install',
'-U'
]
if best == pypi:
where = 'pypi'
command = 'pip install -U %s' % package_name
pypi_package = package_name
if best.is_prerelease:
pypi_package += '==%s' % (best)
command += [pypi_package]
else:
where = 'GitHub'
command = 'pip install -U git+https://github.com/%s.git@%s' % (package_repo, github)
command += ['git+https://github.com/%s.git@%s' % (package_repo, github)]
command_str = ' '.join(command)
log.info("A newer version of %s is available on %s (%s --> %s).\n" % (package_name, where, current_version, best) +
"Update with: $ %s" % command)
"Update with: $ %s" % command_str)
return command
+1 -1
View File
@@ -1 +1 @@
__version__ = '3.0.2'
__version__ = '3.1.1'
+37 -9
View File
@@ -22,6 +22,7 @@ for scheme in INSTALL_SCHEMES.values():
# Find all of the console scripts
console_scripts = []
for filename in glob.glob('pwnlib/commandline/*'):
filename = os.path.basename(filename)
filename, ext = os.path.splitext(filename)
@@ -34,7 +35,7 @@ for filename in glob.glob('pwnlib/commandline/*'):
install_requires = ['paramiko>=1.15.2',
'mako>=1.0.0',
'pyelftools>=0.2.3',
'pyelftools>=0.2.4',
'capstone',
'ropgadget>=5.3',
'pyserial>=2.7',
@@ -43,7 +44,9 @@ install_requires = ['paramiko>=1.15.2',
'tox>=1.8.1',
'pygments>=2.0',
'pysocks',
'python-dateutil']
'python-dateutil',
'pypandoc',
'packaging']
# This is a hack until somebody ports psutil to OpenBSD
if platform.system() != 'OpenBSD':
@@ -56,13 +59,25 @@ if not os.path.exists(PythonH):
print >> sys.stderr, "$ apt-get install python-dev"
sys.exit(-1)
# Convert README.md to reStructuredText for PyPI
long_description = ''
try:
import pypandoc
try:
pypandoc.get_pandoc_path()
except OSError:
pypandoc.download_pandoc()
long_description = pypandoc.convert_file('README.md', 'rst')
except ImportError:
pass
setup(
name = 'pwntools',
packages = find_packages(),
version = '3.0.2',
version = '3.1.1',
data_files = [('',
['LICENSE-pwntools.txt',
]),
glob.glob('*.md') + glob.glob('*.txt')),
],
package_data = {
'pwnlib': [
@@ -75,19 +90,32 @@ setup(
},
entry_points = {'console_scripts': console_scripts},
scripts = glob.glob("bin/*"),
description = "CTF framework and exploit development library.",
description = "Pwntools CTF framework and exploit development library.",
long_description = long_description,
author = "Gallopsled et al.",
author_email = "#pwntools @ freenode.net",
url = 'https://pwntools.com',
download_url = "https://github.com/Gallopsled/pwntools/releases",
install_requires = install_requires,
license = "Mostly MIT, some GPL/BSD, see LICENSE-pwntools.txt",
keywords = 'pwntools exploit ctf capture the flag binary wargame overflow stack heap defcon',
classifiers = [
'Topic :: Security',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Operating System :: OS Independent',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Intended Audience :: Developers'
'Topic :: Security',
'Topic :: Software Development :: Assemblers',
'Topic :: Software Development :: Debuggers',
'Topic :: Software Development :: Disassemblers',
'Topic :: Software Development :: Embedded Systems',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: System Shells',
'Topic :: Utilities',
]
)