77require 'ruby_smb'
88
99module Msf
10- module Exploit ::Remote ::SMB :: Server ::HashCapture
10+ module Exploit ::Remote ::Relay :: NTLM ::HashCapture
1111
1212 include ::Msf ::Auxiliary ::Report
1313
@@ -20,7 +20,7 @@ def initialize(info = {})
2020 ] , self . class )
2121 end
2222
23- def validate_smb_hash_capture_datastore ( datastore , ntlm_provider )
23+ def validate_hash_capture_datastore ( datastore , ntlm_provider )
2424 if datastore [ 'CHALLENGE' ]
2525 # Set challenge for all future server responses
2626
@@ -36,7 +36,7 @@ def validate_smb_hash_capture_datastore(datastore, ntlm_provider)
3636 end
3737 end
3838
39- def report_ntlm_type3 ( address :, ntlm_type1 :, ntlm_type2 :, ntlm_type3 :)
39+ def report_ntlm_type3 ( address :, ntlm_type1 :, ntlm_type2 :, ntlm_type3 :, service_name : )
4040 ntlm_message = ntlm_type3
4141 hash_type = nil
4242
@@ -69,7 +69,7 @@ def report_ntlm_type3(address:, ntlm_type1:, ntlm_type2:, ntlm_type3:)
6969 {
7070 address : address ,
7171 port : srvport ,
72- service_name : 'smb' ,
72+ service_name : service_name . downcase ,
7373 protocol : 'tcp' ,
7474 module_fullname : fullname ,
7575 workspace_id : myworkspace_id
@@ -81,7 +81,7 @@ def report_ntlm_type3(address:, ntlm_type1:, ntlm_type2:, ntlm_type3:)
8181 origin_type : :service ,
8282 address : address ,
8383 port : srvport ,
84- service_name : 'smb' ,
84+ service_name : service_name . downcase ,
8585 username : user ,
8686 server_challenge : challenge ,
8787 client_hash : client_hash ,
@@ -121,10 +121,12 @@ def report_ntlm_type3(address:, ntlm_type1:, ntlm_type2:, ntlm_type3:)
121121
122122 # TODO: write method for mapping +major+ and +minor+ OS values to human-readable OS names.
123123 # client_os_version = ::NTLM::OSVersion.read(type1_msg.os_version)
124- print_line "[SMB] #{ hash_type } Client : #{ address } "
125- # print_line "[SMB] #{hash_type} Client OS : #{client_os_version}"
126- print_line "[SMB] #{ hash_type } Username : #{ domain } \\ #{ user } "
127- print_line "[SMB] #{ hash_type } Hash : #{ combined_hash } "
124+
125+ protocol_prefix = service_name . upcase
126+ print_line "[#{ protocol_prefix } ] #{ hash_type } Client : #{ address } "
127+ # print_line "[#{protocol_prefix}] #{hash_type} Client OS : #{client_os_version}"
128+ print_line "[#{ protocol_prefix } ] #{ hash_type } Username : #{ domain } \\ #{ user } "
129+ print_line "[#{ protocol_prefix } ] #{ hash_type } Hash : #{ combined_hash } "
128130 print_line
129131
130132 if datastore [ 'JOHNPWFILE' ]
@@ -136,12 +138,13 @@ def report_ntlm_type3(address:, ntlm_type1:, ntlm_type2:, ntlm_type3:)
136138 end
137139 end
138140
139- def on_ntlm_type3 ( address :, ntlm_type1 :, ntlm_type2 :, ntlm_type3 :)
141+ def on_ntlm_type3 ( address :, ntlm_type1 :, ntlm_type2 :, ntlm_type3 :, service_name : )
140142 report_ntlm_type3 (
141143 address : address ,
142144 ntlm_type1 : ntlm_type1 ,
143145 ntlm_type2 : ntlm_type2 ,
144- ntlm_type3 : ntlm_type3
146+ ntlm_type3 : ntlm_type3 ,
147+ service_name : service_name
145148 )
146149 end
147150
@@ -174,10 +177,11 @@ def bin_to_hex(str)
174177 class HashCaptureNTLMProvider < ::RubySMB ::Gss ::Provider ::NTLM
175178 # @param [::WindowsError::NTStatus] ntlm_type3_status A specific NT Status to return as the response to the NTLM
176179 # type 3 message. If this value is nil, the message will be processed as normal.
177- def initialize ( allow_anonymous : false , allow_guests : false , default_domain : 'WORKGROUP' , listener : nil , ntlm_type3_status : ::WindowsError ::NTStatus ::STATUS_ACCESS_DENIED )
180+ def initialize ( allow_anonymous : false , allow_guests : false , default_domain : 'WORKGROUP' , listener : nil , ntlm_type3_status : ::WindowsError ::NTStatus ::STATUS_ACCESS_DENIED , service_name : )
178181 super ( allow_anonymous : allow_anonymous , allow_guests : allow_guests , default_domain : default_domain )
179182 @listener = listener
180183 @ntlm_type3_status = ntlm_type3_status
184+ @service_name = service_name
181185 end
182186
183187 # Needs overwritten to ensure our version of Authenticator is returned
@@ -188,7 +192,7 @@ def new_authenticator(server_client)
188192 end
189193
190194 attr_reader :listener
191- attr_accessor :ntlm_type3_status
195+ attr_accessor :ntlm_type3_status , :service_name
192196 end
193197
194198 class HashCaptureAuthenticator < ::RubySMB ::Gss ::Provider ::NTLM ::Authenticator
@@ -208,6 +212,7 @@ def process_ntlm_type3(type3_msg)
208212 ntlm_type1 : @ntlm_type1 ,
209213 ntlm_type2 : @ntlm_type2 ,
210214 ntlm_type3 : type3_msg ,
215+ service_name : @provider . service_name
211216 )
212217 end
213218
0 commit comments