From 52aadfae32eb8a2f4c4e88a981cdefb547aea6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20S=C3=B8holm?= Date: Wed, 15 Feb 2017 00:19:08 +0100 Subject: [PATCH] Added test for issue #891 --- pwnlib/rop/rop.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pwnlib/rop/rop.py b/pwnlib/rop/rop.py index 14f1d2683..450a13fcc 100644 --- a/pwnlib/rop/rop.py +++ b/pwnlib/rop/rop.py @@ -475,6 +475,16 @@ def unresolve(self, value): def generatePadding(self, offset, count): """ Generates padding to be inserted into the ROP stack. + + >>> rop = ROP([]) + >>> val = rop.generatePadding(5,15) + >>> cyclic_find(val[:4]) + 5 + >>> len(val) + 15 + >>> rop.generatePadding(0,0) + '' + """ if count: return cyclic.cyclic(offset + count)[-count:] @@ -786,6 +796,18 @@ def raw(self, value): Arguments: data(int/str): The raw value to put onto the rop chain. + + >>> rop = ROP([]) + >>> rop.raw('AAAAAAAA') + >>> rop.raw('BBBBBBBB') + >>> rop.raw('CCCCCCCC') + >>> print rop.dump() + 0x0000: 'AAAA' 'AAAAAAAA' + 0x0004: 'AAAA' + 0x0008: 'BBBB' 'BBBBBBBB' + 0x000c: 'BBBB' + 0x0010: 'CCCC' 'CCCCCCCC' + 0x0014: 'CCCC' """ if self.migrated: log.error('Cannot append to a migrated chain')