Skip to content

Commit 77a4040

Browse files
committed
Merge branch 'pwn2' of github.com:pwnies/pwntools into pwn2
2 parents e68c9de + 964605e commit 77a4040

58 files changed

Lines changed: 3237 additions & 1182 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/cyclic

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python2
2+
import sys, os, argparse, string, time
3+
4+
# Add make sure we can import stuff
5+
curdir, _ = os.path.split(__file__)
6+
path = os.path.abspath(os.path.join(curdir, '..'))
7+
sys.path.insert(0, path)
8+
9+
from pwnlib.util import cyclic, packing
10+
from pwnlib import log
11+
12+
parser = argparse.ArgumentParser(description="Cyclic pattern creator/finder")
13+
parser.add_argument(
14+
'-a',
15+
metavar = 'alphabet',
16+
default = string.ascii_lowercase,
17+
help = 'The alphabet to use in the cyclic pattern (defaults to all lower case letters)',
18+
)
19+
20+
parser.add_argument(
21+
'-n',
22+
metavar = 'length',
23+
default = 4,
24+
type = int,
25+
help = 'Size of the unique subsequences (defaults to 4).'
26+
)
27+
28+
group = parser.add_mutually_exclusive_group(required = True)
29+
group.add_argument(
30+
'-l',
31+
metavar = '<lookup value>',
32+
help = 'Do a lookup instead printing the alphabet',
33+
)
34+
group.add_argument(
35+
'count',
36+
type = int,
37+
nargs = '?',
38+
help = 'Number of characters to print'
39+
)
40+
41+
args = parser.parse_args()
42+
alphabet = args.a
43+
subsize = args.n
44+
45+
if args.l:
46+
pat = args.l
47+
48+
if pat.startswith('0x'):
49+
pat = packing.pack(int(pat[2:], 16), subsize*8, 'little', 'unsigned')
50+
elif pat.isdigit():
51+
pat = packing.pack(int(pat, 10), subsize*8, 'little', 'unsigned')
52+
53+
if len(pat) != 4:
54+
log.fatal('Subpattern must be 4 bytes', 1)
55+
56+
if not all(c in alphabet for c in pat):
57+
log.fatal('Pattern contains characters not present in the alphabet', 1)
58+
59+
offset = cyclic.cyclic_find(pat, alphabet, subsize)
60+
61+
if offset == -1:
62+
log.fatal('Given pattern does not exist in cyclic pattern', 1)
63+
else:
64+
print offset
65+
else:
66+
want = args.count
67+
result = cyclic.cyclic(want, alphabet, subsize)
68+
got = len(result)
69+
if got < want:
70+
log.failure("Alphabet too small (max length = %i)" % got)
71+
print result

bin/hex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
from binascii import hexlify
3+
import sys
4+
5+
if len(sys.argv) == 1:
6+
print hexlify(sys.stdin.read())
7+
else:
8+
print hexlify(' '.join(sys.argv[1:]))

bin/unhex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
from binascii import unhexlify
3+
import sys, re
4+
5+
try:
6+
if len(sys.argv) == 1:
7+
s = sys.stdin.read()
8+
s = re.sub(r'\s', '', s)
9+
sys.stdout.write(unhexlify(s))
10+
else:
11+
sys.stdout.write(unhexlify(' '.join(sys.argv[1:])))
12+
except TypeError, e:
13+
sys.stderr.write(str(e) + '\n')

