From 25c84daa8aa04149d3d3cae78b9966322270ede3 Mon Sep 17 00:00:00 2001 From: david942j Date: Sat, 10 Feb 2018 02:53:00 +0800 Subject: [PATCH 1/2] Fix usage of syscall open in shellcraft templates (#1106) --- pwnlib/shellcraft/templates/aarch64/linux/open.asm | 4 ++-- pwnlib/shellcraft/templates/amd64/linux/cat.asm | 2 +- pwnlib/shellcraft/templates/arm/linux/cat.asm | 2 +- pwnlib/shellcraft/templates/i386/linux/cat.asm | 2 +- pwnlib/shellcraft/templates/mips/linux/cat.asm | 2 +- pwnlib/shellcraft/templates/thumb/linux/cat.asm | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pwnlib/shellcraft/templates/aarch64/linux/open.asm b/pwnlib/shellcraft/templates/aarch64/linux/open.asm index 420835296..1fd0c4318 100644 --- a/pwnlib/shellcraft/templates/aarch64/linux/open.asm +++ b/pwnlib/shellcraft/templates/aarch64/linux/open.asm @@ -1,7 +1,7 @@ <% from pwnlib import shellcraft %> -<%page args="filename, mode='O_RDONLY'"/> +<%page args="filename, flags='O_RDONLY', mode=0"/> <%docstring> Opens a file @@ -9,4 +9,4 @@ Opens a file AT_FDCWD=-100 %> ${shellcraft.pushstr(filename)} - ${shellcraft.syscall('SYS_openat', AT_FDCWD, 'sp', mode, 0)} + ${shellcraft.syscall('SYS_openat', AT_FDCWD, 'sp', flags, mode)} diff --git a/pwnlib/shellcraft/templates/amd64/linux/cat.asm b/pwnlib/shellcraft/templates/amd64/linux/cat.asm index fcf1d1699..8f252c5f3 100644 --- a/pwnlib/shellcraft/templates/amd64/linux/cat.asm +++ b/pwnlib/shellcraft/templates/amd64/linux/cat.asm @@ -8,5 +8,5 @@ Opens a file and writes its contents to the specified file descriptor. ${pushstr(filename)} - ${syscall('SYS_open', 'rsp', 0, 'O_RDONLY')} + ${syscall('SYS_open', 'rsp', 'O_RDONLY', 0)} ${syscall('SYS_sendfile', fd, 'rax', 0, 0x7fffffff)} \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/arm/linux/cat.asm b/pwnlib/shellcraft/templates/arm/linux/cat.asm index 3da5b7e73..755a74222 100644 --- a/pwnlib/shellcraft/templates/arm/linux/cat.asm +++ b/pwnlib/shellcraft/templates/arm/linux/cat.asm @@ -15,5 +15,5 @@ Example: ${arm.pushstr(filename)} - ${arm.linux.open('sp', 0, int(constants.O_RDONLY))} + ${arm.linux.open('sp', int(constants.O_RDONLY), 0)} ${arm.linux.sendfile(fd, 'r0', 0, 0x7fffffff)} diff --git a/pwnlib/shellcraft/templates/i386/linux/cat.asm b/pwnlib/shellcraft/templates/i386/linux/cat.asm index 992b96a97..412d3a115 100644 --- a/pwnlib/shellcraft/templates/i386/linux/cat.asm +++ b/pwnlib/shellcraft/templates/i386/linux/cat.asm @@ -19,5 +19,5 @@ label = common.label("sendfile_loop") %> ${sc.pushstr(filename)} - ${sc.open('esp', 0, 'O_RDONLY')} + ${sc.open('esp', 'O_RDONLY', 0)} ${sc.sendfile(fd, 'eax', 0, 0x7fffffff)} diff --git a/pwnlib/shellcraft/templates/mips/linux/cat.asm b/pwnlib/shellcraft/templates/mips/linux/cat.asm index f5a17deba..7dd9695f8 100644 --- a/pwnlib/shellcraft/templates/mips/linux/cat.asm +++ b/pwnlib/shellcraft/templates/mips/linux/cat.asm @@ -22,5 +22,5 @@ label = common.label("sendfile_loop") %> ${mips.pushstr(filename)} - ${mips.open('$sp', 0, int(constants.O_RDONLY))} + ${mips.open('$sp', int(constants.O_RDONLY), 0)} ${mips.sendfile(fd, '$v0', 0, 0x7fffffff)} diff --git a/pwnlib/shellcraft/templates/thumb/linux/cat.asm b/pwnlib/shellcraft/templates/thumb/linux/cat.asm index 7f5380392..680cabb28 100644 --- a/pwnlib/shellcraft/templates/thumb/linux/cat.asm +++ b/pwnlib/shellcraft/templates/thumb/linux/cat.asm @@ -20,6 +20,6 @@ label = common.label("sendfile_loop") %> ${thumb.pushstr(filename)} - ${thumb.linux.open('sp', 0, constants.O_RDONLY)} + ${thumb.linux.open('sp', constants.O_RDONLY, 0)} ${thumb.mov('r5', 'r0')} ${thumb.linux.sendfile(fd, 'r5', 0, 0x7fffffff)} From 2a73356c78bf4e62e66ecd65d8b2ef4bdfcb7f1f Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Tue, 20 Feb 2018 14:49:09 -0600 Subject: [PATCH 2/2] Fix test breakage caused by Sphinx deprecation (#1113) * Fix test breakage caused by Sphinx deprecation * Fix missing import in RST Closes #1112 --- docs/source/conf.py | 21 +++++++++++++++++++++ docs/source/elf/corefile.rst | 1 + 2 files changed, 22 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 387fbe08c..59546d05d 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,6 +24,27 @@ import pwnlib +# -- WORK-AROUNDS FOR DEPRECATION ---------------------------------------------- +# Deprecated +# 1.6b1 +# sphinx.util.compat.Directive class is now deprecated. +# Please use instead docutils.parsers.rst.Directive +# +# Pwntools Note: +# Can't just "do the right thing" since we have dependencies that +# are also affected by this, specifically sphinxcontrib.autoprogram +try: + import sphinx.util.compat +except ImportError: + import sys + import types + import sphinx.util + import docutils.parsers.rst + class compat(types.ModuleType): + Directive = docutils.parsers.rst.Directive + sphinx.util.compat = compat('sphinx.util.compat') + sys.modules['sphinx.util.compat'] = sphinx.util.compat + # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. diff --git a/docs/source/elf/corefile.rst b/docs/source/elf/corefile.rst index df73e51b5..abf197891 100644 --- a/docs/source/elf/corefile.rst +++ b/docs/source/elf/corefile.rst @@ -1,5 +1,6 @@ .. testsetup:: * + from glob import glob from pwn import * :mod:`pwnlib.elf.corefile` --- Core Files