Compare commits

..
1300 Commits
Author SHA1 Message Date
Kristoffer Søholm bc93beb576 Merge pull request #625 from cebrusfs/patch-1
Fix wrong format string parameters in memleak.py
2016-06-23 01:32:17 +02:00
Kristoffer Søholm 2490ea207c Merge pull request #630 from justinsteven/bugfix/typo_attaching_you
Fix typo
2016-06-23 01:31:12 +02:00
Justin Steven fc5b7b9425 Fix typo 2016-06-17 00:34:42 +10:00
MengHuan Yu 89d1c67696 Fix wrong format string parameters in memleak.py
Fix wrong format string parameters of a debug message in `memleak.py`.
2016-05-11 16:56:53 +08:00
Morten Brøns-Pedersen 29bf5fc5fc Merge pull request #615 from peter50216/patch-3
fix inconsistent logging level in tube.
2016-04-12 12:08:02 +02:00
Peter Shih fe4086e710 fix inconsistent logging level in tube. 2016-04-12 10:18:06 +08:00
Morten Brøns-Pedersen 8a57fe4143 Merge pull request #612 from Gallopsled/martian-dash-docset
Added support for generating a Dash docset.
2016-03-31 10:15:05 +02:00
Kristoffer Søholm 2da5414609 Merge pull request #601 from Gallopsled/bugfix-memleak
Bugfix: `pwnlib.memleak.MemLeak`
2016-03-31 09:15:06 +02:00
Morten Brøns-Pedersen 9ff2d5b9bd removed tabs and trailing whitespace and tidied up a little 2016-03-31 08:30:41 +02:00
Morten Brøns-Pedersen 5d9b68d1c8 Merge branch 'dash-docset' of https://github.com/martian/pwntools into martian-dash-docset 2016-03-31 08:23:12 +02:00
Morten Brøns-Pedersen bc77ad6c47 Merge pull request #604 from peter50216/patch-1
Remove unused statement in context.arch
2016-03-31 08:09:25 +02:00
Morten Brøns-Pedersen cfb38c4ef4 Merge pull request #606 from peter50216/patch-2
Fix inconsistency between error message and code.
2016-03-31 08:08:38 +02:00
Morten Brøns-Pedersen b2e5ff427b Merge pull request #608 from peter50216/master
Fix pack when sign=True and word_size='all'
2016-03-31 08:08:09 +02:00
Morten Brøns-Pedersen dec4a74efc Merge pull request #610 from binjitsu/issue_609
Fix Gallopsled/pwntools#609
2016-03-31 08:06:13 +02:00
Zach Riggle f64d0b0749 Fix Gallopsled/pwntools#609
(cherry picked from commit 320e0dd80b)
2016-03-28 11:57:16 -04:00
Pi-Hsun Shih 17caf96582 Fix pack when sign=True and word_size='all' 2016-03-28 03:35:29 +00:00
peter50216 def9400d48 Fix inconsistency between error message and code.
Code says context.bits should be > 0, but error message says >= 0.
Since 0 bit architecture doesn't make sense at all, make them all be > 0.
2016-03-25 15:52:10 +08:00
Kristoffer Søholm e6380f75a9 Merge pull request #605 from peter50216/patch-2
Don't depend on python dict.item() order.
2016-03-23 09:55:04 +01:00
peter50216 3564b9e014 Don't depend on python dict.item() order. 2016-03-23 16:36:13 +08:00
peter50216 e16ac422b5 Remove unused statement in context.arch 2016-03-23 16:25:13 +08:00
Morten Brøns-Pedersen fcd62d4cf1 Merge pull request #597 from binjitsu/issue_596
Extract list of data elements from Buffer when unget()'ing a Buffer
2016-03-15 14:49:21 +01:00
Morten Brøns-Pedersen 894ffbc1b7 fixed doctests 2016-03-14 13:50:57 +01:00
Morten Brøns-Pedersen b00a328d8a added __getitem__ for pwnlib.memleak.MemLeak 2016-03-14 13:44:11 +01:00
Morten Brøns-Pedersen ceadb59c93 bugfix: pwnlib.memleak.MemLeak would return wrong addresses when searching backwards if a leak failed; several new doctests has been added as well 2016-03-14 13:43:47 +01:00
Morten Brøns-Pedersen 22038eaf2d Merge pull request #600 from Gallopsled/example-attach
example of `gdb.attach`
2016-03-14 11:35:52 +01:00
Morten Brøns-Pedersen 044a2a630d Merge pull request #546 from Gallopsled/packing-dd
added `pwnlib.util.packing.dd` inspired by the command line util of t…
2016-03-14 11:25:32 +01:00
Morten Brøns-Pedersen f4ae5da477 some slight improvements to pwnlib.util.packing.dd 2016-03-14 11:12:41 +01:00
Morten Brøns-Pedersen 883ddb30b5 example of gdb.attach 2016-03-14 10:41:09 +01:00
martian dc37b0b5b2 Added support for generating a Dash docset.
Dash docsets can be read by various applications:

Dash         OS X, iOS         https://kapeli.com
Zeal         Linux, Windows    https://zealdocs.org
Velocity     Windows           http://velocity.silverlakesoftware.com
LovelyDocs   Android           http://lovelydocs.io
dasht        POSIX             https://github.com/sunaku/dasht
Helm Dash    emacs             https://github.com/areina/helm-dash
2016-03-08 18:15:54 -08:00
Zach Riggle fde04c737b Extract list of data elements from Buffer when unget()'ing a Buffer. Fixes #596 2016-03-03 15:50:05 -05:00
Jonas Rudloff d498a34e70 Merge pull request #594 from YASME-Tim/receiving
💊 Recieved -> Received #593
2016-02-08 12:50:27 +01:00
YASME-Tim 79d4248666 💊 #593 Last occurrence of recieved fixed 2016-02-07 13:23:15 +01:00
YASME-Tim fa25a733bd 💊 Recieved -> Received 2016-02-07 13:17:19 +01:00
Jonas Rudloff 8f355195db Merge pull request #586 from Gallopsled/fiddling-naf
added `pwnlib.util.fiddling.naf` to compute the non-adjacent form of …
2015-11-20 17:07:05 +01:00
Morten Brøns-Pedersen 32b9b90175 Merge pull request #583 from binjitsu/wait
Add `wait` as an alias for `wait_for_close`
2015-11-20 16:49:56 +01:00
Morten Brøns-Pedersen 82500a1bc0 added pwnlib.util.fiddling.naf to compute the non-adjacent form of a number 2015-11-20 15:32:53 +01:00
Kristoffer Søholm 9949d7d979 Merge pull request #584 from Gallopsled/setup-py-requests-issue
Fix annoying setup.py behaviour.
2015-11-09 21:09:35 +01:00
Mathias Svensson f91299986e Fix annoying setup.py behaviour.
When installing pwntools, setup.py required a very new version of
requests -- even though we never used any new features.

This is a problem, since the required version is much never than what is
in e.g. ubuntu's package repo. While this by itself is not much of a
problem, it is a problem if one installs python-pip from the distro's
repo as well, since python-pip will try to use the newest version of the
requests library, which caused pip to break.

The solution: Do not force such a new version of python, instead live
with a much older version.
2015-11-09 21:00:43 +01:00
Zach Riggle e6d64d8ade Add wait alias for wait_for_close 2015-11-03 16:43:07 -05:00
Jonas Rudloff 458c6971ea Merge pull request #507 from binjitsu/faster-travis
Use container-based Travis CI so that it builds faster
2015-10-26 13:02:25 +01:00
Jonas Rudloff 24401a34ce Merge pull request #580 from Gallopsled/alt-fix-pr-563
alternative to PR #563; this works by simply never emitting CR
2015-10-26 10:44:33 +01:00
Kristoffer Søholm 46cc634e8b Merge pull request #581 from scoops/patch-1
Update about.rst
2015-10-24 00:31:07 +02:00
Ryan f71ae3b06f Update about.rst 2015-10-23 11:48:06 -04:00
Ryan 9cdfa82bc3 Update about.rst
Smoothed out some phrasing that bugged me.
2015-10-23 11:45:26 -04:00
Morten Brøns-Pedersen 08c8c2e8e4 alternative to PR #563; this works by simply never emitting CR 2015-10-23 09:11:25 +02:00
Morten Brøns-Pedersen a09d87c579 Merge pull request #579 from Gallopsled/fiddling-bits-0-doctest
added `fiddling.bits(0)` as a doctest
2015-10-15 09:49:59 +02:00
Morten Brøns-Pedersen 10c3f079c5 added fiddling.bits(0) as a doctest 2015-10-15 09:42:37 +02:00
Morten Brøns-Pedersen 55e830b214 Merge pull request #578 from sam-b/master
corrected util.fiddling.bits implementation to handle 0 validly
2015-10-15 09:27:16 +02:00
Sam Brown 6449e14e9e corrected util.twiddling.bits implementation to handle 0 validly 2015-10-14 23:10:17 +01:00
Morten Brøns-Pedersen daf117e270 Merge pull request #576 from antoniobianchi333/master
close file descriptors in process.close() and avoid leaving zombie processes around
2015-10-05 12:33:40 +02:00
antoniob fa2e11391e close file descriptors in process.close() and avoid leaving zombie processes around 2015-10-05 01:05:24 -07:00
Jonas Rudloff 6c9761d83d Merge pull request #574 from en0/master
Fixed lookup feature where the packing util was being called with wrong argument
2015-09-21 19:04:24 +02:00
Ian Laird 80f744cc6d Fixed issue on lookup function where the packing util was being called with inproper argument type 2015-09-19 23:29:57 -06:00
Morten Brøns-Pedersen a454d54975 Merge pull request #571 from Gallopsled/term-before-after-fix
fix `before` and `after` keywords for `term.output()`
2015-08-31 10:13:17 +02:00
Morten Brøns-Pedersen 5a92096231 Merge pull request #570 from Gallopsled/term-completer
import `completer` with `pwnlib.term` and update no-available-complet…
2015-08-31 10:13:04 +02:00
Morten Brøns-Pedersen cfa9b00789 Merge pull request #569 from Gallopsled/term-key-neq
added `__neq__` method to `pwnlib.term.key`
2015-08-31 10:12:38 +02:00
Robert Larsen 60307ed1c7 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-08-18 12:22:13 +02:00
Robert Larsen 71d1535f33 Removed test file. 2015-08-18 12:21:30 +02:00
Jonas Rudloff e0e150f87b Merge pull request #568 from RobertLarsen/master
Shellcodes for MIPS/i386/amd64
2015-08-14 16:55:40 +02:00
Robert Larsen a6fd7f8411 Fixed more documentation. 2015-08-13 09:56:38 +02:00
Robert Larsen 400b5f4995 Fixed documentation. 2015-08-13 09:48:16 +02:00
Morten Brøns-Pedersen 5394d9d91c import completer with pwnlib.term and update no-available-completions-text 2015-08-11 22:07:40 +02:00
Morten Brøns-Pedersen 000d2b2fc7 fix before and after keywords for term.output() 2015-08-11 22:02:45 +02:00
Morten Brøns-Pedersen 31d06cb807 added __neq__ method to pwnlib.term.key 2015-08-11 21:04:37 +02:00
Robert Larsen 55067001c3 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-08-10 11:09:14 +02:00
Morten Brøns-Pedersen 06f0f8c8af Merge pull request #566 from Gallopsled/bugfix-term-enter
bugfix: `ui.yesno()` now correctly handles <enter>
2015-08-06 04:37:04 +02:00
Robert Larsen 175f26c605 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-07-30 13:36:16 +02:00
Robert Larsen 9beb63dc9d Added readfile shellcode for i386. 2015-07-22 16:00:32 +02:00
Robert Larsen d6a358d1dc Added readfile shellcode for amd64. 2015-07-22 15:35:12 +02:00
Morten Brøns-Pedersen 83d44b500d Merge pull request #567 from Gallopsled/bugfix-no-shutdown-on-close
bugfix: don't call `shutdown(2)` when calling `tubes.sock.close()`
2015-07-17 09:37:11 +02:00
Morten Brøns-Pedersen 1eb35819ac Merge pull request #560 from binjitsu/register-ordering
Add setregs shellcode helper for i386 to demonstrate regsort
2015-07-17 09:34:46 +02:00
Morten Brøns-Pedersen 8a2e54232b Merge pull request #561 from binjitsu/gdb-unlink
Unlink GDB temporary files.  Fixes #519
2015-07-17 09:31:09 +02:00
Morten Brøns-Pedersen 77bfc16341 bugfix: don't call shutdown(2) when calling tubes.sock.close()
This can be a problem since sockets inherited by children will see the
`shutdown(2)` call as well.
2015-07-16 23:35:30 +02:00
Morten Brøns-Pedersen 383f245082 bugfix: ui.yesno() now correctly handles <enter>
This bug happened because we no longer disable input processing in the terminal.
In particular `\r` is now translated to `\n`.  The fix is to interpret both `\r`
and `\n` as <enter> in `term/key.py`.
2015-07-16 23:30:45 +02:00
Robert Larsen 853cdb4a25 Prevent nul byte. 2015-07-08 15:32:18 +02:00
Robert Larsen bd547f3fdc Added thumb/Linux shellcode for reading a file. 2015-07-08 14:13:45 +02:00
Robert Larsen a69dc3ebc6 Removed unneeded import. 2015-07-08 13:05:25 +02:00
Robert Larsen 3da395f11a An offset was slightly off. Fixed. 2015-07-08 12:38:28 +02:00
Robert Larsen b6c81925a9 Added MIPS/Linux shellcode for reading a file. 2015-07-08 12:35:08 +02:00
Robert Larsen 18cdcfd409 Added wrappers for ensuring the right operating system. 2015-07-06 15:41:12 +02:00
Robert Larsen c591d69a3a Added bindsh shellcode for MIPS. 2015-07-06 15:11:04 +02:00
Jonas Rudloff 073257dcac Merge pull request #565 from RobertLarsen/fix-sockaddr-usage
Fixed regression due to changed return value.
2015-07-06 14:59:23 +02:00
Robert Larsen 02c67d547d Removed comment. 2015-07-06 14:22:50 +02:00
Robert Larsen 61edc646e1 Use big endian (network byte order) for port. 2015-07-06 13:55:21 +02:00
Robert Larsen f424a9caf7 Merge branch 'fix-sockaddr-usage' of https://github.com/RobertLarsen/pwntools 2015-07-06 13:42:45 +02:00
Robert Larsen a95bb8e353 Revert "Revert "Fix sockaddr, optimize off some zero bytes""
This reverts commit 400013e680.
2015-07-06 13:25:15 +02:00
Jonas Rudloff d66676a862 findpeer- and connectstager shellcodes 2015-07-05 15:54:50 +02:00
Jonas Rudloff 6bdcb41252 fixed mov and syscall for thumb 2015-07-05 15:54:27 +02:00
Jonas Rudloff aa4a0a889c connectback stager for amd64 2015-07-05 13:04:36 +02:00
Jonas Rudloff 401d9f567e connectback stager for i386 2015-07-05 12:55:46 +02:00
Jonas Rudloff 400013e680 Revert "Fix sockaddr, optimize off some zero bytes"
This reverts commit bb5ea7677c.
2015-07-05 12:29:48 +02:00
Jonas Rudloff 5a637a534e amd64 findpeerstager recvives size 2015-07-05 12:14:41 +02:00
Jonas Rudloff f36470e628 findpeerstager now recvives the size 2015-07-05 10:31:56 +02:00
Robert Larsen bfcc9ac326 Works! 2015-07-04 23:34:36 +02:00
Robert Larsen 8ede459860 Fixed regression due to changed return value. 2015-07-04 01:47:55 +02:00
Robert Larsen 7855e433d0 Added connect shellcode which almost work. 2015-07-04 01:34:34 +02:00
Robert Larsen 5ab2f403bd Works...kind of. 2015-07-03 13:50:35 +02:00
Robert Larsen 2ed7e83dad Use the nop generator. 2015-07-03 13:50:08 +02:00
Robert Larsen 64c37569a3 Added stager and a nop generator. 2015-07-03 13:49:49 +02:00
Robert Larsen 8db93e8c04 Support three more arguments for syscalls. 2015-07-03 11:18:18 +02:00
Robert Larsen 7779ebff3c Fixed documentation. 2015-07-03 08:42:08 +02:00
Robert Larsen 2d67781ba4 Shaved off some instructions and made the port matching work. 2015-07-02 23:39:51 +02:00
Robert Larsen 7dfd489e89 Nul free. 2015-07-02 15:55:19 +02:00
Robert Larsen 579d7bf58f Added findpeersh shellcode for MIPS/Linux. Port matching not working yet. Also contains a nul byte. 2015-07-02 15:49:08 +02:00
Robert Larsen eba2352dbc Don't overwrite socket register before using it 2015-07-02 15:48:00 +02:00
Robert Larsen ef451105c2 Added MIPS/Linux dupsh shellcode. 2015-07-02 15:05:27 +02:00
Robert Larsen 9a26be0881 Added MIPS/Linux sh shellcode. 2015-07-02 15:01:05 +02:00
Robert Larsen d21af22f82 Added MIPS/Linux dup shellcode. 2015-07-02 14:46:29 +02:00
Robert Larsen 71ef26281c Added Linux MIPS syscall shellcode. 2015-07-02 13:39:39 +02:00
Robert Larsen fa8d00dcfb Prettier. 2015-07-02 12:54:57 +02:00
Robert Larsen 28911442c4 Added test 2015-07-02 10:48:48 +02:00
Robert Larsen 0c0f609752 Added pushstr for MIPS. 2015-07-01 23:38:52 +02:00
Robert Larsen 5ad8ec2c3f Removed comments I no longer need. 2015-07-01 23:38:12 +02:00
Robert Larsen 504518596d More avoid newline. 2015-07-01 23:06:24 +02:00
Robert Larsen 5a6327537b Avoid newlines. 2015-07-01 22:53:16 +02:00
Robert Larsen 6ede0d2d64 Upper and lower halfword were swapped if they contained nul bytes. 2015-07-01 15:05:38 +02:00
Robert Larsen 966f66b19d Don't use pseudo instructions. 2015-07-01 14:19:24 +02:00
Robert Larsen 52dec55e2d Fixed list of registers. Use this in mips/mov.asm 2015-07-01 09:19:26 +02:00
Robert Larsen b3e4cb12b8 Prettier 2015-07-01 00:38:38 +02:00
Robert Larsen 536416dd83 Added more cases. May be done now. 2015-07-01 00:30:07 +02:00
Robert Larsen 2f88aadf0b More correct comments. 2015-06-30 23:48:02 +02:00
Robert Larsen d67384b283 More stuff tested. 2015-06-30 23:26:33 +02:00
Robert Larsen 5cb35801e9 More stuff tested. 2015-06-30 23:24:35 +02:00
Robert Larsen 88b6ea3b1a Be able to mov src=1 2015-06-30 22:51:32 +02:00
Robert Larsen 6be7b53519 Verified another piece. 2015-06-30 22:42:51 +02:00
Robert Larsen 2f1d4f6ebe Added comments about what works. 2015-06-30 15:34:29 +02:00
Robert Larsen 24dfbc850f Trying to build a mov() shellcode generator for MIPS. 2015-06-29 16:16:47 +02:00
Zach Riggle c0f321fbf2 Unlink GDB temporary files. Fixes #519 2015-06-15 14:06:44 -04:00
Zach Riggle 39beae9c3f Add setregs shellcode helper for i386 to demonstrate regsort
```py
>>> print shellcraft.setregs({'eax':'ebx','ebx':3,'edx':'eax','esi':'edi','edi':'esi','ebp':'ebx'})
    mov edx, eax
    mov eax, ebx
    mov ebp, ebx
    push 0x3
    pop ebx
    xchg edi, esi
```
2015-06-15 13:53:14 -04:00
Morten Brøns-Pedersen 143239bd7f Merge pull request #465 from binjitsu/sorted-imports-upstream
Sort all imports, force import sort checking on doctest
2015-06-11 20:01:52 +02:00
Morten Brøns-Pedersen 61540eb90f Merge pull request #457 from binjitsu/clean-and-log
Don't log twice for clean_and_log.
2015-06-11 20:00:21 +02:00
Morten Brøns-Pedersen 4fbaba7888 Merge pull request #557 from binjitsu/read-n
Enable maximum number of bytes to read
2015-06-11 19:59:07 +02:00
Zach Riggle 13ad3e80f7 Fix doctest 2015-06-11 08:59:58 -04:00
Zach Riggle d2e6db8904 Add config 2015-06-11 08:59:35 -04:00
Zach Riggle a0b6e99e72 Fix failing test due to wrong username 2015-06-11 08:58:07 -04:00
Zach Riggle f5ebcf6dc4 Add mode option to write 2015-06-11 08:55:49 -04:00
Zach Riggle f7eca3e13a Add skip, rename n to count 2015-06-11 08:34:52 -04:00
Zach Riggle 787c015e07 Don't log twice for clean_and_log. 2015-06-11 08:30:12 -04:00
Zach Riggle c69ed7ea15 Sort all imports 2015-06-11 08:25:50 -04:00
Zach Riggle f399a7029d More enhancements to the Travis caching functionality. 2015-06-11 08:13:17 -04:00
Zach Riggle 061ca4ab12 Use container-based Travis CI so that it builds faster 2015-06-11 08:13:17 -04:00
Morten Brøns-Pedersen 74e55a2ef6 Merge pull request #501 from binjitsu/cmdline-enhance
Enhance asm and shellcraft with auto-debugging; add checksec command-line
2015-06-11 10:42:24 +02:00
Morten Brøns-Pedersen 2e8228490f Merge pull request #499 from binjitsu/process-enhancements
Enhance functionality in process
2015-06-11 10:41:14 +02:00
Morten Brøns-Pedersen 8766c3f7ad Merge pull request #498 from binjitsu/ssh-enhancements
Multiple enhancements to SSH
2015-06-11 10:39:14 +02:00
Morten Brøns-Pedersen eb59165810 Merge pull request #542 from binjitsu/net-shorter
Fix sockaddr ipv6, optimize off some zero bytes
2015-06-11 10:26:00 +02:00
Morten Brøns-Pedersen d48d0624d1 Merge pull request #543 from binjitsu/compress-debug-sendrecv
Compress debug send/recv output if it's the same byte
2015-06-11 10:25:07 +02:00
Morten Brøns-Pedersen 3fab235f30 Merge pull request #551 from binjitsu/disasm-strip
Enable disassembly with stripping the offsets and columns
2015-06-11 10:18:55 +02:00
Morten Brøns-Pedersen c83387b2f3 Merge pull request #555 from Gallopsled/issue553
Fixes #553
2015-06-11 10:16:56 +02:00
Morten Brøns-Pedersen cc4102f7d2 Merge pull request #556 from binjitsu/aarch64
Add support for aarch64-linux
2015-06-11 10:15:22 +02:00
Zach Riggle 8849b78ed5 Enable maximum number of bytes to read 2015-06-11 03:27:52 -04:00
Zach Riggle fc2032e830 Add support for aarch64-linux 2015-06-10 23:11:48 -04:00
Jonas Rudloff b0c3abb23c fix doctest to make travis happy 2015-06-10 20:27:22 +02:00
Jonas Rudloff a3d37d6287 fixed #553 2015-06-10 20:09:16 +02:00
Jonas Rudloff 62fedb388b fixed #552 2015-06-10 19:55:04 +02:00
Zach Riggle 20ea1e0a06 Add docs 2015-06-09 12:53:57 -04:00
Zach Riggle e082d441d2 Fix doctest 2015-06-09 12:51:46 -04:00
Zach Riggle af466424ee Don't modify original representation 2015-06-09 12:49:04 -04:00
Zach Riggle 3c188bc27e Enable disassembly with stripping the offsets and columns 2015-06-09 12:47:08 -04:00
Morten Brøns-Pedersen dfe4d2c280 Merge pull request #548 from Gallopsled/ua-license
(hopefully) fixes #547
2015-05-30 09:55:59 +02:00
Morten Brøns-Pedersen d5dae58737 Update LICENSE.txt
Removed irrelevant information.
2015-05-30 09:55:34 +02:00
Morten Brøns-Pedersen b9bf5982f6 (hopefully) fixes #547 2015-05-29 09:35:42 +02:00
Morten Brøns-Pedersen f97045be7c added pwnlib.util.packing.dd inspired by the command line util of the same name 2015-05-28 10:49:17 +02:00
Jonas Rudloff ee0ace9aeb Merge pull request #544 from binjitsu/dealarm
Add dealarm_shell
2015-05-27 10:54:11 +02:00
Jonas Rudloff 31e93128d1 Merge pull request #528 from binjitsu/libcdb
Add code for libcdb lookups
2015-05-26 17:21:59 +02:00
Morten Brøns-Pedersen 27daa1291a Merge pull request #545 from Gallopsled/fit-docs
updated docstring for `pwnlib.util.packing.fit` and added a check tha…
2015-05-26 14:39:27 +02:00
Morten Brøns-Pedersen 2b4ba2e31c updated docstring for pwnlib.util.packing.fit and added a check that the data actually fits 2015-05-26 09:33:50 +02:00
Zach Riggle 734591dd84 Add dealarm_shell 2015-05-22 20:50:13 -04:00
Zach Riggle 6d2ac263df Compress debug send/recv output if it's the same byte 2015-05-22 20:32:46 -04:00
Zach Riggle bb5ea7677c Fix sockaddr, optimize off some zero bytes 2015-05-22 19:54:46 -04:00
Zach Riggle 866f4762ef Remove lookup in .resolve(), add .libc() 2015-05-21 13:30:03 -04:00
Jonas Rudloff 1d251adec5 Merge pull request #523 from binjitsu/push-fix
Fix push() templates
2015-05-21 11:39:58 +02:00
Jonas Rudloff 0fd0677af0 fix travis 2015-05-21 10:51:33 +02:00
Jonas Rudloff a3d7215162 Merge pull request #500 from binjitsu/gdb-enhancements
Add gdb.debug_shellcode and fix cross-arch debugging with qemu-user
2015-05-21 10:08:08 +02:00
Jonas Rudloff 6f23067894 Merge pull request #534 from Gallopsled/terminal-detection
Changed `util.misc.run_in_terminal` to first look for tmux, and then X11
2015-05-21 10:06:46 +02:00
Jonas Rudloff 77a59681b9 Merge pull request #517 from binjitsu/complex-constants
Implement complex constants
2015-05-21 10:05:40 +02:00
Jonas Rudloff 222f0b9474 Merge pull request #535 from Gallopsled/hexdump-highlight
Hexdump highlight
2015-05-21 10:03:27 +02:00
Jonas Rudloff 64f95f5b19 Merge pull request #537 from Gallopsled/iters-exp
added ``iters.exp(s, n)`` as an alias for ``iters.product(*[s]*n)``.
2015-05-21 10:02:47 +02:00
Jonas Rudloff da0bbefb84 Merge pull request #538 from Gallopsled/packing-fit
added `util.packing.fit`
2015-05-21 10:01:49 +02:00
Jonas Rudloff 4ef299a888 Merge pull request #539 from Gallopsled/ui-yesno
added `ui.yesno`
2015-05-21 10:00:47 +02:00
Jonas Rudloff 4aeea41362 Merge pull request #540 from Gallopsled/minor-term-fix
fixes some minor CRLF/LF-issues in `term.term`
2015-05-21 09:59:23 +02:00
Morten Brøns-Pedersen fa8df31c4f removed a print-statement left from debugging 2015-05-21 01:08:57 +02:00
Morten Brøns-Pedersen 9effbad62e updated doctests for pwnlib.util.packing.fit 2015-05-20 23:50:23 +02:00
Morten Brøns-Pedersen 4bf8b71707 Happy now, Travis? 2015-05-20 23:48:02 +02:00
Morten Brøns-Pedersen 1b3e9984f4 fixed typo in docstring for pwnlib.util.iters.exp 2015-05-20 13:55:00 +02:00
Morten Brøns-Pedersen ceca7b5384 fixed doctest in pwnlib.util.iters.exp 2015-05-20 13:39:12 +02:00
Morten Brøns-Pedersen 156db1aea9 fixes some minor CRLF/LF-issues in term.term 2015-05-20 12:22:05 +02:00
Morten Brøns-Pedersen 26c99083bd added ui.yesno 2015-05-20 12:18:11 +02:00
Morten Brøns-Pedersen 3ae7d9ec9a added util.packing.fit 2015-05-20 12:14:58 +02:00
Morten Brøns-Pedersen 011c7d96a2 added `iters.exp(s, n) as an alias for iters.product(*[s]*n)`. 2015-05-20 12:08:59 +02:00
Morten Brøns-Pedersen 1447c361b0 Better default terminal in util.misc.run_in_terminal
Changed to detect X11 by the presence of the ``DISPLAY`` environment variable.  Also added the field `terminal` to `context`, which allows the user to specify a default terminal.
2015-05-20 11:50:49 +02:00
Morten Brøns-Pedersen c9e5a01605 Updated pdh to support highlighting of byte sequences 2015-05-13 15:21:41 +02:00
Morten Brøns-Pedersen cd4a193404 pwnlib.util.fiddling.hexdump can now highlight byte sequences (with wildcards) 2015-05-13 15:20:31 +02:00
Morten Brøns-Pedersen 94e0064c19 Changed util.fiddling.hexdump_iter to take a file object instead of a string. This massively speeds up phd <file> | less for huge files. 2015-05-13 11:06:38 +02:00
Jonas Rudloff 0dafc5d02d Merge pull request #524 from binjitsu/packing-autodetect-sign
Enhancements to packing to allow auto-detection of sign, as well as unpack bytearray objects
2015-04-28 13:50:51 +02:00
Jonas Rudloff 3807889f33 Merge pull request #530 from teroz/master
Added clarity to the pwnlib.cyclic example
2015-04-28 09:37:18 +02:00
Jonas Rudloff 421ca7f82e Merge pull request #532 from Gallopsled/br0ns-fix-531
Quickfix for bpython
2015-04-27 11:09:53 +02:00
Morten Brøns-Pedersen 4e00935630 Quickfix for bpython
Fixes #531
2015-04-26 21:17:34 +02:00
teroz 764da5af10 Added clarity in the pwnlib.cyclic example
modified:   docs/source/intro.rst
2015-04-25 13:06:21 +02:00
Zach Riggle 8e799d0516 Switch to GitLab since they have a 10GB quota. Add error handling :) 2015-04-17 01:22:30 -04:00
Zach Riggle 59537cac6d Add missing architectures 2015-04-16 01:22:03 -04:00
Zach Riggle 34bfd261ca Fix unknown architectures throwing exceptions on GOT/PLT failure. Hide RWX comment if NX is disabled. 2015-04-16 01:22:03 -04:00
Zach Riggle f752a5d474 Miscellaneous bug fixes and enhancements from Binjitsu which are required for this feature to work. 2015-04-16 01:22:03 -04:00
Zach Riggle 7d3147958f Add code for libcdb lookups 2015-04-16 00:25:39 -04:00
Zach Riggle 6802a2c17b Fix bug in gdb.debug which breaks "execute" argument 2015-03-31 05:18:52 -04:00
Jonas Rudloff 94a07cc48c Merge pull request #525 from RobertLarsen/master
Added sockaddr structure generating function
2015-03-27 12:28:40 +01:00
Robert Larsen a7c902ec37 Added docstring. 2015-03-27 00:28:22 +01:00
Robert Larsen 17c9439536 Moved sockaddr function from packing to net. 2015-03-27 00:03:17 +01:00
Robert Larsen ccd225f257 Removed unneeded import. 2015-03-26 23:46:53 +01:00
Robert Larsen 974b0e7543 Added sockaddr code to i386 connect so that it also supports both ipv4
and ipv6.
2015-03-26 23:46:17 +01:00
Robert Larsen 61e3d3bf18 Moved sockaddr code to packing. Probably not the right place for it. 2015-03-26 23:09:57 +01:00
Zach Riggle fa62f18378 Enhancements to packing to allow auto-detection of sign, as well as unpack bytearray objects
(cherry picked from commit 6a3e2591c29d5a176136b1e1e16b63de5b64160c)
2015-03-26 15:48:49 -04:00
Jonas Rudloff dd00e4cfef Merge pull request #520 from Gallopsled/memleak-struct
Memleak can now leak whole structures
2015-03-26 18:26:17 +01:00
Zach Riggle b8cc1cc831 Multiple enhancements to SSH
- Request a TTY by default, and disable echoing
	- This turns off stdout buffering
	- Only negative effect is that you lose Ctrl+C
- Further improvements to ssh.process to allow e.g. file handle dup'ing
- Greatly improved documentation of members/attributes
- Added .pid attribute to ssh_channel
- Uses SCP by default, falls back to old method of cat'ing files
- Switched to use exclusively SHA256 instead of multiple hashes.
	- We lose no flexibility or support
- Sorted imports
2015-03-26 02:16:00 -04:00
Zach Riggle de7d161a87 Fix push() templates 2015-03-26 02:12:47 -04:00
Robert Larsen 5214be49f0 Added function for generating a sockaddr structure for shellcodes. 2015-03-24 23:57:00 +01:00
Jonas Rudloff f5d3b4aac0 Merge pull request #512 from RobertLarsen/thumb-connect
Added connect shellcode for thumb/linux.
2015-03-24 21:02:32 +01:00
Jonas Rudloff eafdc0a13e Merge pull request #496 from binjitsu/asm-enhancements
General enhancements to ASM, add make_elf
2015-03-24 20:05:18 +01:00
Jonas Rudloff 007f362dc1 Merge pull request #497 from binjitsu/context-binary
Add context.binary helper
2015-03-24 20:03:46 +01:00
Jonas Rudloff b7a98c9971 Merge pull request #516 from binjitsu/arm-syscall
Arm syscall
2015-03-24 20:02:38 +01:00
Jonas Rudloff 71c6f3339a Merge pull request #515 from RobertLarsen/thumb-stager
Thumb stager
2015-03-24 20:02:29 +01:00
Jonas Rudloff c7890f79c9 Merge pull request #513 from binjitsu/this-file-is-outdated
Remove install_local.sh since it's outdated
2015-03-24 20:02:15 +01:00
Jonas Rudloff a2bab1ff6f Merge pull request #494 from binjitsu/tube-packing-shortcuts
Tube packing shortcuts
2015-03-24 18:54:23 +01:00
Jonas Rudloff b092b171f8 fixed documentation and whitespace 2015-03-24 18:40:41 +01:00
Jonas Rudloff 20f4b92fd0 Merge pull request #504 from binjitsu/shellcraft-enhancements-mov
Multiple enhancements to shellcraft
2015-03-24 14:29:51 +01:00
Jonas Rudloff 8c73bdc17d Merge pull request #491 from binjitsu/asm-vma-fix
Fix VMA for ASM
2015-03-24 14:19:57 +01:00
Jonas Rudloff a74aea025b Merge pull request #514 from binjitsu/shellcraft-completion-requires-sudo
Don't install shellcraft completion by default.  It requires sudo.
2015-03-24 14:19:42 +01:00
Jonas Rudloff 4c78c1674f Memleak can now leak whole structures 2015-03-24 12:22:42 +01:00
Robert Larsen 74fc4d0e22 Removed comment. 2015-03-23 21:50:37 +01:00
Robert Larsen 1b5145792b Use arm.syscall 2015-03-23 21:49:27 +01:00
Zach Riggle 9ca377c61c Multiple enhancements to shellcraft
- Refactor i386/amd64 mov code to use new register info
	- Mostly this is to clean up the code and remove things like bigger[0][-1]
- A small enhancement to the ARM shellcode
- Resolve hosts for i386.linux.connect
- Add arm.trap
- Add gethostbyname to i386.connect
2015-03-23 02:56:52 -07:00
Zach Riggle 425385e135 Mark .text area as RWX so that self-modifying code can be tested 2015-03-22 23:28:32 -07:00
Zach Riggle 14130f3b40 Implement complex constants
- Keep their name so that we have relevant info in shellcode
- Can be manipulated as integers as you'd expect
- Update generation scripts to emit new-style constants
2015-03-22 16:27:05 -07:00
fhare d761e78d91 Add syscall shellcode for arm.
(cherry picked from commit eb8a166659)
2015-03-22 15:54:25 -07:00
fhare cc9fc0b6b1 Add register validation and constant substitution in mov shellcode for arm.
(cherry picked from commit 16c7954e0a)
2015-03-22 15:54:19 -07:00
Robert Larsen 8021d2bc3c Branch to r8 instead of moving it. 2015-03-22 22:13:28 +01:00
Zach Riggle 7387ed55a5 Don't install shellcraft completion by default. It requires sudo. 2015-03-22 05:26:09 -04:00
Zach Riggle 5e601ebd70 Remove install_local.sh since it's outdated 2015-03-22 05:23:59 -04:00
Robert Larsen f51feb0c85 Set condition flags. 2015-03-22 00:33:24 +01:00
Robert Larsen 7c1567bbce No error label. 2015-03-22 00:04:54 +01:00
Robert Larsen 8b823c813d Added stager for thumb/linux. 2015-03-22 00:03:02 +01:00
Robert Larsen ce5052b415 Added connect shellcode for thumb/linux. 2015-03-21 21:47:44 +01:00
Jonas Rudloff 691fe6f1bc Merge pull request #511 from RobertLarsen/amd64-connect
Amd64 connect
2015-03-21 11:27:11 +01:00
Robert Larsen 0429c8c5c8 Added connect shellcode for amd64/linux. 2015-03-21 00:04:14 +01:00
Kristoffer Søholm e87f998c57 Merge pull request #509 from RobertLarsen/fix-doc
Fixed doc.
2015-03-20 17:14:15 +01:00
Robert Larsen 32162a734e Merge branch 'master' of https://github.com/RobertLarsen/pwntools 2015-03-20 15:03:15 +01:00
Robert Larsen 69fe228fd6 Merge branch 'master' of https://github.com/RobertLarsen/pwntools into fix-doc 2015-03-20 15:03:00 +01:00
Robert Larsen 28721dc876 Fixed doc. 2015-03-20 14:59:33 +01:00
Robert Larsen 881590dd3b Added stager for amd64/linux. 2015-03-20 14:56:38 +01:00
Robert Larsen 4905647807 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-03-20 14:35:07 +01:00
Robert Larsen 470df7fa1e Added stager for amd64/linux. 2015-03-20 14:33:02 +01:00
Kristoffer Søholm 1bb9482c91 Merge pull request #508 from RobertLarsen/amd64-bindsh
Added bindshell shellcode for amd64/linux.
2015-03-20 13:39:24 +01:00
Kristoffer Søholm 25cff5f92b Merge pull request #492 from binjitsu/arm-mov-reg-reg
Enable mov reg, reg for ARM
2015-03-20 13:20:03 +01:00
Kristoffer Søholm 116df98a5e Merge pull request #493 from binjitsu/bugfix-pause
Fix bug in pause()
2015-03-20 13:17:10 +01:00
Robert Larsen 08fe08cd55 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-03-20 13:08:09 +01:00
Kristoffer Søholm ed5229da8b Merge pull request #505 from RobertLarsen/amd64-findpeersh
Amd64 findpeersh
2015-03-20 12:57:54 +01:00
Robert Larsen aad286fbb4 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2015-03-20 12:06:58 +01:00
Robert Larsen ef46969bce Merge branch 'amd64-bindsh' 2015-03-20 11:46:56 +01:00
Robert Larsen f1bd02e571 Merge branch 'amd64-findpeersh' 2015-03-20 11:46:34 +01:00
Robert Larsen 0da1aca8bb Fixed doc. 2015-03-20 11:46:12 +01:00
Robert Larsen 4b869e408b Added bindshell shellcode for amd64/linux. 2015-03-20 11:26:52 +01:00
Zach Riggle 9cdd76cde2 General enhancements to ASM, add make_elf
- Sorted imports
- We can now build whole, compact ELF files.
    - This is useful for e.g. ioarm level 1
