pwntools 모듈 정리
pwnlib.util
bits
pwnlib.util.fiddling.bits(s, endian = 'big', zero = 0, one = 1) → list
>>> bits(100)
'[0, 1, 1, 0, 0, 1, 0, 0]'
>>> sum(bits(100)
3
>>> bits('ABC')
[0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1]
>>> ''.join(bits(511,zero='_',one='-'))
'________---------'
>>> ''.join(bits(511,endian='little',zero='_',one='-')
'---------_______'
unbits
pwnlib.util.fiddling.unbits(s, endian = 'big') → str
>>> unbits('0100000101000001')
'AA'
bits_str
pwnlib.util.fiddling.bits_str(s, endian = 'big', zero = '0', one = '1') → str
bits()는 list로 반환하는 반면에 bits_str()은 비트 값을 str로 반환한다.
>>> bits_str('flag')
'01100110011011000110000101100111'
bitswap
pwnlib.util.fiddling.bitswap(s) → str
1바이트씩 bit값을 뒤집는다고 보면 된다.
ex) 01101101 -> 10110110
>>> bitswap('ab')
'\x86F'
enhex
pwnlib.util.fiddling.enhex(x) → str
>>> enhex('abcd')
'61626364'
>>> 'abcd'.encode('hex')
'61626364'
unhex
pwnlib.util.fiddling.unhex(s) → str
>>> unhex('666c6167')
'flag'
>>> '666c6167'.decode('hex')
'flag'
hexdump
pwnlib.util.fiddling.hexdump(s, width=16, skip=True, hexii=False, begin=0, style=None, highlight=None, cyclic=False)
>>> hexdump(list(map(chr, range(256))),width=16,begin=0x12345678)
12345678 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f │····│····│····│····│
12345688 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f │····│····│····│····│
12345698 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f │ !"#│$%&'│()*+│,-./│
123456a8 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f │0123│4567│89:;│<=>?│
123456b8 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f │@ABC│DEFG│HIJK│LMNO│
123456c8 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f │PQRS│TUVW│XYZ[│\]^_│
123456d8 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f │`abc│defg│hijk│lmno│
123456e8 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f │pqrs│tuvw│xyz{│|}~·│
123456f8 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f │····│····│····│····│
12345708 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f │····│····│····│····│
12345718 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af │····│····│····│····│
12345728 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf │····│····│····│····│
12345738 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf │····│····│····│····│
12345748 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df │····│····│····│····│
12345758 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef │····│····│····│····│
12345768 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff │····│····│····│····│
b64e
pwnlib.util.fiddling.b64e(s) → str
>>> b64e('test')
'dGVzdA=='
b64d
pwnlib.util.fiddling.b64d(s) → str
>>> b64d('dGVzdA==')
'test'
urlencode
pwnlib.util.fiddling.urlencode(s) → str
>>> urlencode('/bin/sh')
'%2f%62%69%6e%2f%73%68'
urldecode
pwnlib.util.fiddling.urldecode(s, ignore_invalid = False) → str
>>> urldecode('%2f%62%69%6e%2f%73%68')
'/bin/sh'
xor
pwnlib.util.fiddling.xor(*args, cut = 'max') → str
xor_key
pwnlib.util.fiddling.xor_key(data, size=None, avoid='x00n') -> None or (int, str)
xor_pair
pwnlib.util.fiddling.xor_pair(data, avoid = 'x00n') -> None or (str, str)
'Python' 카테고리의 다른 글
python struct module (0) | 2019.11.21 |
---|---|
hex encoding to chr() (0) | 2019.05.17 |
파이썬 리스트의 문자열을 int 형태로 변환 (2) | 2019.02.18 |
Python z3 모듈 (0) | 2018.12.02 |