data/crcsums.txt

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Generated with: curl -s 'http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.legend' | sed -nr -e 's@<H3><A NAME="(crc\.cat[^"]*).*@\1@p' -e 's@.*<CODE>(width.*)</CODE>.*@\1@p' > crcsums
2+
crc.cat-bits.3
3+
width=3 poly=0x3 init=0x7 refin=true refout=true xorout=0x0 check=0x6 name="CRC-3/ROHC"
4+
crc.cat-bits.4
5+
width=4 poly=0x3 init=0x0 refin=true refout=true xorout=0x0 check=0x7 name="CRC-4/ITU"
6+
crc.cat-bits.5
7+
width=5 poly=0x09 init=0x09 refin=false refout=false xorout=0x00 check=0x00 name="CRC-5/EPC"
8+
crc.cat.crc-5-itu
9+
width=5 poly=0x15 init=0x00 refin=true refout=true xorout=0x00 check=0x07 name="CRC-5/ITU"
10+
crc.cat.crc-5-usb
11+
width=5 poly=0x05 init=0x1f refin=true refout=true xorout=0x1f check=0x19 name="CRC-5/USB"
12+
crc.cat-bits.6
13+
width=6 poly=0x27 init=0x3f refin=false refout=false xorout=0x00 check=0x0d name="CRC-6/CDMA2000-A"
14+
crc.cat.crc-6-cdma2000-b
15+
width=6 poly=0x07 init=0x3f refin=false refout=false xorout=0x00 check=0x3b name="CRC-6/CDMA2000-B"
16+
crc.cat.crc-6-darc
17+
width=6 poly=0x19 init=0x00 refin=true refout=true xorout=0x00 check=0x26 name="CRC-6/DARC"
18+
crc.cat.crc-6-itu
19+
width=6 poly=0x03 init=0x00 refin=true refout=true xorout=0x00 check=0x06 name="CRC-6/ITU"
20+
crc.cat-bits.7
21+
width=7 poly=0x09 init=0x00 refin=false refout=false xorout=0x00 check=0x75 name="CRC-7"
22+
crc.cat.crc-7-rohc
23+
width=7 poly=0x4f init=0x7f refin=true refout=true xorout=0x00 check=0x53 name="CRC-7/ROHC"
24+
crc.cat-bits.8
25+
width=8 poly=0x07 init=0x00 refin=false refout=false xorout=0x00 check=0xf4 name="CRC-8"
26+
crc.cat.crc-8-cdma2000
27+
width=8 poly=0x9b init=0xff refin=false refout=false xorout=0x00 check=0xda name="CRC-8/CDMA2000"
28+
crc.cat.crc-8-darc
29+
width=8 poly=0x39 init=0x00 refin=true refout=true xorout=0x00 check=0x15 name="CRC-8/DARC"
30+
crc.cat.crc-8-dvb-s2
31+
width=8 poly=0xd5 init=0x00 refin=false refout=false xorout=0x00 check=0xbc name="CRC-8/DVB-S2"
32+
crc.cat.crc-8-ebu
33+
width=8 poly=0x1d init=0xff refin=true refout=true xorout=0x00 check=0x97 name="CRC-8/EBU"
34+
crc.cat.crc-8-i-code
35+
width=8 poly=0x1d init=0xfd refin=false refout=false xorout=0x00 check=0x7e name="CRC-8/I-CODE"
36+
crc.cat.crc-8-itu
37+
width=8 poly=0x07 init=0x00 refin=false refout=false xorout=0x55 check=0xa1 name="CRC-8/ITU"
38+
crc.cat.crc-8-maxim
39+
width=8 poly=0x31 init=0x00 refin=true refout=true xorout=0x00 check=0xa1 name="CRC-8/MAXIM"
40+
crc.cat.crc-8-rohc
41+
width=8 poly=0x07 init=0xff refin=true refout=true xorout=0x00 check=0xd0 name="CRC-8/ROHC"
42+
crc.cat.crc-8-wdcma
43+
width=8 poly=0x9b init=0x00 refin=true refout=true xorout=0x00 check=0x25 name="CRC-8/WCDMA"
44+
crc.cat-bits.10
45+
width=10 poly=0x233 init=0x000 refin=false refout=false xorout=0x000 check=0x199 name="CRC-10"
46+
crc.cat.crc-10-cdma2000
47+
width=10 poly=0x3d9 init=0x3ff refin=false refout=false xorout=0x000 check=0x233 name="CRC-10/CDMA2000"
48+
crc.cat-bits.11
49+
width=11 poly=0x385 init=0x01a refin=false refout=false xorout=0x000 check=0x5a3 name="CRC-11"
50+
crc.cat-bits.12
51+
width=12 poly=0x80f init=0x000 refin=false refout=true xorout=0x000 check=0xdaf name="CRC-12/3GPP"
52+
crc.cat.crc-12-cdma2000
53+
width=12 poly=0xf13 init=0xfff refin=false refout=false xorout=0x000 check=0xd4d name="CRC-12/CDMA2000"
54+
crc.cat.crc-12-dect
55+
width=12 poly=0x80f init=0x000 refin=false refout=false xorout=0x000 check=0xf5b name="CRC-12/DECT"
56+
crc.cat-bits.13
57+
width=13 poly=0x1cf5 init=0x0000 refin=false refout=false xorout=0x0000 check=0x04fa name="CRC-13/BBC"
58+
crc.cat-bits.14
59+
width=14 poly=0x0805 init=0x0000 refin=true refout=true xorout=0x0000 check=0x082d name="CRC-14/DARC"
60+
crc.cat-bits.15
61+
width=15 poly=0x4599 init=0x0000 refin=false refout=false xorout=0x0000 check=0x059e name="CRC-15"
62+
crc.cat.crc-15-mpt1327
63+
width=15 poly=0x6815 init=0x0000 refin=false refout=false xorout=0x0001 check=0x2566 name="CRC-15/MPT1327"
64+
crc.cat-bits.16
65+
width=16 poly=0x8005 init=0x0000 refin=true refout=true xorout=0x0000 check=0xbb3d name="ARC"
66+
crc.cat.crc-16-aug-ccitt
67+
width=16 poly=0x1021 init=0x1d0f refin=false refout=false xorout=0x0000 check=0xe5cc name="CRC-16/AUG-CCITT"
68+
crc.cat.crc-16-buypass
69+
width=16 poly=0x8005 init=0x0000 refin=false refout=false xorout=0x0000 check=0xfee8 name="CRC-16/BUYPASS"
70+
crc.cat.crc-16-ccitt-false
71+
width=16 poly=0x1021 init=0xffff refin=false refout=false xorout=0x0000 check=0x29b1 name="CRC-16/CCITT-FALSE"
72+
crc.cat.crc-16-cdma2000
73+
width=16 poly=0xc867 init=0xffff refin=false refout=false xorout=0x0000 check=0x4c06 name="CRC-16/CDMA2000"
74+
crc.cat.crc-16-dds-110
75+
width=16 poly=0x8005 init=0x800d refin=false refout=false xorout=0x0000 check=0x9ecf name="CRC-16/DDS-110"
76+
crc.cat.crc-16-dect-r
77+
width=16 poly=0x0589 init=0x0000 refin=false refout=false xorout=0x0001 check=0x007e name="CRC-16/DECT-R"
78+
crc.cat.crc-16-dect-x
79+
width=16 poly=0x0589 init=0x0000 refin=false refout=false xorout=0x0000 check=0x007f name="CRC-16/DECT-X"
80+
crc.cat.crc-16-dnp
81+
width=16 poly=0x3d65 init=0x0000 refin=true refout=true xorout=0xffff check=0xea82 name="CRC-16/DNP"
82+
crc.cat.crc-16-en-13757
83+
width=16 poly=0x3d65 init=0x0000 refin=false refout=false xorout=0xffff check=0xc2b7 name="CRC-16/EN-13757"
84+
crc.cat.crc-16-genibus
85+
width=16 poly=0x1021 init=0xffff refin=false refout=false xorout=0xffff check=0xd64e name="CRC-16/GENIBUS"
86+
crc.cat.crc-16-maxim
87+
width=16 poly=0x8005 init=0x0000 refin=true refout=true xorout=0xffff check=0x44c2 name="CRC-16/MAXIM"
88+
crc.cat.crc-16-mcrf4xx
89+
width=16 poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91 name="CRC-16/MCRF4XX"
90+
crc.cat.crc-16-riello
91+
width=16 poly=0x1021 init=0xb2aa refin=true refout=true xorout=0x0000 check=0x63d0 name="CRC-16/RIELLO"
92+
crc.cat.crc-16-t10-dif
93+
width=16 poly=0x8bb7 init=0x0000 refin=false refout=false xorout=0x0000 check=0xd0db name="CRC-16/T10-DIF"
94+
crc.cat.crc-16-teledisk
95+
width=16 poly=0xa097 init=0x0000 refin=false refout=false xorout=0x0000 check=0x0fb3 name="CRC-16/TELEDISK"
96+
crc.cat.crc-16-tms37157
97+
width=16 poly=0x1021 init=0x89ec refin=true refout=true xorout=0x0000 check=0x26b1 name="CRC-16/TMS37157"
98+
crc.cat.crc-16-usb
99+
width=16 poly=0x8005 init=0xffff refin=true refout=true xorout=0xffff check=0xb4c8 name="CRC-16/USB"
100+
crc.cat.crc-a
101+
width=16 poly=0x1021 init=0xc6c6 refin=true refout=true xorout=0x0000 check=0xbf05 name="CRC-A"
102+
crc.cat.kermit
103+
width=16 poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189 name="KERMIT"
104+
crc.cat.modbus
105+
width=16 poly=0x8005 init=0xffff refin=true refout=true xorout=0x0000 check=0x4b37 name="MODBUS"
106+
crc.cat.x-25
107+
width=16 poly=0x1021 init=0xffff refin=true refout=true xorout=0xffff check=0x906e name="X-25"
108+
crc.cat.xmodem
109+
width=16 poly=0x1021 init=0x0000 refin=false refout=false xorout=0x0000 check=0x31c3 name="XMODEM"
110+
crc.cat-bits.24
111+
width=24 poly=0x864cfb init=0xb704ce refin=false refout=false xorout=0x000000 check=0x21cf02 name="CRC-24"
112+
crc.cat.crc-24-flexray-a
113+
width=24 poly=0x5d6dcb init=0xfedcba refin=false refout=false xorout=0x000000 check=0x7979bd name="CRC-24/FLEXRAY-A"
114+
crc.cat.crc-24-flexray-b
115+
width=24 poly=0x5d6dcb init=0xabcdef refin=false refout=false xorout=0x000000 check=0x1f23b8 name="CRC-24/FLEXRAY-B"
116+
crc.cat-bits.31
117+
width=31 poly=0x04c11db7 init=0x7fffffff refin=false refout=false xorout=0x7fffffff check=0x0ce9e46c name="CRC-31/PHILIPS"
118+
crc.cat-bits.32
119+
width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 name="CRC-32"
120+
crc.cat.crc-32-bzip2
121+
width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0xffffffff check=0xfc891918 name="CRC-32/BZIP2"
122+
crc.cat.crc-32c
123+
width=32 poly=0x1edc6f41 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xe3069283 name="CRC-32C"
124+
crc.cat.crc-32d
125+
width=32 poly=0xa833982b init=0xffffffff refin=true refout=true xorout=0xffffffff check=0x87315576 name="CRC-32D"
126+
crc.cat.crc-32-mpeg-2
127+
width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0x00000000 check=0x0376e6e7 name="CRC-32/MPEG-2"
128+
crc.cat.crc-32-posix
129+
width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680 name="CRC-32/POSIX"
130+
crc.cat.crc-32q
131+
width=32 poly=0x814141ab init=0x00000000 refin=false refout=false xorout=0x00000000 check=0x3010bf7f name="CRC-32Q"
132+
crc.cat.jamcrc
133+
width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0x00000000 check=0x340bc6d9 name="JAMCRC"
134+
crc.cat.xfer
135+
width=32 poly=0x000000af init=0x00000000 refin=false refout=false xorout=0x00000000 check=0xbd0be338 name="XFER"
136+
crc.cat-bits.40
137+
width=40 poly=0x0004820009 init=0x0000000000 refin=false refout=false xorout=0xffffffffff check=0xd4164fc646 name="CRC-40/GSM"
138+
crc.cat-bits.64
139+
width=64 poly=0x42f0e1eba9ea3693 init=0x0000000000000000 refin=false refout=false xorout=0x0000000000000000 check=0x6c40df5f0b497347 name="CRC-64"
140+
crc.cat.crc-64-we
141+
width=64 poly=0x42f0e1eba9ea3693 init=0xffffffffffffffff refin=false refout=false xorout=0xffffffffffffffff check=0x62ec59e3f1a4f00a name="CRC-64/WE"
142+
crc.cat.crc-64-xz
143+
width=64 poly=0x42f0e1eba9ea3693 init=0xffffffffffffffff refin=true refout=true xorout=0xffffffffffffffff check=0x995dc9bbdf1939fa name="CRC-64/XZ"
144+
crc.cat-bits.82
145+
width=82 poly=0x0308c0111011401440411 init=0x000000000000000000000 refin=true refout=true xorout=0x000000000000000000000 check=0x09ea83f625023801fd612 name="CRC-82/DARC"