- Various fixes for endianness support, bit sizes when assembling
- Don't catch KeyboardInterrupt
2015-03-20 05:07:15 -04:00
Zach Riggle 15426e410f Add context.binary helper 2015-03-20 05:06:35 -04:00
Robert Larsen ed1eaf2a37 Merge pull request #486 from zachriggle/patch-3
Change IRC channel to #pwntools
2015-03-20 09:50:29 +01:00
Robert Larsen 5c8f64e5f6 Merge pull request #429 from zachriggle/patch-1
Update LICENSE-pwntools.txt
2015-03-20 09:49:53 +01:00
Robert Larsen 6c44b36750 Merge pull request #495 from binjitsu/elf-arch-fixes
Various enhancements to ELF
2015-03-20 09:43:29 +01:00
Robert Larsen 83da6ef918 Document constant. 2015-03-20 09:22:44 +01:00
Robert Larsen a0e18aa58a Set the length of the address structure. 2015-03-20 09:16:05 +01:00
Zach Riggle dfcf26f37a Use setsid instead of setpgrp to capture output to /dev/tty 2015-03-19 17:16:35 -04:00
Robert Larsen ce9f47a009 Closer to working solution. 2015-03-19 16:00:32 +01:00
Robert Larsen e16d1e2883 Added file for implementing findpeer shellcode. 2015-03-19 00:07:30 +01:00
Robert Larsen 6e8940f051 Added template for implementing the shellcode. 2015-03-19 00:05:58 +01:00
Zach Riggle 342cf97099 Enhance asm and shellcraft with auto-debugging; add checksec command-line 2015-03-16 22:32:46 -07:00
Zach Riggle 5ddb4f4bda Add gdb.debug_shellcode and fix cross-arch debugging with qemu-user 2015-03-16 21:40:26 -07:00
Zach Riggle 98c5b18e58 Enhance functionality in process
- Make stdout a PTY
	- This disables buffering on stdout
- Add options to specify how stdin/stdout/stderr are created
- Expose preexec_fn
- Protect the user from common Python-specific pitfalls
	- e.g. argv elements cannot contain or even end with '\x00'
2015-03-16 20:39:26 -07:00
Zach Riggle 820c455b1a Various enhancements to ELF
- Better documentation
- Remove generally unused fields of checksec
- Better support for uncommon architectures
2015-03-16 19:09:49 -07:00
Zach Riggle 2784ea58c9 Add mov reg,reg noop 2015-03-16 18:37:14 -04:00
Zach Riggle 7c9638b6df Enable mov reg, reg for ARM 2015-03-16 18:34:33 -04:00
Kristoffer Søholm 34767b08ef Merge pull request #488 from binjitsu/arch
Add missing architecture constants
2015-03-16 23:24:57 +01:00
Zach Riggle 2c5125a74c Add tube.flat
Conflicts:
	pwnlib/tubes/tube.py
2015-03-16 15:22:32 -07:00
Zach Riggle 143fca406a Add packing shortcuts
Conflicts:
	pwnlib/tubes/tube.py
2015-03-16 15:22:12 -07:00
Zach Riggle 0174b33714 Fix bug in pause() 2015-03-16 15:20:25 -07:00
Zach Riggle 41c7aeda31 Fix VMA for ASM 2015-03-16 16:47:01 -04:00
Zach Riggle beb07285d6 Add missing architecture constants 2015-03-13 10:41:16 -07:00
Zach Riggle 9a87c2032d Change IRC channel to #pwntools 2015-03-13 12:19:56 -04:00
Mathias Svensson 32b05024d3 Merge pull request #482 from Gallopsled/bruteforce_bugfix
Fixed bug in total_iterations calculation
2015-03-13 01:28:39 +01:00
Kristoffer Søholm 69023995d0 Fixed bug in total_iterations calculation 2015-03-12 20:16:42 +01:00
Kristoffer Søholm 31242554eb Merge pull request #461 from StevenVanAcker/master
multithreaded bruteforcing + bugfixes
2015-03-12 20:08:29 +01:00
Kristoffer Søholm eefe307724 Merge pull request #481 from RobertLarsen/cyclic_length
Made cyclic respect the '--length' argument when looking up.
2015-03-12 19:30:43 +01:00
Robert Larsen f80acf8437 Made cyclic respect the '--length' argument when looking up. 2015-03-12 14:47:37 +01:00
Jonas Rudloff 1ddd80c53d Merge pull request #476 from Gallopsled/autofmtstr
Automated format string explotation
2015-02-27 11:05:29 +01:00
Jonas Rudloff d1ae931728 Better heuristic for leaking elf headers on page boundaries 2015-02-27 10:55:58 +01:00
Mathias Svensson 5c0fafc4c9 Merge pull request #480 from binjitsu/issue-442
Fix mis-reporting of NX when there is no GNU_STACK segment
2015-02-26 22:13:36 +01:00
Zach Riggle cefac557d3 Fix mis-reporting of NX when there is no GNU_STACK segment
(cherry picked from commit a96ffc80a2)
2015-02-26 15:42:00 -05:00
Jonas Rudloff 58cc527687 Merge pull request #479 from binjitsu/pwntools-logo
Add logo
2015-02-26 21:37:36 +01:00
Jonas Rudloff ba395ab357 Merge pull request #451 from binjitsu/shellcraft-speedup
Speed up shellcraft loading and clean up code a bit
2015-02-26 21:28:46 +01:00
Jonas Rudloff dc7f4dcff5 fixed logging 2015-02-26 13:22:58 +01:00
Jonas Rudloff bb96f4982c Merge pull request #478 from binjitsu/pwntools-ssh-cwd-executable
Set +x on the directory created via ssh.set_working_directory
2015-02-26 12:56:25 +01:00
Zach Riggle 6e0852baf5 Add logo 2015-02-26 06:31:33 -05:00
Jonas Rudloff 7c0f23476d use pack instead of p32 2015-02-26 10:02:15 +01:00
Zach Riggle 6f8823829f Sort templates 2015-02-25 14:57:47 -05:00
Zach Riggle 71ecf70de6 Speed up shellcraft loading and clean up code a bit 2015-02-25 14:57:47 -05:00
Zach Riggle b7dc9c934f Set +x on the directory created 2015-02-25 14:26:44 -05:00
Jonas Rudloff cb64e2d4aa Merge branch 'master' of github.com:Gallopsled/pwntools
Conflicts:
	pwnlib/tubes/ssh.py
2015-02-25 19:22:55 +01:00
Jonas Rudloff 8ac88d141c Merge branch 'binjitsu-ssh-run-system-rename' 2015-02-25 19:17:54 +01:00
Jonas Rudloff 8f92f07e62 Merge branch 'ssh-run-system-rename' of git://github.com/binjitsu/binjitsu into binjitsu-ssh-run-system-rename 2015-02-25 19:17:07 +01:00
Jonas Rudloff 133d629bd3 Merge pull request #475 from Gallopsled/dynelf-fix
fix dynelf for sysv lookups
2015-02-25 13:42:39 +01:00
Jonas Rudloff 29889a00df Merge pull request #474 from Gallopsled/memleak-bug
fixes bug in memleak.py
2015-02-25 13:42:25 +01:00
Jonas Rudloff abc6360833 Update ssh.py
Use example.pwnme as hostname instead of localhost
2015-02-25 12:45:53 +01:00
Jonas Rudloff 75f48e74dd Merge pull request #444 from binjitsu/ssh-process-execve
SSH Process-style interface with full control over argv
2015-02-25 12:26:57 +01:00
Jonas Rudloff 017f5861ce Automated format string explotation 2015-02-25 12:11:40 +01:00
Jonas Rudloff c50d32d700 fixed nbuckets -> nbucket in dynelf.py for sysv hash lookups 2015-02-25 11:54:03 +01:00
Jonas Rudloff 28bd8fc3a7 Merge pull request #447 from zachriggle/patch-1
Update 'latest version' documentation since pip can install from git
2015-02-24 23:08:08 +01:00
Jonas Rudloff 31b84d7ba9 Merge pull request #471 from zachriggle/patch-2
Fix gdb.attach for foreign architectures
2015-02-24 22:59:34 +01:00
Jonas Rudloff de50da1849 Merge pull request #463 from binjitsu/capstone3
Update dependency versions
2015-02-24 22:28:03 +01:00
Jonas Rudloff 5a36d7fdc6 Merge pull request #464 from binjitsu/proc-pty-stdout
Set stdout to be a PTY on spawned processes so that stdout is not buffered
2015-02-24 22:25:49 +01:00
Jonas Rudloff 23eed9752c Merge pull request #460 from binjitsu/threading-event-wait
Enable a configurable timeout for recvall
2015-02-24 21:33:18 +01:00
Jonas Rudloff ef71b4c1ef Merge pull request #466 from binjitsu/mit-license-badge
Add MIT license badge
2015-02-24 21:32:12 +01:00
Jonas Rudloff ca9f918ac1 Merge pull request #470 from r3dey3/master
Fix #469 - verify search_results has items before using
2015-02-24 21:32:01 +01:00
Jonas Rudloff 12b2b127af Merge pull request #446 from binjitsu/sphinx-warnings
Squash most of the Sphinx warnings
2015-02-24 21:30:02 +01:00
Jonas Rudloff ea1cb8ad7a Merge pull request #439 from binjitsu/ssh-revamp-localhost-only
Restrict demouser for Travis to localhost only.
2015-02-24 21:27:27 +01:00
Jonas Rudloff 4a7d4fcff7 fixes bug in memleak.py 2015-02-23 20:28:19 +01:00
Zach Riggle b9cb550856 Fix gdb.attach for foreign architectures 2015-02-10 08:24:45 -05:00
Kenny 8bd50f958c Fix #469 - verify search_results has items before using 2015-02-08 15:58:22 -05:00
Zach Riggle 38a080022d Add MIT license badge 2015-02-05 04:31:25 -08:00
Zach Riggle bfd1c74ef6 Wait for close on unit test 2015-02-05 01:56:14 -08:00
Zach Riggle f1b5df6d99 Enhance test for process tube 2015-02-05 00:19:51 -08:00
Zach Riggle 99cae63745 Handle IOError, and ensure Ctrl+C sent to parent process does not propagate to child 2015-02-05 00:10:00 -08:00
Zach Riggle 1273bfa1fb Set stdout to be a PTY on spawned processes so that stdout is not buffered. 2015-02-04 23:51:23 -08:00
Zach Riggle 226e4b73a6 Have capstone install itself
Specify versions of all requirements.  Had some complaints about old psutils, and this will cause new installs to upgrade.

Update Capstone installation docs.  The 3.0.1 target is self-installing.

Avoid Travis CI build time penalty by using older, pre-built Capstone 2.1
2015-02-05 02:10:46 -05:00
Steven Van Acker 51e5ee5bf2 support for multithreaded bruteforcing 2015-02-02 12:12:18 +01:00
Steven Van Acker 112b65f8e9 fixing documentation of bruteforce() 2015-02-01 23:50:28 +01:00
Steven Van Acker 890db20b27 fixing order of arguments for consume(), so that bruteforce() works when start is specified 2015-02-01 11:54:27 +01:00
Zach Riggle a875adb533 Work around #459 2015-01-31 22:45:13 -08:00
Zach Riggle faf66a3981 Add a more robust interface to SSH commands which doesn't require hacky shell escaping if Python is available on the remote host. This interface follows the same style as pwnlib.tubes.process.process 2015-01-25 21:50:28 -08:00
Zach Riggle 8710709ca3 Update 'latest version' documentation since pip can install from git 2015-01-24 16:11:51 -08:00
Zach Riggle 0726fb45d8 Squash most of the Sphinx warnings 2015-01-23 23:34:39 -08:00
Zach Riggle 7d08ba6893 Rename ssh.run to ssh.system since that's closer to what it really is 2015-01-23 04:51:07 -08:00
Jonas Rudloff 1be8797cee Merge pull request #440 from binjitsu/issue-438
mips -> tradmips
2015-01-22 14:16:21 +01:00
Zach Riggle 6fc936c708 mips -> tradmips 2015-01-22 04:50:40 -08:00
Zach Riggle 5134d4f6a4 Update self.host to the resolved host 2015-01-22 04:24:57 -08:00
Zach Riggle 51bda21142 Restrict demouser for Travis to localhost only. Change host name from localhost to example.pwnme. Add support for getting the hostname and identityfile from ssh_config. 2015-01-22 04:13:01 -08:00
Mathias Svensson 8d5cf044e7 Merge pull request #434 from binjitsu/close-handles-proc
Close extra handles on child processes
2015-01-18 16:35:07 +01:00
Zach Riggle 02a6145c1d Close extra handles on child processes 2015-01-16 14:55:16 -08:00
Jonas Rudloff 46bd8e93b2 Merge pull request #418 from Gallopsled/performance-logger
Added a performance logger
2015-01-16 16:19:28 +01:00
Jonas Rudloff c0fec5ee5a Merge pull request #416 from Gallopsled/log-pwnhandler
Added support for increasing logging for a specific point in the tree
2015-01-16 16:17:51 +01:00
Jonas Rudloff 5b33186a51 Merge pull request #433 from Gallopsled/update-gitignore
Added swp to gitignore
2015-01-16 16:16:42 +01:00
Mathias Svensson 5b5b7a2544 Added swp to gitignore 2015-01-16 16:14:16 +01:00
Kristoffer Søholm 850efb557f Merge pull request #431 from Gallopsled/fix-stager
Off by one line in stager shellcode
2015-01-13 15:37:47 +01:00
Jonas Rudloff e515d234c7 if construct was of by one line 2015-01-13 14:46:48 +01:00
Mathias Svensson 8a97980bc0 Merge pull request #430 from StevenVanAcker/patch-1
fixing capstone installation under debian/ubuntu
2015-01-13 11:48:51 +01:00
StevenVanAcker e432a6584d fixing capstone installation under debian/ubuntu 2015-01-12 22:04:20 +01:00
Zach Riggle 835a94b356 Update LICENSE-pwntools.txt 2015-01-12 14:42:52 -05:00
Mathias Svensson 91ae3968ed Merge pull request #426 from Gallopsled/connect-shellcode
Added a connect shellcode ported from the old pwntools
2015-01-12 18:14:20 +01:00
Mathias Svensson bfb5d09b5f Added a performance logger and updated tube.py to use it 2015-01-12 17:59:15 +01:00
Mathias Svensson 9a830b7185 Missed a docstring 2015-01-12 17:54:18 +01:00
Mathias Svensson 4edb4b8894 Added support for increasing logging for a specific point in the tree 2015-01-12 17:54:18 +01:00
Mathias Svensson 2fb768f8a4 Merge pull request #423 from Gallopsled/doctest-stdout
Order matters
2015-01-12 17:52:38 +01:00
Zach Riggle 0fab4731e7 Merge pull request #427 from Gallopsled/travis-apt-update-once
Only call apt-get update once, shaves off a few seconds
2015-01-12 11:49:55 -05:00
Zach Riggle 492d81b9f8 Only call apt-get update once, shaves off a few seconds 2015-01-12 11:36:15 -05:00
Zach Riggle 9139dc64d9 Fix stderr changing on term.init breaking the logging 2015-01-12 11:31:36 -05:00
Jonas Rudloff 771a56e207 Added a connect shellcode ported from the old pwntools 2015-01-12 16:56:32 +01:00
Zach Riggle cde5ec8343 Merge pull request #425 from Gallopsled/capstones-servers-sucks
Stop relying on Capstone's servers to be up
2015-01-12 10:25:08 -05:00
Zach Riggle 872e13da20 Stop relying on Capstone's servers to be up 2015-01-12 10:11:59 -05:00
Zach Riggle 1a4664f248 Merge pull request #419 from Gallopsled/doctest-stdout
Set logging to stdout when running doctests
2015-01-12 06:12:32 -05:00
Zach Riggle 6e33077081 Set logging to stdout when running doctests, since otherwise output is not captured. Also fix assumption that the console handler is the first handler. Also ensure that the console handler is applied for doctests, since some of them require it. 2015-01-12 06:06:23 -05:00
Jonas Rudloff bd3a68c9ce Merge pull request #408 from Gallopsled/mov-microoptimizations
More micro-optimizations to mov shellcodes
2015-01-11 19:15:32 +01:00
Mathias Svensson 3c9e95bd6a More micro-optimizations to mov shellcodes 2015-01-11 18:49:10 +01:00
Robert Larsen 27f9e65939 Merge pull request #405 from Gallopsled/asm-update
Updated a lot of shellcode
2015-01-11 13:55:20 +01:00
Mathias Svensson 0da236aefa Merge pull request #407 from Gallopsled/shellcraft-strip-doctest
improved doctest stripping in shellcraft
2015-01-11 12:46:15 +01:00
Morten Brøns-Pedersen 2a86bf2440 improved doctest stripping in shellcraft 2015-01-11 12:30:22 +01:00
Mathias Svensson 73ae97f197 Enable caching of env stores for constants.eval 2015-01-11 12:28:40 +01:00
Mathias Svensson 3071cf65a7 Updated a lot of shellcodes to use the new eval feature 2015-01-11 12:09:54 +01:00
Mathias Svensson 93d2f5746a Added an eval method to the constants module, to evaluate constants in the current context 2015-01-11 12:04:23 +01:00
Mathias Svensson 4a8e8220e3 Added context manager for shellcraft/internal.py to make it exception-safe 2015-01-11 12:03:55 +01:00
Mathias Svensson 895373e053 Merge pull request #403 from Gallopsled/commandline-logging
bugfix: command line tools now installs a log handler
2015-01-11 11:59:44 +01:00
Morten Brøns-Pedersen d0793c4fac bugfix: command line tools now installs a log handler 2015-01-11 11:51:45 +01:00
Jonas Rudloff f7d39688dc Merge pull request #401 from Gallopsled/log-no-handler-in-lib
now only install a log handler when not in lib-mode
2015-01-10 22:47:29 +01:00
Morten Brøns-Pedersen 4bb4f4ca35 update doctest-hack to test logging output 2015-01-10 22:41:23 +01:00
Morten Brøns-Pedersen 7fd4dd9348 forgot to import logging 2015-01-10 22:41:23 +01:00
Morten Brøns-Pedersen 9df1b2d093 now only install a log handler when not in lib-mode 2015-01-10 22:41:23 +01:00
Jonas Rudloff b2bb517655 Merge pull request #400 from Gallopsled/pwn-noterm-text
command line flag NOTERM no longer turns text decoration off
2015-01-10 22:39:06 +01:00
Jonas Rudloff 346c9b00cf Merge pull request #399 from Gallopsled/log-no-prefix-caching
bugfix: log message prefixes are no longer cached
2015-01-10 22:37:40 +01:00
Jonas Rudloff 724f292773 Merge pull request #398 from Gallopsled/shellcraft-bash-completion
added bash completion for shellcraft
2015-01-10 22:36:00 +01:00
Kristoffer Søholm d4184db93c Merge pull request #402 from Gallopsled/issue-395
no longer creates an "a.out" when using `pwnlib.asm`
2015-01-10 22:02:03 +01:00
Morten Brøns-Pedersen 3e87bfb307 no longer creates an "a.out" when using pwnlib.asm 2015-01-10 21:18:41 +01:00
Morten Brøns-Pedersen 5823d848e8 command line flag NOTERM no longer turns text decoration off 2015-01-10 20:43:18 +01:00
Morten Brøns-Pedersen bed5f37084 bugfix: log message prefixes are no longer cached
this means that changes to `pwnlib.term.text.when` will now take effect as they should
2015-01-10 20:40:58 +01:00
Morten Brøns-Pedersen 47fd9b1132 added bash completion for shellcraft 2015-01-10 20:23:59 +01:00
Kristoffer Søholm 5905444ff4 Merge pull request #397 from Gallopsled/shellcraft-strip-doctests
"shellcraft -?" now removes any doctests from the docstring
2015-01-10 18:55:14 +01:00
Morten Brøns-Pedersen 61d7aa91bd strip trailing blank lines 2015-01-10 18:46:12 +01:00
Morten Brøns-Pedersen 6b008d3ac0 "shellcraft -?" now removes any doctests from the docstring 2015-01-10 18:43:04 +01:00
br0ns 2c127ddb8d Merge pull request #391 from Gallopsled/less-hacky-performance-fix
Made logging less hacky and removed legacy code
2015-01-10 18:14:20 +01:00
br0ns e90474dadc Merge pull request #357 from Gallopsled/stager
use i386.linux.syscall in stager shellcode
2015-01-10 16:34:41 +01:00
Jonas Rudloff cf5a4c582d use i386.linux.syscall in stager shellcode 2015-01-10 16:22:28 +01:00
br0ns b8088b8bb4 Merge pull request #353 from Gallopsled/syscall-7arg
fixes #351 syscall can now accept 7 arguments
2015-01-10 16:15:30 +01:00
Morten Brøns-Pedersen 0c9c8b449a added doctest for pwnlib.shellcraft.i386.linux.syscall 2015-01-10 16:12:32 +01:00
br0ns ffaab6cd08 Merge pull request #390 from Gallopsled/extra-toplevel
Added math, pickle and StringIO to toplevel.py
2015-01-10 15:13:39 +01:00
br0ns 15335dfc30 Merge pull request #394 from Gallopsled/fix-example
Fixed bug in examples/asm.py. There is no context variable "net".
2015-01-10 14:46:53 +01:00
Mathias Svensson 8d61322857 Merge pull request #393 from Gallopsled/rop-docstring-cleanup
fixed formatting issue in docstring for `pwnlib.rop.ROP.__getattr__`
2015-01-10 14:25:05 +01:00
Mathias Svensson 6ad5b206da Fixed bug in examples/asm.py. There is no context variable "net". 2015-01-10 14:22:30 +01:00
Morten Brøns-Pedersen 96511e8c29 fixed formatting issue in docstring for pwnlib.rop.ROP.__getattr__ 2015-01-10 14:16:32 +01:00
Mathias Svensson 37811b04f4 Cleaned up a lot of legacy code 2015-01-10 13:38:40 +01:00
Mathias Svensson d51eda5f43 Updated documentation 2015-01-10 13:38:39 +01:00
Mathias Svensson da886c4b79 Replaced ugly performance hack with less ugly performance hack 2015-01-10 12:25:18 +01:00
Mathias Svensson 24542f422a Added math, pickle and StringIO to toplevel.py 2015-01-10 12:13:26 +01:00
br0ns ba477dabbc Merge pull request #388 from Gallopsled/issue-387
Ensure arguments go through context transform
2015-01-10 12:12:59 +01:00
Zach Riggle fe034dc67a Ensure arguments go through context transform 2015-01-09 20:12:07 -08:00
Zach Riggle 7d964f86b6 Merge pull request #385 from Gallopsled/typo
fixed typo: "updatez" -> "update"
2015-01-08 12:12:50 -08:00
Jonas Rudloff f011b1789f fixed typo: "updatez" -> "update" 2015-01-08 20:41:06 +01:00
Jonas Rudloff 90da45d8d5 Merge pull request #383 from Gallopsled/log-rootlogger-level
pwnlib root logger now reports parents level if more verbose
2015-01-08 19:36:10 +01:00
Jonas Rudloff baaabd12ca Merge pull request #375 from Gallopsled/stderr-debug-process
Enable logging process stderr directly to log.debug.  This is useful for...
2015-01-08 19:34:00 +01:00
Jonas Rudloff ff2e8f0e8a Merge pull request #384 from Gallopsled/log-docstrings
updated docs for `pwnlib.log`
2015-01-08 19:33:03 +01:00
Jonas Rudloff c6c853dd3c Merge pull request #382 from Gallopsled/pwn-logfile
added command line option "LOG_FILE"
2015-01-08 19:32:18 +01:00
Morten Brøns-Pedersen 661d820b5f updated docs for pwnlib.log 2015-01-08 17:17:26 +01:00
Morten Brøns-Pedersen 0d4ff3b0b9 pwnlib root logger now reports parents level if more verbose 2015-01-08 14:56:30 +01:00
Morten Brøns-Pedersen 55b879c6d4 have command line option "LOG_LEVEL" install a handler for *all* loggers 2015-01-08 14:53:35 +01:00
Morten Brøns-Pedersen 497d766ff0 added command line option "LOG_FILE" 2015-01-08 13:07:43 +01:00
Mathias Svensson 4d9da37586 Merge pull request #381 from Gallopsled/hexdump-remove-dead-code
removed `pwnlib.util.fiddling.sequential_lines` as it is no longer used
2015-01-08 12:01:57 +01:00
Morten Brøns-Pedersen a01dc91ec1 removed pwnlib.util.fiddling.sequential_lines as it is no longer used 2015-01-08 11:44:27 +01:00
Zach Riggle f16ad780a3 Merge pull request #376 from Gallopsled/assembler-list-str
Fix assembler returned when not in special-case architectures (e.g. cris)
2015-01-07 23:15:54 -08:00
Zach Riggle 45ba7865d4 Merge pull request #377 from Gallopsled/hexdump-faster
Hexdump faster
2015-01-07 23:15:38 -08:00
Zach Riggle 8a25962917 Merge pull request #378 from Gallopsled/flat-hexdump-bytearray
Enable flat() for bytearray().  Pass argument given to hexdump() to flat() first.
2015-01-07 23:15:20 -08:00
Zach Riggle 9b4531a15e Enable flat() for bytearray(). Pass argument given to hexdump() to flat() first. 2015-01-07 21:55:51 -08:00
Zach Riggle ee4e8104a2 Disable detection of sequential de bruijn lines in hexdump until a faster alternative is found 2015-01-07 19:56:49 -08:00
Zach Riggle ecb6717d6d Fix assembler returned when not in special-case architectures (e.g. cris) 2015-01-07 19:53:45 -08:00
Zach Riggle fec0fdc9e1 Enable logging process stderr directly to log.debug. This is useful for e.g. strace or ltrace.
At some point in the future for the pwntools-write-ups, this should be very useful to assist debugging exploits.
2015-01-07 17:50:02 -08:00
br0ns 5cf13cba4e Merge pull request #374 from Gallopsled/binutils-old-version
Check the installed binutils version so that users are aware of old versions
2015-01-08 00:20:19 +01:00
Zach Riggle 2a5e19e71b Check the installed binutils version so that users are aware of old versions 2015-01-07 13:30:53 -08:00
Zach Riggle c0b714f965 Add Twitter link, fix style to be consistent
Fixes #373
2015-01-07 13:20:09 -08:00
Zach Riggle 0ffcee5667 Merge pull request #365 from Gallopsled/logging-cleanup
Attempt at improving logging
2015-01-07 11:22:27 -08:00
Zach Riggle ec262b2d70 Merge pull request #339 from Gallopsled/travis-editable-install
Have travis do an editable installation.  This is how we actually use it...
2015-01-06 17:23:55 -08:00
Zach Riggle 2b44d375f7 Merge pull request #372 from Gallopsled/readline-float-default
readline now lets the prompt+input float by default.  replacements for `raw_input` and `input` are installed.
2015-01-06 17:23:07 -08:00
Morten Brøns-Pedersen a072a4be40 readline now lets the prompt+input float by default. replacements for raw_input and input are installed. 2015-01-07 01:06:22 +01:00
Zach Riggle f3ab8b4edd Merge pull request #371 from Gallopsled/readline-eof
`term.readline` now correctly handles EOF on `sys.stdin`, and ^j is interpreted as <enter> (^m)
2015-01-06 15:47:23 -08:00
Morten Brøns-Pedersen a58815df42 letting term.term take over sys.stderr apparently breaks the doctests, so have Travis set env var PWNLIB_NOTERM 2015-01-06 21:00:36 +01:00
Morten Brøns-Pedersen 3e20b93378 term.readline now correctly handles EOF on sys.stdin, and ^j is interpreted as <enter> (^m)
This is useful if a file is redirected to stdin.
2015-01-06 19:55:07 +01:00
Morten Brøns-Pedersen ef5cfeb6c4 changed sys.stdout to sys.stderr a number of places 2015-01-06 19:40:59 +01:00
br0ns 2411161ed5 Merge pull request #367 from Gallopsled/tube-aliases
Add aliases for all tube methods for read*=recv* and write*=send*
2015-01-06 18:38:34 +01:00
Morten Brøns-Pedersen 97f04e4eb7 removed read_thread (alias for recv_thread) as it is not part of the API 2015-01-06 18:30:17 +01:00
Morten Brøns-Pedersen d72a83355e redirect logging output to sys.stdout so we can catch it in doctests 2015-01-06 12:45:57 +01:00
Morten Brøns-Pedersen c73b731c32 delegated a few more calls to the underlying logger 2015-01-06 12:45:57 +01:00
Morten Brøns-Pedersen 3705db475e fixed issue with multiple values for "level" keyword 2015-01-06 12:45:57 +01:00
Morten Brøns-Pedersen 3dee2bbe41 mega commit -- attempt at improving logging 2015-01-06 12:45:57 +01:00
br0ns d573f70576 Merge pull request #368 from Gallopsled/tubes-docs
Update documentation for tubes, and improve the layout.
2015-01-06 11:06:09 +01:00
Jonas Rudloff c4b28836b5 Merge pull request #364 from Gallopsled/issue-363
Change Args to Arguments
2015-01-06 11:00:25 +01:00
Zach Riggle d00a51ad47 Move sock above remote/listen 2015-01-05 23:43:10 -08:00
Zach Riggle d75910c817 Update documentation for tubes, and improve the layout.
Also, add the serial tube to documentation.
2015-01-05 23:36:16 -08:00
Zach Riggle 0ee0cd7ac0 Add aliases for all tube methods for read*=recv* and write*=send* 2015-01-05 23:34:13 -08:00
Zach Riggle 404f0958d0 Change Args to Arguments 2015-01-05 15:36:47 -08:00
Zach Riggle b2d2c64da3 Add expected build time
Tested on a Macbook Pro by building *all* of the architectures.  I presume desktops would be faster.
2015-01-05 15:30:41 -08:00
Zach Riggle a334bdf343 Merge pull request #358 from Gallopsled/update-stuff-for-2.2.0
Update stuff after the 2.2.0 release
2015-01-05 11:41:45 -05:00
Mathias Svensson 899a3b4410 and version.py 2015-01-05 17:34:42 +01:00
Mathias Svensson 30df1e638a Update stuff for 2.2.0 release 2015-01-05 17:32:38 +01:00
Kristoffer Søholm 3888052ba5 Merge pull request #354 from Gallopsled/log-remove-ansilen
remove `pwnlib.log.ansilen` as it is no longer used
2015-01-05 16:10:00 +01:00
Kristoffer Søholm dde3a2e415 Merge pull request #355 from Gallopsled/setup.py-openbsd
Ugly hack to be able to install on OpenBSD
2015-01-05 16:02:07 +01:00
Mathias Svensson 273ee96fc8 Ugly hack to be able to install on OpenBSD 2015-01-05 15:33:10 +01:00
Morten Brøns-Pedersen 5f28e1461d remove pwnlib.log.ansilen as it is no longer used 2015-01-05 13:58:54 +01:00
Kristoffer Søholm 8a4ff79e4d Merge pull request #345 from Gallopsled/https-links
Use https instead of http wherever possible.
2015-01-05 12:42:26 +01:00
Jonas Rudloff 3062c456f8 Merge remote-tracking branch 'origin/master' into syscall-7arg
Conflicts:
	pwnlib/shellcraft/templates/i386/linux/syscall.asm
2015-01-05 12:41:02 +01:00
Mathias Svensson 8662141d45 Merge pull request #349 from Gallopsled/binutils-osx-remove
Remove all special handling for OSX binutils, since it is broken
2015-01-05 12:31:37 +01:00
Mathias Svensson d8cf68f563 Merge pull request #352 from Gallopsled/update-gitignore
Added robots.txt to gitignore
2015-01-05 12:31:10 +01:00
Jonas Rudloff 6be81d0b7e fixes #351 syscall can now accept 7 arguments 2015-01-05 12:25:44 +01:00
Kristoffer Søholm 6f0c3ccbb7 Added robots.txt to gitignore 2015-01-05 12:25:01 +01:00
Zach Riggle 24f25361c7 Remove all special handling for OSX binutils, since it is broken. Fixes #347
Conflicts:
	pwnlib/asm.py
2015-01-04 21:32:38 -05:00
Mathias Svensson faab1eb299 Use https instead of http wherever possible.
Note that this means that I changed a few of the links from
http://docs.pwntools.org to https://pwntools.readthedocs.org as we do
not currently have https on pwntools.com
2015-01-05 01:11:02 +01:00
Zach Riggle 6225901ba8 Merge pull request #343 from Gallopsled/iss-342
Throw an AttributeError on pwnlib.term.text when an unknown attribute is requested
2015-01-04 18:38:31 -05:00
Mathias Svensson 546fcf8ca7 Merge pull request #341 from Gallopsled/no-exe
Remove the executable bit from things that aren't scripts
2015-01-05 00:22:16 +01:00
Mathias Svensson 91288759c4 Fixed #342 2015-01-05 00:21:18 +01:00
Zach Riggle ff2b4463af Merge pull request #333 from Gallopsled/mega-commit-fixup
Replace instances of mov and int 0x80 with the ${mov} and ${syscall} templates
2015-01-04 18:18:49 -05:00
Zach Riggle ca4b7263f8 Remove the executable bit from things that aren't scripts 2015-01-04 15:05:56 -08:00
Robert Larsen c6ff8417e5 Merge pull request #331 from Gallopsled/amd64-update
Optimized mov, pushstr and syscall for amd64 and updated sh to use them
2015-01-05 00:02:54 +01:00
IdolfHatler facb9ca3a0 Merge pull request #313 from Gallopsled/shellcraft-push
Add ${push} for i386 and amd64 that just uses the pushstr code
2015-01-04 23:40:39 +01:00
Mathias Svensson 3fafbab48f And a doctest 2015-01-04 23:32:10 +01:00
Mathias Svensson 685aaa0458 I forgot a few things in the mega commit. Here they are 2015-01-04 23:29:58 +01:00
IdolfHatler 870e8c1878 Merge pull request #340 from RobertLarsen/thumb-echo
Added pushstr shellcode for thumb.
2015-01-04 23:28:12 +01:00
Mathias Svensson 30d85f07f4 I swear it worked in my machine before, but then somebody went ahead and merged my other PR without me noticing 2015-01-04 23:25:03 +01:00
Mathias Svensson b5a68b6f0b A bazillion doctests 2015-01-04 23:18:41 +01:00
Mathias Svensson a69b2229cb Optimized mov, pushstr and syscall for amd64 and updated sh to use them 2015-01-04 23:18:41 +01:00
Robert Larsen ef0c2173fa Added pushstr shellcode for thumb. 2015-01-04 22:49:58 +01:00
Jonas Rudloff f4d2be9c88 Merge pull request #337 from Gallopsled/shellcraft-newline-outside
Shellcraft functions will now have a single trailing newline
2015-01-04 19:58:46 +01:00
Zach Riggle ad513db436 Have travis do an editable installation. This is how we actually use it, so this is what should work. 2015-01-04 13:16:42 -05:00
Mathias Svensson 8bb6595d38 Made the shellcode formatting a little nicer 2015-01-04 19:16:22 +01:00
Zach Riggle e796338d63 Merge pull request #334 from Gallopsled/use-specialized-first
Try the local assembler *last* instead of *first*.  Force custom-built assemblers to contain the substring 'linux'
2015-01-04 13:05:29 -05:00
Mathias Svensson c9ad57e159 Fixed a doctest 2015-01-04 19:05:06 +01:00
IdolfHatler 22a1f9760f Merge pull request #335 from Gallopsled/issue-263
Fix stackhunter and pushstr
2015-01-04 19:02:32 +01:00
Mathias Svensson 521e675ea9 Removed an unused argument, made the sign/endianness explicit for the pack 2015-01-04 18:59:28 +01:00
Zach Riggle 5da416a179 Merge pull request #329 from Gallopsled/log-geteffectivelevel
Fixed the behavior of `log.Logger.getEffectiveLevel`
2015-01-04 12:58:27 -05:00
Zach Riggle 79129c1d52 Add doctests 2015-01-04 12:44:03 -05:00
Zach Riggle 6752558254 Fix stackhunter and pushstr 2015-01-04 12:44:03 -05:00
IdolfHatler 2ba70b9433 Merge pull request #322 from Gallopsled/shellcraft-tests
Shellcraft tests
2015-01-04 18:40:59 +01:00
Mathias Svensson ccf26c19e2 Only try linux assemblers 2015-01-04 18:40:08 +01:00
Mathias Svensson 86b930bfb8 Shellcraft functions will now have a single trailing newline to their bodies, but only when called from outside shellcraft 2015-01-04 18:38:22 +01:00
Zach Riggle d15ef3e7a7 Merge pull request #332 from Gallopsled/remove-workaround
Removed the no-longer-needed workaround for #317
2015-01-04 12:26:24 -05:00
Zach Riggle 8b1d59bf0f Example 2015-01-04 12:23:43 -05:00
Mathias Svensson 5c89d6d116 We should try to use the non-local assembler before attempting to use the local assembler 2015-01-04 17:26:17 +01:00
Jonas Rudloff 15a5472b0e Merge pull request #327 from Gallopsled/correct-syscall-shellcode
Stopped using amd64.syscall and i386.syscall, as they will not work without a set context
2015-01-04 17:21:12 +01:00
Zach Riggle c71978e4c1 Restrict size of values pushed 2015-01-04 11:17:14 -05:00
Zach Riggle 71e2582949 Enable fall back to the literal entered by the user to support pushing registers 2015-01-04 11:16:28 -05:00
Zach Riggle f45dd08413 Add ${push} for i386 and amd64 that just uses the pushstr code 2015-01-04 11:16:28 -05:00
IdolfHatler 9d988bbda3 Merge pull request #312 from Gallopsled/shellcode
Made stager shellcode more readable + 21 /bin/sh shellcode(down from 25 bytes)
2015-01-04 17:11:49 +01:00
Jonas Rudloff 9d41fff8f2 make stager shellcode more readable 2015-01-04 17:00:28 +01:00
Mathias Svensson b8df835ef5 Removed the no-longer-needed workaround for #317 2015-01-04 16:14:46 +01:00
Jonas Rudloff 770e9dcc5d Merge pull request #326 from Gallopsled/sh-21-bytes
Made i386.linux.sh be 22 bytes again while keeping readability up
2015-01-04 14:28:16 +01:00
Mathias Svensson f25586d858 Fixed the docs 2015-01-04 14:22:20 +01:00
Mathias Svensson 2f22fc47af Compromise between readability and size of shellcode 2015-01-04 14:13:21 +01:00
Morten Brøns-Pedersen feb2dd3985 Changed the behavior of log.Logger.getEffectiveLevel
Before `log.Logger.getEffectiveLevel` would return the log level of the current context or the parent logger depending on which was more verbose.  This lead to some surprising behavior.  Example:
```
from pwn import *
context(log_level = 'DEBUG')

log.setLevel(logging.WARNING)
log.debug('debug')
log.info('info')
log.warning('warning')
```

