mirror of
https://github.com/Gallopsled/pwntools.git
synced 2026-11-10 10:11:32 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72a93f7a3c | ||
|
|
c520efca42 | ||
|
|
a743ccc7fe | ||
|
|
0eb7fdbd88 | ||
|
|
ec4cc53bd0 | ||
|
|
99d3cd708f | ||
|
|
0ee2939a9d |
No files matched your search
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: backport-required, bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Thanks for contributing to Pwntools!
|
||||
|
||||
## Update Pwntools First
|
||||
|
||||
When reporting an issue, be sure that you are running the latest released version of pwntools (`pip install --upgrade pwntools`).
|
||||
|
||||
## Debug Output
|
||||
|
||||
Having the extra debug output really helps us, and might help you diagnose the problem yourself.
|
||||
|
||||
When submitting an issue that has output from Pwntools, make sure to run your script as shown below, to enable the extra debugging data.
|
||||
|
||||
```sh
|
||||
$ python exploit.py DEBUG LOG_FILE=log.txt
|
||||
```
|
||||
|
||||
You should see `[DEBUG]` statements that show what's happening behind the scenes:
|
||||
|
||||
```
|
||||
[+] Starting local process '/bin/sh' argv=['sh'] : pid 16823
|
||||
[DEBUG] Sent 0x7 bytes:
|
||||
'whoami\n'
|
||||
[DEBUG] Sent 0x5 bytes:
|
||||
'exit\n'
|
||||
[+] Receiving all data: Done (11B)
|
||||
[DEBUG] Received 0xb bytes:
|
||||
'crashheap\n'
|
||||
[*] Process '/bin/sh' stopped with exit code 0 (pid 16823)
|
||||
```
|
||||
|
||||
## Verify on Ubuntu
|
||||
|
||||
If possible, please verify that your issue occurs on 64-bit Ubuntu 18.04. We provide a Dockerfile based on Ubuntu 18.04 via `docker.io` to make this super simple, no VM required!
|
||||
|
||||
```sh
|
||||
# Download the Docker image
|
||||
$ docker pull pwntools/pwntools:stable
|
||||
|
||||
# Boot the image
|
||||
$ docker run -it pwntools/pwntools:stable
|
||||
|
||||
pwntools@7dc3ef409476:~$ python
|
||||
>>> from pwn import *
|
||||
>>> # Test your code here
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Thanks for contributing to Pwntools! Ideas from the community help make Pwntools an amazing tool for everybody.
|
||||
|
||||
If you've got an idea for a new feature, please provide information about:
|
||||
|
||||
* What the feature does
|
||||
* Why the feature should exit
|
||||
* What tests should be included
|
||||
|
||||
If you think you can write the feature yourself, please submit a Pull Request and we can review your changes!
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask us a question about Pwntools
|
||||
title: ''
|
||||
labels: question
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Thanks for using Pwntools! If you have a question, here are some tips that will make it easier for us to help you.
|
||||
|
||||
## Check the Documentation
|
||||
|
||||
Pwntools has REALLY extensive documentation. Please check there first! https://docs.pwntools.com
|
||||
|
||||
## Debug Output
|
||||
|
||||
If you're having an issue with an exploit, run your script with full debugging output, i.e. `python exploit.py DEBUG`. This may help you to see what's happening under the hood, and the debug output will help to diagnose any issues you're encountering.
|
||||
+55
-13
@@ -10,6 +10,12 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Git History 2
|
||||
run: git log --oneline --graph -10
|
||||
|
||||
- name: Cache for pip
|
||||
uses: actions/cache@v1
|
||||
id: cache-pip
|
||||
@@ -54,7 +60,7 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 \
|
||||
ash bash-static dash ksh mksh zsh \
|
||||
pandoc gdb socat sshpass \
|
||||
pandoc gdb gdbserver socat sshpass \
|
||||
binutils-multiarch qemu-user-static \
|
||||
binutils-aarch64-linux-gnu \
|
||||
binutils-arm-linux-gnueabihf \
|
||||
@@ -74,16 +80,7 @@ jobs:
|
||||
|
||||
- name: Set up SSH
|
||||
run: |
|
||||
chmod og-rw ~ # see https://stackoverflow.com/a/60367309/3869724
|
||||
ssh-keygen -t ed25519 -f ~/.ssh/pwntools-ci -N ''
|
||||
cat > ~/.ssh/config <<EOF
|
||||
Host example.pwnme
|
||||
User $USER
|
||||
HostName 127.0.0.1
|
||||
IdentityFile ~/.ssh/pwntools-ci
|
||||
EOF
|
||||
echo -n 'from="127.0.0.1" ' | cat - ~/.ssh/pwntools-ci.pub > ~/.ssh/authorized_keys
|
||||
ssh -o 'StrictHostKeyChecking no' example.pwnme id
|
||||
travis/ssh_setup.sh
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
@@ -98,12 +95,54 @@ jobs:
|
||||
- name: Install documentation dependencies
|
||||
run: pip install -r docs/requirements.txt
|
||||
|
||||
- name: Disable broken tests
|
||||
run: |
|
||||
rm -f docs/source/elf/corefile.rst
|
||||
rm -f docs/source/ui.rst
|
||||
|
||||
- name: Manually install non-broken Unicorn
|
||||
run: pip install unicorn==1.0.2rc3
|
||||
|
||||
- name: Coverage doctests
|
||||
run: |
|
||||
source .android.env || :
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # required by some gdb doctests
|
||||
PWNLIB_NOTERM=1 coverage run -m sphinx -b doctest docs/source docs/build/doctest
|
||||
coverage combine
|
||||
|
||||
- name: Coverage running examples
|
||||
run: |
|
||||
export TERM=linux
|
||||
set -x
|
||||
python travis/coverage_chdir.py examples/fmtstr examples/fmtstr/exploit.py
|
||||
python travis/coverage_chdir.py examples/fmtstr examples/fmtstr/exploit2.py || : # can fail randomly?
|
||||
coverage run examples/asm.py
|
||||
coverage run examples/asm.py
|
||||
coverage run examples/text.py
|
||||
# for f in examples/sigreturn_corefile_*.py; do coverage run "$f"; done # XXX something is wrong
|
||||
|
||||
- name: Coverage running commandline tools
|
||||
run: |
|
||||
export TERM=linux
|
||||
pwn() { coverage run -m pwnlib.commandline.main "$@"; }
|
||||
set -x
|
||||
|
||||
pwn cyclic 32
|
||||
pwn cyclic -l 0x62616161
|
||||
|
||||
pwn shellcraft -f asm --color amd64.linux.sh
|
||||
|
||||
pwn disasm --color ff3424c3ebfe
|
||||
|
||||
pwn hex abcd
|
||||
pwn unhex 4141 4141
|
||||
|
||||
head -c256 /dev/urandom | pwn phd
|
||||
|
||||
pwn errno 2
|
||||
|
||||
pwn constgrep -c freebsd -m ^PROT_ '3 + 4'
|
||||
pwn constgrep ^MAP_ 0
|
||||
pwn constgrep ^O_
|
||||
|
||||
- name: Build source and wheel distributions
|
||||
run: |
|
||||
@@ -116,7 +155,9 @@ jobs:
|
||||
path: dist/
|
||||
|
||||
- name: Upload coverage to coveralls.io
|
||||
run: COVERALLS_REPO_TOKEN=PP20MEgztXIQJJTguQwe2jeCh6Bm4lkbv coveralls
|
||||
run: |
|
||||
coverage combine
|
||||
COVERALLS_REPO_TOKEN=PP20MEgztXIQJJTguQwe2jeCh6Bm4lkbv coveralls
|
||||
|
||||
staging-merge:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -144,6 +185,7 @@ jobs:
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: packages
|
||||
path: dist
|
||||
|
||||
- name: Publish package
|
||||
uses: pypa/[email protected]
|
||||
|
||||
+4
-2
@@ -2,7 +2,6 @@ language: python
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- gcc-multilib
|
||||
- lib32stdc++6
|
||||
- ash
|
||||
- bash
|
||||
@@ -21,6 +20,10 @@ addons:
|
||||
- binutils-arm-linux-gnueabihf
|
||||
- binutils-mips-linux-gnu
|
||||
- binutils-powerpc-linux-gnu
|
||||
- gcc-aarch64-linux-gnu
|
||||
- gcc-arm-linux-gnueabihf
|
||||
- bash-static
|
||||
|
||||
cache:
|
||||
- pip
|
||||
- directories:
|
||||
@@ -54,7 +57,6 @@ script:
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
- flake8 . --count --select=E9,F63,F7 --show-source --statistics --exclude=android-?dk # TODO: Add F82
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=pwnlib/constants,android-?dk,.git,__pycache__
|
||||
- PWNLIB_NOTERM=1 coverage run -m sphinx -b doctest docs/source docs/build/doctest
|
||||
- coverage combine
|
||||
after_success:
|
||||
|
||||
+5
-5
@@ -383,7 +383,7 @@ def debug(args, gdbscript=None, exe=None, ssh=None, env=None, sysroot=None, **kw
|
||||
>>> # Connect to the SSH server
|
||||
|
||||
>>> # Start a process on the server
|
||||
>>> shell = ssh('runner', 'example.pwnme', password='demopass')
|
||||
>>> shell = ssh('travis', 'example.pwnme', password='demopass')
|
||||
>>> io = gdb.debug(['bash'],
|
||||
... ssh = shell,
|
||||
... gdbscript = '''
|
||||
@@ -564,9 +564,9 @@ def attach(target, gdbscript = '', exe = None, need_ptrace_scope = True, gdb_arg
|
||||
... ''')
|
||||
|
||||
>>> # Interact with the process
|
||||
>>> bash.sendline("whoami")
|
||||
>>> bash.sendline("/bin/echo hello")
|
||||
>>> bash.recvline()
|
||||
b'runner\n'
|
||||
b'hello\n'
|
||||
>>> bash.close()
|
||||
|
||||
>>> # Start a forking server
|
||||
@@ -591,7 +591,7 @@ def attach(target, gdbscript = '', exe = None, need_ptrace_scope = True, gdb_arg
|
||||
>>> io.close()
|
||||
|
||||
>>> # Connect to the SSH server
|
||||
>>> shell = ssh('runner', 'example.pwnme', password='demopass')
|
||||
>>> shell = ssh('travis', 'example.pwnme', password='demopass')
|
||||
|
||||
>>> # Start a process on the server
|
||||
>>> cat = shell.process(['cat'])
|
||||
@@ -866,7 +866,7 @@ def find_module_addresses(binary, ssh=None, ulimit=False):
|
||||
Example:
|
||||
|
||||
>>> with context.local(log_level=9999):
|
||||
... shell = ssh(host='example.pwnme', user='runner', password='demopass')
|
||||
... shell = ssh(host='example.pwnme', user='travis', password='demopass')
|
||||
... bash_libs = gdb.find_module_addresses('/bin/bash', shell)
|
||||
>>> os.path.basename(bash_libs[0].path)
|
||||
'libc.so.6'
|
||||
|
||||
+18
-18
@@ -561,11 +561,11 @@ class ssh(Timeout, Logger):
|
||||
Example proxying:
|
||||
|
||||
>>> s1 = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> r1 = s1.remote('localhost', 22)
|
||||
>>> s2 = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass',
|
||||
... proxy_sock=r1.sock)
|
||||
>>> r2 = s2.remote('localhost', 22) # and so on...
|
||||
@@ -702,7 +702,7 @@ class ssh(Timeout, Logger):
|
||||
|
||||
Examples:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> sh = s.shell('/bin/sh')
|
||||
>>> sh.sendline(b'echo Hello; exit')
|
||||
@@ -781,7 +781,7 @@ class ssh(Timeout, Logger):
|
||||
|
||||
Examples:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> sh = s.process('/bin/sh', env={'PS1':''})
|
||||
>>> sh.sendline(b'echo Hello; exit')
|
||||
@@ -1127,7 +1127,7 @@ os.execve(exe, argv, env)
|
||||
|
||||
Examples:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> py = s.run('python -i')
|
||||
>>> _ = py.recvuntil(b'>>> ')
|
||||
@@ -1188,7 +1188,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
|
||||
Examples:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> print(s.run_to_end('echo Hello; exit 17'))
|
||||
(b'Hello\n', 17)
|
||||
@@ -1213,7 +1213,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
>>> from pwn import *
|
||||
>>> l = listen()
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> a = s.connect_remote(s.host, l.lport)
|
||||
>>> a=a; b = l.wait_for_connection() # a=a; prevents hangs
|
||||
@@ -1238,7 +1238,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
|
||||
>>> from pwn import *
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> l = s.listen_remote()
|
||||
>>> a = remote(s.host, l.port)
|
||||
@@ -1258,7 +1258,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
Examples:
|
||||
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> print(repr(s['echo hello']))
|
||||
b'hello'
|
||||
@@ -1271,7 +1271,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
Examples:
|
||||
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> print(repr(s('echo hello')))
|
||||
b'hello'
|
||||
@@ -1284,12 +1284,12 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
Examples:
|
||||
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> s.echo('hello')
|
||||
b'hello'
|
||||
>>> s.whoami()
|
||||
b'runner'
|
||||
b'travis'
|
||||
>>> s.echo(['huh','yay','args'])
|
||||
b'huh yay args'
|
||||
"""
|
||||
@@ -1317,7 +1317,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
Example:
|
||||
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> s.connected()
|
||||
True
|
||||
@@ -1475,7 +1475,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
>>> with open('/tmp/bar','w+') as f:
|
||||
... _ = f.write('Hello, world')
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass',
|
||||
... cache=False)
|
||||
>>> s.download_data('/tmp/bar')
|
||||
@@ -1565,7 +1565,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
|
||||
Example:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> s.upload_data(b'Hello, world', '/tmp/upload_foo')
|
||||
>>> print(open('/tmp/upload_foo').read())
|
||||
@@ -1796,7 +1796,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
|
||||
Examples:
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> cwd = s.set_working_directory()
|
||||
>>> s.ls()
|
||||
@@ -1805,7 +1805,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
True
|
||||
|
||||
>>> s = ssh(host='example.pwnme',
|
||||
... user='runner',
|
||||
... user='travis',
|
||||
... password='demopass')
|
||||
>>> homedir = s.pwd()
|
||||
>>> _=s.touch('foo')
|
||||
@@ -1975,7 +1975,7 @@ from ctypes import *; libc = CDLL('libc.so.6'); print(libc.getenv(%r))
|
||||
|
||||
Example:
|
||||
|
||||
>>> s = ssh("runner", "example.pwnme")
|
||||
>>> s = ssh("travis", "example.pwnme")
|
||||
>>> s.aslr
|
||||
True
|
||||
"""
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
__version__ = '4.1.1'
|
||||
__version__ = '4.1.2'
|
||||
@@ -61,6 +61,7 @@ install_requires = ['paramiko>=1.15.2',
|
||||
'intervaltree>=3.0',
|
||||
'sortedcontainers',
|
||||
'unicorn>=1.0.2rc1,<1.0.2rc4', # see unicorn-engine/unicorn#1100, unicorn-engine/unicorn#1170, Gallopsled/pwntools#1538
|
||||
'six>=1.12.0',
|
||||
]
|
||||
|
||||
# Check that the user has installed the Python development headers
|
||||
@@ -82,7 +83,7 @@ setup(
|
||||
name = 'pwntools',
|
||||
python_requires = '>=2.7',
|
||||
packages = find_packages(),
|
||||
version = '4.1.1',
|
||||
version = '4.1.2',
|
||||
data_files = [('',
|
||||
glob.glob('*.md') + glob.glob('*.txt')),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import coverage
|
||||
import os
|
||||
import sys
|
||||
|
||||
os.environ.setdefault("COVERAGE_PROCESS_START", ".coveragerc")
|
||||
coverage.process_startup()
|
||||
|
||||
__file__ = os.path.abspath(sys.argv.pop(2))
|
||||
with open(__file__) as fp:
|
||||
code = compile(fp.read(), __file__, 'exec')
|
||||
os.chdir(sys.argv.pop(1))
|
||||
exec(code, globals())
|
||||
Regular → Executable
File mode changed.
Regular → Executable
+8
-1
@@ -32,6 +32,7 @@ fi
|
||||
|
||||
# Generate a new key so that we can log into it
|
||||
ssh-keygen -t rsa -f ~/.ssh/$U -N ''
|
||||
chmod og-rw ~/.ssh
|
||||
|
||||
# Load the public key into a memory for below
|
||||
pubkey=$(cat ~/.ssh/$U.pub)
|
||||
@@ -42,6 +43,7 @@ USUDO mkdir $H/.ssh || true
|
||||
USUDO tee -a $H/.ssh/authorized_keys <<EOF
|
||||
from="127.0.0.1" $pubkey
|
||||
EOF
|
||||
USUDO chmod 700 $H $H/.ssh $H/.ssh/authorized_keys
|
||||
|
||||
# In the pwntools examples, we ssh to 'example.pwnme'
|
||||
# Set up an SSH config entry to make this actually work
|
||||
@@ -51,8 +53,13 @@ Host example.pwnme
|
||||
User $U
|
||||
HostName 127.0.0.1
|
||||
IdentityFile ~/.ssh/$U
|
||||
StrictHostKeyChecking no
|
||||
EOF
|
||||
chmod 700 ~ ~/.ssh
|
||||
|
||||
ssh -o "StrictHostKeyChecking no" -vvvv [email protected] id
|
||||
ls -la ~/.ssh
|
||||
USUDO ls -la $H/.ssh
|
||||
|
||||
ssh -v [email protected] id
|
||||
|
||||
set +ex
|
||||
Regular → Executable
File mode changed.
Reference in new issue
Block a user