Skip to content

Commit

Permalink
Add aarch64 documentation, which enables doctests (#875)
Browse files Browse the repository at this point in the history
* Add aarch64 documentation, which enables doctests

* Fix failing doctest

* Attempt to figure out whats going on with Travis

* Use the Xenial version of qemu-static since the Zesty version is broken for AArch64
  • Loading branch information
zachriggle committed Feb 2, 2017
1 parent 2d04acb commit f3968af
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
19 changes: 19 additions & 0 deletions docs/source/shellcraft/aarch64.rst
@@ -0,0 +1,19 @@
.. testsetup:: *

from pwn import *
context.clear(arch='aarch64')

:mod:`pwnlib.shellcraft.aarch64` --- Shellcode for AArch64
===========================================================

:mod:`pwnlib.shellcraft.aarch64`
-----------------------------

.. automodule:: pwnlib.shellcraft.aarch64
:members:

:mod:`pwnlib.shellcraft.aarch64.linux`
-----------------------------------

.. automodule:: pwnlib.shellcraft.aarch64.linux
:members:
23 changes: 22 additions & 1 deletion pwnlib/shellcraft/templates/aarch64/linux/cat.asm
Expand Up @@ -9,7 +9,28 @@ Opens a file and writes its contents to the specified file descriptor.
Example:

>>> write('flag', 'This is the flag\n')
>>> run_assembly(shellcraft.cat('flag')).recvline()
>>> shellcode = shellcraft.cat('flag') + shellcraft.exit(0)
>>> print disasm(asm(shellcode))
0: d10043ff sub sp, sp, #0x10
4: d28d8cc0 mov x0, #0x6c66 // #27750
8: f2acec20 movk x0, #0x6761, lsl #16
c: f80003e0 stur x0, [sp]
10: 910003e0 mov x0, sp
14: aa1f03e1 mov x1, xzr
18: aa1f03e2 mov x2, xzr
1c: d2808008 mov x8, #0x400 // #1024
20: d4000001 svc #0x0
24: aa0003e1 mov x1, x0
28: d2800020 mov x0, #0x1 // #1
2c: aa1f03e2 mov x2, xzr
30: d29fffe3 mov x3, #0xffff // #65535
34: f2afffe3 movk x3, #0x7fff, lsl #16
38: d28008e8 mov x8, #0x47 // #71
3c: d4000001 svc #0x0
40: aa1f03e0 mov x0, xzr
44: d2800ba8 mov x8, #0x5d // #93
48: d4000001 svc #0x0
>>> run_assembly(shellcode).recvline()
'This is the flag\n'
</%docstring>

Expand Down
4 changes: 2 additions & 2 deletions travis/install.sh
Expand Up @@ -10,7 +10,7 @@ local_deb_extract()

install_deb()
{
version=zesty
version=${2:-zesty}
package=$1
echo "Installing $package"
INDEX="http://packages.ubuntu.com/en/$version/amd64/$package/download"
Expand All @@ -28,7 +28,7 @@ setup_travis()
[[ -f usr/bin/objcopy ]] || install_deb binutils

# Install/upgrade qemu
[[ -f usr/bin/qemu-arm-static ]] || install_deb qemu-user-static
[[ -f usr/bin/qemu-arm-static ]] || install_deb qemu-user-static xenial

# Install cross-binutils
[[ -f usr/bin/x86_64-linux-gnu-ar ]] || install_deb binutils-multiarch
Expand Down

0 comments on commit f3968af

Please sign in to comment.