We would expect to see only a warning, but since `context.log_level` is a more verbose level we will see all three messages.

This commit changes `log.Logger.getEffectiveLevel` to work exactly as `logging.Logger.getEffectiveLevel` except if the current logger is named 'pwnlib', in which case the log level of the current context is returned.
2015-01-04 13:28:03 +01:00
Kristoffer Søholm 8a8c7454ad Merge pull request #328 from Gallopsled/tubes-listen-close-bugfix
Check that a connection was actually established before calling `close` in `pwnlib.tubes.listen`.
2015-01-04 13:01:24 +01:00
Morten Brøns-Pedersen 13fa7855d6 check that a connection was actually established before calling close 2015-01-04 12:45:15 +01:00
Mathias Svensson 1fe4217e2a Updated a docstring 2015-01-04 11:41:59 +01:00
Mathias Svensson 3b872e9b33 Optimized the mov, pushstr and syscall shellcodes for less whitespace in the output 2015-01-04 11:41:49 +01:00
Mathias Svensson 66232941b0 Stopped using amd64.syscall and i386.syscall, as they will not work without a set context 2015-01-04 11:28:22 +01:00
Mathias Svensson 8d07ba6dc6 Made i386.linux.sh be 21 bytes again while keeping readability up 2015-01-04 11:26:41 +01:00
Zach Riggle b4ceaaeea4 Merge pull request #325 from Gallopsled/ui-bugfix
bugfix: changed `log.output` to `term.output` in `ui.options` and `ui.more` as `log.output` no longer exists
2015-01-03 23:22:57 -05:00
Morten Brøns-Pedersen 8b758cd43d bugfix: changed log.output to term.output in ui.options and ui.more as log.output no longer exists 2015-01-04 00:12:15 +01:00
Zach Riggle f465f11072 Merge pull request #318 from Gallopsled/shellcraft-docs
Include documentation for alternate architectures
2015-01-03 18:09:35 -05:00
br0ns 9297b23f41 Merge pull request #324 from Gallopsled/iss-307
Fixed #307
2015-01-04 00:05:57 +01:00
br0ns 9523cbccb9 Merge pull request #310 from Gallopsled/ssh-context-manager
Add a context manager, and put all of the doctests inside of them.  This...
2015-01-03 23:57:11 +01:00
Mathias Svensson 1ce101eb7c Fixed #307 2015-01-03 23:40:32 +01:00
Zach Riggle 90732d681f Merge pull request #302 from Gallopsled/asm-mega-rewrite
Enhance shellcraft by adding sys all templates and using {mov} to handle user input
2015-01-03 16:14:00 -05:00
Zach Riggle 19ddc24a0f Merge pull request #323 from Gallopsled/iss-317
Enable direct importation of shell craft modules.  Fixed #317
2015-01-03 16:11:31 -05:00
Mathias Svensson 395ff15c4c Fixed #317 2015-01-03 11:35:12 +01:00
Kristoffer Søholm 74583f9ad9 Merge pull request #282 from Gallopsled/psutil-getpid-debian-systemd
Remove references to "init" as PID 1
2015-01-03 02:36:39 +01:00
Zach Riggle 783deba7f4 Merge pull request #321 from Gallopsled/asm-binutils-link
Update binutils documentation link
2015-01-02 20:02:21 -05:00
Zach Riggle 3b9fac6115 Update binutils documentation link 2015-01-02 20:00:18 -05:00
Zach Riggle 02a7fb27fc Include documentation for alternate architectures 2015-01-02 19:34:27 -05:00
IdolfHatler 72539f7f64 Merge pull request #308 from Gallopsled/hex-trailing-L
Replace builtin hex with one that doesn't do stupid things
2015-01-03 00:53:03 +01:00
Zach Riggle 54a2c7ddaf Merge pull request #315 from Gallopsled/ftp-220-failure
Ignore what comes after 220 so we dont fail
2015-01-02 18:18:36 -05:00
Zach Riggle 0bdbc3ff0b Ignore what comes after 220 so we dont fail 2015-01-02 18:02:33 -05:00
IdolfHatler 0119dd2b64 Merge pull request #309 from Gallopsled/shellcraft-ret-value
Add return values for all RET shellcrafts
2015-01-02 22:26:46 +01:00
Zach Riggle d949c8e8a0 Add a context manager, and put all of the doctests inside of them. This should make the failures less verbose. 2015-01-02 15:51:01 -05:00
Zach Riggle 6a0262dd9f Replace builtin hex with one that doesn't do stupid things 2015-01-02 14:57:52 -05:00
Zach Riggle 29590a38db Add return values for all RET shellcrafts 2015-01-02 14:41:19 -05:00
Zach Riggle 362b16ba8e Merge pull request #306 from Gallopsled/import-cleanup
Another import cleanup
2015-01-02 14:12:49 -05:00
Mathias Svensson 7d97c1c82a Another import cleanup 2015-01-02 19:52:02 +01:00
Zach Riggle 8a2cd3bb0c Merge pull request #305 from Gallopsled/tube-recvn-recvrepeat-timeout
Fix timeout behavior for recvn and recvrepeat.  Fixes #303.
2015-01-02 13:35:56 -05:00
Zach Riggle 24942e01e7 Fix timeout behavior for recvn and recvrepeat 2015-01-02 13:32:12 -05:00
Zach Riggle d274105601 Merge branch 'countdown-active' 2015-01-02 13:04:59 -05:00
Zach Riggle c23d42e939 Fix countdown_active 2015-01-02 13:04:20 -05:00
Zach Riggle 32ac3e6e83 Merge pull request #268 from Gallopsled/tube-recvrepeat-timeout
The default timeout for `pwnlib.tubes.tube.recvrepeat()` should be short.  Set to 0.05s in this PR.
2015-01-02 12:45:02 -05:00
Mathias Svensson 5267f4cfe9 Yes, Travis did know. But only because doctests. 2015-01-02 17:07:50 +01:00
Mathias Svensson 538b688c05 Mega commit. I have no idea if this works and neither does Travis. 2015-01-02 14:53:24 +01:00
Robert Larsen bdb1201d1c Merge pull request #298 from Gallopsled/i386-echo
Added echo shellcode for i386
2015-01-02 14:10:38 +01:00
Robert Larsen 238364894e Merge pull request #297 from Gallopsled/pushstr-fix
There is no instruction called pushb
2015-01-02 14:08:30 +01:00
Robert Larsen 003b9e931c Merge pull request #296 from Gallopsled/update-links
Update module links in globals.rst
2015-01-02 14:02:05 +01:00
Robert Larsen 6f753740c7 Merge pull request #295 from Gallopsled/update-contributing
Updated CONTRIBUTING.md a bit
2015-01-02 14:01:20 +01:00
Robert Larsen eaed986668 Merge pull request #301 from Gallopsled/amd64-echo
Added amd64.linux.echo shellcode
2015-01-02 13:56:42 +01:00
Robert Larsen 9a59906b52 Merge pull request #299 from Gallopsled/amd64-pushstr
amd64.pushstr shellcode
2015-01-02 13:46:49 +01:00
Robert Larsen 4ff61fb9b9 Merge pull request #300 from Gallopsled/mov-fix
Fixed a bug in amd64.mov.
2015-01-02 13:32:53 +01:00
Mathias Svensson 742ae3dcd6 Added amd64.linux.echo shellcode 2015-01-02 13:12:22 +01:00
Mathias Svensson b89e932053 Fixed a bug in amd64.mov. 2015-01-02 13:08:30 +01:00
Mathias Svensson 869050bfd9 Added echo shellcode for i386 2015-01-02 13:07:06 +01:00
Mathias Svensson e43bf9ed74 amd64.pushstr shellcode 2015-01-02 13:04:44 +01:00
Mathias Svensson f54621db55 Updated the pushstr a bit more 2015-01-02 12:36:20 +01:00
Mathias Svensson 53654f66d4 There is no instruction called pushb 2015-01-02 11:50:55 +01:00
Mathias Svensson f6eff226c3 Update module links in globals.rst 2015-01-02 11:46:13 +01:00
Mathias Svensson e8e4ce0476 Updated CONTRIBUTING.md a bit 2015-01-02 11:35:47 +01:00
Robert Larsen d4a430596e Merge pull request #294 from Gallopsled/remove-binutils
Removed pre-compiled binutils as they are not used anymore
2015-01-02 11:20:31 +01:00
Mathias Svensson 1dfeb59acd Removed pre-compiled binutils as they are not used anymore 2015-01-02 11:17:50 +01:00
IdolfHatler e3b269ee5c Merge pull request #290 from Gallopsled/new-readme
Update README to point to new installation and contribution instructions
2015-01-02 11:11:42 +01:00
IdolfHatler 4d686214b8 Merge pull request #289 from Gallopsled/contributing
Add contributing.md
2015-01-02 11:11:33 +01:00
IdolfHatler 21bd92fa06 Merge pull request #288 from Gallopsled/installation-documentation
Add better documentation for installation.
2015-01-02 11:11:21 +01:00
IdolfHatler bd73e5032a Merge pull request #287 from Gallopsled/i386_to_amd64
Fix i386_to_amd64 and pushstr against GNU GAS syntax
2015-01-02 10:59:07 +01:00
Zach Riggle e5ee13c7ce Merge pull request #293 from Gallopsled/keepends
Change keep to keepends
2015-01-02 03:12:29 -05:00
Zach Riggle 235412903a Merge pull request #292 from Gallopsled/timeout-object-name
Give default timeout a name so that it looks better in the HTML documentation vs <object 0xFooBar>
2015-01-02 02:50:32 -05:00
Zach Riggle cfc8c04f5d Change keep to keepends 2015-01-02 02:49:08 -05:00
Zach Riggle b58d3f0f89 Give default timeout a name so that it looks better in the HTML documentation (vs. <object 0xf00bar>) 2015-01-02 02:36:48 -05:00
Zach Riggle ed308c5842 Merge pull request #291 from Gallopsled/tube-newline
Use user-provided newline
2015-01-02 02:01:35 -05:00
Zach Riggle 7c4f13e504 Use user-provided newline 2015-01-02 01:59:04 -05:00
Zach Riggle dbf5145bbf Remove references to "init" as PID 1 which is not accurate for Debian after switching to systemd.
Fixes #250
2015-01-01 23:55:53 -05:00
Zach Riggle 40e09baa71 Update README to point to new installation and contribution instructions 2015-01-01 23:39:19 -05:00
Zach Riggle 6eaed4082f Add contributing.md 2015-01-01 23:20:29 -05:00
Zach Riggle 8c29c2d41e Update doctests 2015-01-01 23:06:16 -05:00
Zach Riggle 84aae27d22 Add better documentation for installation.
Specifically, use "pip install -e" isntead of environment paths.
Give instructions for installing binutils.
2015-01-01 23:04:48 -05:00
Zach Riggle 33b70138db Fix i386_to_amd64 and pushstr against GNU GAS syntax 2015-01-01 22:13:42 -05:00
IdolfHatler 0e00dfa5f9 Merge pull request #283 from Gallopsled/issue-171
Fix weird interaction between tube, sock, and ssh_channel caused by a ra...
2015-01-02 00:20:06 +01:00
Zach Riggle 3c528bce11 Fix weird interaction between tube, sock, and ssh_channel caused by a race condition on whether the return value would propagate quickly when calling .recvall().
Fixes #171
2015-01-01 17:58:47 -05:00
Zach Riggle 38ab3d59e3 Change behavior of .clean to return the data received 2015-01-01 16:20:01 -05:00
Zach Riggle 67d27c33fc Merge pull request #281 from Gallopsled/safeeval-in-toplevel-documentation
Added documentation for #278
2015-01-01 16:09:20 -05:00
Zach Riggle 4209d90daa Merge pull request #261 from Gallopsled/import-cleanup
Big import cleanup. Also removes context.context.thread
2015-01-01 15:57:29 -05:00
IdolfHatler 90afaa5817 Merge pull request #249 from zachriggle/ssh-travis
SSH Tests on Travis
2015-01-01 21:33:52 +01:00
Mathias Svensson 82db1ad0ab Updated some documentation for pwnlib.context.Thread and removed the lower-case alias for it 2015-01-01 21:27:29 +01:00
Zach Riggle 25ece1dcfe Move Thread underneath the ContextType class so that pwnlib.context.Thread == pwnlib.context.context.Thread 2015-01-01 21:24:18 +01:00
Mathias Svensson a69fb15fd7 Removed a cycle, that was unnecessary anyways 2015-01-01 21:23:54 +01:00
Mathias Svensson 00d919966b Re-added a removed re-export, because I thought it was a normal import 2015-01-01 21:23:54 +01:00
Mathias Svensson da40529b7e Added the right Thread top toplevel 2015-01-01 21:23:54 +01:00
Mathias Svensson ea058d20ae Make it pass tests (maybe?) 2015-01-01 21:23:54 +01:00
Mathias Svensson 0f1a445a89 Big import cleanup. Also removes context.context.thread 2015-01-01 21:23:54 +01:00
Mathias Svensson e8b92c6bed Added documentation for #278 2015-01-01 21:14:24 +01:00
Zach Riggle 566448e34c Split SSH setup into its own file 2015-01-01 15:13:51 -05:00
Zach Riggle bb3d98f95b Enable testing SSH on Travis CI 2015-01-01 15:10:12 -05:00
IdolfHatler fbd7bb69d9 Merge pull request #280 from Gallopsled/timeout-None-forever
Make ssh object inherit from Timeout so that it can use Timeout.default ...
2015-01-01 21:00:34 +01:00
IdolfHatler 93396dd3da Merge pull request #275 from Gallopsled/asm-osx-sane
Make pwnlib.asm.asm more robust
2015-01-01 20:57:16 +01:00
IdolfHatler 8b8cae8b5c Merge pull request #276 from Gallopsled/travis-install-script
Split Travis installation steps into its own script
2015-01-01 20:55:09 +01:00
Zach Riggle 66aeaec73c Make ssh object inherit from Timeout so that it can use Timeout.default and the related semantics 2015-01-01 14:55:01 -05:00
Zach Riggle e79dac429d Merge pull request #279 from Gallopsled/timeout-None-forever
Update Timeout semantics in a few more places
2015-01-01 14:39:54 -05:00
Zach Riggle 9b66afbb41 Update semantics in a few more places 2015-01-01 14:36:55 -05:00
Zach Riggle 27813a86e8 Merge pull request #255 from zachriggle/timeout-None-forever
Update Timeout semantics
2015-01-01 14:24:33 -05:00
Zach Riggle cce361da90 Merge pull request #278 from Gallopsled/safeeval-in-toplevel
Added safeeval toplevel
2015-01-01 14:19:02 -05:00
Zach Riggle feea70aba3 Clean up a bit more 2015-01-01 14:17:03 -05:00
Zach Riggle 02ffff6f76 Fix regression from 023b7ba 2015-01-01 14:15:38 -05:00
Morten Brøns-Pedersen 023b7baf47 cleaned code up a bit 2015-01-01 14:01:47 -05:00
Morten Brøns-Pedersen 1a8090d29e more slight performance improvements in pwnlib.tubes.tube 2015-01-01 14:01:47 -05:00
Morten Brøns-Pedersen 3aac624b56 slight performance improvement in pwnlib.tubes.tube.recvuntil() 2015-01-01 14:01:47 -05:00
Zach Riggle 5b45bd957b Fix regressions and get performance back up 2015-01-01 14:01:47 -05:00
Zach Riggle cf9c5d6ee9 Change Timeout module path 2015-01-01 14:01:47 -05:00
Zach Riggle 199c7869ac Update Timeout semantics to use None to imply "never", and to use a sentinel object for default timeouts 2015-01-01 14:01:47 -05:00
Zach Riggle 84e4444923 Merge pull request #271 from Gallopsled/readline-utf8
Make `pwnlib.term.readline()` return a utf8 encoded `str` instead of a `unicode`.  This is the behavoir of the built-in readline, so we should mimic that.
2015-01-01 13:24:16 -05:00
Mathias Svensson 208ef471c6 Added safeeval toplevel 2015-01-01 17:07:21 +01:00
Zach Riggle 063a1a465e Binutils for alternate architectures doesn't add the LC_SEGMENT crap. The -j flag takes wildcards, so use it. Verified with stock binutils and binutils-sparc built via homebrew 2014-12-30 15:39:36 -05:00
Zach Riggle 214862e4f7 Split Travis installation steps into its own script so we can check the OS 2014-12-30 15:32:16 -05:00
Zach Riggle a10dc9d920 Merge pull request #254 from zachriggle/autoprogram
Enable autogeneration of command-line tool documentation
2014-12-30 13:09:58 -05:00
Zach Riggle 35ef5589b6 Remove tabs 2014-12-30 11:10:01 -05:00
Zach Riggle b596f0d6b6 Merge pull request #264 from Gallopsled/tube-log-debug
bugfix: use correct log level in `pwnlib.tubes.tube`
2014-12-30 10:48:30 -05:00
Zach Riggle 1fd84d5389 Merge pull request #267 from Gallopsled/tube-bugfix-recvline-contains
bugfix: `pwnlib.tubes.tube.recvline_contains` now works when a single item is given
2014-12-30 10:47:21 -05:00
Zach Riggle 34e6bab46a Merge pull request #269 from Gallopsled/tube-recvall-logging
Logging in `pwnlib.tubes.tube.recvall()` reported a wrong size upon completion. Fixed that.
2014-12-30 10:29:15 -05:00
Zach Riggle d33499f660 Merge pull request #270 from Gallopsled/log-waitfor-bugfix
Removed duplicate status throttling used by `pwnlib.log.waitfor`.
2014-12-30 10:28:27 -05:00
Morten Brøns-Pedersen b348c1821d make pwnlib.term.readline() return a utf8 encoded str instead of a unicode 2014-12-30 14:49:27 +01:00
Morten Brøns-Pedersen 9caf00b8e3 removed duplicate status throttling used by pwnlib.log.waitfor 2014-12-30 13:25:41 +01:00
Morten Brøns-Pedersen 9ccd0f4c12 bugfix: fixed logging in pwnlib.tubes.tube.recvall() 2014-12-30 13:20:39 +01:00
Morten Brøns-Pedersen 275ba56338 added doctests to pwnlib.tubes.tube.recvline_contains() 2014-12-30 12:58:49 +01:00
Morten Brøns-Pedersen b3cd49de98 bugfix: pwnlib.tubes.tube.recvline_contains now works when a single item is given 2014-12-27 22:06:19 +01:00
Zach Riggle 95b7aed1e2 Merge pull request #266 from Gallopsled/log-show-spinner-immediately
bugfix: show spinners immediately
2014-12-27 15:08:26 -05:00
Zach Riggle a4751a617c Merge pull request #265 from Gallopsled/tube-clean-and-log
better logging output in `pwnlib.tubes.tube.clean_and_log`
2014-12-27 15:07:35 -05:00
Morten Brøns-Pedersen 3bf3145b4c updated doctest 2014-12-27 20:57:10 +01:00
Morten Brøns-Pedersen 213936fead bugfix: show spinners immediately 2014-12-27 19:38:01 +01:00
Morten Brøns-Pedersen b235e4f42a better logging output in pwnlib.tubes.tube.clean_and_log 2014-12-27 19:13:53 +01:00
Kristoffer Søholm 2c92f24eb9 Merge pull request #262 from Gallopsled/stagershellcode
stager shellcode and findpeerstager shellcode
2014-12-27 19:10:42 +01:00
Jonas Rudloff 97097743b8 get stager shellcode to use i386.mov 2014-12-27 19:08:35 +01:00
Morten Brøns-Pedersen 8335f611be bugfix: use correct log level in pwnlib.tubes.tube 2014-12-27 19:06:32 +01:00
IdolfHatler a1d7152855 Merge pull request #259 from Gallopsled/log-waitfor-default-success
If not explicitly set, spinners are marked as succeeded unless an exception was raised in which case they are marked as failed.
2014-12-27 13:37:28 +01:00
IdolfHatler ababe3d3f2 Merge pull request #257 from Gallopsled/log-remove-done-functions
Gets rid of `pwnlib.log.done_*`, since we no longer have a spinner stack.  "Fixes" #229.
2014-12-27 13:36:45 +01:00
Morten Brøns-Pedersen 3c1b61eb4d if not explicitly set, spinners are marked as succeeded unless an exception was raised in which case they are marked as failed 2014-12-27 13:28:27 +01:00
Morten Brøns-Pedersen 56a8f1438b updated pwnlib.util.proc.wait_for_debugger() to not use pwnlib.log.done_success() 2014-12-27 13:02:56 +01:00
Morten Brøns-Pedersen a5062ed77f updated pwnlib.ui.pause() to not use pwnlib.log.done_success() 2014-12-27 13:00:44 +01:00
Morten Brøns-Pedersen fcbda7276e updated pwnlib/data/useragents/download-useragents.py to not use pwnlib.log.done_success() 2014-12-27 12:58:16 +01:00
Morten Brøns-Pedersen e00f417d19 removed pwnlib.log.done_* 2014-12-27 12:33:54 +01:00
Jonas Rudloff 59804af704 stager shellcode and findpeerstager shellcode 2014-12-27 12:17:36 +01:00
br0ns 30f2f9ef14 Merge pull request #256 from Gallopsled/text-when
removed `pwnlib.term.text.enabled` in favor of `pwnlib.term.text.when`
2014-12-27 12:12:21 +01:00
Morten Brøns-Pedersen 22b49e2f6a removed pwnlib.term.text.enabled in favor of pwnlib.term.text.when 2014-12-27 12:05:59 +01:00
Zach Riggle 637635e9f6 Restrict the scope of the modified context defaults so we don't break everything else 2014-12-26 17:39:40 -05:00
Zach Riggle a79663e59c Get rid of test text 2014-12-26 17:33:25 -05:00
Zach Riggle 8be05dd3eb Update requirements.txt 2014-12-26 17:29:58 -05:00
Zach Riggle b06998a740 Break commit into two parts for proper rename tracking 2014-12-26 17:29:58 -05:00
Zach Riggle 46db5ee48a Enable autogeneration of command-line tool documentation from the help output. In order to achieve this, we move from having a "bin" directory to using the "entry_points" mechanism. 2014-12-26 17:29:54 -05:00
Zach Riggle 25bef46da9 Merge pull request #243 from zachriggle/recvline-contains
Add a recvline_contains routine. Fixes #239.
2014-12-26 12:22:50 -05:00
Zach Riggle 8a72aba912 Merge pull request #248 from zachriggle/tube-recvuntil-str-find-bufsize-fastpath2
Improve tube performance. Fixes #238
2014-12-26 12:22:03 -05:00
Zach Riggle 943aad7a66 Merge pull request #253 from kristoff3r/amd64-mov-shellcode
Add mov shellcode for amd64
2014-12-26 12:20:28 -05:00
Zach Riggle 38af8aceb9 Finish docstring and add test 2014-12-25 15:30:22 -05:00
Kristoffer Søholm 9d94de9565 Merge pull request #247 from zachriggle/dynelf-nodecorator
Add DynELF example and documentation.  Remove requirement for MemLeak decorator.
2014-12-25 21:26:06 +01:00
Kristoffer Søholm a86a00ae9d Add mov shellcode for amd64 2014-12-25 21:11:28 +01:00
Zach Riggle de9dc3267a Merge pull request #252 from Gallopsled/feature-i386-mov-shellcode
Ported old mov shellcode for i386
2014-12-25 13:29:25 -05:00
Kristoffer Søholm 5ba1dcc0f1 Fixed details 2014-12-25 19:17:11 +01:00
Kristoffer Søholm f16966ab0b Ported old mov shellcode for i386 2014-12-25 19:04:47 +01:00
Morten Brøns-Pedersen 1c0d37597d tighter code in pwnlib.tubes.tube.recvuntil() 2014-12-25 16:06:10 +01:00
Zach Riggle aa1f3c1ad4 Fix regression which causes infinite loop 2014-12-24 23:27:47 -05:00
Zach Riggle e885635114 Fix doctest so it can be copy-pasted 2014-12-24 19:45:49 -05:00
Zach Riggle 358b5e1ff0 Fix syntax error and some of the tests 2014-12-24 19:07:28 -05:00
Zach Riggle 1255aa9c3a Remove double call to settimeout_raw. This is set via property update. See timeout_change. 2014-12-24 18:35:13 -05:00
Zach Riggle 2c1f357d39 Fastpath2. Minor optimizations 2014-12-24 18:30:51 -05:00
Zach Riggle cb9a39959c Add recvline_contains routine 2014-12-24 18:00:31 -05:00
Zach Riggle 56fd66f73b Fast paths for timeout 2014-12-24 11:53:18 -05:00
Zach Riggle 2a993650b2 Reduce buffer size to 4096 2014-12-24 11:46:39 -05:00
Zach Riggle 11f2671e33 Add DynELF example and documentation. Remove requirement for MemLeak decorator. 2014-12-24 09:24:44 -05:00
IdolfHatler e0563cbb70 Merge pull request #244 from zachriggle/recvall-recvrepeat-break-on-eoferror
Break on EOFError for recvrepeat and recvall
2014-12-23 17:23:22 +01:00
Zach Riggle acdc6bce86 Break on EOFError for recvrepeat 2014-12-23 11:06:35 -05:00
Zach Riggle 6747db60a1 Replace re.search with string.find 2014-12-23 11:03:55 -05:00
Zach Riggle 7e01b03090 Merge pull request #236 from RobertLarsen/master
Added two characters to the list of regex special chars.
2014-12-23 07:45:57 -05:00
Robert Larsen cfe29e7948 Added two characters to the list of regex special chars. 2014-12-23 13:23:29 +01:00
br0ns ea46132af6 Merge pull request #235 from Gallopsled/hexdump-nonprintable-chars
hexdump now shows non-printable chars as dots, and regards space as printable
2014-12-23 13:21:18 +01:00
Morten Brøns-Pedersen 54736623de hexdump now shows non-printable chars as dots, and regards space as printable 2014-12-23 14:06:37 +01:00
IdolfHatler 65037a6d00 Merge pull request #234 from Gallopsled/missing-docs-issue-215
Fixed #215
2014-12-23 12:39:34 +01:00
Morten Brøns-Pedersen 92b311d655 fixed broken doctest in pwnlib.util.web.wget 2014-12-23 13:01:02 +01:00
Morten Brøns-Pedersen abdf0100e4 added docstring to pwnlib.util.hashes 2014-12-23 13:00:22 +01:00
Morten Brøns-Pedersen 3cfca21ace updated docstring and fixed broken doctest 2014-12-23 12:59:47 +01:00
Morten Brøns-Pedersen d997a6922a added util/web.rst 2014-12-23 12:59:04 +01:00
Morten Brøns-Pedersen 6855077ebd added util/hashes.rst 2014-12-23 12:58:52 +01:00
Morten Brøns-Pedersen 7d590c974c added useragents.rst 2014-12-23 12:58:39 +01:00
br0ns 1f61ea8600 Merge pull request #208 from Gallopsled/log_error_exception
Implements the changes suggested in #207.
2014-12-23 11:25:26 +01:00
IdolfHatler 11f33fba1b Merge pull request #228 from Gallopsled/atexception
updated `atexception` to act like the the new `atexit`
2014-12-23 11:08:10 +01:00
IdolfHatler ab746c786d Merge pull request #227 from Gallopsled/atexit-issue-120-and-121
fixes #120 and #121
2014-12-23 10:48:41 +01:00
IdolfHatler 0c870a4e34 Merge pull request #232 from Gallopsled/readline
fixes #231
2014-12-23 10:46:10 +01:00
Morten Brøns-Pedersen 5b70db89b8 bugfix: declare suggest_handle as global 2014-12-23 03:24:05 +01:00
Morten Brøns-Pedersen f685b1af2d updated atexception to mimic the new atexit 2014-12-23 02:28:44 +01:00
Morten Brøns-Pedersen 6d58217ac9 removed unused import 2014-12-23 02:25:42 +01:00
IdolfHatler 0fa91a66fc Merge pull request #230 from Gallopsled/download-useragents
Updated the list of useragents
2014-12-23 02:17:15 +01:00
Morten Brøns-Pedersen 3d90e3012d updated the list of useragents 2014-12-23 02:56:36 +01:00
Morten Brøns-Pedersen bfb59a6e98 download-useragents.py now never removes a user agent from the list 2014-12-23 02:55:57 +01:00
Morten Brøns-Pedersen db4c824603 fixed docstring for atexit.register 2014-12-23 01:44:54 +01:00
Morten Brøns-Pedersen 08715e4eb3 fixes #120 and #121 2014-12-23 00:17:53 +01:00
br0ns 6c7136cd8d Merge pull request #219 from zachriggle/hexdump-colors
Remove check for sys.stdout.isatty()
2014-12-22 23:59:54 +01:00
IdolfHatler 882355383b Merge pull request #216 from zachriggle/issue-210
Default timeout, timeout magic string 'inf', OSX timeout max
2014-12-22 16:51:59 +01:00
Zach Riggle e70536e180 Merge pull request #218 from Gallopsled/iss217
Resolve SyntaxWarnings in pwnutil.util.web.  Fixes #217.
2014-12-22 10:39:34 -05:00
Zach Riggle 35d2a985c8 Remove check for sys.stdout.isatty() 2014-12-22 07:32:21 -08:00
Mathias Svensson b621a725e3 Fixed #217. 2014-12-22 14:52:52 +01:00
Mathias Svensson 2df67f9439 Fixed doctest mistake found in Travis 2014-12-22 11:31:52 +01:00
Mathias Svensson 276ebb27a7 Implements the changes discussed in #207 2014-12-22 11:22:16 +01:00
Zach Riggle dd530df04e Merge pull request #214 from Gallopsled/faster_import
Faster imports as per #198
2014-12-22 00:20:12 -05:00
Zach Riggle 993a3a5b5a Merge pull request #209 from Gallopsled/randoms-alphabet-fix
Implements the changes suggested in #202. Do not accept until a consensus is reached.
2014-12-22 00:15:11 -05:00
Zach Riggle 3fdc6bd146 Fix issue on OSX within the socket itself 2014-12-21 19:19:01 -08:00
Zach Riggle c1e31f7ab3 Set default timeout to infinite. Ensure that pwnlib.tubes.tube.timeout.Timeout.__init__ properly handles any magic values by passing them through context.timeout. 2014-12-21 19:13:01 -08:00
Mathias Svensson 3af8c6b81f Fixed bug found by Travis 2014-12-21 23:28:24 +01:00
Mathias Svensson 57ac2235a5 Faster imports as port #198 2014-12-21 23:24:25 +01:00
Robert Larsen 1fec4b9df7 Merge pull request #212 from Gallopsled/infloop_in_listen
Fixed the infinite loop from #137. The code still does not work, but now it does not work in a more reasonable way
2014-12-21 22:46:19 +01:00
Mathias Svensson 5d2cbdf5ea I really should learn to test my commits 2014-12-21 22:23:12 +01:00
Mathias Svensson 2270425d49 Fixed the infinite loop from #137. The code still does not work, but now it does not work in a more reasonable way 2014-12-21 22:19:30 +01:00
Robert Larsen 3b896435e0 Merge pull request #206 from Gallopsled/landscape-bugfixes
A few bugfixes found with landscape.io
2014-12-21 21:40:56 +01:00
Mathias Svensson ff926ca49f Implements the changes suggested in #202. 2014-12-21 21:33:27 +01:00
Robert Larsen 3025212421 Merge pull request #204 from Gallopsled/bug-iter-documentation
Fixed documentation. Should be safe to merge
2014-12-21 21:27:32 +01:00
Robert Larsen 77f231b91f Merge pull request #203 from Gallopsled/bug-randoms
random.sample does not use replacement. With a small alphabet this could throw an exception
2014-12-21 21:26:08 +01:00
Mathias Svensson 42215bea8c A few bugfixes found with landscape.io 2014-12-21 20:55:06 +01:00
Mathias Svensson 983a07c91d Fixed some documentation bugs in iters.py 2014-12-21 20:23:50 +01:00
Mathias Svensson ee187596bc random.sample does not use replacement. With a small alphabet this could throw an exception 2014-12-21 20:17:56 +01:00
Zach Riggle 4c1ab865f1 Merge pull request #201 from zachriggle/deferred-load-requests
Defer loading of requests module.  Fixes #198
2014-12-21 12:43:20 -06:00
Zach Riggle 9276c1fb1d Merge pull request #200 from zachriggle/hexdump-colors
Fixes #199
2014-12-21 12:41:26 -06:00
Zach Riggle 8f1583d588 Defer loading of requests module. Fixes #198 2014-12-21 12:40:09 -06:00
Zach Riggle 8ed28e6239 Fixes #199 2014-12-21 12:35:17 -06:00
Zach Riggle f1284bfc4d Update README.md 2014-12-18 15:27:47 -05:00
Zach Riggle ab7147c871 Update version.py 2014-12-18 15:22:51 -05:00
Mathias Svensson b13a4b9518 Merge branch 'mathiasbynens-add-socket-example' 2014-12-18 16:59:59 +01:00
Mathias Svensson 3c72aff21a Updated README.md 2014-12-18 16:59:48 +01:00
Mathias Bynens 69538c3f09 Add minimal example showing how to use remote 2014-12-18 15:28:14 +01:00
Mathias Svensson 7e5c9ce485 Hopefully make git language statistics more accurate 2014-12-18 12:30:47 +01:00
Mathias Svensson 4b286d1d44 Closes #195. Closes #190. Fixes a small bug with regards to the return value in ssh.upload_file. 2014-12-18 12:01:35 +01:00
Mathias Svensson dbac29eb73 Changed which in asm.py to which_binutils as per #190. Also made the tests work even if the binaries are not in /usr/bin 2014-12-18 10:55:57 +01:00
Morten Brøns-Pedersen 9c4cfc2d34 fixed #126 2014-12-17 13:07:12 +01:00
Mathias Svensson c2034afc3c Fixed a few small bugs found through landscape.io 2014-12-17 12:27:55 +01:00
Morten Brøns-Pedersen f7695695b2 fixed #193 2014-12-17 12:26:23 +01:00
Mathias Svensson b344f8f316 I should learn to spell 2014-12-17 11:59:15 +01:00
Mathias Svensson 0c48de7726 Fixed #185 and will hopefully get Travis to build again 2014-12-17 11:51:35 +01:00
Mathias Svensson cbd0323223 Implements the changes to proc.py mentioned in #181 2014-12-17 11:35:18 +01:00
Mathias Svensson 0ee3ce8eb1 Uses which instead of hardcoded paths in doctests. Fixes #182, #183, #184 2014-12-17 10:43:43 +01:00
Zach Riggle 57e5e81846 Merge pull request #188 from zachriggle/logging-errors-and-exceptions
Add log.exception to be able to print out an error message *with* an exception.
2014-12-16 20:42:48 -05:00
Zach Riggle ddbfe89d2f Add log.exception to be able to print out an error message *with* an exception.
Update log.error (and log.exception) to stop the active progress item.
2014-12-16 17:25:30 -08:00
Zach Riggle b84f563549 Merge pull request #187 from Gallopsled/asm-delete-tempdir
Actually call rmtree. Fixes #186
2014-12-16 20:18:39 -05:00
Zach Riggle 033f26c922 Do not delete files on exception 2014-12-16 17:10:14 -08:00
Zach Riggle c8874e080a Ignore docs output dir 2014-12-16 16:38:00 -08:00
Zach Riggle 27535ade83 Actually call rmtree. Fixes #186 2014-12-16 16:31:17 -08:00
Zach Riggle d3c863ca07 Set logger to pwnlib.exploit that is imported into the global namespace 2014-12-16 15:15:40 -08:00
Zach Riggle 6e6fe50b8f Default to /dev/null if stdin does not have a fileno (for example, a memory-only file buffer) 2014-12-16 15:08:21 -08:00
Zach Riggle 6d5ac6710f Make PWNLIB_NOTERM in the environment not ever even initialize curses 2014-12-16 15:06:01 -08:00
Zach Riggle c1d4312235 powerpc-linux-gnu 2014-12-16 12:39:30 -08:00
Zach Riggle 5bff52d9e2 Powerpc! 2014-12-16 12:08:38 -08:00
Zach Riggle 9f3ae14770 Move pwnlib.asm documentation to source docstring; rename _find to which; expose it via __all__ so that it gets picked up for doctests. Expressly import asm,disasm,cpp in toplevel so we don't import pwnlib.asm.which 2014-12-16 11:57:59 -08:00
Zach Riggle 7074b9a4da Update asm.py 2014-12-16 14:43:27 -05:00
Zach Riggle 556996e0ea Prefer exactly-named assembler first 2014-12-16 11:30:28 -08:00
Zach Riggle 481a699f10 Enable amd64-*-objdump so that it'll use the local copy when platform.machine() returns 'amd64' on not-Debian 2014-12-16 11:23:40 -08:00
Zach Riggle 36a9b4c93a Actually do the check 2014-12-16 11:13:58 -08:00
Zach Riggle 912baa28f5 Add warning message 2014-12-16 11:12:00 -08:00
Zach Riggle ad30c7dc7d Send platform.machine() through the context.arch setting for OpenBSD 2014-12-16 11:07:44 -08:00
Zach Riggle 15072ff66b Do it a few times so it gets cached 2014-12-16 10:05:04 -08:00
Zach Riggle df54013df3 I dont think Travis likes TERM_MODE 2014-12-15 21:01:38 -08:00
Zach Riggle 03d5d579f5 Merge pull request #166 from zachriggle/cyclic-hexdump-skip
Enable collapsing contiguous cyclic patterns
2014-12-16 09:45:51 -08:00
Zach Riggle d0e0291462 These tests are really for OSX, not for Linux 2014-12-15 20:56:32 -08:00
Zach Riggle 91a861773e Add "from pwn import *" install step to test load time 2014-12-15 20:40:39 -08:00
Zach Riggle 24c9207c3a Handle case where width is very low 2014-12-15 20:38:13 -08:00
Zach Riggle b54c64290d Enable collapsing contiguous cyclic patterns 2014-12-15 20:38:13 -08:00
Zach Riggle fe73751ec0 Better docs for pwnlib.log 2014-12-15 20:08:27 -08:00
Zach Riggle 7b919ea013 Move python-dev requirement up to prereqs 2014-12-15 19:04:23 -08:00
Zach Riggle bcd822763e Add installation docs; add global docs; enhance intro docs 2014-12-15 18:49:38 -08:00
Zach Riggle 185334c50d Add documentation for globals, context, pwnlib.context.Thread. Fix pwnlib.asm docs 2014-12-15 18:49:38 -08:00
Zach Riggle e1a161fb95 context.term_mode was not implemented due to cyclic dependencies 2014-12-15 18:49:38 -08:00
Zach Riggle d67dccf4ac typo [ci skip] 2014-12-15 16:09:12 -08:00
Zach Riggle 58b08d9544 Update README.md 2014-12-15 17:45:55 -05:00
Zach Riggle 7f2bd5556d Update README.md 2014-12-15 17:00:01 -05:00
Zach Riggle 6296670cbf Update README.md 2014-12-15 16:59:46 -05:00
Zach Riggle 2796a65d42 Fixes #180 2014-12-15 16:56:41 -05:00
Zach Riggle 8e9b8ef9b2 Update README.md 2014-12-15 16:49:57 -05:00
Zach Riggle 83ff0838d1 Fixes #179 2014-12-15 05:06:09 -05:00
Zach Riggle 767db7e242 linux-gnu 2014-12-15 03:42:12 -05:00
Zach Riggle 4ef2f90670 Yes. 2014-12-15 03:36:06 -05:00
Zach Riggle 2b30d51022 Helps to have the repo 2014-12-15 03:33:44 -05:00
Zach Riggle ffa349e07d Update travis config to install binutils now that we build for Precise 2014-12-15 03:32:58 -05:00
Zach Riggle 5674fc451a IRC link 2014-12-15 03:28:14 -05:00
Zach Riggle e054881bdf Add note about Python headers being required. 2014-12-14 20:52:36 -05:00
Zach Riggle da393452cf Fixes #173 2014-12-14 20:36:54 -05:00
Zach Riggle 206c3a8630 OSX workaround for binutils prefixed with "g" a la "gobjdump" 2014-12-14 16:57:51 -08:00
Zach Riggle ee267269d9 Use Python bindings for Capstone 2.1 until Capstone 3.0 deb is published 2014-12-14 16:45:16 -08:00
Zach Riggle 5f5fda530f Typo fix 2014-12-14 16:41:05 -08:00
Zach Riggle a119c6c393 Install libcapstone 2014-12-14 14:26:21 -08:00
Zach Riggle a6474c75e7 Travis doesn't have tag names available 2014-12-14 13:28:19 -08:00
Zach Riggle 071dc455d2 Reorder icons for consistency 2014-12-14 12:38:19 -08:00
Zach Riggle 414f72d8c3 Add docs/doctest requirements 2014-12-14 12:37:49 -08:00
Zach Riggle 157375b6cf Add travis badge 2014-12-14 12:34:12 -08:00
Zach Riggle 7ca3bdc67d Add travis configuration 2014-12-14 12:21:19 -08:00
Zach Riggle bcc92a7fff Fixes #177 2014-12-14 12:08:28 -08:00
Zach Riggle 9772093178 Add doctest for remote 2014-12-13 21:54:24 -08:00
Zach Riggle 6439ffdb32 Fixes #175 2014-12-13 21:00:56 -08:00
Zach Riggle fef068e812 Docstring for pwnlib.socket.remote.remote.fromsocket 2014-12-13 20:59:19 -08:00
Zach Riggle e81071b6f9 Merge branch 'pwnlib-2.2' 2014-12-13 20:57:45 -08:00
Zach Riggle 6529970b9a log.error should throw an exception 2014-12-13 20:57:18 -08:00
Zach Riggle c103989ddc Update remote to implement remote.fromsocket 2014-12-13 20:55:30 -08:00
Zach Riggle a78a0dbbf5 Fix typo 2014-12-02 20:20:38 -08:00
Zach Riggle 4ab70b880c pop REG should not include pop ss 2014-12-02 20:20:30 -08:00
Zach Riggle 16fd822ad1 Add SSL support to remote 2014-11-29 10:56:29 -08:00
Zach Riggle 8b24bbd574 Fix typo from 192065b 2014-11-17 11:12:45 -08:00
Zach Riggle c9a581229b Merge branch 'ssh-interactive-repl'
Conflicts:
	pwnlib/tubes/ssh.py
