Skip to content

Commit

Permalink
Merge branch 'dev' into libcdb_unstrip
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Jul 23, 2021
2 parents 096a1ea + f7283bf commit fe50083
Show file tree
Hide file tree
Showing 45 changed files with 1,247 additions and 246 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@ MANIFEST
dist
venv
.vscode
.idea
*.egg-info
*.core
.coverage
Expand Down
44 changes: 35 additions & 9 deletions CHANGELOG.md
Expand Up @@ -9,10 +9,12 @@ The table below shows which release corresponds to each branch, and what date th

| Version | Branch | Release Date |
| ---------------- | -------- | ---------------------- |
| [4.7.0](#470) | `dev` | May 29, 2020 (planned)
| [4.6.0](#460) | `beta` | May 29, 2020 (planned)
| [4.5.0](#450) | `stable` | Apr 30, 2020
| [4.4.0](#440) | | Mar 29, 2020
| [4.8.0](#480) | `dev` |
| [4.7.0](#470) | `beta` |
| [4.6.0](#460) | `stable` | Jul 12, 2021
| [4.5.1](#451) | | May 30, 2021
| [4.5.0](#450) | | Apr 30, 2021
| [4.4.0](#440) | | Mar 29, 2021
| [4.3.1](#431) | | Nov 29, 2020
| [4.3.0](#430) | | Oct 20, 2020
| [4.2.0](#420) | | Jul 3, 2020
Expand Down Expand Up @@ -59,23 +61,41 @@ The table below shows which release corresponds to each branch, and what date th
| [3.0.0](#300) | | Aug 20, 2016
| [2.2.0](#220) | | Jan 5, 2015

## 4.7.0 (`dev`)
## 4.8.0 (`dev`)

- [#1733][1733] Update libc headers -> more syscalls available!
- [#1922][1922] Fix logic in `wait_for_debugger`
- [#1828][1828] libcdb: Load debug info and unstrip libc binary

[1922]: https://github.com/Gallopsled/pwntools/pull/1922
[1828]: https://github.com/Gallopsled/pwntools/pull/1828

## 4.7.0 (`beta`)

- [#1733][1733] Update libc headers -> more syscalls available!
- [#1876][1876] add `self.message` and change `sys.exc_type` to `sys.exec_info()` in PwnlibException
- [#1877][1877] encoders error message handles when `avoid` is bytes in python3
- [#1891][1891] Keep ROP gadgets when setting registers via setattr/call
- [#1892][1892] Silence SIGPIPE error for "pwn phd"
- [#1893][1893] Fix bytes warning in "pwn cyclic"
- [#1897][1897] Add basic support for RISC-V
- [#1903][1903] Add zsh completion script
- [#1904][1904] Add bash completion script
- [#1906][1906] Defer import of several modules to save on startup time
- [#1921][1921] Add basic support for the bare-metal ARM specific toolchain

[1733]: https://github.com/Gallopsled/pwntools/pull/1733
[1828]: https://github.com/Gallopsled/pwntools/pull/1828
[1876]: https://github.com/Gallopsled/pwntools/pull/1876
[1877]: https://github.com/Gallopsled/pwntools/pull/1877
[1891]: https://github.com/Gallopsled/pwntools/pull/1891
[1892]: https://github.com/Gallopsled/pwntools/pull/1892
[1893]: https://github.com/Gallopsled/pwntools/pull/1893
[1897]: https://github.com/Gallopsled/pwntools/pull/1897
[1903]: https://github.com/Gallopsled/pwntools/pull/1903
[1904]: https://github.com/Gallopsled/pwntools/pull/1904
[1906]: https://github.com/Gallopsled/pwntools/pull/1906
[1921]: https://github.com/Gallopsled/pwntools/pull/1921

## 4.6.0 (`beta`)
## 4.6.0 (`stable`)

- [#1429][1429] Add a mechanism for ret2csu (originally #1138)
- [#1566][1566] Add `ignore_config` argument to `pwnlib.tubes.ssh` and improve `allow_agent` implementation
Expand All @@ -97,7 +117,13 @@ The table below shows which release corresponds to each branch, and what date th
[1776]: https://github.com/Gallopsled/pwntools/pull/1776
[1846]: https://github.com/Gallopsled/pwntools/pull/1846

## 4.5.0 (`stable`)
## 4.5.1

- [#1902][1902] Always specify -F and -P for tmux in `run_in_new_terminal`

[1902]: https://github.com/Gallopsled/pwntools/pull/1902

## 4.5.0

- [#1261][1261] Misc `run_in_new_terminal` improvements (notably gdb terminated by default)
- [#1695][1695] Allow using GDB Python API
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Expand Up @@ -52,7 +52,7 @@ Each of the ``pwntools`` modules is documented here.
context
dynelf
encoders
elf
elf/*
exception
filepointer
filesystem
Expand All @@ -65,7 +65,6 @@ Each of the ``pwntools`` modules is documented here.
protocols
qemu
replacements
rop
rop/*
runner
shellcraft
Expand All @@ -83,6 +82,7 @@ Each of the ``pwntools`` modules is documented here.
:hidden:

testexample
rop/call

.. only:: not dash

Expand Down
File renamed without changes.
9 changes: 0 additions & 9 deletions docs/source/rop/call.rst

This file was deleted.

12 changes: 12 additions & 0 deletions extra/bash_completion.d/README.md
@@ -0,0 +1,12 @@
# Bash Completion

To install the completion, add `. /path/to/bash_completion.d/pwn`to your e.g. `~/.bash_profile`.

The `./install.sh` script attempts to do this for you automatically.

### Shellcraft Autocomplete

The legacy autocompletion for `pwn shellcraft` is also available at `./shellcraft`.

It is unsupported, and slow (runs `pwn shellcraft -l` every time your shell starts).

13 changes: 13 additions & 0 deletions extra/bash_completion.d/install.sh
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

BASH_COMPLETION_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

if grep "$BASH_COMPLETION_DIR" ~/.bash_profile; then
>&2 echo "Already installed"
exit
fi >/dev/null

cat >> ~/.bash_profile <<EOF
# Install autocompletion for Pwntools
. "$BASH_COMPLETION_DIR/pwn"
EOF
103 changes: 103 additions & 0 deletions extra/bash_completion.d/pwn
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# AUTOMATCALLY GENERATED by `shtab`

_shtab_pwnlib_options_='-h --help'
_shtab_pwnlib_commands_='asm checksec constgrep cyclic debug disablenx disasm elfdiff elfpatch errno hex phd pwnstrip scramble shellcraft template unhex update version'

_shtab_pwnlib_asm='-h --help -f --format -o --output -c --context -v --avoid -n --newline -z --zero -d --debug -e --encoder -i --infile -r --run'
_shtab_pwnlib_checksec='-h --help --file'
_shtab_pwnlib_constgrep='-h --help -e --exact -i --case-insensitive -m --mask-mode -c --context'
_shtab_pwnlib_cyclic='-h --help -a --alphabet -n --length -c --context -l -o --offset --lookup'
_shtab_pwnlib_debug='-h --help -x --pid -c --context --exec --process --sysroot'
_shtab_pwnlib_disablenx='-h --help'
_shtab_pwnlib_disasm='-h --help -c --context -a --address --color --no-color'
_shtab_pwnlib_elfdiff='-h --help'
_shtab_pwnlib_elfpatch='-h --help'
_shtab_pwnlib_errno='-h --help'
_shtab_pwnlib_hex='-h --help'
_shtab_pwnlib_phd='-h --help -w --width -l --highlight -s --skip -c --count -o --offset --color'
_shtab_pwnlib_pwnstrip='-h --help -b --build-id -p --patch -o --output'
_shtab_pwnlib_scramble='-h --help -f --format -o --output -c --context -p --alphanumeric -v --avoid -n --newline -z --zero -d --debug'
_shtab_pwnlib_shellcraft='-h --help -? --show -o --out -f --format -d --debug -b --before -a --after -v --avoid -n --newline -z --zero -r --run --color --no-color --syscalls --address -l --list -s --shared'
_shtab_pwnlib_template='-h --help --host --port --user --pass --password --path --quiet --color'
_shtab_pwnlib_unhex='-h --help'
_shtab_pwnlib_update='-h --help --install --pre'
_shtab_pwnlib_version='-h --help'


# $1=COMP_WORDS[1]
_shtab_compgen_files() {
compgen -f -- $1 # files
compgen -d -S '/' -- $1 # recurse into subdirs
}

# $1=COMP_WORDS[1]
_shtab_compgen_dirs() {
compgen -d -S '/' -- $1 # recurse into subdirs
}

# $1=COMP_WORDS[1]
_shtab_replace_hyphen() {
echo $1 | sed 's/-/_/g'
}

# $1=COMP_WORDS[1]
_shtab_replace_nonword() {
echo "${1//[^[:word:]]/_}"
}

# $1=COMP_WORDS[1]
_shtab_pwnlib_compgen_root_() {
local args_gen="_shtab_pwnlib_COMPGEN"
case "$word" in
-*) COMPREPLY=( $(compgen -W "$_shtab_pwnlib_options_" -- "$word"; [ -n "${!args_gen}" ] && ${!args_gen} "$word") ) ;;
*) COMPREPLY=( $(compgen -W "$_shtab_pwnlib_commands_" -- "$word"; [ -n "${!args_gen}" ] && ${!args_gen} "$word") ) ;;
esac
}

# $1=COMP_WORDS[1]
_shtab_pwnlib_compgen_command_() {
local flags_list="_shtab_pwnlib_$(_shtab_replace_nonword $1)"
local args_gen="${flags_list}_COMPGEN"
COMPREPLY=( $(compgen -W "${!flags_list}" -- "$word"; [ -n "${!args_gen}" ] && ${!args_gen} "$word") )
}

# $1=COMP_WORDS[1]
# $2=COMP_WORDS[2]
_shtab_pwnlib_compgen_subcommand_() {
local flags_list="_shtab_pwnlib_$(_shtab_replace_nonword "${1}_${2}")"
local args_gen="${flags_list}_COMPGEN"
[ -n "${!args_gen}" ] && local opts_more="$(${!args_gen} "$word")"
local opts="${!flags_list}"
if [ -z "$opts$opts_more" ]; then
_shtab_pwnlib_compgen_command_ $1
else
COMPREPLY=( $(compgen -W "$opts" -- "$word"; [ -n "$opts_more" ] && echo "$opts_more") )
fi
}

# Notes:
# `COMPREPLY` contains what will be rendered after completion is triggered
# `word` refers to the current typed word
# `${!var}` is to evaluate the content of `var`
# and expand its content as a variable
# hello="world"
# x="hello"
# ${!x} -> ${hello} -> "world"
_shtab_pwnlib() {
local word="${COMP_WORDS[COMP_CWORD]}"

COMPREPLY=()

if [ "${COMP_CWORD}" -eq 1 ]; then
_shtab_pwnlib_compgen_root_ ${COMP_WORDS[1]}
elif [ "${COMP_CWORD}" -eq 2 ]; then
_shtab_pwnlib_compgen_command_ ${COMP_WORDS[1]}
elif [ "${COMP_CWORD}" -ge 3 ]; then
_shtab_pwnlib_compgen_subcommand_ ${COMP_WORDS[1]} ${COMP_WORDS[2]}
fi

return 0
}

complete -o nospace -F _shtab_pwnlib pwn
27 changes: 16 additions & 11 deletions extra/docker/Makefile
@@ -1,25 +1,30 @@
subdirs=$(shell find . -type d -depth 1 | xargs basename)
tags=base stable beta dev
ROOT=$(shell git rev-parse --show-toplevel)
CMD ?= zsh

ifneq ($(HISTFILE),)
MOUNT_HISTFILE=--mount type=bind,source="$(HISTFILE)",target=/home/pwntools/.history
endif

all: $(subdirs) $(tags)

tags: $(tags)

base:
@echo "Building $@"
docker build -t pwntools/pwntools:$(shell basename $(@)) "$@"

stable beta dev: base
$(subdirs)::
@echo "Building $@"
docker build -t pwntools/pwntools:$(shell basename $(@)) "$@"

develop:
@echo "Building $@"
docker build -t pwntools/pwntools:$(shell basename $(@)) "$@"
docker run -it --privileged --net=host --hostname localhost \
develop::
docker run -it \
--privileged \
--net=host \
--hostname localhost \
--ulimit core=-1:-1 \
--mount type=bind,source="$(shell git rev-parse --show-toplevel)",target=/home/pwntools/pwntools \
pwntools/pwntools:$(shell basename $(@))
$(MOUNT_HISTFILE) \
--mount type=bind,source="$(ROOT)",target=/home/pwntools/pwntools \
pwntools/pwntools:$(shell basename $(@)) \
$(CMD)

debug:
@echo "Subdirs $(subdirs)"
Expand Down
6 changes: 6 additions & 0 deletions extra/docker/base/Dockerfile
Expand Up @@ -7,8 +7,13 @@ FROM ubuntu:bionic
MAINTAINER Maintainer Gallopsled et al.

env DEBIAN_FRONTEND=noninteractive
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN apt-get update \
&& apt-get install locales \
&& locale-gen en_US.UTF-8 \
&& apt-get install -y \
build-essential \
elfutils \
Expand All @@ -29,6 +34,7 @@ RUN apt-get update \
binutils-powerpc-linux-gnu \
binutils-powerpc64-linux-gnu \
binutils-sparc64-linux-gnu \
tmux \
&& pip install --upgrade pip \
&& python -m pip install --upgrade pwntools \
&& pip3 install --upgrade pip \
Expand Down
8 changes: 8 additions & 0 deletions extra/docker/buster/Dockerfile
@@ -0,0 +1,8 @@
from debian:buster

RUN apt-get update
RUN apt-get -y dist-upgrade
RUN apt-get -y install python3 python3-pip
RUN apt-get -y install git wget unzip

RUN pip3 install --upgrade git+https://github.com/Gallopsled/pwntools@dev
5 changes: 5 additions & 0 deletions extra/docker/develop/10-import.py
@@ -0,0 +1,5 @@
try:
from pwn import *
except Exception:
print("Could not import pwntools")
import os, re, sys, time, random, urllib, datetime, itertools, subprocess, multiprocessing
27 changes: 27 additions & 0 deletions extra/docker/develop/Dockerfile
@@ -1,5 +1,8 @@
FROM pwntools/pwntools:base

# Support sharing history with the develop Dockerfile
ENV HISTFILE=/home/pwntools/.history

# Uninstall existing versions of pwntools
USER root
RUN python -m pip uninstall -q -y pwntools \
Expand All @@ -23,6 +26,10 @@ RUN git clone https://github.com/Gallopsled/pwntools \
RUN python -m pip install --upgrade --requirement pwntools/docs/requirements.txt \
&& python3 -m pip install --upgrade --requirement pwntools/docs/requirements.txt

# Python niceties for debugging
RUN python -m pip install -U ipython ipdb \
&& python3 -m pip install -U ipython ipdb

# Dependencies from .travis.yml addons -> apt -> packages
RUN sudo apt-get install -y \
ash \
Expand All @@ -43,6 +50,7 @@ RUN sudo apt-get install -y \
qemu-user-static \
socat \
sshpass \
vim \
zsh

# Misc useful things when developing
Expand All @@ -55,5 +63,24 @@ RUN sudo apt-get install -y \
unzip \
wget

# Use zsh by default
RUN sudo chsh -s /bin/zsh pwntools

# Get and install prezto
RUN git clone --recursive https://github.com/sorin-ionescu/prezto.git .zprezto
RUN bash -c 'for file in .zprezto/runcoms/z*; do ln -s $file .$(basename $file); done'

# Get and install pwndbg
RUN git clone --recursive https://github.com/pwndbg/pwndbg
RUN cd pwndbg && ./setup.sh

# Install autocompletion
RUN ln -s /home/pwntools/pwntools/extra/zsh_completion/_pwn /home/pwntools/.zprezto/modules/completion/external/src

# Install ipython profile and auto-import
RUN mkdir -p /home/pwntools/.ipython/profile_default/startup
ADD 10-import.py /home/pwntools/.ipython/profile_default/startup
ADD ipython_config.py /home/pwntools/.ipython/profile_default

# Do not require password for sudo
RUN echo "pwntools ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/travis

0 comments on commit fe50083

Please sign in to comment.