docs/source/asm.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:mod:`pwnlib.asm` --- Assembler functions
2-
====================================================
2+
=========================================
33

44
.. automodule:: pwnlib.asm
55
:members:

docs/source/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
import pwnlib
4141
pwnlib.context.reset_local()
4242
'''
43+
44+
autodoc_member_order = 'bysource'
45+
4346
# Add any paths that contain templates here, relative to this directory.
4447
templates_path = ['_templates']
4548

@@ -266,7 +269,13 @@ def linkcode_resolve(domain, info):
266269

267270
import importlib, inspect, types
268271
mod = importlib.import_module(info['module'])
269-
val = getattr(mod, info['fullname'], None)
272+
273+
# Try to find the value
274+
val = mod
275+
for k in info['fullname'].split('.'):
276+
val = getattr(val, k, None)
277+
if val == None:
278+
break
270279

271280
# Special case for shellcraft
272281
if info['module'].startswith('pwnlib.shellcraft.'):

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ Contents:
1313
exception
1414
log
1515
memleak
16+
tubes
1617
shellcraft
1718
term
19+
ui
1820
util/*
1921

2022
Indices and tables

docs/source/memleak.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
.. module:: pwnlib.memleak
55

66
.. autoclass:: MemLeak
7-
:members: raw, b, w, d, q, s, n, clearb, clearw, cleard, clearq, setb, setw, setd, setq, sets
7+
:members:

docs/source/term.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:mod:`pwnlib.term` --- Terminal handling
22
========================================
33

4-
We put it in raw mode, HAHAHAH.
5-
4+
.. automodule:: pwnlib.term
5+
:members:

docs/source/tubes.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
:mod:`pwnlib.tubes` --- Talking to the World!
2+
=============================================
3+
4+
.. automodule:: pwnlib.tubes
5+
6+
Sockets
7+
-------
8+
9+
.. automodule:: pwnlib.tubes.remote
10+
11+
.. autoclass:: pwnlib.tubes.remote.remote(host, port, fam = None, typ = None, proto = 0, timeout = 'default', log_level = INFO)
12+
:members:
13+
:show-inheritance:
14+
15+
.. automodule:: pwnlib.tubes.listen
16+
17+
.. autoclass:: pwnlib.tubes.listen.listen(port, bindaddr = "0.0.0.0", fam = "any", typ = "tcp", timeout = 'default', log_level = INFO)
18+
:members:
19+
:show-inheritance:
20+
21+
.. automodule:: pwnlib.tubes.sock
22+
23+
.. autoclass:: pwnlib.tubes.sock.sock()
24+
:members: shutdown
25+
:show-inheritance:
26+
27+
Common functionality
28+
--------------------
29+
30+
.. automodule:: pwnlib.tubes.tube
31+
32+
.. autoclass:: pwnlib.tubes.tube.tube()
33+
:members:
34+
:exclude-members: recv_raw, send_raw, settimeout_raw,
35+
can_recv_raw

0 commit comments

Comments
 (0)