2014-11-12 17:02:19 -05:00
Zach Riggle 2485ab9795 Actually pass the event object to the Thread, and defer list(ord()) 2014-11-12 17:01:55 -05:00
Zach Riggle 37d31724e0 Need threading 2014-11-12 17:00:48 -05:00
Zach Riggle af5d9fe816 Merge branch 'ssh-interactive-repl' 2014-11-10 23:03:25 -05:00
Zach Riggle fbf6e58231 Use a proper threading.Event for synchronization rather than a list 2014-11-10 22:45:05 -05:00
Zach Riggle caee95628f Make ssh_channel.interactive() work when term_mode is not active 2014-11-10 22:35:35 -05:00
Zach Riggle 1db8f1d890 Merge branch 'proc-not-executable' 2014-11-09 07:32:06 -05:00
Zach Riggle 321db0fa81 Better detection 2014-11-09 07:31:52 -05:00
Zach Riggle 599b61468f Merge branch 'proc-not-executable'
Conflicts:
	pwnlib/tubes/process.py
2014-11-09 07:30:55 -05:00
Zach Riggle 807afc8266 Add message when given a non-executable 2014-11-09 07:29:34 -05:00
Zach Riggle 406dce863e Merge branch 'proc-psutil'
Conflicts:
	pwnlib/util/proc.py
	setup.py
2014-11-09 06:15:18 -05:00
Zach Riggle c55273c52a Convert some of proc's functionality to use psutil 2014-11-09 06:11:11 -05:00
Zach Riggle 09f69d804d Merge branch 'pwnlib-2.2' 2014-11-08 20:33:00 -05:00
Zach Riggle 9ba495366c Should timeout 2014-11-08 20:32:54 -05:00
Zach Riggle 5d21dddb50 Merge branch 'checksec' 2014-11-08 20:15:57 -05:00
Zach Riggle 46e1ac95ea alsr alias 2014-11-08 20:11:09 -05:00
Zach Riggle 34101f2710 Merge branch 'checksec' 2014-11-08 19:11:41 -05:00
Zach Riggle 4aa3dd5e34 execstack = not nx 2014-11-08 19:11:35 -05:00
Zach Riggle 8aa952935d Merge branch 'checksec'
Conflicts:
	pwnlib/elf/__init__.py
2014-11-08 08:41:56 -05:00
Zach Riggle 3814003d4f Add checksec 2014-11-08 06:48:08 -05:00
Zach Riggle 4af89b4ddc Merge branch 'rop-no-leave-gadgets' 2014-11-07 01:49:08 -05:00
Zach Riggle 98c0542f20 Check that there are leave gadgets before indexing 2014-11-07 01:48:49 -05:00
Zach Riggle 192065bb36 Merge branch 'wget-requests'
Conflicts:
	pwnlib/util/web.py
2014-11-07 00:05:53 -05:00
Zach Riggle 3ab20f22a9 Merge branch 'pwnlib-2.2' 2014-11-07 00:04:16 -05:00
Zach Riggle 8acd69a82c Reduce maximum update speed of waitfor when not using term-mode 2014-11-07 00:04:09 -05:00
Zach Riggle fe1b5df57e Merge branch 'pwnlib-2.2' 2014-11-06 22:12:40 -05:00
Zach Riggle c92bd308b4 Reduce maximum update speed of waitfor 2014-11-06 22:12:23 -05:00
Zach Riggle a7e7bcfd4f Merge branch 'elf-entry-point' 2014-11-06 22:05:28 -05:00
Zach Riggle b2cd8fde32 Switch to using pwnlib.util.misc.size for calculating sizes 2014-11-06 18:11:22 -05:00
Zach Riggle 6f3fe07e29 Change "wget" to use the requests library. Also adds the entire requests library to the top level. E.g. from pwn import * => "get" is now a global object 2014-11-06 17:29:38 -05:00
Zach Riggle 67ecd7ab0d Add pwnlib.elf.ELF.entry and a few aliases for the entry point 2014-11-06 15:23:45 -05:00
IdolfHatler ff07362012 Merge pull request #155 from zachriggle/tmux
run_in_new_terminal now behaves as per documentation; also can launch new tmux panes
2014-11-06 10:14:52 +01:00
IdolfHatler dddba723d5 Merge pull request #161 from zachriggle/gdb-attach-warning
Add warning message.  Closes #160
2014-11-06 10:14:06 +01:00
Zach Riggle 8a069f192a Merge branch 'gdb.debug' 2014-11-05 01:44:10 -05:00
Zach Riggle 1a7c1f5085 Merge branch 'dynelf-consolidate' 2014-11-05 01:14:02 -05:00
Zach Riggle b88ada7e80 Remove unused code 2014-11-05 01:05:02 -05:00
Zach Riggle f1efc6ae49 Re-add legacy @classmethod methods 2014-11-05 01:03:11 -05:00
Zach Riggle c443c38457 Fix inference of address from ELF, and ELF-only instantiation 2014-11-05 01:01:35 -05:00
Zach Riggle 3fda0c0dbd Fix thumb assembly "-thumb" vs "-mthumb". Also add RET shellcodes for each architecture. 2014-11-05 00:54:13 -05:00
Zach Riggle a5e7202194 Merge branch 'gdb-attach-warning'
Conflicts:
	pwnlib/dynelf.py
	pwnlib/memleak.py
	pwnlib/util/packing.py
2014-11-04 23:41:56 -05:00
Zach Riggle 2d5de974e7 Add warning message. Closes #160 2014-11-04 23:28:35 -05:00
Zach Riggle 666583f1ca Merge branch 'tmux' 2014-11-04 23:20:06 -05:00
Zach Riggle 1ee9bb8d56 Address @IdolfHatler's issue from IRC 2014-11-04 23:19:22 -05:00
Zach Riggle 7d3e5af6de Merge branch 'dynelf-consolidate'
Conflicts:
	pwnlib/dynelf.py
	pwnlib/elf/__init__.py
	pwnlib/elf/datatypes.py
	pwnlib/memleak.py
2014-11-04 22:09:17 -05:00
Zach Riggle 4783df2d5a Fix regression on getting the base address from an ELF 2014-11-04 16:15:17 -05:00
Zach Riggle 293d4773c0 Merge branch 'pwnlib-2.2'
Conflicts:
	pwnlib/asm.py
2014-11-03 21:33:01 -05:00
Zach Riggle f66c6b7936 Permit auto-detection of the current OS to use the maintainer-installed version of binutils. For example, on an i386 system, there should be no reason for an extra version of binutils to be installed. 2014-11-03 21:32:16 -05:00
Zach Riggle 38db1e7e2e Fixes for asm/disasm command-line tools; better handling of includes/section header flags 2014-11-02 05:16:35 -05:00
Zach Riggle 7aae87bd69 Only suppress stdout immediately surrounding ropgadget call; use info_once for messages (see #102) 2014-11-02 05:15:45 -05:00
Zach Riggle 8dd31cb10f Add log.info_once and related messages to only print an error/warning/info message one time 2014-11-02 05:15:44 -05:00
Zach Riggle a39891cc5f Fixes for asm/disasm command-line tools; better handling of includes/section header flags 2014-11-02 05:15:17 -05:00
Zach Riggle e4d95e94d2 Only suppress stdout immediately surrounding ropgadget call; use info_once for messages (see #102) 2014-11-02 05:14:43 -05:00
Zach Riggle 4e0ad45f9e Add log.info_once and related messages to only print an error/warning/info message one time 2014-11-02 04:52:16 -05:00
Zach Riggle 823d909498 Add doctests for previous commit 2014-11-01 12:20:32 -04:00
Zach Riggle b41dc036ae Add doctests for previous commit 2014-11-01 12:20:09 -04:00
Zach Riggle e744813cf0 Fix regression on process.connected_raw 2014-11-01 12:03:53 -04:00
Zach Riggle 3b09781efa Fix regression on process.connected_raw 2014-11-01 11:56:42 -04:00
IdolfHatler 4a88c3e1af Merge pull request #143 from zachriggle/patch-4
log.die is deprecated
2014-10-29 01:34:43 +01:00
IdolfHatler 0febd45d06 Merge pull request #152 from RobertLarsen/master
Thumb bindshell shellcode for Linux
2014-10-29 01:34:26 +01:00
IdolfHatler 0aafd7cba9 Merge pull request #153 from zachriggle/memleak-documentation-endianness
Memleak documentation endianness
2014-10-29 01:34:14 +01:00
IdolfHatler 4b7715e295 Merge pull request #157 from zachriggle/static-elf-symrelplt
Fixes NullSection for Static ELF
2014-10-29 01:33:10 +01:00
Zach Riggle 26d713bf0d Update constgrep 2014-10-28 16:34:48 -07:00
Zach Riggle 8ae04bcd01 Return the tube instead 2014-10-28 16:24:25 -07:00
Zach Riggle 5a63681849 Fix which "which" is used 2014-10-28 16:20:56 -07:00
Zach Riggle f2729530bf Fix previous commit 2014-10-28 01:48:55 -07:00
Zach Riggle 586e62538c Further enhancements thanks to Ilfak. DynELF now works for all RELRO permutations. 2014-10-28 01:41:39 -07:00
Zach Riggle 2ef7fc17d3 Merge remote-tracking branch 'origin/tmux' 2014-10-27 12:53:32 -07:00
Zach Riggle 32699836cb Merge branch 'static-elf-symrelplt' 2014-10-27 12:53:23 -07:00
Zach Riggle e347a5a81b Merge branch 'memleak-documentation-endianness-2.2'
Conflicts:
	pwnlib/memleak.py
2014-10-27 12:51:01 -07:00
Zach Riggle ae4507ef98 Merge branch 'dynelf-consolidate-2.2' 2014-10-27 12:50:16 -07:00
Zach Riggle c4f3e26019 Fix success spinner 2014-10-27 12:49:38 -07:00
Zach Riggle e1b143104d Rework DynELF to use consolidated routines for resolution 2014-10-27 12:49:38 -07:00
Zach Riggle d89c3ff04d wipwip 2014-10-27 12:46:31 -07:00
Zach Riggle 2d79765b5b Make memleak doctest work 2014-10-27 12:45:23 -07:00
Zach Riggle fa4fc41248 Change sizes to be sure to excercise search functionality 2014-10-27 12:45:23 -07:00
Zach Riggle 48c3ba343b Added documentation and doctests 2014-10-27 12:45:23 -07:00
Zach Riggle 5b7905813e asasdf 2014-10-27 12:45:08 -07:00
Zach Riggle c2fd526b7e Migrate back-fill operation to _leak 2014-10-27 12:44:10 -07:00
Zach Riggle 2a0467e105 Merge branch 'pwnlib-2.2'
Conflicts:
	pwnlib/gdb.py
	pwnlib/tubes/ssh.py
2014-10-27 12:43:08 -07:00
Zach Riggle 69e84b790d pwnlib 2.2 rewrite of context, logging, tubes, various bugfixes 2014-10-26 16:02:22 -07:00
Zach Riggle 20d39df46b Fixes #156 2014-10-26 15:19:15 -07:00
Zach Riggle 71250900b2 Make memleak doctest work 2014-10-25 17:16:01 -07:00
Zach Riggle 34db05ca0f run_in_new_terminal now behaves as per documentation; also can launch new tmux panes 2014-10-25 11:30:10 -07:00
Zach Riggle 94f31d3813 Fix success spinner 2014-10-23 13:57:13 -07:00
Zach Riggle c494f6c31d Rework DynELF to use consolidated routines for resolution 2014-10-23 03:07:28 -07:00
Zach Riggle 0b66263696 Change sizes to be sure to excercise search functionality 2014-10-20 19:17:11 -07:00
Zach Riggle bb7f86c3a5 Added documentation and doctests 2014-10-20 19:08:07 -07:00
Zach Riggle f3024c24da asasdf 2014-10-18 19:08:38 -07:00
Zach Riggle 9a7bfd6205 Migrate back-fill operation to _leak 2014-10-18 17:52:31 -07:00
Zach Riggle 45117ec75d Remove unnecessary list() 2014-10-18 17:22:53 -07:00
Robert Larsen 6c57393c57 Describe arguments. 2014-10-14 20:31:12 +02:00
Robert Larsen 2d7fde4b97 Describe arguments. 2014-10-14 20:30:07 +02:00
Robert Larsen 9a17e04ac3 Better doc. 2014-10-14 20:29:01 +02:00
Robert Larsen 2682d31f6a Address family is AF_INET6 for IPv6. 2014-10-14 20:25:23 +02:00
Robert Larsen 63fb952973 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2014-10-12 23:08:52 +02:00
Robert Larsen 89c6ed1520 Added bindshell shellcode for thumb mode. 2014-10-12 23:07:52 +02:00
Zach Riggle 014d8f24ec Merge remote-tracking branch 'upstream/master' 2014-09-30 13:24:04 -04:00
IdolfHatler 8e3b05e016 Merge pull request #139 from zachriggle/patch-3
Enhance error messages
2014-09-30 13:40:47 +02:00
Zach Riggle 256decad52 log.fatal is deprecated 2014-09-29 23:03:53 -04:00
Zach Riggle a810c0204b Enhance error messages 2014-09-29 21:09:55 -04:00
IdolfHatler 74094d562d Merge pull request #138 from zachriggle/patch-2
Rewrite front-page docs a bit
2014-09-26 21:26:04 +02:00
Zach Riggle eb752e720d Rewrite front-page docs a bit
The `install.sh` just runs `pip2 -r requirements.txt` and echoes this same info to the screen.  It's short enough, may as well have it in the README.
2014-09-26 14:56:16 -04:00
IdolfHatler e6f33624d0 Merge pull request #136 from zachriggle/patch-1
Link to write-ups in README
2014-09-25 20:05:33 +02:00
Zach Riggle aad6276a83 Update README.md 2014-09-25 14:01:19 -04:00
IdolfHatler 8ea1d0e011 Merge pull request #132 from zachriggle/timeout-default
Add default timeout
2014-09-23 09:18:48 +02:00
IdolfHatler c198d4aede Merge pull request #134 from zachriggle/bug-stacktrace
Bugs should always emit a stack trace
2014-09-23 09:09:44 +02:00
Zach Riggle 3d8a1950a4 Bugs should always emit a stack trace 2014-09-23 01:25:08 -04:00
Zach Riggle b4bb6f41f3 Add default timeout 2014-09-23 00:56:44 -04:00
Mathias Svensson 60428c462b Fixed #125 2014-09-20 17:19:42 +02:00
Mathias Svensson 7604ea5319 A shebang does nothing if it is not the first line 2014-09-20 17:16:44 +02:00
Mathias Svensson a0bcd69abf Fixed #127 (bad copy paste) 2014-09-20 17:15:35 +02:00
Mathias Svensson 4cf6f7b4f6 Fixed bug in tube 2014-09-20 15:35:29 +02:00
IdolfHatler 5c44735842 Merge pull request #124 from zachriggle/context-threaded
Implement context-preserving threads
2014-09-18 23:07:19 +02:00
Zach Riggle 5121df4c4d Copy context to avoid secondary effects of scoping affecting the thread 2014-09-18 16:24:40 -04:00
Mathias Svensson d40c88e368 recvall will now close the connection 2014-09-18 08:09:42 +02:00
Mathias Svensson cb9d5357c4 Fixed uroboros (#123) 2014-09-18 08:09:42 +02:00
Zach Riggle 1d5ee71597 Merge branch 'context-threaded' 2014-09-17 20:11:51 -04:00
Zach Riggle 873afe189b Fixed regression in local copy 2014-09-17 20:09:17 -04:00
Zach Riggle e59aceecc2 Timeout message is too verbose after fixing thread context, when using .interactive() 2014-09-17 19:52:18 -04:00
Zach Riggle 24d247cc1b Implement context-preserving thread
Add threading back to toplevel
2014-09-17 19:52:06 -04:00
IdolfHatler e37b606cdc Merge pull request #119 from zachriggle/cyclic-newline-fix
Cyclic should only emit a newline when writing to a TTY
2014-09-17 21:08:15 +02:00
Zach Riggle d9079f4baa Merge branch 'cyclic-newline-fix' 2014-09-17 14:57:41 -04:00
Zach Riggle 6ff0fe8b2a Cyclic should only emit a newline when writing to a TTY 2014-09-17 14:49:31 -04:00
Zach Riggle 487fa32692 Merge remote-tracking branch 'upstream/master' 2014-09-17 14:48:58 -04:00
Mathias Svensson 1183fe4f66 Fixed a bug where readthedocs did not have rop documentation 2014-09-16 11:14:01 +02:00
IdolfHatler 43c0e7abce Merge pull request #117 from zachriggle/setxid
Update setXid
2014-09-15 20:52:53 +02:00
Zach Riggle 8796ba3477 Merge branch 'setxid' 2014-09-15 14:13:51 -04:00
Zach Riggle 22eb78d425 Update setXid 2014-09-15 14:13:43 -04:00
Mathias Svensson 5475de3f73 Tweaked the atexit-for-tubes commit a bit. We now use our local version of atexit, and we will not have a flag for choosing it. 2014-09-15 17:50:06 +02:00
Mathias Svensson 81ad2c32ac Merge branch 'tube-cleanup' of https://github.com/zachriggle/pwntools 2014-09-15 17:41:44 +02:00
Mathias Svensson 8d11a1596c Fixed debug message 2014-09-15 17:41:36 +02:00
IdolfHatler a830893c1f Merge pull request #112 from RobertLarsen/master
Made having two eggs in a row optional.
2014-09-15 14:54:50 +02:00
IdolfHatler c5305c6613 Merge pull request #110 from zachriggle/i386-dup-fix
Fix dupsh NUL bytes and make it shorter
2014-09-15 14:54:27 +02:00
IdolfHatler 3b010f92b6 Merge pull request #116 from zachriggle/shellcraft-amd64
amd64 shellcodes
2014-09-15 14:54:13 +02:00
Zach Riggle 32e767fb38 Merge branch 'shellcraft-amd64' 2014-09-15 04:35:03 -04:00
Zach Riggle 5d109f114c Merge branch 'tube-cleanup' 2014-09-15 04:34:46 -04:00
Zach Riggle 46957f01b3 Merge branch 'gdb.debug' 2014-09-15 04:34:36 -04:00
Zach Riggle e350668ba1 Merge remote-tracking branch 'upstream/master' 2014-09-15 04:34:30 -04:00
Zach Riggle e3846d3d83 amd64 shellcodes 2014-09-15 04:31:37 -04:00
IdolfHatler 63c1245931 Merge pull request #115 from zachriggle/shellcraft-chain
Permit chaining of `shellcraft`
2014-09-15 09:39:12 +02:00
Zach Riggle d6ba19d148 Ensure gdbserver is installed. Important since it is not installed for any overthewire or smashthestack challenges 2014-09-15 03:21:22 -04:00
Zach Riggle 2b111c84cd Autodetect output format 2014-09-15 03:07:34 -04:00
Zach Riggle 47f31d8741 Permit chaining of shellcraft 2014-09-15 03:04:12 -04:00
Zach Riggle 2a472e2c39 Make it optional, but default 2014-09-15 02:49:39 -04:00
Zach Riggle 9dce9c50fd Clean up tubes on process exit 2014-09-15 02:42:51 -04:00
Robert Larsen becaebc17d Fixed documentation. 2014-09-14 12:47:47 +02:00
Robert Larsen 8259572280 Made having two eggs in a row optional. 2014-09-14 12:44:27 +02:00
Mathias Svensson 3b793cdb57 Fixed #111 2014-09-12 13:59:01 +02:00
Mathias Svensson 786390ffa0 Fixed logging bug in dynelf 2014-09-12 13:57:48 +02:00
Zach Riggle 31a27eda3f Get rid of skinny-space 2014-09-11 19:37:13 -04:00
Zach Riggle 1e3257cddd Merge branch 'i386-dup-fix' 2014-09-11 19:09:47 -04:00
Zach Riggle bd29de04a3 Fix dupsh NUL bytes and make it shorter 2014-09-11 19:07:19 -04:00
IdolfHatler a923b9a155 Merge pull request #109 from zachriggle/rop-cache-quiet
Make message a bit quieter
2014-09-11 05:46:45 +02:00
Zach Riggle b80c08af3c Merge remote-tracking branch 'upstream/master' 2014-09-10 20:41:37 -04:00
Zach Riggle 7e58a25a92 Merge branch 'rop-cache-quiet' 2014-09-10 20:39:18 -04:00
Zach Riggle 87a85e92fe Merge branch 'gdb.debug' 2014-09-10 20:39:15 -04:00
Zach Riggle b0661a42c3 Make message a bit quieter 2014-09-10 20:18:24 -04:00
Zach Riggle 77baaed1d6 Autodetect binary for gdb based on provided arguments if running locally 2014-09-10 20:08:03 -04:00
Zach Riggle b30b34b3af Add gdb.debug for launching gdbserver locally or over ssh 2014-09-10 20:04:58 -04:00
Zach Riggle 45cc9e172a Merge branch 'ssh-directories' 2014-09-10 15:56:13 -04:00
Zach Riggle 1eb85ac20e Fix issue which makes top-level "process" be the module instead of the class when importing * from pwn 2014-09-10 15:56:03 -04:00
Zach Riggle 60d4921125 Merge branch 'ssh-directories' 2014-09-10 15:50:43 -04:00
Zach Riggle e17f33d741 Enable recursive upload/download of folders 2014-09-10 15:50:30 -04:00
IdolfHatler 5e8590c090 Merge pull request #106 from RobertLarsen/master
Shaved off one instruction.
2014-09-10 17:28:52 +02:00
Robert Larsen 0ec9bd93ff Shaved off one instruction. 2014-09-10 13:51:09 +02:00
IdolfHatler a814a2d90f Merge pull request #103 from RobertLarsen/master
Added egghunter for ARM
2014-09-10 13:32:24 +02:00
Robert Larsen 256b340354 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2014-09-10 13:27:00 +02:00
Robert Larsen 637ff82f5a Be able to specify the address to start the search. 2014-09-10 13:04:50 +02:00
IdolfHatler aaaabb7295 Merge pull request #92 from RobertLarsen/master
Added findpeersh shellcode for thumb
2014-09-10 10:33:35 +02:00
IdolfHatler b5d2ed19c3 Merge pull request #94 from zachriggle/pwnlib-util-web-wget
Pwnlib util web wget
2014-09-10 10:33:05 +02:00
Zach Riggle 62a039501e Merge remote-tracking branch 'upstream/master' 2014-09-10 03:23:11 -04:00
IdolfHatler d6a977122d Merge pull request #99 from zachriggle/elf-vaddr-fixup
Fix calculations based on header.p_vaddr
2014-09-10 09:22:32 +02:00
IdolfHatler fe702fc6e3 Merge pull request #98 from zachriggle/elf-bss-default
Default elf.bss argument
2014-09-10 09:21:57 +02:00
IdolfHatler 1aa06f3781 Merge pull request #97 from zachriggle/listen-wait-port-zero-status
Add status message for "listening" to expressly print out port
2014-09-10 09:21:39 +02:00
IdolfHatler 1e947a72c2 Merge pull request #95 from zachriggle/elf-plt-stopgap-fix
ELF PLT Symbol Fix
2014-09-10 09:21:06 +02:00
IdolfHatler 04cabea872 Merge pull request #96 from zachriggle/elf-symbols-got-plt-prefixes
Add plt.XXXX and got.XXXX symbols so that rop.dump() output is better
2014-09-10 09:19:27 +02:00
Zach Riggle c29919560a Merge branch 'elf-vaddr-fixup' 2014-09-10 03:14:03 -04:00
Zach Riggle 19c59a44e7 Fix calculations based on header.p_vaddr 2014-09-10 03:10:49 -04:00
Zach Riggle 5b79e53126 Merge branch 'elf-bss-default' 2014-09-10 02:37:53 -04:00
Zach Riggle 93ad3e7e42 Default elf.bss argument 2014-09-10 02:35:30 -04:00
Zach Riggle 073f925974 Merge branch 'listen-wait-port-zero-status' 2014-09-10 02:26:41 -04:00
Zach Riggle 0ee84aec1e Add status message for "listening" to expressly print out port, which is useful if port was zero 2014-09-10 02:26:18 -04:00
Zach Riggle 68db0532a4 Merge branch 'elf-symbols-got-plt-prefixes' 2014-09-10 02:20:12 -04:00
Zach Riggle 5d150fd930 Add plt.XXXX and got.XXXX symbols so that rop.dump() output is better 2014-09-10 02:18:20 -04:00
Zach Riggle 5742eceab4 Merge branch 'elf-plt-stopgap-fix' 2014-09-10 01:38:15 -04:00
Zach Riggle a9145ad8f7 Rename variables to match BFD 2014-09-10 01:38:04 -04:00
Zach Riggle 17ff609e39 Apply intermediary fix 2014-09-10 00:37:07 -04:00
Robert Larsen ae3bb1fe20 Start from page 0. 2014-09-09 13:33:25 +02:00
Robert Larsen f7a047af68 Made the egghunter work. 2014-09-09 13:07:05 +02:00
Robert Larsen ba053eed81 Improved mov() helper. 2014-09-09 12:53:57 +02:00
Robert Larsen 860668621b Added egghunter for ARM. 2014-09-09 10:40:19 +02:00
Robert Larsen b08f81a788 Added mov() shellcode helper for ARM. 2014-09-09 10:38:11 +02:00
Robert Larsen 5b8375a027 Merge branch 'master' of https://github.com/Gallopsled/pwntools 2014-09-09 10:23:32 +02:00
Zach Riggle aafe85092a Merge branch 'pwnlib-util-web-wget' 2014-09-03 21:46:07 -07:00
Zach Riggle 85d7229691 Add timeout 2014-09-03 21:41:48 -07:00
Zach Riggle e514328d02 add pwnlib.util.web.wget 2014-09-03 21:36:44 -07:00
Zach Riggle f70665546b Merge branch 'master' of https://github.com/pwnies/pwntools 2014-09-03 14:57:43 -07:00
IdolfHatler 09b5b74bd2 Merge pull request #93 from zachriggle/setreXid
Add i386 shellcode for 'setreuid' and 'setregid'
2014-09-01 14:26:40 +02:00
Zach Riggle 723d053a8b Merge branch 'setreXid' 2014-08-31 23:03:19 -07:00
Zach Riggle 06970b082d add shellcodes 2014-08-31 23:02:38 -07:00
Zach Riggle ccbc7b93ec Merge branch 'master' of https://github.com/pwnies/pwntools 2014-08-31 21:53:20 -07:00
Robert Larsen 75917a9a41 Fixed doc. 2014-08-29 10:46:57 +02:00
Robert Larsen e8e8f70f60 Put port into the right register prior to comparison. 2014-08-29 10:41:36 +02:00
Robert Larsen 60d0e82dd3 Fixed dup() shellcode. 2014-08-29 10:16:13 +02:00
Robert Larsen d4fa4f3057 First attempt at findpeer() and findpeersh() shellcode. 2014-08-29 01:02:01 +02:00
IdolfHatler 06a95ddb70 Merge pull request #91 from RobertLarsen/master
Indent correctly for more cases
2014-08-29 00:37:41 +02:00
Robert Larsen 90f92185bc More elegant check for ':'. 2014-08-29 00:19:54 +02:00
Robert Larsen 0350724eb2 '.' and '_' should be considered legal label characters too. 2014-08-29 00:06:49 +02:00
Robert Larsen 63a2fd2bc4 First non whitespace characters in a label is alphanumeric. 2014-08-28 23:48:24 +02:00
Mathias Svensson d1a83f5c92 process.kill() will now actually kill the process 2014-08-28 23:35:42 +02:00
Mathias Svensson 52fe5d6ef7 A few more bugfixes to rop.py 2014-08-28 23:27:18 +02:00
Robert Larsen 54d5e7bdac Handle case with colon inside comment 2014-08-28 23:11:47 +02:00
Robert Larsen 60ed4a3b01 Indent so that shellcrafts prettyfier will work. 2014-08-28 22:31:21 +02:00
Mathias Svensson 54d027ae77 Made rop.search more useful 2014-08-28 22:27:17 +02:00
Mathias Svensson e5037c251d Bugfix: Last-call optimization was broken 2014-08-28 22:26:56 +02:00
Robert Larsen e395284dea Prevent indention for lines starting with a label.
Indent remaining lines by four spaces if they are indented at any level.
2014-08-28 22:22:16 +02:00
Morten Brøns-Pedersen 579ea543df fixed docstring syntax in pwnlib.rop.ROP.__getattr__(). 2014-08-28 21:28:40 +02:00
Morten Brøns-Pedersen 5ffcd945cc fix doctests for pwnlib.rop. 2014-08-28 21:28:40 +02:00
Morten Brøns-Pedersen a059b49a58 suppress output from ropgadget in pwnlib.rop. 2014-08-28 21:28:40 +02:00
Mathias Svensson 0a5d9956ea There should not be any log_level=info in interactive 2014-08-28 21:26:17 +02:00
Mathias Svensson 3d9af2f8f3 Bugfix: recvn was broken 2014-08-28 21:15:06 +02:00
Mathias Svensson b2e15b19b1 Added preliminary changelog 2014-08-28 21:00:07 +02:00
Morten Brøns-Pedersen ab628a3231 addde pwnlib.rop to docs. 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen 033526e044 added docstrings for pwnlib.rop. 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen 50e1b723f2 added docs for pwnlib.replacements. 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen 894fe13d0c updated docstrings in pwnlib.replacements. 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen 4ea339230c added pwnlib.replacements.* to pwn.toplevel 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen d0907f8677 added replacements to __init__.py 2014-08-28 20:54:52 +02:00
Morten Brøns-Pedersen 17135990e5 moved pwnlib.replacements.time.sleep() to pwnlib.replacements.sleep() 2014-08-28 20:54:52 +02:00
Mathias Svensson 2e586d05c6 Removed trailing whitespace 2014-08-28 20:04:51 +02:00
Mathias Svensson a1a0877b8f Removed trailing whitespace 2014-08-28 20:01:00 +02:00
Jonas Rudloff f62ea2d3e6 Merge pull request #88 from RobertLarsen/master
Ported ARM/THUMB shellcode from old pwntools
2014-08-28 19:30:25 +02:00
Morten Brøns-Pedersen 61cdbfcbf1 fixed #90 2014-08-28 19:21:10 +02:00
Morten Brøns-Pedersen 082aab697b updated the README.md 2014-08-28 19:21:10 +02:00
Zach Riggle bafee07292 Merge remote-tracking branch 'origin/elfpatch' 2014-08-28 09:45:24 -07:00
Zach Riggle 10df479581 Merge remote-tracking branch 'origin/elfdiff' 2014-08-28 09:45:20 -07:00
mortenbp d32af7f0c4 Merge pull request #84 from zachriggle/cyclic-find-not-in-alphabeta
Catch invalid characters early in cyclic_find()
2014-08-28 10:37:56 +02:00
Zach Riggle d4ad15cfc9 Merge remote-tracking branch 'upstream/master' 2014-08-27 22:59:27 -07:00
Mathias Svensson f09bf54ab4 Fixed a few bugs in rop.py 2014-08-28 07:51:03 +02:00
Robert Larsen 59968de491 Added dupsh thumb shellcode. 2014-08-28 00:35:38 +02:00
Robert Larsen 05f31950c5 Added dup shellcode for thumb. 2014-08-28 00:33:18 +02:00
Robert Larsen e3907f5dd6 Added thumb shellcode for spawning a shell. 2014-08-27 23:52:55 +02:00
Robert Larsen 70d313cbcc Added thumb shellcode helper for initializing a register. 2014-08-27 23:42:49 +02:00
Robert Larsen ec1452c781 Added shell spawning shellcode for arm. 2014-08-27 22:44:09 +02:00
Robert Larsen 737809b563 Added arm->thumb shellcode. 2014-08-27 22:28:14 +02:00
Robert Larsen 56af2d7cdd Fixed typo in comment 2014-08-27 22:09:10 +02:00
IdolfHatler 99695f3873 Merge pull request #87 from RobertLarsen/master
Made DynELF much more modular and able to solve more tasks
2014-08-27 15:51:10 +02:00
Robert Larsen 80e312144c No test 2014-08-27 12:42:54 +02:00
Robert Larsen 79833088bf Added docstring. 2014-08-27 12:39:29 +02:00
Robert Larsen 8e16f22172 Made dynelf work with new elf implementation. 2014-08-27 11:54:08 +02:00
Morten Brøns-Pedersen 318d01ce51 logging functions now write to sys.stderr if not in term mode 2014-08-27 11:15:28 +02:00
Morten Brøns-Pedersen 2369700409 replace sys.stderr in pwnlib.term.term.init() so exceptions etc. shows right 2014-08-27 11:14:30 +02:00
Morten Brøns-Pedersen 38c560d526 let the terminal wrap lines that are too long. fixes copy'n'pasting of such lines 2014-08-26 16:03:28 +02:00
Zach Riggle 67a544bf5f kill assemblers 2014-08-25 21:06:01 -07:00
Zach Riggle 82cb3f5dfd Add .lhost and .lport for ssh_connector() 2014-08-25 19:34:53 -07:00
mortenbp fc27c74f14 Merge pull request #86 from zachriggle/ssh-listener-broken-typo
acceptor => accepter
2014-08-25 22:36:19 +02:00
Zach Riggle 02e6b3a768 acceptor => accepter 2014-08-25 11:44:13 -07:00
Robert Larsen dfee5a50e5 Made dynelf implementation much cleaner.
Added factory methods for easier instantiation.
2014-08-25 15:31:54 +02:00
Robert Larsen cb81b9dfbf Merge branch 'master' of https://github.com/Gallopsled/pwntools
Conflicts:
	pwn/test/leaky/Makefile
	pwn/test/leaky/resolve.py
	pwnlib/dynelf.py
2014-08-25 15:21:36 +02:00
IdolfHatler 6a05dbd606 Merge pull request #85 from zachriggle/blocking-poll-ssh
Add a blocking variant of poll() and a helper, wait(), to invoke it
2014-08-24 20:02:07 +02:00
Zach Riggle a182d739ee Merge branch 'blocking-poll-ssh' 2014-08-24 09:43:24 -07:00
Zach Riggle d3b5f79362 Add a blocking variant of poll() and a helper, wait(), to invoke it. Replace poll() with wait() where we need the exit status. Without this, the exit code may not be available and file uploads/downloads will "fail" when they really succeeded (but the return value just didn't propagate yet) 2014-08-24 09:41:09 -07:00
Zach Riggle 6dd29547ac Merge branch 'cyclic-find-not-in-alphabeta' 2014-08-23 07:46:25 -07:00
Zach Riggle 25fda64e03 More readable 2014-08-23 06:36:41 -07:00
Zach Riggle b2ad179845 Merge branch 'cyclic-find-not-in-alphabeta' 2014-08-22 20:41:53 -07:00
Zach Riggle dc2dc0b87f Catch invalid characters early in cyclic_find(). Sometimes I forget to u32() the data, and it searches forever for eight bytes of irrelevant data. 2014-08-22 20:10:53 -07:00
Zach Riggle ed77b3b397 Merge remote-tracking branch 'upstream/master' 2014-08-22 14:32:08 -07:00
Morten Brøns-Pedersen 4e8c9a6913 better ascii-art in pwnlib.util.splash.splash(). 2014-08-22 17:46:34 +02:00
Mathias Svensson 5463cdcb31 Made the serialtube a bit better 2014-08-17 20:27:50 +02:00
Mathias Svensson a358bf0b4b Added infloop and nop for ARM 2014-08-17 16:43:05 +02:00
Mathias Svensson e05cd05155 Removed octal constants from header files 2014-08-17 15:58:02 +02:00
Mathias Svensson 495a60c102 Ignore e.g. vim files in the templates directory 2014-08-17 15:54:52 +02:00
Mathias Svensson a35a5a318a Better constant handling for shellcraft 2014-08-17 15:53:36 +02:00
Mathias Svensson cd25505009 Added open_file for ARM 2014-08-17 15:52:45 +02:00
Mathias Svensson c20033e7b4 Added thumb nop and infloop 2014-08-17 15:42:04 +02:00
Mathias Svensson a791f3122a Updated shellcraft to remove all newlines following just after two other newlines 2014-08-17 15:39:18 +02:00
Mathias Svensson c7898a4e48 Added a replacement for time.sleep which does not return on signals 2014-08-17 15:12:36 +02:00
Mathias Svensson b31c527212 Fixed bug in case there was no plt 2014-08-17 15:12:36 +02:00
IdolfHatler c1ebb79ef7 Merge pull request #80 from brifordwylie/small_setup_changes
Small setup changes
2014-08-16 11:36:13 +02:00
Morten Brøns-Pedersen aa67eded8a improved performance of pwnlib.util.fiddling.hexdump_iter(). 2014-08-14 20:47:09 +02:00
Morten Brøns-Pedersen 3678934c86 added argument "--color" to bin/phd. 2014-08-14 20:34:52 +02:00
Morten Brøns-Pedersen 0e9f855133 added property pwnlib.term.text.when which controls when to output control characters. 2014-08-14 20:26:48 +02:00
Morten Brøns-Pedersen a23a608854 bin/phd now handles top-level exceptions KeyboardInterrupt and IOError (which happens when e.g. phd | less). 2014-08-14 19:11:40 +02:00
Morten Brøns-Pedersen 61f6842483 added pwnlib.util.fiddling.hexdump_iter() and made pwnlib.util.fiddling.hexdump() a thin wrapper. bin/phd now uses the iterator variant for better performance. 2014-08-14 18:53:22 +02:00
Morten Brøns-Pedersen b07d337b96 bugfix: bin/phd now offsets addresses by skip. 2014-08-14 18:40:34 +02:00
Morten Brøns-Pedersen 8a5141a52a bugfix: pwnlib.util.fiddling.hexdump() now reports the correct address on the last line. 2014-08-14 18:39:24 +02:00
Morten Brøns-Pedersen bb777b923e added CLI frontend to pwnlib.util.fiddling.hexdump: phd (Pwnlib HexDump). 2014-08-14 04:24:37 +02:00
Morten Brøns-Pedersen 60ddfb3f03 added highlights to pwnlib.util.fiddling.hexdump. 2014-08-14 03:57:13 +02:00
Morten Brøns-Pedersen 196499095b added colors to pwnlib.util.fiddling.hexdump(). 2014-08-14 03:53:06 +02:00
Brian Wylie fa61307a73 add pyserial as a required dependency (at least on MacOSX you need it :) 2014-08-13 13:43:24 -06:00
Brian Wylie 05838c1d2a have requirements.txt just 'call' setup.py install_requires so that you don't have two copies of the python dependencies 2014-08-13 13:42:29 -06:00
Morten Brøns-Pedersen aab7122870 pwn now also looks for environment variables starting with "PWNLIB_"; "PWNLIB_LOG_LEVEL" sets context.log_level. added a new flag "NOTERM". 2014-08-13 17:26:55 +02:00
Morten Brøns-Pedersen 20933e1ac1 removed per tube log levels from pwnlib.tubes.tube as the feature was hardly ever used and not very intuitive. might reintroduce later. 2014-08-13 17:26:55 +02:00
Morten Brøns-Pedersen d53a59b604 bugfix: pwnlib.tubes.tube.recvline() now uses the timeout argument when called with no delims. 2014-08-13 17:26:46 +02:00
Morten Brøns-Pedersen 251eccbc70 added argument keepend(s) to functions in pwnlib.tubes.tube recieving lines. 2014-08-13 17:22:55 +02:00
Morten Brøns-Pedersen c07637d05b rewrote major parts of pwnlib.tubes.tube for hugely increased performance. introduced slight API changes in the process. 2014-08-13 15:05:51 +02:00
Morten Brøns-Pedersen 8996cdf363 fixed a bug where pwnlib.term.term would simetimes throw an exception if there was free space at the bottom of the terminal and the window was resized. 2014-08-13 01:33:40 +02:00
Mathias Svensson 4cf1e55129 Added initial support for serial tubes 2014-08-09 01:31:58 -07:00
IdolfHatler 083b5c854e Merge pull request #79 from zachriggle/elfpatch-correct
elf.asm now uses "org" directive for correct relative jumps
2014-08-08 22:56:24 -07:00
Zach Riggle b95246fc5a elf.asm now uses "org" directive for correct relative jumps 2014-08-08 15:38:05 -07:00
Morten Brøns-Pedersen edc43b0de4 bugfix: pwnlib.gdb.attach() now waits for the debugger 2014-08-08 21:24:51 +02:00
Zach Riggle a346d64d98 elfdiff 2014-08-08 11:09:45 -07:00
Zach Riggle 3956b76144 fix 2014-08-08 10:48:05 -07:00
Zach Riggle 5a5ac38e06 elfpatch 2014-08-08 10:43:00 -07:00
Morten Brøns-Pedersen b74a3ad991 added example showing pwnlib.term.text and updated examples/README.md 2014-08-07 21:15:23 +02:00
Morten Brøns-Pedersen 58c4abae82 bugfix: pwnlib.term.term now handles xterm color definition escapes 2014-08-07 20:45:48 +02:00
Morten Brøns-Pedersen 136694509d bugfix: pwnlib.term.termcap.get() now also works for integer and boolean values 2014-08-07 20:08:33 +02:00
Morten Brøns-Pedersen 743bf4cb38 pwnlib.ui.options(): options too long to fit on a single line are now indented properly 2014-08-07 00:37:57 +02:00
IdolfHatler dcb4435e62 Merge pull request #71 from zachriggle/interactive-working-dir
cd on .interactive() if .set_working_dir() has been called
2014-08-06 13:21:41 -07:00
IdolfHatler 3a0f41493a Merge pull request #75 from zachriggle/patch-2
Bugfix: ssh.run(tuple) => error
2014-08-06 13:21:26 -07:00
IdolfHatler 1b4d1a2cb9 Merge pull request #74 from zachriggle/patch-1
`cyclic` currently broken due to aliased command
2014-08-06 13:21:10 -07:00
Morten Brøns-Pedersen 6a1b1f3bab fixed #76 2014-08-06 19:27:18 +02:00
Morten Brøns-Pedersen b9649ea4dc fixed #73 2014-08-06 11:01:14 +02:00
Morten Brøns-Pedersen d45bfe134a added documentation badges to README.md 2014-08-06 10:57:14 +02:00
Morten Brøns-Pedersen 79dc4d46e6 added badges to README.md and changed the header 2014-08-06 10:41:14 +02:00
Zach Riggle 62686836fd Bugfix: ssh.run(tuple) => error
Otherwise throws this

```py
  File "/home/user/pwntools/pwnlib/tubes/ssh.py", line 17, in __init__
    h = log.waitfor('Opening new channel: %r' % (process or 'shell'), log_level = self.log_level)
TypeError: not all arguments converted during string formatting
```
2014-08-06 04:29:10 -04:00
Zach Riggle 1c9ee40592 cyclic currently broken due to aliased command 2014-08-06 03:07:35 -04:00
Zach Riggle 1875ceea5b Merge remote-tracking branch 'upstream/master' 2014-08-05 20:16:25 -07:00
Mathias Svensson 76d58479fa Merge branch 'master' of github.com:Gallopsled/pwntools 2014-08-05 18:53:55 -07:00
Mathias Svensson 3f2298d2d8 Merge branch 'zachriggle-absolute-rop' 2014-08-05 18:53:22 -07:00
Mathias Svensson 3c6d54affd Merge branch 'absolute-rop' of https://github.com/zachriggle/pwntools into zachriggle-absolute-rop
Conflicts:
	pwnlib/util/packing.py

But also changed the rop.py a lot. I am bad at git, I know. :/
2014-08-05 18:52:21 -07:00
Zach Riggle c74ac96ef6 cd on .interactive() if .set_working_dir() has been called 2014-08-05 17:19:19 -07:00
Zach Riggle 1afd42a32a Merge remote-tracking branch 'upstream/master' 2014-08-05 16:51:59 -07:00
Morten Brøns-Pedersen 90e2b69ac5 example showing pwnlib.ui.options(). 2014-08-06 01:46:57 +02:00
Morten Brøns-Pedersen 7785615055 added bells and whistles to pwnlib.ui.options when in term_mode. 2014-08-06 01:46:10 +02:00
Morten Brøns-Pedersen 856e75d2cc pwnlib.ui.more now just prints the text if not in term_mode. 2014-08-06 01:06:11 +02:00
Morten Brøns-Pedersen 7d98a0a6dd added pwnlib.ui.more. 2014-08-06 01:04:09 +02:00
Morten Brøns-Pedersen d601ccfc64 added links to itertools aliases in pwnlib.util.iters documentation. 2014-08-06 00:04:11 +02:00
Morten Brøns-Pedersen 465b53ee61 fixed doctest setup for pwnlib.util.iters. 2014-08-05 23:44:12 +02:00
Morten Brøns-Pedersen c828fd05ae added module pwnlib.useragents. 2014-08-05 23:31:33 +02:00
Morten Brøns-Pedersen ba68548e02 added __all__ to pwnlib.util.iters. 2014-08-05 19:14:55 +02:00
Morten Brøns-Pedersen 6e06b0e808 added "iters" to pwnlib.util.__all__. 2014-08-05 18:28:58 +02:00
Morten Brøns-Pedersen c6b2015158 added support for status updates to pwnlib.log.waitfor() when not in term_mode 2014-08-05 09:33:49 +02:00
Morten Brøns-Pedersen 9548fa6b69 added pwnlib.util.iters to pwn toplevel 2014-08-05 09:33:49 +02:00
Morten Brøns-Pedersen 9d79323df9 ported iterutil from old pwnlib to pwnlib.util.iters. 2014-08-05 09:33:49 +02:00
Mathias Svensson d3fc464eaf Added the method spawn_process for tubes, which will spawn a process communicating on that tube 2014-08-04 23:54:15 -07:00
Mathias Svensson c45edb3419 I cannot see any reason not to use ebp in pivots 2014-08-04 23:23:25 -07:00
Mathias Svensson 41d6b8542d Added the possibility for preprocessing to flat 2014-08-04 22:52:40 -07:00
Mathias Svensson 9351ed93c7 Missed one 2014-08-04 22:51:58 -07:00
Mathias Svensson 1f71e690e5 Removed slow tests 2014-08-04 22:48:41 -07:00
Mathias Svensson 1b3d426377 Does the same transformation for connected as was done for shutdown 2014-08-04 22:18:06 -07:00
Mathias Svensson fd72c895af Make pack support unicode 2014-08-04 22:06:53 -07:00
Mathias Svensson 124a473432 Make run_in_new_terminal less noisy 2014-08-04 22:06:19 -07:00
Mathias Svensson b615ba58d0 ECONNRESET should be translated into EOFError 2014-08-04 22:05:46 -07:00
Mathias Svensson b5d12f680f Added cwd argument to process 2014-08-04 19:35:35 -07:00
Morten Brøns-Pedersen 86773a5a4a pwnlib.tubes.tube.shutdown() now accepts "in", "out", "recv", "send", "read" and "write"; subclasses should now implement shutdown_raw(). 2014-08-05 04:24:33 +02:00
Morten Brøns-Pedersen 3ed230d410 changed pwnlib.util.safeeval.expr_eval/const_eval to pwnlib.util.safeeval.exrp/const. 2014-08-05 04:24:33 +02:00
Morten Brøns-Pedersen a5d62b8e2e added modules collections and operator to pwn.toplevel. 2014-08-05 04:24:33 +02:00
Zach Riggle 5a95e8e9d2 Implement absolute ROP loading given a static base address 2014-08-04 19:23:05 -07:00
IdolfHatler b90e6cdc3d Merge pull request #67 from zachriggle/elf-bss
Add pwnlib.elf.ELF.bss()
2014-08-04 19:08:51 -07:00
Mathias Svensson d970304bd2 We now support interactive outside term mode 2014-08-04 19:01:43 -07:00
Zach Riggle d534a3a929 Add pwnlib.elf.ELF.bss() 2014-08-04 19:01:26 -07:00
Mathias Svensson 3e01b5ab97 Fixed bug in run_in_new_terminal and removed tabs 2014-08-04 18:27:06 -07:00
Mathias Svensson 485005cab8 Support using a string as an argument to ROP 2014-08-04 18:14:44 -07:00
Morten Brøns-Pedersen 25060ef502 set context.log_level to "silent" when running doctests 2014-08-05 02:08:25 +02:00
IdolfHatler 11e2b3a677 Merge pull request #62 from zachriggle/gdb-resolve-library-addresses
GDB resolution for modules
2014-08-04 16:46:22 -07:00
Zach Riggle 6898eae383 Merge branch 'elf-fix-offsets-after-addr-change' 2014-08-04 16:23:29 -07:00
Zach Riggle 3097a60433 Merge branch 'gdb-resolve-library-addresses' 2014-08-04 16:21:47 -07:00
Zach Riggle e61812d7aa Clarify docs 2014-08-04 16:21:04 -07:00
Zach Riggle 215c42b2c5 Example, doctest works 2014-08-04 16:18:35 -07:00
Mathias Svensson d51e71f738 Merge branch 'zachriggle-elf-fix-offsets-after-addr-change' 2014-08-04 16:05:32 -07:00
Mathias Svensson 4a28bd824f Removed some debugging code 2014-08-04 16:05:23 -07:00
Mathias Svensson cb52da39b8 Merge branch 'elf-fix-offsets-after-addr-change' of https://github.com/zachriggle/pwntools into zachriggle-elf-fix-offsets-after-addr-change 2014-08-04 16:04:51 -07:00
Zach Riggle 81500b5a6e Merge remote-tracking branch 'upstream/master' 2014-08-04 16:00:00 -07:00
Zach Riggle a492a5a5c9 Fix docs 2014-08-04 15:57:50 -07:00
Mathias Svensson 8ffef8af9f Merge branch 'zachriggle-rop-easy' 2014-08-04 15:52:41 -07:00
Mathias Svensson 20b1b90987 Added docstring 2014-08-04 15:52:21 -07:00
Mathias Svensson 937ab31947 Merge branch 'rop-easy' of https://github.com/zachriggle/pwntools into zachriggle-rop-easy 2014-08-04 15:50:29 -07:00
Zach Riggle 488e4b8d11 flush = chain(); clear(); 2014-08-04 15:49:55 -07:00
Zach Riggle baf5b68cf4 Implement shorthand for rop.call(); add .flush(); remove arg to .chain() 2014-08-04 15:47:11 -07:00
Zach Riggle 4ae64db213 Fix vaddr_to_offset and offset_to_vaddr after the base address changes 2014-08-04 15:36:03 -07:00
Mathias Svensson 3b69b293cd Moved re import 2014-08-04 13:37:55 -07:00
Zach Riggle d168eaed40 Merge branch 'rop-easy' 2014-08-04 12:36:38 -07:00
Zach Riggle d0c71bd6e9 Slight syntax enhancement 2014-08-04 12:36:23 -07:00
Zach Riggle 43971132b1 Merge remote-tracking branch 'upstream/master'
Conflicts:
	pwnlib/elf.py
2014-08-04 12:34:36 -07:00
Zach Riggle 4751e8e473 easy rop gadget notation 2014-08-04 12:24:49 -07:00
Morten Brøns-Pedersen 4b7c13e873 updated example docstrings and README.md 2014-08-04 20:01:22 +02:00
Morten Brøns-Pedersen e53af0657f added script to generate examples/README.md and the new README.md 2014-08-04 19:56:01 +02:00
Mathias Svensson ab33cbe4c0 Merge branch 'zachriggle-elf-dont-load-dyn-dependencies' 2014-08-04 09:22:22 -07:00
Mathias Svensson 76817799fd Replaced a generic "except:" in elf.py with a catching a specific exception 2014-08-04 09:22:15 -07:00
Mathias Svensson 9d7858ad7d Merge branch 'elf-dont-load-dyn-dependencies' of https://github.com/zachriggle/pwntools into zachriggle-elf-dont-load-dyn-dependencies 2014-08-04 09:18:16 -07:00
Morten Brøns-Pedersen 90e7da6d31 fixed #60 -- this would not (could not) have happened in a statically typed language 2014-08-04 18:03:00 +02:00
Mathias Svensson f1d38959ca Merge branch 'master' of github.com:Gallopsled/pwntools
Conflicts:
	pwnlib/elf.py
2014-08-04 08:49:04 -07:00
Mathias Svensson e255e92dcf Merge branch 'zachriggle-v2-rop' 2014-08-04 08:47:16 -07:00
Mathias Svensson 149fc79f41 Fixed up the rop commit a bit 2014-08-04 08:47:05 -07:00
Mathias Svensson 846822b424 Merge branch 'v2-rop' of https://github.com/zachriggle/pwntools into zachriggle-v2-rop 2014-08-04 07:45:55 -07:00
IdolfHatler b0debef19d Merge pull request #61 from zachriggle/elf-dso-address-fix
Bugfix: ELF load address for DSO is 0, libc addresses now correct
2014-08-04 07:19:54 -07:00
Zach Riggle f18bca5112 Merge branch 'gdb-resolve-library-addresses' 2014-08-04 07:17:38 -07:00
IdolfHatler 107806f13a Merge pull request #58 from zachriggle/ssh-easy-bad-attrs
Filter a few things which should not spawn SSH commands
2014-08-04 07:17:19 -07:00
Zach Riggle 31330a653b Permit local running of gdb(), better support for ulimit, no reliance on "start" command in GDB or symbols 2014-08-04 07:17:11 -07:00
Mathias Svensson 0a2e37e3c6 Merge branch 'zachriggle-ssh-channel-with-statement' 2014-08-04 07:16:20 -07:00
Mathias Svensson e3fd4ceea7 Fixed the placement of the __enter__ and __exit__ functions in pwnlib/tubes/tube.py 2014-08-04 07:16:11 -07:00
Mathias Svensson a67b47a49e Merge branch 'ssh-channel-with-statement' of https://github.com/zachriggle/pwntools into zachriggle-ssh-channel-with-statement 2014-08-04 07:15:08 -07:00
Zach Riggle d92ce7ff2c Merge branch 'elf-dont-load-dyn-dependencies' 2014-08-04 07:14:09 -07:00
Mathias Svensson cc2540d72f Merge branch 'zachriggle-less-silent-ssh' 2014-08-04 07:13:54 -07:00
Mathias Svensson 5af54ddb9f The log_level argument was not needed here 2014-08-04 07:13:45 -07:00
Zach Riggle ca8b62414d Better fallback 2014-08-04 07:13:08 -07:00
Mathias Svensson 7dbdcd538d Merge branch 'less-silent-ssh' of https://github.com/zachriggle/pwntools into zachriggle-less-silent-ssh 2014-08-04 07:12:44 -07:00
IdolfHatler 1974282888 Merge pull request #56 from zachriggle/elf-disasm-vma
Add --vma-offset to asm.disasm() and ELF.disasm() helper to automate
2014-08-04 07:10:41 -07:00
IdolfHatler 33c48e54eb Merge pull request #63 from zachriggle/freebsd-ssh-cache
FreeBSD hash utility is called shasum
2014-08-04 07:08:17 -07:00
Zach Riggle c110726e43 Merge branch 'ssh-easy-bad-attrs' 2014-08-04 07:03:28 -07:00
Zach Riggle e46c9db477 Blacklist anything that starts with a _ 2014-08-04 07:01:59 -07:00
Zach Riggle c71a7436d2 Merge branch 'elf-repr'
Conflicts:
	pwnlib/elf.py
2014-08-04 06:49:27 -07:00
Zach Riggle be283273b0 Merge branch 'v2-rop' 2014-08-04 06:47:54 -07:00
Zach Riggle b3b9117cdb ROP repr 2014-08-04 06:45:59 -07:00
Zach Riggle ed85b85692 Make ELF repr meaningful for working in REPL 2014-08-04 06:42:38 -07:00
Zach Riggle 34d4a71235 Merge branch 'freebsd-ssh-cache' 2014-08-04 06:36:36 -07:00
Zach Riggle f952e9dd0f FreeBSD .so are not recognized as shared objects, so ldd throws an error. Since there's not really a need to check the dependencies of an .so (use-case is we loaded all the deps from an exe via ldd), don't do it. 2014-08-04 06:32:45 -07:00
Zach Riggle 03d42522a6 FreeBSD hash utility is called shasum. Others exist, but they dont put the hash first. 2014-08-04 06:29:54 -07:00
Zach Riggle accfe828c7 Merge branch 'gdb-resolve-library-addresses' 2014-08-04 05:49:00 -07:00
Zach Riggle b63794599f Merge branch 'ssh-channel-with-statement' 2014-08-04 05:48:54 -07:00
Zach Riggle 8565d0ff71 Move __enter__ and __exit__ to tubes.tube so it's available globally 2014-08-04 05:46:55 -07:00
Zach Riggle 666ef2ed62 GDB resolution for modules 2014-08-04 05:40:47 -07:00
Zach Riggle 1551706362 Merge branch 'elf-dso-address-fix'
Conflicts:
	pwnlib/elf.py
2014-08-04 04:30:23 -07:00
Zach Riggle 0e2f28892c Merge branch 'v2-rop' 2014-08-04 04:29:47 -07:00
Zach Riggle efb4be6c56 Bugfix: ELF load address for DSO is 0, libc addresses now correct 2014-08-04 04:28:29 -07:00
Zach Riggle 455e15d648 Bugfix: Permit both int and long 2014-08-04 04:26:12 -07:00
Zach Riggle 6f888bfe8a Merge branch 'v2-rop' 2014-08-04 03:24:22 -07:00
Zach Riggle b6272a809b Cache ROP gadgets for speed. Parsing libc is really slow. 2014-08-04 03:06:51 -07:00
Zach Riggle 705ca87d47 Merge branch 'v2-rop' 2014-08-04 02:49:06 -07:00
Zach Riggle 06a14cfdef Merge branch 'elf-disasm-vma' 2014-08-04 02:49:01 -07:00
Zach Riggle 3217ff98c9 Merge branch 'less-silent-ssh' 2014-08-04 02:48:54 -07:00
Zach Riggle 0b26375619 Merge branch 'ssh-easy-bad-attrs' 2014-08-04 02:48:48 -07:00
Zach Riggle 4a13eb03fc Merge branch 'ssh-channel-with-statement' 2014-08-04 02:48:39 -07:00
Zach Riggle 5220490f8d Allow "with" on ssh_channel/ssh.run 2014-08-04 02:10:46 -07:00
Zach Riggle 3a139cff75 Filter a few things which should not spawn SSH commands 2014-08-04 01:14:36 -07:00
Zach Riggle 019c3b33db ssh.foo and ssh['foo'] were accidentally silcening output from commands (e.g. 'opening new channel', 'receiving all data') 2014-08-04 00:12:13 -07:00
Morten Brøns-Pedersen 338014f77b bugfix: default value for argument sock in pwnlib.shellcraft.i386.linux.dupsh() changed from None to 'ebp'. 2014-08-04 09:07:28 +02:00
Zach Riggle f9c3f64319 Fix typo 2014-08-03 23:56:43 -07:00
Zach Riggle 4690339b48 Add --vma-offset to asm.disasm() and ELF.disasm() helper to automate 2014-08-03 23:50:28 -07:00
Zach Riggle c558b53ffa Docs and small fixes 2014-08-03 23:13:25 -07:00
Zach Riggle 9324ef2af4 ROP rewritten to use new ELF stuff, and ropgadget/capstone 2014-08-03 23:13:25 -07:00
Morten Brøns-Pedersen b3ec35797c removed circular import in pwnlib.term.key/keymap 2014-08-04 02:11:12 +02:00
Morten Brøns-Pedersen 62dc5d0a39 removed accidental self-import 2014-08-04 02:11:12 +02:00
Mathias Svensson 97fe8e6491 Added ulimit -s unlimited to the places where we called ldd 2014-08-03 16:25:53 -07:00
Mathias Svensson 1ed9199a41 Fixed doctests 2014-08-03 16:25:02 -07:00
Mathias Svensson d61d1453fa Fixed mistake in the merge 2014-08-03 15:58:18 -07:00
Mathias Svensson 76485c6456 Merge branch 'zachriggle-ldd-universal' 2014-08-03 15:53:00 -07:00
Mathias Svensson b05017ee19 Merge branch 'ldd-universal' of https://github.com/zachriggle/pwntools into zachriggle-ldd-universal
Conflicts:
	pwnlib/tubes/ssh.py
2014-08-03 15:52:51 -07:00
Mathias Svensson eb06d4120c Merge branch 'zachriggle-ssh-easy-pwn2' 2014-08-03 15:13:40 -07:00
Mathias Svensson fcd7a013a6 Fixed up the ssh getattr/getitem a bit 2014-08-03 15:13:22 -07:00
Mathias Svensson ccd541fbe6 Merge branch 'ssh-easy-pwn2' of https://github.com/zachriggle/pwntools into zachriggle-ssh-easy-pwn2 2014-08-03 14:17:01 -07:00
Zach Riggle 8592c0b0de Implement #38 for pwn v2 2014-08-03 14:01:13 -07:00
Mathias Svensson 7b35fada6a Updated ssh_gdb to user port 0, so any free port is chosen. Also updated the example 2014-08-03 13:33:30 -07:00
Mathias Svensson 6f10e75c9b Updated remote_gdb_debugging.py example 2014-08-03 12:15:14 -07:00
Morten Brøns-Pedersen eaf1551a7f changed keyword argument non_writable to writable in pwnlib.elf.search(). also changed the default behaviour and updated the docstring 2014-08-03 20:55:02 +02:00
Mathias Svensson c7ef29b4c1 Another bug 2014-08-03 11:16:59 -07:00
Morten Brøns-Pedersen 13d5a4a090 introduced a lock in pwnlib.log to ensure that different logging messages don't get interleaved 2014-08-03 20:07:27 +02:00
Mathias Svensson 25bfae5e05 Fixed bug with the getattr of the listeners 2014-08-03 11:06:39 -07:00
Mathias Svensson 91f88daf8c Added gdb.ssh_gdb and fixed a few bugs, primarily with ctrl-c being ignored 2014-08-03 10:15:35 -07:00
Mathias Svensson d138174890 Made call to the constructors of the listeners non-blocking 2014-08-03 10:15:35 -07:00
Morten Brøns-Pedersen 85a5ceefb5 pwnlib.tubes.tube.clean_and_log() is now a no-op if the tube is not connected 2014-08-03 18:23:24 +02:00
Morten Brøns-Pedersen 7db0b6709f bugfix: when not in term_mode pwnlib.log.indented() mixed writing to sys.stdout and sys.stderr 2014-08-03 08:30:41 +02:00
Morten Brøns-Pedersen 88c957b3a4 updated/removed many examples 2014-08-03 08:29:47 +02:00
Morten Brøns-Pedersen 877388811d example: simple port forwarder 2014-08-03 07:12:29 +02:00
Morten Brøns-Pedersen 0bf988eb39 fixed typo in docstring for pwnlib.tubes.tube.connect_both() 2014-08-03 06:59:17 +02:00
Morten Brøns-Pedersen eb4199fdea updated docstrings for pwnlib.atexit.register() and pwnlib.atexception.register() 2014-08-03 06:54:25 +02:00
Morten Brøns-Pedersen 4573742522 pwnlib.atexception.register() and pwnlib.atexit.register() can now be used as decorators 2014-08-03 06:42:16 +02:00
Morten Brøns-Pedersen 43a46d34e9 added an example showing a use case for pwnlib.tubes.tube.clean_and_log 2014-08-03 05:46:24 +02:00
Morten Brøns-Pedersen 8a05319f58 added pwnlib.tubes.tube.clean_and_log() 2014-08-03 05:46:24 +02:00
Morten Brøns-Pedersen 1b5bfe89d9 added modules pwnlib.atexit and pwnlib.atexception 2014-08-03 05:46:24 +02:00
Mathias Svensson 1a9687a917 Added documentation for ssh forwards 2014-08-02 20:39:28 -07:00
Mathias Svensson 1bffb5a986 Fixed sh_string and its documentation a bit 2014-08-02 20:36:50 -07:00
Mathias Svensson 8b975b2fb7 Added support for ssh port forwards in both directions 2014-08-02 20:30:51 -07:00
Mathias Svensson 652e7b4e36 Merge branch 'zachriggle-ssh-working-dir' 2014-08-02 18:00:11 -07:00
Mathias Svensson 8afebd1c9e Fixed up the pull request a bit 2014-08-02 17:58:40 -07:00
Zach Riggle b126f02851 Newline at OEF 2014-08-02 17:58:40 -07:00
Zach Riggle 36c56143e1 Fix incorrect doc 2014-08-02 17:58:40 -07:00
Zach Riggle de67736650 Squelch output from bad working directories; set_working_directory shows a warning 2014-08-02 17:58:40 -07:00
Zach Riggle c66d1ffcf2 No need for old_wd now that we "cd foo;" vs "cd foo &&" 2014-08-02 17:58:40 -07:00
Zach Riggle 413ee34750 Permit wd= arguments for run and run_to_end 2014-08-02 17:58:40 -07:00
Zach Riggle f2b2cfcbfc Move prepending 'cd %r' into the ssh_channel after the command has been printed, to prevent cluttering the screen 2014-08-02 17:58:40 -07:00
Zach Riggle f95c7bf9c9 Introduce ssh.set_working_directory 2014-08-02 17:58:40 -07:00
Mathias Svensson fa0f221533 Fixed up the pull request a bit 2014-08-02 17:57:34 -07:00
Mathias Svensson 7086ab2c77 Merge branch 'ssh-working-dir' of https://github.com/zachriggle/pwntools into zachriggle-ssh-working-dir 2014-08-02 17:35:45 -07:00
IdolfHatler f94aed066f Merge pull request #54 from zachriggle/mindfuck
Add <> for tubes, fix typo
2014-08-02 17:22:53 -07:00
Mathias Svensson 60910fb161 Minor optimizations to the tubes module 2014-08-02 17:22:01 -07:00
Morten Brøns-Pedersen c287b098a9 changed command line option from NOINFO to SILENT 2014-08-03 01:19:22 +02:00
Zach Riggle 576c2fe739 Add <> for tubes, fix type 2014-08-02 16:04:25 -07:00
Mathias Svensson 7a5ba94447 Fixed listen and added connect_* methods to tubes 2014-08-02 14:58:03 -07:00
Zach Riggle 1466c2e470 Newline at OEF 2014-08-02 14:37:52 -07:00
Zach Riggle 8d6188d1c2 Fix incorrect doc 2014-08-02 14:36:39 -07:00
Zach Riggle ae851c53c0 Squelch output from bad working directories; set_working_directory shows a warning 2014-08-02 14:36:02 -07:00
Zach Riggle 347d5ff08f No need for old_wd now that we "cd foo;" vs "cd foo &&" 2014-08-02 14:33:30 -07:00
Zach Riggle da60af4729 Permit wd= arguments for run and run_to_end 2014-08-02 14:28:05 -07:00
Zach Riggle 377e43689b Move prepending 'cd %r' into the ssh_channel after the command has been printed, to prevent cluttering the screen 2014-08-02 14:23:47 -07:00
Zach Riggle 12a2954770 Introduce ssh.set_working_directory 2014-08-02 14:19:28 -07:00
IdolfHatler 713eee3085 Merge pull request #52 from zachriggle/patch-5
Typo
2014-08-02 14:10:42 -07:00
Mathias Svensson df6192bc15 Made _raw_sh_string from tubes.ssh public and put it into util.misc 2014-08-02 14:09:47 -07:00
Zach Riggle b0cb561b94 Typo 2014-08-02 17:02:25 -04:00
Zach Riggle 45dee58e23 Single point for ldd, male ELF.libs and SSH.libs return consistent output of {full local path: ldd address} 2014-08-02 12:51:35 -07:00
Mathias Svensson 5e4b0d7cc6 Fixed typo 2014-08-02 11:36:08 -07:00
Mathias Svensson a4b6e886ca Fixed #48 2014-08-02 11:21:25 -07:00
Mathias Svensson e7b2552b1e Better links on readthedocs 2014-08-02 10:30:58 -07:00
Mathias Svensson 9c950d66cd Some more readthedocs 2014-08-02 10:21:23 -07:00
Mathias Svensson 82b22629cd Fixed #46 2014-08-02 08:17:59 -07:00
Mathias Svensson 37a2ad91cd version bump to 2.1.3 -- I really should have included this in 2.1.2 2014-08-02 00:13:42 -07:00
Mathias Svensson e2540c9f80 More readthedocs testing 2014-08-02 00:10:33 -07:00
Mathias Svensson 914b94131e Added the file docs/requirements.txt as a test for readthedocs 2014-08-02 00:08:32 -07:00
Robert Larsen 934b1d9112 Fixed arm targets. 2014-06-17 10:42:09 +02:00
Robert Larsen ce17e10f7e Added processor specific targets. Also targets for arm. 2014-06-17 10:39:59 +02:00
Robert Larsen 122530b874 Begin by making tarkets 2014-06-17 10:25:55 +02:00
Robert Larsen f9e7437e26 Added script that tests all targets.
Build non PIE binaries.
2014-06-17 10:21:06 +02:00
Robert Larsen 13c2aae045 Fixed regression. 2014-06-16 22:51:38 +02:00
Robert Larsen 5300a350c4 link_map can be found in both .got and .got.plt so if one is missing try
the other.
2014-05-27 15:43:46 +02:00
338 changed files with 63864 additions and 13799 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
pwnlib/data/* linguist-vendored
+2
View File
@@ -2,9 +2,11 @@
*.hi
*.pyc
*~
*.swp
*.pdf
*/auto/*
*/bin/*
docs/build
build
MANIFEST
dist
+4
View File
@@ -0,0 +1,4 @@
[settings]
indent=' '
not_skip = __init__.py
force_single_line = 1
+23
View File
@@ -0,0 +1,23 @@
sudo: false
language: python
cache:
- pip
- directories:
- usr
- /home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/
- /home/travis/virtualenv/python2.7.9/bin/
python:
- "2.7"
before_install:
- source .travis_ssh_setup.sh
- source .travis_install.sh
install:
- pip install -e .
- pip install -r docs/requirements.txt
before_script:
- python -c 'from pwn import *; print pwnlib.term.term_mode' NOTERM
- python -c 'from pwn import *; print pwnlib.term.term_mode' NOTERM
- python -c 'from pwn import *; print pwnlib.term.term_mode' NOTERM
- python -c 'from pwn import *; print pwnlib.term.term_mode' NOTERM
script: PWNLIB_NOTERM=1 make -C docs doctest
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
local_deb_extract()
{
wget $1
ar vx *.deb
tar xvf data.tar.gz
rm -f *.tar.gz *deb*
}
get_binutils()
{
BINUTILS_PREFIX='https://launchpad.net/~pwntools/+archive/ubuntu/binutils/+files/binutils-'
BINUTILS_SUFFIX='-linux-gnu_2.22-6ubuntu1.1cross0.11pwntools12~precise_amd64.deb'
local_deb_extract "${BINUTILS_PREFIX}${1}${BINUTILS_SUFFIX}"
}
setup_travis()
{
export PATH=$PWD/usr/bin:$PATH
export LD_LIBRARY_PATH=$PWD/usr/lib
if [ ! -d usr/bin ];
then
which arm-linux-as || get_binutils arm
which mips-linux-as || get_binutils mips
which powerpc-linux-as || get_binutils powerpc
local_deb_extract http://mirrors.mit.edu/ubuntu/ubuntu/pool/universe/b/binutils/binutils-multiarch_2.22-6ubuntu1_amd64.deb
rm -rf usr/share
fi
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
which arm-linux-gnu-as
which mips-linux-gnu-as
which powerpc-linux-gnu-as
}
setup_linux()
{
sudo apt-get install software-properties-common pwgen
sudo apt-add-repository --yes ppa:pwntools/binutils
sudo apt-get update
sudo apt-get install binutils-arm-linux-gnu binutils-mips-linux-gnu binutils-powerpc-linux-gnu
}
setup_osx()
{
brew update
brew install binutils
brew install capstone
}
if [[ "$TRAVIS" ]]; then
setup_travis
elif [[ "$(uname)" == "Darwin" ]]; then
setup_osx
elif [[ "$(uname)" == "Linux" ]]; then
setup_linux
fi
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
#
# Install a demo user for SSH purposes
#
U=travis
H=/home/$U
USUDO()
{
if [ "$TRAVIS" ];
then
$*
else
sudo -u $U $*
fi
}
if [ "$TRAVIS" ];
then
rm -f ~/.ssh/*
else
# Create the new user account
# Disable password login for the user, and ensure the account is not locked
sudo useradd -m $U
sudo passwd --delete --unlock $U
fi
# Generate a new key so that we can log into it
ssh-keygen -t rsa -f ~/.ssh/$U -N ''
# Load the public key into a memory for below
pubkey=$(cat ~/.ssh/$U.pub)
# Set the authorized_keys entry to only permit login from localhost,
# and only with
USUDO mkdir $H/.ssh
USUDO tee -a $H/.ssh/authorized_keys <<EOF
from="127.0.0.1" $pubkey
EOF
# In the pwntools examples, we ssh to 'example.pwnme'
# Set up an SSH config entry to make this actually work
cat >> ~/.ssh/config <<EOF
Host example.pwnme
User travis
HostName 127.0.0.1
IdentityFile ~/.ssh/$U
EOF
ssh-keyscan -t rsa example.pwnme >>~/.ssh/known_hosts
ssh -o "StrictHostKeyChecking no" -v [email protected] id
+26
View File
@@ -0,0 +1,26 @@
# Changelog
This changelog only includes added major features and changes. Bugfixes and
minor changes are omitted.
## 2.2.0
This was a large release with a lot of bugfixes and changes. Only the most significant
are mentioned here.
- Added shellcodes
- Added phd
- Re-added our expansion of itertools
- Added replacements for some semi-broken python standard library modules
- Re-implemented the rop module
- Added a serial tube
- Huge performance gains in the buffering for tubes
- Re-added user agents
- Begun using Travis CI with lots of test
- Removed bundled binutils in favor of documenting how to build them yourselves
- Added support for port forwarding though our SSH module
- Added dependency for capstone and ropgadget
- Added a lots of shellcodes
- Stuff we forgot
- Lots of documentation fixes
- Lots of bugfixes
+38
View File
@@ -0,0 +1,38 @@
# Contributing
We love pull requests!
Github has a great guide for contributing to open source projects:
- [Contributing to a project](https://guides.github.com/activities/forking/)
- [Fork the repository](https://guides.github.com/activities/forking/#fork)
- [Clone your fork](https://guides.github.com/activities/forking/#clone)
- [Making and pushing changes](https://guides.github.com/activities/forking/#making-changes)
- [Making a Pull Request](https://guides.github.com/activities/forking/#making-a-pull-request)
- [Huzzah!](https://guides.github.com/activities/forking/#huzzah)
## Pwntools Specifics
In general, we like to keep things documented. You should add documentation to any new functionality, and update it for any changed functionality. Our docstrings use the [Google Style Python Docstrings](https://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html#example-google).
After you have documentation, you should add a [doctest](https://docs.python.org/2/library/doctest.html).
Finally, it is probably a good idea to run the test suite locally before doing
the pull-request to make sure everything works, however this is not a
requirement.
Once you do the pull-request Travis CI will run the test-suite on it. Once it
passes one of the core developers will look at your pull request, possibly
comment on it and then hopefully merge it into master.
## Test Suite
To run the test suite, you should be running Ubuntu 12.04 or 14.04, and run the following commands. **Be aware** that this will add a user to your machine, and create a public key for SSH login!
```sh
bash .travis_install.sh
bash .travis_ssh_setup.sh
cd docs
pip install -r requirements.txt
make doctest
```
+1 -1
View File
@@ -13,7 +13,7 @@ directories:
- pwnlib/data/
Copyright (c) 2013 Gallopsled
Copyright (c) 2015 Gallopsled and Zach Riggle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+41 -20
View File
@@ -1,38 +1,59 @@
# Introduction
![pwntools logo](docs/source/logo.png?raw=true)
[![Docs latest](https://readthedocs.org/projects/pwntools/badge/)](https://pwntools.readthedocs.org/en/latest)
[![Docs 2.2.0](https://readthedocs.org/projects/pwntools/badge/?version=2.2.0)](https://pwntools.readthedocs.org/en/2.2.0)
[![PyPI](https://img.shields.io/pypi/v/pwntools.svg?style=flat)](https://pypi.python.org/pypi/pwntools/)
[![Gittip](https://img.shields.io/gittip/gallopsled.svg?style=flat)](https://www.gittip.com/gallopsled/)
[![Travis](https://travis-ci.org/Gallopsled/pwntools.svg)](https://travis-ci.org/Gallopsled/pwntools)
[![Twitter](https://img.shields.io/badge/twitter-Gallopsled-4099FF.svg?style=flat)](https://twitter.com/Gallopsled)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/)
This is the CTF framework used by Gallopsled in every CTF.
Most code is inside the pwnlib folder with some functionality inside pwn or
bin. It is typically used as:
```python
from pwn import *
context(arch = 'i386', os = 'linux')
# EXPLOIT HERE
r = remote('exploitme.example.com', 31337)
# EXPLOIT CODE GOES HERE
r.send(asm(shellcraft.sh()))
r.interactive()
```
However we have made command-line frontends for some of the functionality
inside the pwnlib. These are:
in `pwnlib`. These are:
* `asm`/`disasm`: Small wrapper for various assemblers
* `constgrep`: Tool for finding constants defined in header files
* `cyclic`: De Bruijn sequence generator and lookup tool
* `hex`/`unhex`: Command line tools for doing common hexing/unhexing operations
* `shellcraft`: Frontend to our shellcode
* `asm`/`disasm`: Small wrapper for various assemblers.
* `constgrep`: Tool for finding constants defined in header files.
* `cyclic`: De Bruijn sequence generator and lookup tool.
* `hex`/`unhex`: Command line tools for doing common hexing/unhexing operations.
* `shellcraft`: Frontend to our shellcode.
* `phd`: Replacement for `hexdump` with colors.
# Documentation
Our documentation is available on http://pwntools.readthedocs.org/
Our documentation is available at [pwntools.readthedocs.org](https://pwntools.readthedocs.org/en/latest/)
To get you started, we've provided some example solutions for past CTF challenges in our [write-ups repository](https://github.com/Gallopsled/pwntools-write-ups).
# Installation
Pwntools is available as a pip package. You can install it by running
`pip install pwntools`.
Alternatively if you prefer to have the latest version in git, you can
simply clone this repository, run `pip install -r requirements.txt`
and add entries in your `PATH` and `PYTHONPATH` variables. The script
`install_local.sh` will help you do so, in case you are using bash.
pwntools is best supported on Ubuntu 12.04 and 14.04, but most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).
Most of the functionality of pwntools is self-contained and Python-only. You should be able to get running quickly with
```sh
pip install pwntools
```
However, some of the features (ROP generation and assembling/disassembling foreign architectures) require non-Python dependencies. For more information, see the [complete installation instructions here](https://pwntools.readthedocs.org/en/latest/install.html).
# Contribution
See [CONTRIBUTING.md](CONTRIBUTING.md)
# Contact
If you have any questions not worthy of a bug report, feel free to join us
at `#gallopsled` on Freenode and ask away.
If you have any questions not worthy of a [bug report](https://github.com/Gallopsled/pwntools/issues), feel free to join us
at [`#pwntools` on Freenode](irc://irc.freenode.net/pwntools) and ask away.
Click [here](https://kiwiirc.com/client/irc.freenode.net/pwntools) to connect.
-59
View File
@@ -1,59 +0,0 @@
#!/usr/bin/env python2
import argparse, sys
from pwnlib.asm import asm
from pwnlib.context import __possible__ as contexts
from pwnlib.util.fiddling import enhex
parser = argparse.ArgumentParser(
description = 'Assemble shellcode into bytes'
)
parser.add_argument(
'lines',
metavar='line',
nargs='*',
help='Lines to assemble. If none are supplied, use stdin'
)
parser.add_argument(
"-f", "--format",
help="Output format (defaults to hex for ttys, otherwise raw)",
choices=['raw', 'hex', 'string']
)
parser.add_argument(
"-o","--output",
metavar='file',
help="Output file (defaults to stdout)",
type=argparse.FileType('w'),
default=sys.stdout
)
parser.add_argument(
'-c', '--context',
metavar = '<opt>',
choices = contexts['os'] + contexts['arch'],
default = ['i386','linux'],
action = 'append',
help = 'The os/architecture the shellcode will run in (default: linux/i386), choose from: %s' % \
', '.join(contexts['os'] + contexts['arch'])
)
args = parser.parse_args()
tty = args.output.isatty()
for arch in args.context[::-1]:
if arch in contexts['arch']: break
for os in args.context[::-1]:
if os in contexts['os']: break
data = '\n'.join(args.lines) or sys.stdin.read()
output = asm(data.replace(';', '\n'), arch = arch, os = os)
fmt = args.format or ('hex' if tty else 'raw')
formatters = {'r':str, 'h':enhex, 's':repr}
args.output.write(formatters[fmt[0]](output))
if tty and fmt is not 'raw':
args.output.write('\n')
-136
View File
@@ -1,136 +0,0 @@
#!/usr/bin/env python2
import argparse, sys, os, types, re
from pwnlib import asm, util, constants
from pwnlib.util import safeeval
from pwnlib.context import __possible__ as contexts
p = argparse.ArgumentParser(
description = "Looking up constants from header files.\n\nExample: constgrep -c freebsd -m ^PROT_ '3 + 4'",
formatter_class = argparse.RawDescriptionHelpFormatter,
)
group = p.add_mutually_exclusive_group()
group.add_argument(
'-e', '--exact',
metavar = '<constant name>',
# nargs = 1,
default = None,
help = 'Do an exact match for a constant instead of searching for a regex',
)
group.add_argument(
'regex',
nargs = '?',
default = '',
help = 'The regex matching constant you want to find',
)
p.add_argument(
'constant',
nargs = '?',
default = None,
help = 'The constant to find',
)
p.add_argument(
'-i', '--case-insensitive',
action = 'store_true',
help = 'Search case insensitive',
)
p.add_argument(
'-m', '--mask-mode',
action = 'store_true',
help = 'Instead of searching for a specific constant value, search for values not containing strictly less bits that the given value.',
)
p.add_argument(
'-c', '--context',
metavar = '<opt>',
choices = contexts['os'] + contexts['arch'],
default = ['i386','linux'],
action = 'append',
help = 'The os/architecture to find constants for (default: linux/i386), choose from: %s' % \
', '.join(dir(constants) + dir(constants.linux))
)
args = p.parse_args()
# Find the architecture and os from the list of contexts
for arch in args.context[::-1]:
if arch in contexts['arch']: break
for os in args.context[::-1]:
if os in contexts['os']: break
if args.exact:
# This is the simple case
print asm.cpp(args.exact, os = os, arch = arch).strip()
else:
# New we search in the right module.
# But first: We find the right module
if os == 'freebsd':
mod = constants.freebsd
else:
mod = getattr(getattr(constants, os), arch)
# Compile the given regex, for optimized lookup
if args.case_insensitive:
matcher = re.compile(args.regex, re.IGNORECASE)
else:
matcher = re.compile(args.regex)
# Evaluate the given constant
if args.constant:
constant = safeeval.expr_eval(args.constant)
else:
constant = None
# The found matching constants and the length of the longest string
out = []
maxlen = 0
for k in dir(mod):
# No python stuff
if k.endswith('__') and k.startswith('__'):
continue
# Run the regex
if not matcher.search(k):
continue
# Check the constant
if constant != None:
val = getattr(mod, k)
if args.mask_mode:
if constant & val != val:
continue
else:
if constant != val:
continue
# Append it
out.append((getattr(mod, k), k))
maxlen = max(len(k), maxlen)
# Output all matching constants
for _, k in sorted(out):
print '#define %s %s' % (k.ljust(maxlen), asm.cpp(k, os = os, arch = arch).strip())
# If we are in match_mode, then try to find a combination of
# constants that yield the exact given value
# We do not want to find combinations using the value 0.
if not (constant == None or constant == 0) and args.mask_mode:
mask = constant
good = []
out = [(v, k) for v, k in out if v != 0]
while mask and out:
cur = out.pop()
mask &= ~cur[0]
good.append(cur)
out = [(v, k) for v, k in out if mask & v == v]
if reduce(lambda x, cur: x | cur[0], good, 0) == constant:
print
print '(%s) == %s' % (' | '.join(k for v, k in good), args.constant)
-69
View File
@@ -1,69 +0,0 @@
#!/usr/bin/env python2
import argparse, string
from pwnlib.util import cyclic, packing
from pwnlib import log
parser = argparse.ArgumentParser(
description = "Cyclic pattern creator/finder"
)
parser.add_argument(
'-a', '--alphabet',
metavar = 'alphabet',
default = string.ascii_lowercase,
help = 'The alphabet to use in the cyclic pattern (defaults to all lower case letters)',
)
parser.add_argument(
'-n', '--length',
metavar = 'length',
default = 4,
type = int,
help = 'Size of the unique subsequences (defaults to 4).'
)
group = parser.add_mutually_exclusive_group(required = True)
group.add_argument(
'-l', '-o', '--offset', '--lookup',
metavar = '<lookup value>',
help = 'Do a lookup instead printing the alphabet',
)
group.add_argument(
'count',
type = int,
nargs = '?',
help = 'Number of characters to print'
)
args = parser.parse_args()
alphabet = args.alphabet
subsize = args.length
if args.lookup:
pat = args.lookup
if pat.startswith('0x'):
pat = packing.pack(int(pat[2:], 16), subsize*8, 'little', 'unsigned')
elif pat.isdigit():
pat = packing.pack(int(pat, 10), subsize*8, 'little', 'unsigned')
if len(pat) != 4:
log.fatal('Subpattern must be 4 bytes', 1)
if not all(c in alphabet for c in pat):
log.fatal('Pattern contains characters not present in the alphabet', 1)
offset = cyclic.cyclic_find(pat, alphabet, subsize)
if offset == -1:
log.fatal('Given pattern does not exist in cyclic pattern', 1)
else:
print offset
else:
want = args.count
result = cyclic.cyclic(want, alphabet, subsize)
got = len(result)
if got < want:
log.failure("Alphabet too small (max length = %i)" % got)
print result
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/env python2
import argparse, sys
from pwnlib import asm, context
from string import whitespace, hexdigits
parser = argparse.ArgumentParser(
description = 'Disassemble bytes into text format'
)
parser.add_argument(
'hex',
metavar = 'hex',
nargs = '*',
help = 'Hex-string to disasemble. If none are supplied, then it uses stdin in non-hex mode.'
)
parser.add_argument(
'-c', '--context',
metavar = '<opt>',
choices = context.__possible__['arch'],
default = 'i386',
help = 'The architecture of the shellcode (default: i386), choose from:\n%s' % ', '.join(context.__possible__['arch'])
)
args = parser.parse_args()
if len(args.hex) > 0:
dat = ''.join(args.hex)
dat = dat.translate(None, whitespace)
if not set(hexdigits) >= set(dat):
print "This is not a hex string"
exit(-1)
dat = dat.decode('hex')
else:
dat = sys.stdin.read()
print asm.disasm(dat, arch = args.context)
-7
View File
@@ -1,7 +0,0 @@
#!/usr/bin/env python2
import sys
if len(sys.argv) == 1:
print sys.stdin.read().encode('hex')
else:
print ' '.join(sys.argv[1:]).encode('hex')
-173
View File
@@ -1,173 +0,0 @@
#!/usr/bin/env python2
import argparse, sys, os, types
import pwnlib
from pwnlib import asm, log, util
from pwnlib.context import __possible__ as contexts
import pwnlib.term.text as text
r = text.red
g = text.green
b = text.blue
banner = '\n'.join([' ' + r('____') + ' ' + g('_') + ' ' + r('_') + ' ' + g('_') + ' ' + b('__') + ' ' + r('_'),
' ' + r('/ ___|') + g('| |__') + ' ' + b('___') + r('| |') + ' ' + g('|') + ' ' + b('___') + ' ' + r('_ __') + ' ' + g('__ _') + ' ' + b('/ _|') + ' ' + r('|_'),
' ' + r('\___ \\') + g('| \'_ \\') + ' ' + b('/ _ \\') + ' ' + r('|') + ' ' + g('|') + b('/ __|') + ' ' + r('\'__/') + ' ' + g('_` |') + ' ' + b('|_') + r('| __|'),
' ' + r('___) |') + ' ' + g('| | |') + ' ' + b('__/') + ' ' + r('|') + ' ' + g('|') + ' ' + b('(__') + r('| |') + ' ' + g('| (_| |') + ' ' + b('_|') + ' ' + r('|_'),
' ' + r('|____/') + g('|_| |_|') + b('\\___|') + r('_|') + g('_|') + b('\\___|') + r('_|') + ' ' + g('\\__,_|') + b('_|') + ' ' + r('\\__|'),
''
])
# ____ _ _ _ __ _
# / ___|| |__ ___| | | ___ _ __ __ _ / _| |_
# \___ \| '_ \ / _ \ | |/ __| '__/ _` | |_| __|
# ___) | | | | __/ | | (__| | | (_| | _| |_
# |____/|_| |_|\___|_|_|\___|_| \__,_|_| \__|
def _string(s):
out = []
for c in s:
co = ord(c)
if co >= 0x20 and co <= 0x7e and c not in '/$\'"`':
out.append(c)
else:
out.append('\\x%02x' % co)
return '"' + ''.join(out) + '"\n'
def _carray(s):
out = []
for c in s:
out.append('0x' + util.fiddling.enhex(c))
return '{' + ', '.join(out) + '};\n'
def _hex(s):
return pwnlib.util.fiddling.enhex(s) + '\n'
p = argparse.ArgumentParser(
description = banner + '\nMicrowave shellcode -- Easy, fast and delicious',
formatter_class = argparse.RawDescriptionHelpFormatter,
)
p.add_argument(
'shellcode',
nargs = '?',
default = '',
metavar = '<shellcode>',
help = 'The shellcode you want',
)
p.add_argument(
'args',
nargs = '*',
metavar = '<arg>',
default = (),
help = 'Argument to the chosen shellcode',
)
p.add_argument(
'-?', '--show',
action = 'store_true',
help = 'Show shellcode documentation',
)
p.add_argument(
'-o', '--out',
metavar = '<file>',
type = argparse.FileType('w'),
default = sys.stdout,
help = 'Output file (default: stdout)',
)
p.add_argument(
'-f', '--format',
metavar = '<format>',
choices = ['r', 'raw',
's', 'str', 'string',
'c',
'h', 'hex',
'a', 'asm', 'assembly',
'p',
'i', 'hexii'],
default = 'hex',
help = 'Output format (default: hex), choose from {r}aw, {s}tring, {c}-style array, {h}ex string, hex{i}i, {a}ssembly code, {p}reprocssed code',
)
args = p.parse_args()
def get_tree(path, val, result):
if path:
path += '.'
if path.startswith('common.'):
return
mods = []
for k in sorted(dir(val)):
if k and k[0] != '_':
cur = getattr(val, k)
if isinstance(cur, types.ModuleType):
mods.append((path + k, cur))
else:
result.append((path + k, cur))
for path, val in mods:
get_tree(path, val, result)
return result
vals = get_tree('', pwnlib.shellcraft, [])
if args.shellcode:
vals = [(k, val) for k, val in vals if k.startswith(args.shellcode + '.') or k == args.shellcode]
if len(vals) == 0:
log.fatal("Cannot find subtree by the name of %r" % args.shellcode)
elif len(vals) > 1:
for k, _ in vals:
print k
exit()
else:
func = vals[0][1]
if args.show:
print func.__doc__
exit()
defargs = len(func.func_defaults or ())
reqargs = func.func_code.co_argcount - defargs
if len(args.args) < reqargs:
if defargs > 0:
log.fatal('%s takes at least %d arguments' % (args.shellcode, reqargs))
else:
log.fatal('%s takes exactly %d arguments' % (args.shellcode, reqargs))
# Captain uglyness saves the day!
for i in range(len(args.args)):
if args.args[i] in ['False', 'false']:
args.args[i] = False
# And he strikes again!
os = arch = None
for k in args.shellcode.split('.')[:-1]:
if k in contexts['arch']:
arch = k
elif k in contexts['os']:
os = k
code = func(*args.args)
if args.format in ['a', 'asm', 'assembly']:
print code
exit()
if args.format == 'p':
print pwnlib.asm.cpp(code, arch = arch, os = os)
exit()
code = pwnlib.asm.asm(code, arch = arch, os = os)
if args.format in ['s', 'str', 'string']:
code = _string(code)
elif args.format == 'c':
code = _carray(code)
elif args.format in ['h', 'hex']:
code = _hex(code)
elif args.format in ['i', 'hexii']:
code = pwnlib.util.fiddling.hexii(code) + '\n'
sys.stdout.write(code)
-11
View File
@@ -1,11 +0,0 @@
#!/usr/bin/env python2
import sys
from string import whitespace
try:
if len(sys.argv) == 1:
s = sys.stdin.read().translate(None, whitespace)
sys.stdout.write(s.decode('hex'))
else:
sys.stdout.write(''.join(sys.argv[1:]).decode('hex'))
except TypeError, e:
sys.stderr.write(str(e) + '\n')
+1
View File
@@ -1 +1,2 @@
build
robots.txt
Regular → Executable
+10 -1
View File
@@ -6,6 +6,8 @@ SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
DASHBUILD = ./dashbuild.py
TAR = tar
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
@@ -14,7 +16,8 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) sou
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext dash
help:
@echo "Please use \`make <target>' where <target> is one of"
@@ -34,6 +37,7 @@ help:
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " dash to make a Dash docset"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@@ -136,6 +140,11 @@ gettext:
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
dash:
$(DASHBUILD) source $(BUILDDIR)/dash
$(TAR) --exclude='.DS_Store' -cvzf $(BUILDDIR)/dash/pwntools.tgz -C $(BUILDDIR)/dash pwntools.docset
@echo "Build finished. The Dash docset is in $(BUILDDIR)/dash."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Helper to build Dash docset from sphinx source files.
#
# Dash docsets can be read by various applications:
#
# Dash OS X, iOS https://kapeli.com
# Zeal Linux, Windows https://zealdocs.org
# Velocity Windows http://velocity.silverlakesoftware.com
# LovelyDocs Android http://lovelydocs.io
# dasht POSIX https://github.com/sunaku/dasht
# Helm Dash emacs https://github.com/areina/helm-dash
#
import argparse
import doc2dash.__main__
import os, os.path
import sphinx
import sqlite3
import sys
sys.path.append(os.path.abspath(os.path.join('..', 'pwnlib')))
import version
def main(args):
"""Generate a Dash docset from Sphinx source files."""
srcdir = args.srcdir
dstdir = args.dstdir
name = args.name
if not os.path.exists(dstdir):
os.makedirs(dstdir)
# Generate HTML without indices.
sphinx.build_main([ "sphinx-build", "-b", "html", "-d", os.path.join(dstdir, "doctrees"), \
"-t", "dash", srcdir, os.path.join(dstdir, "html") ])
# Convert to docset.
try:
doc2dash.__main__.main.main( \
[ os.path.join(dstdir, "html"), "-d", dstdir, "-n", name, \
"-f", "-I", "index.html"], "doc2dash", False)
except SystemExit,e:
pass
# Insert a link to the online version.
online = args.online
if online is not None and online != "":
url = online.replace("@VERSION", args.version)
with open(os.path.join(dstdir, name+".docset", "Contents", "Info.plist"), "r+") as f_info:
pl = f_info.read()
pl = pl.replace("</dict>", \
"\t<key>DashDocSetFallbackURL</key>\n\t<string>%s</string>\n</dict>" % url)
f_info.seek(0)
f_info.write(pl)
f_info.truncate()
# Modify the CSS to hide the menu included in the HTML.
with open(os.path.join(dstdir, name+".docset", "Contents", "Resources", "Documents", "_static", "css", "theme.css"), "r+") as f_css:
css = f_css.read()
css = css.replace( \
'@media screen and (max-width: 768px){.wy-body-for-nav{background:#fcfcfc}.wy-nav-top{display:block}',\
'@media screen {.wy-body-for-nav{background:#fcfcfc}' )
css = css.replace( \
'@media screen and (max-width: 480px)', \
'@media screen ')
f_css.seek(0)
f_css.write(css)
f_css.truncate()
# Modify the index
db_conn = sqlite3.connect(os.path.join(dstdir, name+".docset", "Contents", "Resources", "docSet.dsidx"))
try:
db_conn.execute('INSERT INTO "searchIndex" ("name","type","path") VALUES ' \
'("1 Contents", "Guide", "index.html"), ' \
'("2 About pwntools", "Guide", "about.html"), ' \
'("3 Installation", "Guide", "install.html"), ' \
'("4 Getting Started", "Guide", "intro.html"), ' \
'("5 Globals (pwn)", "Guide", "globals.html"), ' \
'("6 Command Line Tools", "Guide", "commandline.html")')
db_conn.execute('DELETE FROM "searchIndex" WHERE "type" = "Module" AND ("name" = "pwn" OR "name" = "pwnlib")')
db_conn.commit()
finally:
db_conn.close()
return 0
parser = argparse.ArgumentParser()
parser.add_argument("--name", help="docset name", default="pwntools")
parser.add_argument("--online", help="URL for online docs", default="https://pwntools.readthedocs.org/en/@VERSION/")
parser.add_argument("--version", help="pwntools version", default=version.__version__)
parser.add_argument("srcdir", help="Source directory containing .rst files")
parser.add_argument("dstdir", help="Destination and working directory")
main(parser.parse_args())
+8
View File
@@ -0,0 +1,8 @@
paramiko
argparse
mako
pyelftools
sphinxcontrib-napoleon
sphinxcontrib-autoprogram
sphinx_rtd_theme
doc2dash
+56
View File
@@ -0,0 +1,56 @@
About pwntools
========================
Whether you're using it to write exploits, or as part
of another software project will dictate how you use it.
Historically pwntools was used as a sort of exploit-writing DSL. Simply doing
``from pwn import *`` in a previous version of pwntools would bring all sorts of
nice side-effects.
When redesigning pwntools for 2.0, we noticed two contrary goals:
* We would like to have a "normal" python module structure, to allow other
people to familiarize themselves with pwntools quickly.
* We would like to have even more side-effects, especially by putting the
terminal in raw-mode.
To make this possible, we decided to have two different modules. :mod:`pwnlib`
would be our nice, clean Python module, while :mod:`pwn` would be used during
CTFs.
:mod:`pwn` --- Toolbox optimized for CTFs
-----------------------------------------
.. module:: pwn
As stated, we would also like to have the ability to get a lot of these
side-effects by default. That is the purpose of this module. It does
the following:
* Imports everything from the toplevel :mod:`pwnlib` along with
functions from a lot of submodules. This means that if you do
``import pwn`` or ``from pwn import *``, you will have access to
everything you need to write an exploit.
* Calls :func:`pwnlib.term.init` to put your terminal in raw mode
and implements functionality to make it appear like it isn't.
* Setting the :data:`pwnlib.context.log_level` to `"info"`.
* Tries to parse some of the values in :data:`sys.argv` and every
value it succeeds in parsing it removes.
:mod:`pwnlib` --- Normal python library
---------------------------------------
.. module:: pwnlib
This module is our "clean" python-code. As a rule, we do not think that
importing :mod:`pwnlib` or any of the submodules should have any significant
side-effects (besides e.g. caching).
For the most part, you will also only get the bits you import. You for instance
not get access to :mod:`pwnlib.util.packing` simply by doing ``import
pwnlib.util``.
Though there are a few exceptions (such as :mod:`pwnlib.shellcraft`), that does
not quite fit the goals of being simple and clean, but they can still be
imported without implicit side-effects.
+6
View File
@@ -1,6 +1,12 @@
.. testsetup:: *
import tempfile
import os
from pwnlib.context import context
from pwnlib.asm import *
from pwnlib import shellcraft
from pwnlib.tubes.process import process
:mod:`pwnlib.asm` --- Assembler functions
=========================================
+5
View File
@@ -0,0 +1,5 @@
:mod:`pwnlib.atexception` --- Callbacks on unhandled exception
==============================================================
.. automodule:: pwnlib.atexception
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`pwnlib.atexit` --- Replacement for atexit
===============================================
.. automodule:: pwnlib.atexit
:members:
+46
View File
@@ -0,0 +1,46 @@
.. testsetup:: *
from pwn import *
old = context.defaults.copy()
.. testcleanup:: *
context.defaults.copy = old
Command Line Tools
========================
pwntools comes with a handful of useful command-line utilities which serve as wrappers for some of the internal functionality.
.. toctree::
.. autoprogram:: pwnlib.commandline.asm:parser
:prog: asm
.. autoprogram:: pwnlib.commandline.constgrep:p
:prog: constgrep
.. autoprogram:: pwnlib.commandline.cyclic:parser
:prog: cyclic
.. autoprogram:: pwnlib.commandline.disasm:parser
:prog: disasm
.. autoprogram:: pwnlib.commandline.elfdiff:p
:prog: elfdiff
.. autoprogram:: pwnlib.commandline.elfpatch:p
:prog: elfpatch
.. autoprogram:: pwnlib.commandline.hex:parser
:prog: hex
.. autoprogram:: pwnlib.commandline.phd:parser
:prog: phd
.. autoprogram:: pwnlib.commandline.shellcraft:p
:prog: shellcraft
.. autoprogram:: pwnlib.commandline.unhex:parser
:prog: unhex
Regular → Executable
+50 -26
View File
@@ -11,7 +11,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import os
import subprocess
import sys
build_dash = tags.has('dash')
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -31,22 +35,23 @@ extensions = [
'sphinx.ext.doctest',
'sphinx.ext.linkcode',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.todo',
'sphinx.ext.intersphinx',
'sphinxcontrib.autoprogram',
'sphinxcontrib.napoleon'
]
try:
import sphinxcontrib.napoleon
extensions.append('sphinxcontrib.napoleon')
except ImportError:
pass
doctest_global_setup = '''
import pwnlib
pwnlib.context.reset_local()
import pwnlib, sys
pwnlib.context.context.reset_local()
pwnlib.context.ContextType.defaults['log_level'] = 'ERROR'
pwnlib.term.text.when = 'never'
pwnlib.log.install_default_handler()
pwnlib.log.console.stream = sys.stdout
'''
autodoc_member_order = 'bysource'
autodoc_member_order = 'alphabetical'
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -57,7 +62,7 @@ doctest_test_doctest_blocks = True
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
@@ -161,10 +166,10 @@ html_static_path = []
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
html_domain_indices = not build_dash
# If false, no index is generated.
#html_use_index = True
html_use_index = not build_dash
# If true, the index is split into individual pages for each letter.
#html_split_index = False
@@ -210,7 +215,8 @@ latex_documents = [
u'Gallopsled et al', 'manual'),
]
intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None)}
intersphinx_mapping = {'python': ('https://docs.python.org/2.7', None),
'paramiko': ('https://paramiko-docs.readthedocs.org/en/1.15/', None)}
# The name of an image file (relative to this directory) to place at the top of
# the title page.
@@ -266,6 +272,19 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
branch = release
try:
git_branch = subprocess.check_output('git describe --tags', shell = True)
except subprocess.CalledProcessError:
git_branch = '-'
try:
if '-' in git_branch:
branch = subprocess.check_output('git rev-parse HEAD', shell = True).strip()[:10]
except subprocess.CalledProcessError:
pass
def linkcode_resolve(domain, info):
if domain != 'py':
return None
@@ -290,21 +309,26 @@ def linkcode_resolve(domain, info):
else:
filename = info['module'].replace('.', '/') + '.py'
# Fixup for context properties
if info['module'].startswith('pwnlib.context'):
filename = 'pwnlib/context.py'
if not isinstance(val, (types.FunctionType, types.MethodType)):
import pwnlib.context.defaults
val = getattr(pwnlib.context.defaults.__class__, info['fullname'], None)
if isinstance(val, property):
val = val.fget
val = getattr(val, '_inner', val)
if isinstance(val, (types.ModuleType, types.ClassType, types.MethodType, types.FunctionType, types.TracebackType, types.FrameType, types.CodeType)):
try:
lines, first = inspect.getsourcelines(val)
filename += '#L%d-%d' % (first, first + len(lines) - 1)
except IOError:
pass
return "https://github.com/Gallopsled/pwntools/blob/%s/%s" % (release, filename)
return "https://github.com/Gallopsled/pwntools/blob/%s/%s" % (branch, filename)
# The readthedocs theme is used by the Dash generator. (Can be used for HTML too.)
if build_dash:
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
+2 -1
View File
@@ -1,6 +1,7 @@
.. testsetup:: *
from pwnlib import context, constants
from pwnlib import constants
from pwnlib.context import context
:mod:`pwnlib.constants` --- Easy access to header file constants
================================================================
+7 -40
View File
@@ -1,49 +1,16 @@
.. testsetup:: *
from pwnlib import context
import pwnlib
from pwnlib.context import context
import threading, logging
:mod:`pwnlib.context` --- Setting runtime variables
=====================================================
.. autodata:: pwnlib.context.context
:mod:`pwnlib.context`
---------------------
.. autoclass:: pwnlib.context.ContextType
:members:
.. automodule:: pwnlib.context
.. exec::
import pwnlib
from inspect import cleandoc
mod = pwnlib.context.defaults.__class__
for key in sorted(dir(mod)):
val = getattr(mod, key)
if isinstance(val, property):
print ".. data:: " + key
print ""
print cleandoc(val.__doc__)
print ""
.. autofunction:: pwnlib.context.__call__(**kwargs)
.. autofunction:: pwnlib.context.local(**kwargs)
.. autofunction:: pwnlib.context.reset_local()
:mod:`pwnlib.context.defaults`
------------------------------
.. automodule:: pwnlib.context.defaults
.. exec::
import pwnlib
mod = pwnlib.context.defaults.__class__
for key in sorted(dir(mod)):
val = getattr(mod, key)
if isinstance(val, property):
print ".. data:: " + key
print ""
print "This is the global version of :data:`pwnlib.context.%s`." % key
print
.. autofunction:: pwnlib.context.defaults.__call__(**kwargs)
.. autoclass:: pwnlib.context.Thread
+1
View File
@@ -1,6 +1,7 @@
.. testsetup:: *
from pwnlib.elf import *
from pwnlib.util.misc import which
:mod:`pwnlib.elf` --- Working with ELF binaries
===============================================
+102
View File
@@ -0,0 +1,102 @@
.. testsetup:: *
from pwn import *
``from pwn import *``
========================
The most common way that you'll see pwntools used is
>>> from pwn import *
Which imports a bazillion things into the global namespace to make your life easier.
This is a quick list of most of the objects and routines imported, in rough order of importance and frequency of use.
- ``context``
- :data:`pwnlib.context.context`
- Responsible for most of the pwntools convenience settings
- Set `context.log_level = 'debug'` when troubleshooting your exploit
- Scope-aware, so you can disable logging for a subsection of code via ``pwnlib.context.ContextType.local``
- ``remote``, ``listen``, ``ssh``, ``process``
- :mod:`pwnlib.tubes`
- Super convenient wrappers around all of the common functionality for CTF challenges
- Connect to anything, anywhere, and it works the way you want it to
- Helpers for common tasks like ``recvline``, ``recvuntil``, ``clean``, etc.
- Interact directly with the application via ``.interactive()``
- ``p32`` and ``u32``
- :mod:`pwnlib.util.packing`
- Useful functions to make sure you never have to remember if ``'>'`` means signed or unsigned for ``struct.pack``, and no more ugly ``[0]`` index at the end.
- Set ``signed`` and ``endian`` in sane manners (also these can be set once on ``context`` and not bothered with again)
- Most common sizes are pre-defined (``u8``, ``u64``, etc), and :func:`pwnlib.util.packing.pack` lets you define your own.
- ``log``
- :mod:`pwnlib.log`
- Make your output pretty!
- ``cyclic`` and ``cyclic_func``
- :mod:`pwnlib.util.cyclic`
- Utilities for generating strings such that you can find the offset of any given substring given only N (usually 4) bytes. This is super useful for straight buffer overflows. Instead of looking at 0x41414141, you could know that 0x61616171 means you control EIP at offset 64 in your buffer.
- ``asm`` and ``disasm``
- :mod:`pwnlib.asm`
- Quickly turn assembly into some bytes, or vice-versa, without mucking about
- Supports any architecture for which you have a binutils installed
- Over 20 different architectures have pre-built binaries at `ppa:pwntools/binutils <https://launchpad.net/~pwntools/+archive/ubuntu/binutils>`_.
- ``shellcraft``
- :mod:`pwnlib.shellcraft`
- Library of shellcode ready to go
- ``asm(shellcraft.sh())`` gives you a shell
- Templating library for reusability of shellcode fragments
- ``ELF``
- :mod:`pwnlib.elf`
- ELF binary manipulation tools, including symbol lookup, virtual memory to file offset helpers, and the ability to modify and save binaries back to disk
- ``DynELF``
- :mod:`pwnlib.dynelf`
- Dynamically resolve functions given only a pointer to any loaded module, and a function which can leak data at any address
- ``ROP``
- :mod:`pwnlib.rop`
- Automatically generate ROP chains using a DSL to describe what you want to do, rather than raw addresses
- ``gdb.debug`` and ``gdb.attach``
- :mod:`pwnlib.gdb`
- Launch a binary under GDB and pop up a new terminal to interact with it. Automates setting breakpoints and makes iteration on exploits MUCH faster.
- Alternately, attach to a running process given a PID, ``pwnlib.tubes`` object, or even just a socket that's connected to it
- ``args``
- Dictionary contining all-caps command-line arguments for quick access
- Run via ``python foo.py REMOTE=1`` and ``args['REMOTE'] == '1'``.
- Can also control logging verbosity and terminal fancyness
- `NOTERM`
- `SILENT`
- `DEBUG`
- ``randoms``, ``rol``, ``ror``, ``xor``, ``bits``
- :mod:`pwnlib.util.fiddling`
- Useful utilities for generating random data from a given alphabet, or simplifying math operations that usually require masking off with `0xffffffff` or calling `ord` and `chr` an ugly number of times
- ``net``
- :mod:`pwnlib.util.net`
- Routines for querying about network interfaces
- ``proc``
- :mod:`pwnlib.util.proc`
- Routines for querying about processes
- ``pause``
- It's the new ``getch``
- ``safeeval``
- :mod:`pwnlib.util.safeeval`
- Functions for safely evalutaing python code without nasty side-effects.
These are all pretty self explanatory, but are useful to have in the global namespace.
- ``hexdump``
- ``read`` and ``write``
- ``enhex`` and ``unhex``
- ``more``
- ``group``
- ``align`` and ``align_down``
- ``urlencode`` and ``urldecode``
- ``which``
- ``wget``
Additionally, all of the following modules are auto-imported for you. You were going to do it anyway.
- ``os``
- ``sys``
- ``time``
- ``requests``
- ``re``
- ``random``
Regular → Executable
+38 -8
View File
@@ -1,14 +1,36 @@
Welcome to pwntools's documentation!
pwntools
====================================
Contents:
``pwntools`` is a CTF framework and exploit development library.
Written in Python, it is designed for rapid prototyping and development,
and intended to make exploit writing as simple as possible.
Getting Started
---------------
.. toctree::
:maxdepth: 3
:glob:
about
install
intro
globals
commandline
Module Index
------------
Each of the ``pwntools`` modules is documented here.
.. toctree::
:maxdepth: 1
:glob:
asm
atexception
atexit
constants
context
dynelf
@@ -17,15 +39,23 @@ Contents:
gdb
log
memleak
tubes
replacements
rop
shellcraft
shellcraft/*
term
timeout
tubes
tubes/*
ui
useragents
util/*
Indices and tables
==================
.. only:: not dash
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
+40
View File
@@ -0,0 +1,40 @@
Installation
============
pwntools is best supported on Ubuntu 12.04 and 14.04, but most
functionality should work on any Posix-like distribution (Debian, Arch,
FreeBSD, OSX, etc.).
Prerequisites
-------------
In order to get the most out of ``pwntools``, you should have the
following system libraries installed.
.. toctree::
:maxdepth: 3
:glob:
install/*
Released Version
-----------------
Pwntools is available as a ``pip`` package.
.. code-block:: bash
$ apt-get install python2.7 python2.7-dev python-pip
$ pip install pwntools
Latest Version
--------------
Alternatively if you prefer to use the latest version from the
repository, pip can install directly from github.
.. code-block:: bash
$ pip install git+https://github.com/Gallopsled/pwntools#egg=pwntools
.. _Ubuntu: https://launchpad.net/~pwntools/+archive/ubuntu/binutils
+84
View File
@@ -0,0 +1,84 @@
Binutils
-------------
Assembly of foreign architectures (e.g. assembling Sparc shellcode on
Mac OS X) requires cross-compiled versions of ``binutils`` to be
installed. We've made this process as smooth as we can.
In these examples, replace ``$ARCH`` with your target architecture (e.g., arm, mips64, vax, etc.).
Building `binutils` from source takes about 60 seconds on a modern 8-core machine.
Ubuntu
^^^^^^^^^^^^^^^^
First, add our `Personal Package Archive repository <http://binutils.pwntools.com>`__.
.. code-block:: bash
$ apt-get install software-properties-common
$ apt-add-repository ppa:pwntools/binutils
$ apt-get update
Then, install the binutils for your architecture.
.. code-block:: bash
$ apt-get install binutils-$ARCH-linux-gnu
Mac OS X
^^^^^^^^^^^^^^^^
Mac OS X is just as easy, but requires building binutils from source.
However, we've made ``homebrew`` recipes to make this a single command.
After installing `brew <http://brew.sh>`__, grab the appropriate
recipe from our `binutils
repo <https://github.com/Gallopsled/pwntools-binutils/>`__.
.. code-block:: bash
$ brew install https://raw.githubusercontent.com/Gallopsled/pwntools-binutils/master/osx/binutils-$ARCH.rb
Alternate OSes
^^^^^^^^^^^^^^^^
If you want to build everything by hand, or don't use any of the above
OSes, ``binutils`` is simple to build by hand.
.. code-block:: bash
#!/usr/bin/env bash
V=2.25 # Binutils Version
ARCH=arm # Target architecture
cd /tmp
wget -nc https://ftp.gnu.org/gnu/binutils/binutils-$V.tar.gz
wget -nc https://ftp.gnu.org/gnu/binutils/binutils-$V.tar.gz.sig
gpg --keyserver keys.gnupg.net --recv-keys 4AE55E93
gpg --verify binutils-$V.tar.gz.sig
rm -rf binutils-*
tar xf binutils-$V.tar.gz
mkdir binutils-build
cd binutils-build
export AR=ar
export AS=as
../binutils-$V/configure \
--prefix=/usr/local \
--target=$ARCH-unknown-linux-gnu \
--disable-static \
--disable-multilib \
--disable-werror \
--disable-nls
MAKE=gmake
hash gmake || MAKE=make
$MAKE -j
sudo $MAKE install
+18
View File
@@ -0,0 +1,18 @@
Python Development Headers
-----------------------------
Some of pwntools' Python dependencies require native extensions (for example, Paramiko requires PyCrypto).
In order to build these native extensions, the development headers for Python must be installed.
Ubuntu
^^^^^^^^^^^^^^^^
.. code-block:: bash
$ apt-get install python-dev
Mac OS X
^^^^^^^^^^^^^^^^
No action needed.
+207 -39
View File
@@ -1,53 +1,221 @@
Introduction to pwntools
.. testsetup:: *
from pwn import *
Getting Started
========================
Historically pwntools was used as a sort of exploit-writing DSL. Simply doing
``from pwn import *`` in a previous version of pwntools would bring all sorts of
nice side-effects.
To get your feet wet with pwntools, let's first go through a few examples.
When redesigning pwntools for 2.0, we noticed two contrary goals:
When writing exploits, pwntools generally follows the "kitchen sink" approach.
* We would like to have a "normal" python module structure, to allow other
people to faster get familiar with how pwntools works.
* We would like to have even more side-effects, especially by putting the
terminal in raw-mode.
>>> from pwn import *
To make this possible, we decided to have two different modules. :mod:`pwnlib`
would be our nice, clean python module, while :mod:`pwn` would be used during
CTFs.
This imports a lot of functionality into the global namespace. You can now
assemble, disassemble, pack, unpack, and many other things with a single function.
:mod:`pwnlib` --- Normal python library
---------------------------------------
A full list of everything that is imported is available on :doc:`globals`.
.. module:: pwnlib
This module is our "clean" python-code. As a rule, we do not think that
importing :mod:`pwnlib` or any of the submodules should have any significant
side-effects (besides e.g. caching).
Making Connections
------------------
For the most part, you will also only get the bits you import. You for instance
not get access to :mod:`pwnlib.util.packing` simply by doing ``import
pwnlib.util``.
You need to talk to the challenge binary in order to pwn it, right?
pwntools makes this stupid simple with its :mod:`pwnlib.tubes` module.
Though there are a few exceptions (such as :mod:`pwnlib.shellcraft`), that does
not quite fit the goals of being simple and clean, but they can still be
imported without implicit side-effects.
This exposes a standard interface to talk to processes, sockets, serial ports,
and all manner of things, along with some nifty helpers for common tasks.
For example, remote connections via :mod:`pwnlib.tubes.remote`.
:mod:`pwn` --- Toolbox optimized for CTFs
-----------------------------------------
>>> conn = remote('ftp.debian.org',21)
>>> conn.recvline() # doctest: +ELLIPSIS
'220 ...'
>>> conn.send('USER anonymous\r\n')
>>> conn.recvuntil(' ', drop=True)
'331'
>>> conn.recvline()
'Please specify the password.\r\n'
>>> conn.close()
.. module:: pwn
It's also easy to spin up a listener
As stated, we would also like to have the ability to get a lot of these
side-effects by default. That is the purpose of this module. It does
the following:
>>> l = listen()
>>> r = remote('localhost', l.lport)
>>> c = l.wait_for_connection()
>>> r.send('hello')
>>> c.recv()
'hello'
Interacting with processes is easy thanks to :mod:`pwnlib.tubes.process`.
::
>>> sh = process('/bin/sh')
>>> sh.sendline('sleep 3; echo hello world;')
>>> sh.recvline(timeout=1)
''
>>> sh.recvline(timeout=5)
'hello world\n'
>>> sh.close()
Not only can you interact with processes programmatically, but you can
actually **interact** with processes.
>>> sh.interactive() # doctest: +SKIP
$ whoami
user
There's even an SSH module for when you've got to SSH into a box to perform
a local/setuid exploit with :mod:`pwnlib.tubes.ssh`. You can quickly spawn
processes and grab the output, or spawn a process and interact iwth it like
a ``process`` tube.
::
>>> shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0')
>>> shell['whoami']
'bandit0'
>>> shell.download_file('/etc/motd')
>>> sh = shell.run('sh')
>>> sh.sendline('sleep 3; echo hello world;') # doctest: +SKIP
>>> sh.recvline(timeout=1)
''
>>> sh.recvline(timeout=5)
'hello world\n'
>>> shell.close()
Packing Integers
------------------
A common task for exploit-writing is converting between integers as Python
sees them, and their representation as a sequence of bytes.
Usually folks resort to the built-in ``struct`` module.
pwntools makes this easier with :mod:`pwnlib.util.packing`. No more remembering
unpacking codes, and littering your code with helper routines.
>>> import struct
>>> p32(0xdeadbeef) == struct.pack('I', 0xdeadbeef)
True
>>> leet = '37130000'.decode('hex')
>>> u32('abcd') == struct.unpack('I', 'abcd')[0]
True
The packing/unpacking operations are defined for many common bit-widths.
>>> u8('A') == 0x41
True
Setting the Target Architecture and OS
--------------------------------------
The target architecture can generally be specified as an argument to the routine that requires it.
>>> asm('nop')
'\x90'
>>> asm('nop', arch='arm')
'\x00\xf0 \xe3'
However, it can also be set once in the global ``context``. The operating system, word size, and endianness can also be set here.
>>> context.arch = 'i386'
>>> context.os = 'linux'
>>> context.endian = 'little'
>>> context.word_size = 32
Additionally, you can use a shorthand to set all of the values at once.
>>> asm('nop')
'\x90'
>>> context(arch='arm', os='linux', endian='big', word_size=32)
>>> asm('nop')
'\xe3 \xf0\x00'
.. doctest::
:hide:
>>> context.clear()
Setting Logging Verbosity
-------------------------
You can control the verbosity of the standard pwntools logging via ``context``.
For example, setting
>>> context.log_level = 'debug'
Will cause all of the data sent and received by a ``tube`` to be printed to the screen.
.. doctest::
:hide:
>>> context.clear()
Assembly and Disassembly
------------------------
Never again will you need to run some already-assembled pile of shellcode
from the internet! The :mod:`pwnlib.asm` module is full of awesome.
>>> asm('mov eax, 0').encode('hex')
'b800000000'
But if you do, it's easy to suss out!
>>> print disasm('6a0258cd80ebf9'.decode('hex'))
0: 6a 02 push 0x2
2: 58 pop eax
3: cd 80 int 0x80
5: eb f9 jmp 0x0
However, you shouldn't even need to write your own shellcode most of the
time! Pwntools comes with the :mod:`pwnlib.shellcraft` module, which is
loaded with useful time-saving shellcodes.
Let's say that we want to `setreuid(getuid(), getuid())` followed by `dup`ing
file descriptor 4 to `stdin`, `stdout`, and `stderr`, and then pop a shell!
>>> asm(shellcraft.setreuid() + shellcraft.dupsh(4)).encode('hex')
'6a3158cd8089c389d96a4658cd806a045b6a0359496a3f58cd8075f86a68682f2f2f73682f62696e89e331c96a0b5899cd80'
Misc Tools
----------------------
Never write another hexdump, thanks to :mod:`pwnlib.util.fiddling`.
Find offsets in your buffer that cause a crash, thanks to :mod:`pwnlib.cyclic`.
>>> print cyclic(20)
aaaabaaacaaadaaaeaaa
>>> # Assume EIP = 0x62616166 ('faab' which is pack(0x62616166)) at crash time
>>> print cyclic_find('faab')
120
ELF Manipulation
----------------
Stop hard-coding things! Look them up at runtime with :mod:`pwnlib.elf`.
>>> e = ELF('/bin/cat')
>>> print hex(e.address) #doctest: +SKIP
0x400000
>>> print hex(e.symbols['write']) #doctest: +SKIP
0x401680
>>> print hex(e.got['write']) #doctest: +SKIP
0x60b070
>>> print hex(e.plt['write']) #doctest: +SKIP
0x401680
You can even patch and save the files.
>>> e = ELF('/bin/cat')
>>> e.read(e.address+1, 3)
'ELF'
>>> e.asm(e.address, 'ret')
>>> e.save('/tmp/quiet-cat')
>>> disasm(file('/tmp/quiet-cat','rb').read(1))
' 0: c3 ret'
* Imports everything from the toplevel :mod:`pwnlib` along with
functions from a lot of submodules. This means that if you do
``import pwn`` or ``from pwn import *``, you will access to
everything you need to write an exploit.
* Calls :func:`pwnlib.term.init` to put your terminal in raw mode
and implementing functionality to make it look like it is not.
* Setting the :data:`pwnlib.context.log_level` to `"info"`.
* Tries to parse some of the values in :data:`sys.argv` and every
value it succeeds in parsing it removes.
+17 -7
View File
@@ -1,11 +1,21 @@
:mod:`pwnlib.log` and --- Logging stuff
=================================================================
:mod:`pwnlib.log` --- Logging stuff
===================================
.. automodule:: pwnlib.log
:members:
:members: getLogger, install_default_handler, rootlogger
:mod:`pwnlib.log_levels` --- Possible log levels
------------------------------------------------
.. automodule:: pwnlib.log_levels
.. autoclass:: pwnlib.log.Progress
:members:
:member-order: bysource
.. autoclass:: pwnlib.log.Logger
:members:
:member-order: bysource
.. autoclass:: pwnlib.log.Handler
:members:
:member-order: bysource
.. autoclass:: pwnlib.log.Formatter
:members:
:member-order: bysource
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

+4
View File
@@ -1,3 +1,7 @@
.. testsetup:: *
from pwnlib.memleak import *
:mod:`pwnlib.memleak` --- Helper class for leaking memory
=========================================================
+5
View File
@@ -0,0 +1,5 @@
:mod:`pwnlib.replacements` --- Replacements for various functions
=================================================================
.. automodule:: pwnlib.replacements
:members:
+11
View File
@@ -0,0 +1,11 @@
.. testsetup:: *
from pwnlib.elf import *
from pwnlib.rop import *
from pwnlib.util.misc import which
:mod:`pwnlib.rop` --- Return Oriented Programming
=================================================
.. automodule:: pwnlib.rop
:members:
+18
View File
@@ -0,0 +1,18 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.shellcraft.amd64` --- Shellcode for AMD64
===========================================================
:mod:`pwnlib.shellcraft.amd64`
---------------------------------------
.. automodule:: pwnlib.shellcraft.amd64
:members:
:mod:`pwnlib.shellcraft.amd64.linux`
---------------------------------------
.. automodule:: pwnlib.shellcraft.amd64.linux
:members:
+18
View File
@@ -0,0 +1,18 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.shellcraft.arm` --- Shellcode for ARM
===========================================================
:mod:`pwnlib.shellcraft.arm`
-----------------------------
.. automodule:: pwnlib.shellcraft.arm
:members:
:mod:`pwnlib.shellcraft.arm.linux`
-----------------------------------
.. automodule:: pwnlib.shellcraft.arm.linux
:members:
+4
View File
@@ -1,3 +1,7 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.shellcraft.i386` --- Shellcode for Intel 80386
===========================================================
+9
View File
@@ -0,0 +1,9 @@
.. testsetup:: *
from pwnlib.regsort import *
:mod:`pwnlib.regsort` --- Register sorting
===========================================================
.. automodule:: pwnlib.regsort
:members:
+18
View File
@@ -0,0 +1,18 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.shellcraft.thumb` --- Shellcode for Thumb Mode
===========================================================
:mod:`pwnlib.shellcraft.thumb`
-------------------------------
.. automodule:: pwnlib.shellcraft.thumb
:members:
:mod:`pwnlib.shellcraft.thumb.linux`
---------------------------------------
.. automodule:: pwnlib.shellcraft.thumb.linux
:members:
+11
View File
@@ -0,0 +1,11 @@
.. testsetup:: *
from pwnlib.context import context
from pwnlib.timeout import Timeout
import time
:mod:`pwnlib.timeout` --- Timeout handling
========================================
.. automodule:: pwnlib.timeout
:members:
+18 -44
View File
@@ -1,56 +1,30 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.tubes` --- Talking to the World!
=============================================
.. automodule:: pwnlib.tubes
Sockets
-------
.. automodule:: pwnlib.tubes.remote
Types of Tubes
-------------------
.. autoclass:: pwnlib.tubes.remote.remote(host, port, fam = None, typ = None, proto = 0, timeout = 'default', log_level = INFO)
:members:
:show-inheritance:
.. toctree::
:maxdepth: 3
:glob:
.. automodule:: pwnlib.tubes.listen
.. autoclass:: pwnlib.tubes.listen.listen(port, bindaddr = "0.0.0.0", fam = "any", typ = "tcp", timeout = 'default', log_level = INFO)
:members:
:show-inheritance:
.. automodule:: pwnlib.tubes.sock
.. autoclass:: pwnlib.tubes.sock.sock()
:show-inheritance:
Processes
---------
.. automodule:: pwnlib.tubes.process
.. autoclass:: pwnlib.tubes.process.process(args, shell = False, executable = None, env = None, timeout = 'default', log_level = INFO)
:members: kill, poll, communicate
:show-inheritance:
SSH
---
.. automodule:: pwnlib.tubes.ssh
.. autoclass:: pwnlib.tubes.ssh.ssh(user, host, port = 22, password = None, key = None, keyfile = None, proxy_command = None, proxy_sock = None, timeout = 'default', log_level = INFO)
:members:
.. autoclass:: pwnlib.tubes.ssh.ssh_channel()
:members: kill, poll, interactive
:show-inheritance:
tubes/*
Common functionality
--------------------
:mod:`pwnlib.tubes.tube` --- Common Functionality
-------------------------------------------------
.. automodule:: pwnlib.tubes.tube
.. autoclass:: pwnlib.tubes.tube.tube()
:members:
:exclude-members: recv_raw, send_raw, settimeout_raw,
can_recv_raw
.. automodule:: pwnlib.tubes.tube
.. autoclass:: pwnlib.tubes.tube.tube()
:members:
:exclude-members: recv_raw, send_raw, settimeout_raw,
can_recv_raw
+12
View File
@@ -0,0 +1,12 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.tubes.process` --- Processes
===========================================================
.. automodule:: pwnlib.tubes.process
.. autoclass:: pwnlib.tubes.process.process
:members: kill, poll, communicate
:show-inheritance:
+11
View File
@@ -0,0 +1,11 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.tubes.serialtube` --- Serial Ports
===========================================================
.. automodule:: pwnlib.tubes.serialtube
.. autoclass:: pwnlib.tubes.serialtube.serialtube
:members:
+25
View File
@@ -0,0 +1,25 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.tubes.sock` --- Sockets
===========================================================
.. automodule:: pwnlib.tubes.sock
.. autoclass:: pwnlib.tubes.sock.sock()
:show-inheritance:
.. automodule:: pwnlib.tubes.remote
.. autoclass:: pwnlib.tubes.remote.remote
:members:
:show-inheritance:
.. automodule:: pwnlib.tubes.listen
.. autoclass:: pwnlib.tubes.listen.listen
:members:
:show-inheritance:
+21
View File
@@ -0,0 +1,21 @@
.. testsetup:: *
from pwn import *
:mod:`pwnlib.tubes.ssh` --- SSH
===========================================================
.. automodule:: pwnlib.tubes.ssh
.. autoclass:: pwnlib.tubes.ssh.ssh
:members:
.. autoclass:: pwnlib.tubes.ssh.ssh_channel()
:members: kill, poll, interactive
:show-inheritance:
.. autoclass:: pwnlib.tubes.ssh.ssh_connecter()
:show-inheritance:
.. autoclass:: pwnlib.tubes.ssh.ssh_listener()
:show-inheritance:
+9
View File
@@ -0,0 +1,9 @@
.. testsetup:: *
from pwnlib.useragents import *
:mod:`pwnlib.useragents` --- A database of useragent strings
============================================================
.. automodule:: pwnlib.useragents
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`pwnlib.util.hashes` --- Hashing functions
===============================================
.. automodule:: pwnlib.util.hashes
:members:
+113
View File
@@ -0,0 +1,113 @@
.. testsetup:: *
import string, operator
from pwnlib.util.iters import *
:mod:`pwnlib.util.iters` --- Extension of standard module :mod:`itertools`
==========================================================================
.. automodule:: pwnlib.util.iters
:members:
:exclude-members:
chain ,
combinations ,
combinations_with_replacement ,
compress ,
count ,
cycle ,
dropwhile ,
groupby ,
ifilter ,
ifilterfalse ,
imap ,
islice ,
izip ,
izip_longest ,
permutations ,
product ,
repeat ,
starmap ,
takewhile ,
tee
.. function:: chain
Alias for :func:`itertools.chain`.
.. function:: combinations
Alias for :func:`itertools.combinations`
.. function:: combinations_with_replacement
Alias for :func:`itertools.combinations_with_replacement`
.. function:: compress
Alias for :func:`itertools.compress`
.. function:: count
Alias for :func:`itertools.count`
.. function:: cycle
Alias for :func:`itertools.cycle`
.. function:: dropwhile
Alias for :func:`itertools.dropwhile`
.. function:: groupby
Alias for :func:`itertools.groupby`
.. function:: ifilter
Alias for :func:`itertools.ifilter`
.. function:: ifilterfalse
Alias for :func:`itertools.ifilterfalse`
.. function:: imap
Alias for :func:`itertools.imap`
.. function:: islice
Alias for :func:`itertools.islice`
.. function:: izip
Alias for :func:`itertools.izip`
.. function:: izip_longest
Alias for :func:`itertools.izip_longest`
.. function:: permutations
Alias for :func:`itertools.permutations`
.. function:: product
Alias for :func:`itertools.product`
.. function:: repeat
Alias for :func:`itertools.repeat`
.. function:: starmap
Alias for :func:`itertools.starmap`
.. function:: takewhile
Alias for :func:`itertools.takewhile`
.. function:: tee
Alias for :func:`itertools.tee`
+1 -1
View File
@@ -1,7 +1,7 @@
.. testsetup:: *
from pwnlib.util.misc import *
import os
import os, subprocess
os.chdir("..")
:mod:`pwnlib.util.misc` --- We could not fit it any other place
+1
View File
@@ -1,6 +1,7 @@
.. testsetup:: *
from pwnlib.util.proc import *
import os, sys
:mod:`pwnlib.util.proc` --- Working with ``/proc/``
+10
View File
@@ -0,0 +1,10 @@
.. testsetup:: *
from pwnlib.context import context
from pwnlib.util.web import *
:mod:`pwnlib.util.web` --- Utilities for working with the WWW
=============================================================
.. automodule:: pwnlib.util.web
:members:
-6
View File
@@ -1,6 +0,0 @@
While these examples should all work, they are not very representative of
the pwntools project.
We have a plan to create a separate repository with examples, primarily
exploits. Until we do so, we recommend new users to look at
http://pwntools.readthedocs.org, as this is a better overview of our features.
+109
View File
@@ -0,0 +1,109 @@
# Examples
While these examples should all work, they are not very representative of
the pwntools project.
We have a plan to create a separate repository with examples, primarily
exploits. Until we do so, we recommend new users to look at
https://pwntools.readthedocs.org, as this is a better overview of our features.
In no particular order the docstrings for each example:
* `args.py`
```
When not in lib-mode (import `pwn` rather than `pwnlib`) we parse the
commandline for variables definitions. A variable definition has the form::
<var>=<val>
where ``<var>`` contains only uppercase letters, digits and underscores and
doesn't start with a digit.
Try running this example with::
$ python args.py RHOST=localhost RPORT=1337
```
* `asm.py`
```
Example showing the interface to `pwnlib.asm.asm` and `pwnlib.shellcraft`.
```
* `clean_and_log.py`
```
Use case for `pwnlib.tubes.tube.clean_and_log`.
Sometimes you will have a solution to a challenge but you don't know what it
will look like when you get the flag. Sometimes that will leave you with a
top-level exception, no flag, and angry team members.
Solution:
1. Always run wireshark or tcpdump. Always.
2. Register <your socket>.clean or <your socket>.clean_and_log to run at exit.
```
* `indented.py`
```
When running in term-mode (import `pwn` rather than `pwnlib`, stdout is a TTY
and not running in a REPL), we can do proper indentation where lines too long to
fit on a screen are split into multiple individually indented lines.
Too see the difference try running with::
$ python indented.py
and
$ python -i indented.py
Also notice that `pause()` can react on any key when in `term_mode`.
```
* `listen_uroboros.py`
```
An example showing interconnection of sockets. This script will wait for three
connections on port 1337, then connect them like a three-way Uroboros.
```
* `options.py`
```
Example showing `pwnlib.ui.options()`
```
* `port_forward.py`
```
A very simple port forwarder using `pwnlib.tubes.tube.connect_both()`. Notice
that `<>` is just a shorthand.
```
* `readline_completers.py`
```
Example showing pwnlib's readline implementation and a few completers. This
part of pwnlib will probably see some major changes soon, but we wanted to show
off some proof-of-concepts.
```
* `remote_gdb_debugging.py`
```
Simple example showing how to use the remote
gdb debugging features available in pwntools.
```
* `spinners.py`
```
Just a lot of spinners!
```
* `splash.py`
```
"Easteregg"
```
* `ssh.py`
```
Example showing how to use the ssh class.
```
* `text.py`
```
Example showing how to use `pwnlib.term.text`.
Try running with::
$ TERM=xterm python text.py
and::
$ TERM=xterm-256color python text.py
```
* `remote.py`
```
Example showing how to use the remote class.
```
+18
View File
@@ -0,0 +1,18 @@
"""
When not in lib-mode (import `pwn` rather than `pwnlib`) we parse the
commandline for variables definitions. A variable definition has the form::
<var>=<val>
where ``<var>`` contains only uppercase letters, digits and underscores and
doesn't start with a digit.
Try running this example with::
$ python args.py RHOST=localhost RPORT=1337
"""
from pwn import *
print args['RHOST'] or 'RHOST is not set'
print args['RPORT'] or 'RPORT is not set'
-4
View File
@@ -1,4 +0,0 @@
import pwn
print pwn.args['RHOST'],
print pwn.args['RPORT']
+5 -1
View File
@@ -1,5 +1,9 @@
"""
Example showing the interface to `pwnlib.asm.asm` and `pwnlib.shellcraft`.
"""
from pwn import *
context(arch='i386', os='linux', net='tcp4')
context(arch='i386', os='linux')
shellcode = shellcraft.i386_to_amd64()
shellcode_asm = asm(shellcode)
+12
View File
@@ -0,0 +1,12 @@
"""
Example showing `pwnlib.gdb.attach()`
"""
from pwn import *
bash = process('/bin/bash')
gdb.attach(bash, execute = '''
p "hello from pwnlib"
c
''')
bash.interactive()
+29
View File
@@ -0,0 +1,29 @@
"""
Use case for `pwnlib.tubes.tube.clean_and_log`.
Sometimes you will have a solution to a challenge but you don't know what it
will look like when you get the flag. Sometimes that will leave you with a
top-level exception, no flag, and angry team members.
Solution:
1. Always run wireshark or tcpdump. Always.
2. Register <your socket>.clean or <your socket>.clean_and_log to run at exit.
"""
from pwn import *
os.system('''((
echo prefix sometext ;
echo prefix someothertext ;
echo here comes the flag ;
echo LostInTheInterTubes
) | nc -l 1337) &
''')
r = remote('localhost', 1337)
atexit.register(r.clean_and_log)
while True:
line = r.recvline()
print re.findall('^prefix (\S+)$', line)[0]
-15
View File
@@ -1,15 +0,0 @@
import pwn
import pwnlib.term.completer
c1 = pwn.term.completer.LongestPrefixCompleter([
'foobar',
'foobaz',
'fooquux',
])
c2 = pwn.term.completer.PathCompleter(mask = '*.py')
with c1:
while True:
s = pwn.term.readline.readline(prompt = '> ')
print 'You wrote', s
-6
View File
@@ -1,6 +0,0 @@
import pwn
print pwn.context
pwn.context.arch = 'i386'
pwn.context.arch = 'yolo'
+41
View File
@@ -0,0 +1,41 @@
"""
Script to generate README.md
"""
from pwn import *
out = '''# Examples
While these examples should all work, they are not very representative of
the pwntools project.
We have a plan to create a separate repository with examples, primarily
exploits. Until we do so, we recommend new users to look at
https://pwntools.readthedocs.org, as this is a better overview of our features.
In no particular order the docstrings for each example:
'''
def append_example(_arg, top, names):
global out
for name in names:
if not (name.endswith('.py') and name != __file__):
continue
path = os.path.join(top, name)[2:] # strip './'
log.info('-> %s' % path)
data = read(path).strip()
if data[0:3] not in ('"""', "'''"):
log.warning(' Has no docstring!')
continue
try:
i = data.index(data[0:3], 3)
except ValueError:
log.warning(' Docstring is weird')
continue
doc = util.safeeval.const(data[0:i + 3])
out += '* `%s`\n' % path
out += '```%s```\n' % doc
os.path.walk('.', append_example, None)
write('README.md', out)
+25
View File
@@ -0,0 +1,25 @@
"""
When running in term-mode (import `pwn` rather than `pwnlib`, stdout is a TTY
and not running in a REPL), we can do proper indentation where lines too long to
fit on a screen are split into multiple individually indented lines.
Too see the difference try running with::
$ python indented.py
and
$ python -i indented.py
Also notice that `pause()` can react on any key when in `term_mode`.
"""
from pwn import *
context.log_level = 'info'
log.indented('A' * 100)
log.indented('B' * 100)
log.indented('C' * 100)
pause()
-8
View File
@@ -1,8 +0,0 @@
import pwn
pwn.context.log_level = 'info'
# print pwn2.lib
pwn.log.info(('A' * 100 + '\n') * 4)
raw_input('>')
-48
View File
@@ -1,48 +0,0 @@
# raise Exception('1234')
# import sys
# _write = sys.stdout.write
# class Proxy:
# def __init__(self, fd):
# self._fd = fd
# def readline(self):
# _write('Input plox: ')
# return self._fd.readline()
# def read(self, n):
# _write('xxx')
# return self._fd.read(n)
# def __getattr__(self, k):
# # _write('[%s]\n' % k)
# return self._fd.__getattribute__(k)
# # sys.stdout = Proxy(sys.stdout)
# sys.stdin = Proxy(sys.stdin)
# print raw_input()
import pwn
import pwnlib.term.readline
h = pwn.term.output('yolo\n')
i = 0
def foo(_):
global i
i += 1
pwn.term.output('foooooo%d\n' % i, frozen = True, before = h)
def bar():
print
def baz(_):
import sys
sys.exit()
pwnlib.term.readline.startup_hook = bar
pwnlib.term.readline.keymap.register({
'C-x C-a': foo,
'C-x C-s': baz,
})
while True:
print raw_input('> ')
-70
View File
@@ -1,70 +0,0 @@
import termios, tty, sys, string, time
def get_term_size():
fd = os.open(os.ctermid(), os.O_RDONLY)
height, width = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
os.close(fd)
return width, height
def get_cursor_pos():
sys.stdout.write("\033[6n")
s = ''
while True:
c = sys.stdin.read(1)
if c == 'R':
break
s += c
col, row = map(int, s[2:].split(';'))
return col, row
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
tty.setraw(sys.stdin.fileno())
while True:
# print 'At (%d, %d)' % get_cursor_pos()
c = sys.stdin.read(1)
if c == 'q':
break
if c == '\r':
print
if c == 'w':
s = '\x01\x1b[s\x1b[50Ayolo\x1b[u\x02'
sys.stdout.write(s)
if c == 'e':
sys.stdout.write('\x1b[s')
for i in range(100):
sys.stdout.write('\x1b[0;15f%s' % '/-\\|'[i % 4])
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\x1b[u')
if c == 'E':
sys.stdout.write('\x1b[s')
for i in range(100):
sys.stdout.write('\x1b[0;15H%s' % '.oO*'[i % 4])
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\x1b[u')
if c == 'r':
sys.stdout.write('\x1b[S')
if c == 't':
sys.stdout.write('\x1b[T')
if c == 'y':
sys.stdout.write('\x1b[syolo\r\n\x1b[ufoo')
if c == 'u':
x = ord('a')
for i in range(10):
sys.stdout.write('\x1b[A' + chr(x))
sys.stdout.flush()
time.sleep(0.3)
x += 1
sys.stdout.write('\x1b[B' + chr(x))
sys.stdout.flush()
time.sleep(0.3)
x += 1
if c in string.printable:
sys.stdout.write(c)
else:
sys.stdout.write('\\x%02x' % ord(c))
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
-27
View File
@@ -1,27 +0,0 @@
import pwn
def match(t):
print 'match', t
def nomatch(t):
print 'nomatch', t
def key(t):
print 'key', t
def tab(t):
print 'tab', t
def tabtab(t):
print 'tabtab', t
import pwnlib.term.keymap
km = pwnlib.term.keymap.Keymap({
'<match>' : match,
'<nomatch>' : nomatch,
'<any>' : key,
'<tab>' : tab,
'<tab> <tab>' : tabtab,
})
km.handle_input()
+14
View File
@@ -0,0 +1,14 @@
"""
An example showing interconnection of sockets. This script will wait for three
connections on port 1337, then connect them like a three-way Uroboros.
"""
from pwn import *
cs = [listen(1337).wait_for_connection() for _ in range(3)]
cs[0] << cs[1] << cs[2] << cs[0]
cs[0].wait_for_close()
cs[1].wait_for_close()
cs[2].wait_for_close()
-55
View File
@@ -1,55 +0,0 @@
# import pwn2.lib as lib
import pwn
import time
pwn.context.log_level = 0
n = 0
h = pwn.log.waitfor('spinners running', status = '0')
hs = []
while True:
s = raw_input('> ')
if s == 'q':
break
hs.append(pwn.log.waitfor(s, status = 'running'))
n += 1
h.status(str(n))
h.success()
for h in hs:
h.failure()
# pwn.log.waitfor('waiting for stuff')
# time.sleep(0.5)
# pwn.log.info('something happened')
# time.sleep(0.5)
# pwn.log.success('something went well')
# time.sleep(0.5)
# pwn.log.waitfor('waiting for some minor stuff')
# time.sleep(0.5)
# pwn.log.failure('went wrong')
# raw_input('please hit <enter> ')
# time.sleep(0.5)
# pwn.log.done_failure()
# time.sleep(0.5)
# pwn.log.info('all in all it went ok')
# time.sleep(0.5)
# pwn.log.done_success()
# def foo():
# plib.log.stub()
# foo()
# try:
# try:
# raise KeyError
# except:
# plib.log.die('no reason')
# except Exception as e:
# print `e`
# # raise
-12
View File
@@ -1,12 +0,0 @@
from pwn import *
context(endianness='little', sign='unsigned')
def legit_leak(addr):
return p32(addr)
mem = MemLeak(legit_leak)
print mem.b(0x08040001) # prints 1
mem.setd(0x08040000, 0xaabbccdd)
print hex(mem.b(0x08040001)) # prints 0xcc
print mem.raw(0x08040000, 20) # prints stuff
+8
View File
@@ -0,0 +1,8 @@
"""
Example showing `pwnlib.ui.options()`
"""
from pwn import *
opts = [string.letters[x] for x in range(10)]
print 'You choose "%s"' % opts[options('Pick one:', opts)]
+11
View File
@@ -0,0 +1,11 @@
"""
A very simple port forwarder using `pwnlib.tubes.tube.connect_both()`. Notice
that `<>` is just a shorthand.
"""
from pwn import *
while True:
listen(1337).wait_for_connection() <> remote('google.com', 80)
# now point your browser (or curl(1)) to http://localhost:1337
-37
View File
@@ -1,37 +0,0 @@
import pty, os, select, sys, time, pwn
pid, fd = pty.fork()
if pid == 0:
argv = ('/usr/bin/vim',)
argv = ('/bin/bash',)
os.execlp(argv[0], *argv)
else:
# time.sleep(1)
# sys.stdout.write(os.read(fd, 4096))
while True:
rfds, wfds, xfds = select.select([fd, 0], [], [])
if fd in rfds:
s = os.read(fd, 4096)
if not s:
raise EOFError
sys.stdout.write(s)
sys.stdout.flush()
if 0 in rfds:
s = os.read(0, 4096)
if not s:
raise EOFError
os.write(fd, s)
# def master_read(fd):
# import os
# s = os.read(fd, 4096)
# return s
# def stdin_read(fd):
# import os
# s = os.read(fd, 4096)
# return s
# pty.spawn('/bin/sh', master_read = master_read, stdin_read = stdin_read)
+31
View File
@@ -0,0 +1,31 @@
"""
Example showing pwnlib's readline implementation and a few completers. This
part of pwnlib will probably see some major changes soon, but we wanted to show
off some proof-of-concepts.
"""
from pwn import *
from pwnlib.term.completer import LongestPrefixCompleter, \
PathCompleter
c1 = LongestPrefixCompleter([
'foobar',
'foobaz',
'fooqux',
'exit',
'enough!',
])
c2 = PathCompleter(mask = '*.py')
with c1:
print 'type "exit" to exit'
while True:
s = term.readline.readline(prompt = '> ').strip()
if s in ('exit', 'enough!'):
break
print 'You wrote', s
with c2:
print 'choose a file'
s = term.readline.readline(prompt = text.bold_green('$ ')).strip()
print 'You picked', s
-15
View File
@@ -1,15 +0,0 @@
# import sys
# class Wrapper:
# def __init__(self, fd):
# self._fd = fd
# def readline(self, size = None):
# return ''
# def __getattr__(self, k):
# return self._fd.__getattribute__(k)
# sys.stdin = Wrapper(sys.stdin)
# print `raw_input()`
import readline
import pwn
raw_input('> ')
+11
View File
@@ -0,0 +1,11 @@
"""
Example showing how to use the remote class.
"""
from pwn import *
sock = remote('127.0.0.1', 9001)
print sock.recvline()
sock.send('foo')
sock.interactive()
+16
View File
@@ -0,0 +1,16 @@
"""
Simple example showing how to use the remote
gdb debugging features available in pwntools.
"""
from pwn import *
import getpass
s = ssh(getpass.getuser(), '127.0.0.1', port = 22, keyfile = "~/.ssh/id_rsa")
c = gdb.ssh_gdb(s, '/bin/sh', execute = '''
p/x $pc
c''')
c.sendline('ls -la')
c.sendline('exit')
print c.recvall()
+25
View File
@@ -0,0 +1,25 @@
"""
Just a lot of spinners!
"""
from pwn import *
context.log_level = 0
n = 1
h = log.waitfor('spinners running', status = str(n))
hs = []
print 'type "q" to quit'
while True:
s = raw_input('> ')
if s == 'q':
break
hs.append(log.waitfor(s, status = 'running'))
n += 1
h.status(str(n))
h.success()
for h in hs:
h.failure()
+7 -4
View File
@@ -1,9 +1,12 @@
import pwn
"""
"Easteregg"
"""
pwn.splash()
pwn.pause()
from pwn import *
h = pwn.log.waitfor("Inputting:")
splash()
h = log.waitfor("You wrote", status = "--")
while True:
l = raw_input('> ')
+40
View File
@@ -0,0 +1,40 @@
"""
Example showing how to use the ssh class.
"""
from pwn import *
shell = ssh(host='bandit.labs.overthewire.org',user='bandit0',password='bandit0')
# Show basic command syntax
log.info("username: %s" % shell.whoami())
log.info("pwd: %s" % shell.pwd())
# Show full tube syntax
tube = shell.run('cat')
tube.send("Hello, cat")
tube.shutdown("out")
print tube.recvall()
# Show automatic working directories
shell.set_working_directory()
log.info("pwd: %s" % shell.pwd())
shell.upload_data("""
#include <stdio.h>
int main() {
return printf("Hello, world");
}
""", 'example.c')
shell.gcc(['example.c','-o','example'])
print shell['./example']
# Show the different styles of calling
print shell.echo("single string")
print shell.echo(["list","of","strings"])
print shell["echo single statement"]
# Show off the interactive shell
shell.interactive()
-93
View File
@@ -1,93 +0,0 @@
import pwn
import pwnlib.term
from pwnlib.term import *
import time, os, sys, threading
from pwnlib.log import *
try:
# output(os.urandom(10))
# print 'foo'
# print 'bar'
# h = output('')
# for i in range(250):
# time.sleep(0.005)
# print 'foo%d' % i
# # print 'xx'
# # time.sleep(1)
# # update(h, 'hello \x1b[3%dmthere\x1b[m\n' % (i % 6 + 1))
# # freeze(h)
# # print pwn2.nonlib.term.parse('hello \x1b[32mthere\x1b[m\n')
# # output('hello \x1b[32mthere\x1b[m\n')
# # update(h, 'asdf')
# print 'hello'
# output('fooxxx')
# h1 = output('')
# h2 = output('bar')
# output(' baz\n')
# # update(h2, 'BAR')
# update(h1, '\x1b[K\x1b[2A\x1b[1;31mYOLO\x1b[m\x1b[2B')
# print 'fooxxx\x1b[2Dbar', 'baz'
clock = output(float = True, frozen = False)
def loop():
while True:
clock.update('\n' + time.asctime(time.localtime()) + '\n')
time.sleep(1)
t = threading.Thread(target = loop)
t.daemon = True
t.start()
i = 0
# numlines = output()
numlines = info(frozen = False)
while True:
s = ''
numlines.update('You have written %d lines' % i)
i += 1
s = raw_input('> ')
output('you wrote: ')
output('%s\n' % s, indent = 20)
if s == 'q':
break
# output('\xc3\xb8' * 85)
# output('\x1b[44m \x1b[m')
# # output('\x1b[J')
# time.sleep(1)
# h = output('last\n', float = True)
# output('foo')
# # update(h, 'LAST\n')
# h = output('bar')
# output('baz\n')
# # delete(h)
# update(h, 'BAR')
# output('\x1b[s\x1b[20;40H')
# h = output('yolo')
# update(h, 'YOLO\x1b[u')
# output('\n')
# pwn2.nonlib.term.goto((1, 0))
# pwn2.nonlib.term.put('%d' % pwn2.nonlib.term.scroll)
# pwn2.nonlib.term.flush()
# time.sleep(1)
# pwn2.nonlib.term.put('\n'*10)
pass
except:
# pwn2.nonlib.term.fini()
# raise e
# pwn2.nonlib.term.put(str(e))
pass
raise
pwn2.nonlib.term.put('\n' * 20)
for c in pwn2.nonlib.term.cells:
pwn2.nonlib.term.put('%s %s %s %s\n' % (c.start, c.end, c.float, `c.content`))
+19
View File
@@ -0,0 +1,19 @@
'''
Example showing how to use `pwnlib.term.text`.
Try running with::
$ TERM=xterm python text.py
and::
$ TERM=xterm-256color python text.py
'''
from pwn import *
s = 'hello from pwntools'
print text.black_on_green(s)
print text.black_on_bright_green(s)
print text.green_on_black(s)
print text.bright_green_on_black(s)
print text.bold_green_on_black(s)
+10
View File
@@ -0,0 +1,10 @@
"""
Example showing `pwnlib.ui.yesno()`
"""
from pwn import *
if ui.yesno('Do you like Pwntools?'):
print ':D'
else:
print ':('
+46
View File
@@ -0,0 +1,46 @@
# cache list of shellcodes
_shellcraft_shellcodes=$(shellcraft)
_shellcraft()
{
COMPREPLY=()
local cur prev opts word code
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-h --help -? --show -o --out -f --format"
if [ "${prev}" == "-f" -o \
"${prev}" == "--format" \
] ; then
opts="raw str c hex asm p hexii"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [ "${prev}" == "-o" -o \
"${prev}" == "--out" \
] ; then
COMPREPLY=( $(compgen -f ${cur}))
return 0
fi
if [[ "${cur}" == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# check if a shellcode was already chosen
for word in "${COMP_WORDS[@]}" ; do
for code in ${_shellcraft_shellcodes} ; do
if [ "${word}" == "${code}" ] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
done
done
# complete shellcode name
COMPREPLY=( $(compgen -W "${_shellcraft_shellcodes}" -- ${cur}) )
}
complete -F _shellcraft shellcraft
-12
View File
@@ -1,12 +0,0 @@
#!/bin/sh
sudo pip install -r requirements.txt
echo "================================================"
echo "Now please put this directory in your PYTHONPATH"
echo "and the bin directory in your PATH."
echo
echo "If you are using bash, you do can this by putting"
echo "These in your .bashrc:"
echo
echo "export PATH=\"`realpath bin`:\$PATH\""
echo "export PYTHONPATH=\"`realpath .`:\$PYTHONPATH\""
+86 -10
View File
@@ -1,15 +1,10 @@
# Promote useful stuff to toplevel
import sys
from .toplevel import *
# Put the terminal in raw mode
term.init()
# default log level in non-lib mode
context.defaults.log_level = 'info'
# look for special args in argv
def closure():
term_mode = True
import sys
if not hasattr(sys, 'argv'):
return
@@ -26,18 +21,99 @@ def closure():
if not all(c in body for c in s[1:]):
return False
return True
for arg in sys.argv[:]:
def asbool(s):
if s.lower() == 'true':
return True
elif s.lower() == 'false':
return False
elif s.isdigit():
return bool(int(s))
else:
raise ValueError('must be integer or boolean')
# parse environtment variables
for k, v in os.environ.items():
if not k.startswith('PWNLIB_'):
continue
k = k[7:]
if k == 'DEBUG':
if asbool(v):
context.log_level = 'DEBUG'
elif k == 'SILENT':
if asbool(v):
context.log_level = 'ERROR'
elif k == 'NOTERM':
if asbool(v):
term_mode = False
elif isident(k):
args[k] = v
# parse command line
# save a copy of argv for the log file header (see below)
argv = sys.argv[:]
for arg in argv:
if arg == 'DEBUG':
sys.argv.remove(arg)
context.log_level = 'debug'
elif arg == 'NOINFO':
context.log_level = 'DEBUG'
elif arg == 'SILENT':
sys.argv.remove(arg)
context.log_level = 'silent'
context.log_level = 'ERROR'
elif arg == 'NOTERM':
term_mode = False
elif arg.find('=') > 0:
k, v = arg.split('=', 1)
if not isident(k):
continue
sys.argv.remove(arg)
args[k] = v
if 'LOG_LEVEL' in args:
context.log_level = args['LOG_LEVEL']
if 'LOG_FILE' in args:
# install a file logger
import logging, time
modes = ('w', 'wb', 'a', 'ab')
filename = args['LOG_FILE']
mode = 'a'
# check if mode was specified as "[filename],[mode]"
if ',' in filename:
filename_, mode_ = filename.rsplit(',', 1)
if mode in modes:
filename = filename_
mode = mode_
# ISO 8601
dfmt = '%Y-%m-%dT%H:%M:%S'
# write a "header" to the file, which makes it easier to find the start
# of a session
with open(filename, mode) as fd:
lines = [
'=' * 78,
' Started at %s ' % time.strftime(dfmt),
' sys.argv = [',
]
for arg in argv:
lines.append(' %r,' % arg)
lines.append(' ]')
lines.append('=' * 78)
for line in lines:
fd.write('=%s=\n' % line.ljust(78))
# if the mode was 'w' or 'wb' we need to change it to 'a'/'ab' now so
# the logging module wont overwrite the header
mode = mode.replace('w', 'a')
# create a formatter and a handler and install them for the pwnlib root
# logger (i.e. 'pwnlib')
handler = logging.FileHandler(filename, mode)
fmt = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
formatter = logging.Formatter(fmt, dfmt)
handler.setFormatter(formatter)
logging.root.addHandler(handler)
# put the terminal in rawmode unless NOTERM was specified
if term_mode:
term.init()
# install a log handler and turn logging all the way up
import pwnlib.log as log
import logging
log.rootlogger.setLevel(logging.DEBUG)
log.install_default_handler()
closure()
del closure
log = getLogger('pwnlib.exploit')
+63 -22
View File
@@ -1,26 +1,67 @@
# Promote these modules, so that "from pwn import *" will let you access them
import collections
import math
import operator
import os
import re
import string
import struct
import subprocess
import sys
import tempfile
import threading
import time
import pwnlib
# Get all the modules from pwnlib
from pwnlib import *
from pwnlib import *
# Promote functions from these modules to toplevel
from pwnlib.asm import *
from pwnlib.dynelf import DynELF
from pwnlib.elf import ELF, load
from pwnlib.log_levels import *
from pwnlib.memleak import MemLeak
from pwnlib.tubes.listen import *
from pwnlib.tubes.process import *
from pwnlib.tubes.remote import *
from pwnlib.tubes.ssh import *
from pwnlib.ui import *
from pwnlib.util import crc, net, proc
from pwnlib.util.cyclic import *
from pwnlib.util.fiddling import *
from pwnlib.util.hashes import *
from pwnlib.util.lists import *
from pwnlib.util.misc import *
from pwnlib.util.packing import *
from pwnlib.util.proc import pidof
from pwnlib.util.splash import *
from pwnlib.asm import asm
from pwnlib.asm import cpp
from pwnlib.asm import disasm
from pwnlib.context import Thread
from pwnlib.context import context
from pwnlib.dynelf import DynELF
from pwnlib.elf import ELF
from pwnlib.elf import load
from pwnlib.exception import PwnlibException
from pwnlib.fmtstr import FmtStr
from pwnlib.log import getLogger
from pwnlib.memleak import MemLeak
from pwnlib.regsort import *
from pwnlib.replacements import *
from pwnlib.rop import ROP
from pwnlib.timeout import Timeout
from pwnlib.tubes.listen import listen
from pwnlib.tubes.process import process
from pwnlib.tubes.remote import remote
from pwnlib.tubes.serialtube import serialtube
from pwnlib.tubes.ssh import ssh
from pwnlib.tubes.tube import tube
from pwnlib.ui import *
from pwnlib.util import crc
from pwnlib.util import iters
from pwnlib.util import net
from pwnlib.util import proc
from pwnlib.util import safeeval
from pwnlib.util.cyclic import *
from pwnlib.util.fiddling import *
from pwnlib.util.hashes import *
from pwnlib.util.lists import *
from pwnlib.util.misc import *
from pwnlib.util.packing import *
from pwnlib.util.proc import pidof
from pwnlib.util.splash import *
from pwnlib.util.web import *
# Promote these modules, so that "from pwn import *" will let you access them
import pwn, pwnlib, re, time, sys, os, string, threading, subprocess, struct
try:
import cPickle as pickle
except ImportError:
import pickle
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
+33 -10
View File
@@ -1,12 +1,35 @@
__all__ = [
'asm', 'constants', 'context', 'dynelf',
'elf', 'exception', 'gdb', 'log_levels',
'log', 'memleak', 'shellcraft', 'term',
'tubes', 'ui', 'util'
]
from . import asm, constants, context, dynelf
from . import elf, exception, gdb, log_levels
from . import log, memleak, shellcraft, term
from . import tubes, ui, util
import importlib
from .version import __version__
version = __version__
__all__ = [
'asm',
'atexception',
'atexit',
'commandline',
'constants',
'context',
'dynelf',
'elf',
'exception',
'fmtstr',
'gdb',
'libcdb',
'log',
'memleak',
'pep237',
'regsort',
'replacements',
'rop',
'shellcraft',
'term',
'tubes',
'ui',
'useragents',
'util'
]
for module in __all__:
importlib.import_module('.%s' % module, 'pwnlib')
+494 -201
View File
@@ -1,118 +1,284 @@
from . import context, log
import tempfile, subprocess, shutil, tempfile, errno
# -*- coding: utf-8 -*-
r"""
Utilities for assembling and disassembling code.
Architecture Selection
------------------------
Architecture, endianness, and word size are selected by using :mod:`pwnlib.context`.
Any parameters which can be specified to ``context`` can also be specified as
keyword arguments to either :func:`asm` or :func:`disasm`.
Assembly
------------------------
To assemble code, simply invoke :func:`asm` on the code to assemble.
>>> asm('mov eax, 0')
'\xb8\x00\x00\x00\x00'
Additionally, you can use constants as defined in the :mod:`pwnlib.constants`
module.
>>> asm('mov eax, SYS_execve')
'\xb8\x0b\x00\x00\x00'
Finally, :func:`asm` is used to assemble shellcode provided by ``pwntools``
in the :mod:`shellcraft` module.
>>> asm(shellcraft.sh())
'jhh///sh/bin\x89\xe31\xc9j\x0bX\x99\xcd\x80'
Disassembly
------------------------
To disassemble code, simply invoke :func:`disasm` on the bytes to disassemble.
>>> disasm('\xb8\x0b\x00\x00\x00')
' 0: b8 0b 00 00 00 mov eax,0xb'
"""
import errno
import os
import platform
import re
import shutil
import string
import subprocess
import sys
import tempfile
from collections import defaultdict
from glob import glob
from os import environ
from os import path
__all__ = ['asm', 'cpp', 'disasm']
from .context import context
from .log import getLogger
log = getLogger(__name__)
__all__ = ['asm', 'cpp', 'disasm', 'make_elf']
_basedir = path.split(__file__)[0]
_bindir = path.join(_basedir, 'data', 'binutils')
_incdir = path.join(_basedir, 'data', 'includes')
def _assembler(arch):
def which_binutils(util, **kwargs):
"""
Finds a binutils in the PATH somewhere.
Expects that the utility is prefixed with the architecture name.
Examples:
>>> import platform
>>> which_binutils('as', arch=platform.machine())
'.../bin/as'
>>> which_binutils('as', arch='arm') #doctest: +ELLIPSIS
'.../bin/arm-...-as'
>>> which_binutils('as', arch='powerpc') #doctest: +ELLIPSIS
'.../bin/powerpc...-as'
>>> which_binutils('as', arch='msp430') #doctest: +SKIP
...
Traceback (most recent call last):
...
Exception: Could not find 'as' installed for ContextType(arch = 'msp430')
"""
with context.local(**kwargs):
arch = context.arch
bits = context.bits
# Fix up pwntools vs Debian triplet naming, and account
# for 'thumb' being its own pwntools architecture.
arches = [arch] + {
'thumb': ['arm', 'aarch64'],
'i386': ['x86_64', 'amd64'],
'amd64': ['x86_64', 'i386'],
}.get(arch, [])
# If one of the candidate architectures matches the native
# architecture, use that as a last resort.
machine = platform.machine()
try:
with context.local(arch = machine):
if context.arch in arches:
arches.append(None)
except AttributeError:
log.warn_once("Your local binutils won't be used because architecture %r is not supported." % machine)
for arch in arches:
# hack for homebrew-installed binutils on mac
for gutil in ['g'+util, util]:
# e.g. objdump
if arch is None: pattern = gutil
# e.g. aarch64-linux-gnu-objdump
else: pattern = '%s*linux*-%s' % (arch,gutil)
for dir in environ['PATH'].split(':'):
res = sorted(glob(path.join(dir, pattern)))
if res:
return res[0]
locals()['context'] = context
log.warning("""
Could not find %(util)r installed for %(context)s
Try installing binutils for this architecture:
https://pwntools.readthedocs.org/en/latest/install/binutils.html
""".strip() % locals())
raise Exception('Could not find %(util)r installed for %(context)s' % locals())
checked_assembler_version = defaultdict(lambda: False)
def _assembler():
gas = which_binutils('as')
E = {
'big': '-EB',
'little': '-EL'
}[context.endianness]
B = '-%s' % context.bits
assemblers = {
'i386' : ['nasm', '-Ox'],
'amd64' : ['nasm', '-Ox'],
'thumb' : [path.join(_bindir, 'arm-as')],
'mips' : [path.join(_bindir, 'mips-as' ), '--EB'],
'mipsel' : [path.join(_bindir, 'mips-as' ), '--EL'],
'i386' : [gas, B],
'amd64' : [gas, B],
# Most architectures accept -EL or -EB
'thumb' : [gas, '-mthumb', E],
'arm' : [gas, E],
'aarch64': [gas, E],
'mips' : [gas, E, B],
'mips64' : [gas, E, B],
'sparc': [gas, E, B],
'sparc64': [gas, E, B],
# Powerpc wants -mbig or -mlittle, and -mppc32 or -mppc64
'powerpc': [gas, '-m%s' % context.endianness, '-mppc%s' % context.bits],
'powerpc64': [gas, '-m%s' % context.endianness, '-mppc%s' % context.bits],
# ia64 only accepts -mbe or -mle
'ia64': [gas, '-m%ce' % context.endianness[0]]
}
if arch in assemblers:
return assemblers[arch]
else:
return [path.join(_bindir, arch + '-as')]
assembler = assemblers.get(context.arch, [gas])
if not checked_assembler_version[gas]:
checked_assembler_version[gas] = True
result = subprocess.check_output([gas, '--version','/dev/null'],
stderr=subprocess.STDOUT)
version = re.search(r' (\d\.\d+)', result).group(1)
if version < '2.19':
log.warn_once('Your binutils version is too old and may not work!\n' + \
'Try updating with: https://pwntools.readthedocs.org/en/latest/install/binutils.html\n' + \
'Reported Version: %r' % result.strip())
def _objcopy(arch):
if arch in ['i386', 'amd64']:
return 'objcopy'
else:
return path.join(_bindir, 'objcopy')
return assembler
def _linker():
ld = [which_binutils('ld')]
bfd = ['--oformat=' + _bfdname()]
def _objdump(arch):
if arch in ['i386', 'amd64']:
return ['objdump', '-Mintel']
else:
return [path.join(_bindir, 'objdump')]
E = {
'big': '-EB',
'little': '-EL'
}[context.endianness]
arguments = {
'i386': ['-m', 'elf_i386'],
}.get(context.arch, [])
return ld + bfd + [E] + arguments
def _objcopy():
return [which_binutils('objcopy')]
def _objdump():
path = [which_binutils('objdump')]
if context.arch in ('i386', 'amd64'):
path += ['-Mintel']
return path
def _include_header():
os = context.os
arch = context.arch
def _include_header(arch, os):
if os == 'freebsd':
return '#include <freebsd.h>\n'
elif os == 'linux' and arch:
return '#include <linux/%s.h>\n' % arch
else:
return ''
include = 'freebsd.h'
elif os == 'linux':
include = 'linux/%s.h' % arch
if not include or not path.exists(path.join(_incdir, include)):
log.warn_once("Could not find system include headers for %s-%s" % (arch,os))
return '\n'
return '#include <%s>\n' % include
def _arch_header(arch):
def _arch_header():
prefix = ['.section .shellcode,"ax"']
headers = {
'i386' : ['bits 32'],
'amd64' : ['bits 64'],
'arm' : [
'.section .shellcode,"ax"',
'.syntax unified',
'.arch armv7-a',
'.arm'
],
'thumb' : [
'.section .shellcode,"ax"',
'.syntax unified',
'.arch armv7-a',
'.thumb'
],
'mips' : [
'.section .shellcode,"ax"',
'.set mips2',
'.set noreorder',
],
'mipsel' : [
'.section .shellcode,"ax"',
'.set mips2',
'.set noreorder',
],
'i386' : ['.intel_syntax noprefix'],
'amd64' : ['.intel_syntax noprefix'],
'arm' : ['.syntax unified',
'.arch armv7-a',
'.arm'],
'thumb' : ['.syntax unified',
'.arch armv7-a',
'.thumb'],
'mips' : ['.set mips2',
'.set noreorder'],
}
if arch in headers:
return '\n'.join(headers[arch]) + '\n'
else:
return ''
return '\n'.join(prefix + headers.get(context.arch, [])) + '\n'
def _bfdname():
arch = context.arch
E = context.endianness
def _bfdname(arch):
bfdnames = {
'i386' : 'elf32-i386',
'aarch64' : 'elf64-%saarch64' % E,
'amd64' : 'elf64-x86-64',
'arm' : 'elf32-littlearm',
'thumb' : 'elf32-littlearm',
'mips' : 'elf32-bigmips',
'mipsel' : 'elf32-littlemips',
'arm' : 'elf32-%sarm' % E,
'thumb' : 'elf32-%sarm' % E,
'mips' : 'elf32-trad%smips' % E,
'mips64' : 'elf64-trad%smips' % E,
'alpha' : 'elf64-alpha',
'cris' : 'elf32-cris',
'ia64' : 'elf64-ia64-little',
'ia64' : 'elf64-ia64-%s' % E,
'm68k' : 'elf32-m68k',
'powerpc' : 'elf32-powerpc',
'powerpc64' : 'elf64-powerpc',
'vax' : 'elf32-vax',
'sparc' : 'elf32-sparc',
'sparc64' : 'elf64-sparc',
}
if arch in bfdnames:
return bfdnames[arch]
else:
log.error("Cannot find bfd name for architecture %r" % arch)
raise Exception("Cannot find bfd name for architecture %r" % arch)
def _bfdarch(arch):
if arch == 'amd64':
return 'i386:x86-64'
elif arch == 'thumb':
return 'arm'
elif arch == 'ia64':
return 'ia64-elf64'
else:
return arch
def _bfdarch():
arch = context.arch
convert = {
'i386': 'i386',
'amd64': 'i386:x86-64',
'thumb': 'arm',
'ia64': 'ia64-elf64'
}
if arch in convert:
return convert[arch]
return arch
def _run(cmd, stdin = None):
log.debug(subprocess.list2cmdline(cmd))
try:
proc = subprocess.Popen(
cmd,
@@ -124,60 +290,140 @@ def _run(cmd, stdin = None):
exitcode = proc.wait()
except OSError as e:
if e.errno == errno.ENOENT:
log.error('Could not run %r the program' % cmd[0])
log.exception('Could not run %r the program' % cmd[0])
else:
raise
if (exitcode, stderr) != (0, ''):
msg = 'There was an error running %s:\n' % repr(cmd[0])
msg = 'There was an error running %s:\n' % repr(cmd)
if exitcode != 0:
msg += 'It had the exitcode %d.\n' % exitcode
if stderr != '':
msg += 'It had this on stdout:\n%s\n' % stderr
log.error(msg)
return stdout
def cpp(shellcode, arch = None, os = None):
"""cpp(shellcode, arch = None, os = None) -> str
def cpp(shellcode, **kwargs):
r"""cpp(shellcode, ...) -> str
Runs CPP over the given shellcode.
The output will always contain exactly one newline at the end.
Arguments:
shellcode(str): Shellcode to preprocess
Kwargs:
Any arguments/properties that can be set on ``context``
Examples:
>>> cpp("testing: SYS_setresuid")
'testing: SYS_setresuid\\n'
>>> cpp("mov al, SYS_setresuid", arch = "i386", os = "linux")
'mov al, 164\\n'
>>> cpp("weee SYS_setresuid", arch = "arm", os = "linux")
'weee (0x900000+164)\\n'
>>> cpp("SYS_setresuid", arch = "thumb", os = "linux")
'(0+164)\\n'
>>> cpp("SYS_setresuid", os = "freebsd")
'311\\n'
.. doctest::
>>> cpp("mov al, SYS_setresuid", arch = "i386", os = "linux")
'mov al, 164\n'
>>> cpp("weee SYS_setresuid", arch = "arm", os = "linux")
'weee (0x900000+164)\n'
>>> cpp("SYS_setresuid", arch = "thumb", os = "linux")
'(0+164)\n'
>>> cpp("SYS_setresuid", os = "freebsd")
'311\n'
"""
arch = arch or context.arch
os = os or context.os
code = _include_header(arch, os) + shellcode
cmd = [
'cpp',
'-C',
'-nostdinc',
'-undef',
'-P',
'-I' + _incdir,
'/dev/stdin'
]
return _run(cmd, code).strip('\n').rstrip() + '\n'
with context.local(**kwargs):
arch = context.arch
os = context.os
code = _include_header() + shellcode
cmd = [
'cpp',
'-C',
'-nostdinc',
'-undef',
'-P',
'-I' + _incdir,
'/dev/stdin'
]
return _run(cmd, code).strip('\n').rstrip() + '\n'
elf_template = '''
.global _start
.global __start
.text
_start:
__start:
'''
def asm(shellcode, arch = None, os = None):
"""asm(code, arch = None, os = None) -> str
def make_elf(data, vma = None, strip=True, **kwargs):
r"""
Builds an ELF file with the specified binary data as its
executable code.
Runs CPP over a given shellcode and then assembles it into bytes.
Arguments:
data(str): Assembled code
vma(int): Load address for the ELF file
Examples:
This example creates an i386 ELF that just does
execve('/bin/sh',...).
>>> context.clear()
>>> context.arch = 'i386'
>>> context.bits = 32
>>> filename = tempfile.mktemp()
>>> bin_sh = '6a68682f2f2f73682f62696e89e331c96a0b5899cd80'.decode('hex')
>>> data = make_elf(bin_sh)
>>> with open(filename,'wb+') as f:
... f.write(data)
... f.flush()
>>> os.chmod(filename,0777)
>>> p = process(filename)
>>> p.sendline('echo Hello; exit')
>>> p.recvline()
'Hello\n'
"""
with context.local(**kwargs):
assembler = _assembler()
linker = _linker()
code = elf_template
code += '.string "%s"' % ''.join('\\x%02x' % c for c in bytearray(data))
code += '\n'
log.debug(code)
tmpdir = tempfile.mkdtemp(prefix = 'pwn-asm-')
step1 = path.join(tmpdir, 'step1-asm')
step2 = path.join(tmpdir, 'step2-obj')
step3 = path.join(tmpdir, 'step3-elf')
try:
with open(step1, 'wb+') as f:
f.write(code)
_run(assembler + ['-o', step2, step1])
load_addr = []
if vma is not None:
load_addr = ['-Ttext-segment=%#x' % vma]
_run(linker + load_addr + ['-N', '-o', step3, step2])
if strip:
_run([which_binutils('objcopy'), '-Sg', step3])
_run([which_binutils('strip'), '--strip-unneeded', step3])
with open(step3, 'r') as f:
return f.read()
except Exception:
log.exception("An error occurred while building an ELF:\n%s" % code)
else:
shutil.rmtree(tmpdir)
def asm(shellcode, vma = 0, **kwargs):
r"""asm(code, vma = 0, ...) -> str
Runs :func:`cpp` over a given shellcode and then assembles it into bytes.
To see which architectures or operating systems are supported,
look in :mod:`pwnlib.contex`.
@@ -185,65 +431,81 @@ def asm(shellcode, arch = None, os = None):
To support all these architecture, we bundle the GNU assembler
and objcopy with pwntools.
Args:
Arguments:
shellcode(str): Assembler code to assemble.
arch: A supported architecture or None. In case of None,
:data:`pwnlib.context.arch` will be used.
os: A supported operating system or None. In case of None,
:data:`pwnlib.context.os` will be used.
vma(int): Virtual memory address of the beginning of assembly
Kwargs:
Any arguments/properties that can be set on ``context``
Examples:
>>> asm("mov eax, SYS_select", arch = 'i386', os = 'freebsd')
'\\xb8]\\x00\\x00\\x00'
>>> asm("mov rax, SYS_select", arch = 'amd64', os = 'linux')
'\\xb8\\x17\\x00\\x00\\x00'
>>> asm("ldr r0, =SYS_select", arch = 'arm', os = 'linux')
'\\x04\\x00\\x1f\\xe5R\\x00\\x90\\x00'
.. doctest::
>>> asm("mov eax, SYS_select", arch = 'i386', os = 'freebsd')
'\xb8]\x00\x00\x00'
>>> asm("mov eax, SYS_select", arch = 'amd64', os = 'linux')
'\xb8\x17\x00\x00\x00'
>>> asm("mov rax, SYS_select", arch = 'amd64', os = 'linux')
'H\xc7\xc0\x17\x00\x00\x00'
>>> asm("ldr r0, =SYS_select", arch = 'arm', os = 'linux', bits=32)
'\x04\x00\x1f\xe5R\x00\x90\x00'
"""
result = ''
arch = arch or context.arch
os = os or context.os
if not arch:
raise ValueError(
"asm() needs to get 'arch' through an argument or the context"
)
with context.local(**kwargs):
assembler = _assembler()
linker = _linker()
objcopy = _objcopy() + ['-j', '.shellcode', '-Obinary']
code = ''
code += _arch_header()
code += cpp(shellcode)
tmpdir = tempfile.mkdtemp(prefix = 'pwn-asm-')
def tmp(name):
return path.join(tmpdir, name)
log.debug('Assembling\n%s' % code)
assembler = _assembler(arch)
objcopy = [_objcopy(arch), '-j.shellcode', '-Obinary']
code = _arch_header(arch) + cpp(shellcode, arch, os)
tmpdir = tempfile.mkdtemp(prefix = 'pwn-asm-')
step1 = path.join(tmpdir, 'step1')
step2 = path.join(tmpdir, 'step2')
step3 = path.join(tmpdir, 'step3')
step4 = path.join(tmpdir, 'step4')
try:
with open(tmp('step1'), 'w') as fd:
fd.write(code)
try:
with open(step1, 'w') as fd:
fd.write(code)
_run(assembler + ['-o', tmp('step2'), tmp('step1')])
_run(assembler + ['-o', step2, step1])
if arch in ['i386', 'amd64']:
with open(tmp('step2')) as fd:
return fd.read()
if not vma:
shutil.copy(step2, step3)
# Sanity check for seeing if the output has relocations
relocs = subprocess.check_output(
['readelf', '-r', tmp('step2')]
).strip()
if len(relocs.split('\n')) > 1:
raise Exception(
'There were relocations in the shellcode:\n\n%s' % relocs
)
if vma:
_run(linker + ['--section-start=.shellcode=%#x' % vma,
'--entry=%#x' % vma,
'-o', step3, step2])
_run(objcopy + [tmp('step2'), tmp('step3')])
elif file(step2,'rb').read(4) == '\x7fELF':
# Sanity check for seeing if the output has relocations
relocs = subprocess.check_output(
[which_binutils('readelf'), '-r', step2]
).strip()
if len(relocs.split('\n')) > 1:
log.error('Shellcode contains relocations:\n%s' % relocs)
else:
shutil.copy(step2, step3)
with open(tmp('step3')) as fd:
return fd.read()
finally:
shutil.rmtree(tmpdir)
_run(objcopy + [step3, step4])
def disasm(data, arch = None):
"""disasm(data, arch = None) -> str
with open(step4) as fd:
result = fd.read()
except Exception:
log.exception("An error occurred while assembling:\n%s" % code)
else:
shutil.rmtree(tmpdir)
return result
def disasm(data, vma = 0, byte = True, offset = True, **kwargs):
"""disasm(data, ...) -> str
Disassembles a bytestring into human readable assembler.
@@ -253,62 +515,93 @@ def disasm(data, arch = None):
To support all these architecture, we bundle the GNU objcopy
and objdump with pwntools.
Args:
Arguments:
data(str): Bytestring to disassemble.
arch: A supported architecture or None. In case of None,
:data:`pwnlib.context.arch` will be used.
vma(int): Passed through to the --adjust-vma argument of objdump
byte(bool): Include the hex-printed bytes in the disassembly
offset(bool): Include the virtual memory address in the disassembly
Kwargs:
Any arguments/properties that can be set on ``context``
Examples:
>>> print disasm('b85d000000'.decode('hex'), arch = 'i386')
0: b8 5d 00 00 00 mov eax,0x5d
>>> print disasm('b817000000'.decode('hex'), arch = 'amd64')
0: b8 17 00 00 00 mov eax,0x17
>>> print disasm('04001fe552009000'.decode('hex'), arch = 'arm')
0: e51f0004 ldr r0, [pc, #-4] ; 0x4
4: 00900052 addseq r0, r0, r2, asr r0
>>> print disasm('4ff00500'.decode('hex'), arch = 'thumb')
0: f04f 0005 mov.w r0, #5
.. doctest::
>>> print disasm('b85d000000'.decode('hex'), arch = 'i386')
0: b8 5d 00 00 00 mov eax,0x5d
>>> print disasm('b85d000000'.decode('hex'), arch = 'i386', byte = 0)
0: mov eax,0x5d
>>> print disasm('b85d000000'.decode('hex'), arch = 'i386', byte = 0, offset = 0)
mov eax,0x5d
>>> print disasm('b817000000'.decode('hex'), arch = 'amd64')
0: b8 17 00 00 00 mov eax,0x17
>>> print disasm('48c7c017000000'.decode('hex'), arch = 'amd64')
0: 48 c7 c0 17 00 00 00 mov rax,0x17
>>> print disasm('04001fe552009000'.decode('hex'), arch = 'arm')
0: e51f0004 ldr r0, [pc, #-4] ; 0x4
4: 00900052 addseq r0, r0, r2, asr r0
>>> print disasm('4ff00500'.decode('hex'), arch = 'thumb', bits=32)
0: f04f 0005 mov.w r0, #5
>>>
"""
result = ''
arch = arch or context.arch
if not arch:
raise ValueError(
"asm() needs to get 'arch' through an argument or the context"
)
with context.local(**kwargs):
arch = context.arch
os = context.os
tmpdir = tempfile.mkdtemp(prefix = 'pwn-disasm-')
def tmp(name):
return path.join(tmpdir, name)
tmpdir = tempfile.mkdtemp(prefix = 'pwn-disasm-')
step1 = path.join(tmpdir, 'step1')
step2 = path.join(tmpdir, 'step2')
bfdarch = _bfdarch(arch)
bfdname = _bfdname(arch)
objdump = _objdump(arch) + ['-d']
objcopy = [
_objcopy(arch),
'-I', 'binary',
'-O', bfdname,
'-B', bfdarch,
'--set-section-flags', '.data=code',
'--rename-section', '.data=.text',
]
bfdarch = _bfdarch()
bfdname = _bfdname()
objdump = _objdump() + ['-d', '--adjust-vma', str(vma), '-b', bfdname]
objcopy = _objcopy() + [
'-I', 'binary',
'-O', bfdname,
'-B', bfdarch,
'--set-section-flags', '.data=code',
'--rename-section', '.data=.text',
]
if arch == 'thumb':
objcopy += ['--prefix-symbol=$t.']
else:
objcopy += ['-w', '-N', '*']
try:
with open(tmp('step1'), 'w') as fd:
fd.write(data)
_run(objcopy + [tmp('step1'), tmp('step2')])
output0 = subprocess.check_output(objdump + [tmp('step2')])
output1 = output0.split('<.text>:\n')
if len(output1) != 2:
raise IOError(
'Something went wrong with objdump:\n\n%s' % output0
)
if arch == 'thumb':
objcopy += ['--prefix-symbol=$t.']
else:
return output1[1].strip('\n').rstrip().expandtabs()
finally:
shutil.rmtree(tmpdir)
objcopy += ['-w', '-N', '*']
try:
with open(step1, 'w') as fd:
fd.write(data)
res = _run(objcopy + [step1, step2])
output0 = subprocess.check_output(objdump + [step2])
output1 = output0.split('<.text>:\n')
if len(output1) != 2:
log.error('Could not find .text in objdump output:\n%s' % output0)
result = output1[1].strip('\n').rstrip().expandtabs()
except Exception:
log.exception("An error occurred while disassembling:\n%s" % data)
else:
shutil.rmtree(tmpdir)
lines = []
pattern = '^( *[0-9a-f]+: *)((?:[0-9a-f]+ )+ *)(.*)'
for line in result.splitlines():
o, b, i = re.search(pattern, line).groups()
line = ''
if offset:
line += o
if byte:
line += b
line += i
lines.append(line)
return '\n'.join(lines)
+104
View File
@@ -0,0 +1,104 @@
"""
Analogous to atexit, this module allows the programmer to register functions to
be run if an unhandled exception occurs.
"""
import sys
import threading
import traceback
from .context import context
__all__ = ['register', 'unregister']
_lock = threading.Lock()
_ident = 0
_handlers = {}
def register(func, *args, **kwargs):
"""register(func, *args, **kwargs)
Registers a function to be called when an unhandled exception occurs. The
function will be called with positional arguments `args` and keyword
arguments `kwargs`, i.e. ``func(*args, **kwargs)``. The current `context`
is recorded and will be the one used when the handler is run.
E.g. to suppress logging output from an exception-handler one could write::
with context.local(log_level = 'error'):
atexception.register(handler)
An identifier is returned which can be used to unregister the
exception-handler.
This function can be used as a decorator::
@atexception.register
def handler():
...
Notice however that this will bind ``handler`` to the identifier and not the
actual exception-handler. The exception-handler can then be unregistered
with::
atexception.unregister(handler)
This function is thread safe.
"""
global _ident
with _lock:
ident = _ident
_ident += 1
_handlers[ident] = (func, args, kwargs, vars(context))
return ident
def unregister(func):
"""unregister(func)
Remove `func` from the collection of registered functions. If `func` isn't
registered this is a no-op.
"""
if func in _handlers:
del _handlers[func]
def _run_handlers():
"""_run_handlers()
Run registered handlers. They run in the reverse order of which they were
registered.
If a handler raises an exception, it will be printed but nothing else
happens, i.e. other handlers will be run.
"""
context.clear()
for _ident, (func, args, kwargs, ctx) in \
sorted(_handlers.items(), reverse = True):
try:
with context.local(**ctx):
func(*args, **kwargs)
except SystemExit:
pass
except:
# extract the current exception and rewind the traceback to where it
# originated
typ, val, tb = sys.exc_info()
traceback.print_exception(typ, val, tb.tb_next)
# we rely on the existing excepthook to print exceptions
if hasattr(sys, 'excepthook'):
_oldhook = sys.excepthook
else:
_oldhook = None
def _newhook(typ, val, tb):
"""_newhook(typ, val, tb)
Our excepthook replacement. First the original hook is called to print the
exception, then each handler is called.
"""
if _oldhook:
_oldhook(typ, val, tb)
_run_handlers()
sys.excepthook = _newhook
+96
View File
@@ -0,0 +1,96 @@
"""
Replacement for the Python standard library's atexit.py.
Whereas the standard :mod:`atexit` module only defines :func:`atexit.register`,
this replacement module also defines :func:`unregister`.
This module also fixes a the issue that exceptions raised by an exit handler is
printed twice when the standard :mod:`atexit` is used.
"""
import sys
import threading
import traceback
from .context import context
__all__ = ['register', 'unregister']
_lock = threading.Lock()
_ident = 0
_handlers = {}
def register(func, *args, **kwargs):
"""register(func, *args, **kwargs)
Registers a function to be called on program termination. The function will
be called with positional arguments `args` and keyword arguments `kwargs`,
i.e. ``func(*args, **kwargs)``. The current `context` is recorded and will
be the one used when the handler is run.
E.g. to suppress logging output from an exit-handler one could write::
with context.local(log_level = 'error'):
atexit.register(handler)
An identifier is returned which can be used to unregister the exit-handler.
This function can be used as a decorator::
@atexit.register
def handler():
...
Notice however that this will bind ``handler`` to the identifier and not the
actual exit-handler. The exit-handler can then be unregistered with::
atexit.unregister(handler)
This function is thread safe.
"""
global _ident
with _lock:
ident = _ident
_ident += 1
_handlers[ident] = (func, args, kwargs, vars(context))
return ident
def unregister(ident):
"""unregister(ident)
Remove the exit-handler identified by `ident` from the list of registered
handlers. If `ident` isn't registered this is a no-op.
"""
if ident in _handlers:
del _handlers[ident]
def _run_handlers():
"""_run_handlers()
Run registered exit-handlers. They run in the reverse order of which they
were registered.
If a handler raises an exception, it will be printed but nothing else
happens, i.e. other handlers will be run and `sys.excepthook` will not be
called for that reason.
"""
context.clear()
for _ident, (func, args, kwargs, ctx) in \
sorted(_handlers.items(), reverse = True):
try:
with context.local(**ctx):
func(*args, **kwargs)
except SystemExit:
pass
except:
# extract the current exception and rewind the traceback to where it
# originated
typ, val, tb = sys.exc_info()
traceback.print_exception(typ, val, tb.tb_next)
# if there's already an exitfunc registered be sure to run that too
if hasattr(sys, "exitfunc"):
register(sys.exitfunc)
sys.exitfunc = _run_handlers
View File
Whitespace-only changes.
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python2
import argparse
import sys
from pwn import *
from . import common
parser = argparse.ArgumentParser(
description = 'Assemble shellcode into bytes'
)
parser.add_argument(
'lines',
metavar='line',
nargs='*',
help='Lines to assemble. If none are supplied, use stdin'
)
parser.add_argument(
"-f", "--format",
help="Output format (defaults to hex for ttys, otherwise raw)",
choices=['raw', 'hex', 'string']
)
parser.add_argument(
"-o","--output",
metavar='file',
help="Output file (defaults to stdout)",
type=argparse.FileType('w'),
default=sys.stdout
)
parser.add_argument(
'-c', '--context',
metavar = 'context',
action = 'append',
type = common.context_arg,
choices = common.choices,
help = 'The os/architecture/endianness/bits the shellcode will run in (default: linux/i386), choose from: %s' % common.choices,
)
parser.add_argument(
'-d',
'--debug',
help='Debug the shellcode with GDB',
action='store_true'
)
def main():
args = parser.parse_args()
tty = args.output.isatty()
data = '\n'.join(args.lines) or sys.stdin.read()
output = asm(data.replace(';', '\n'))
fmt = args.format or ('hex' if tty else 'raw')
formatters = {'r':str, 'h':enhex, 's':repr}
if args.debug:
proc = gdb.debug_shellcode(output, arch=context.arch)
proc.interactive()
sys.exit(0)
args.output.write(formatters[fmt[0]](output))
if tty and fmt is not 'raw':
args.output.write('\n')
if __name__ == '__main__': main()
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python2
import argparse
import sys
from pwn import *
from . import common
parser = argparse.ArgumentParser(
description = 'Check binary security settings'
)
parser.add_argument(
'elf',
nargs='+',
type=file,
help='Files to check'
)
def main():
args = parser.parse_args()
for f in args.elf:
e = ELF(f.name)
if __name__ == '__main__': main()
Loaded 100 of 338 files, more files were not shown because too many files have changed in this diff. Show more