@@ -20,39 +20,40 @@ def initialize
20
20
is sent to enumerate a a type 2 message from the target server. The type
21
21
2 message is then parsed for information such as the Active Directory
22
22
domain and NetBIOS name. A single URI can be specified with TARGET_URI
23
- or a file or URIs can be specified with TARGET_URIS_FILE (default).
23
+ and/ or a file of URIs can be specified with TARGET_URIS_FILE (default).
24
24
} ,
25
25
'Author' => 'Brandon Knight' ,
26
26
'License' => MSF_LICENSE
27
27
)
28
28
register_options (
29
29
[
30
30
OptString . new ( 'TARGET_URI' , [ false , "Single target URI" , nil ] ) ,
31
- OptPath . new ( 'TARGET_URIS_FILE' , [ false , "Path to list of URIs to request" , File . join ( Msf ::Config . data_directory , "wordlists" , "http_owa_common.txt" ) ] ) ,
31
+ OptPath . new ( 'TARGET_URIS_FILE' , [ false , "Path to list of URIs to request" ,
32
+ File . join ( Msf ::Config . data_directory , "wordlists" , "http_owa_common.txt" ) ] ) ,
32
33
] , self . class )
33
34
end
34
35
35
36
def run_host ( ip )
36
- if datastore [ 'TARGET_URI' ]
37
- test_path = normalize_uri ( datastore [ 'TARGET_URI' ] )
38
- result = check_url ( test_path )
39
- if result
40
- handle_result ( test_path , result )
41
- return
42
- end
37
+ test_uris = [ ]
38
+ turi = datastore [ 'TARGET_URI' ]
39
+ turis_file = datastore [ 'TARGET_URIS_FILE' ]
40
+ if ( !turi && !turis_file )
41
+ # can't simply return here as we'll print an error for each host
42
+ fail_with "Either TARGET_URI or TARGET_URIS_FILE must be specified"
43
+ end
44
+ if ( turi and !turi . blank? )
45
+ test_uris << normalize_uri ( turi )
43
46
end
44
- if ( datastore [ 'TARGET_URIS_FILE' ] && !datastore [ 'TARGET_URIS_FILE' ] . blank? )
45
- File . open ( datastore [ 'TARGET_URIS_FILE' ] , 'rb' ) . each_line do |line |
46
- test_uri = line . chomp
47
- test_path = normalize_uri ( test_uri )
48
- result = check_url ( test_path )
49
- if result
50
- handle_result ( test_path , result )
51
- return
52
- end
47
+ if ( turis_file && !turis_file . blank? )
48
+ File . open ( turis_file , 'rb' ) { |f | test_uris += f . readlines }
49
+ test_uris . collect! do |test_uri |
50
+ normalize_uri ( test_uri . chomp )
53
51
end
54
- elsif not datastore [ 'TARGET_URI' ]
55
- print_error ( "Either TARGET_URI or TARGET_URIS_FILE must be specified." )
52
+ end
53
+ test_uris . each do |test_path |
54
+ result = check_url ( test_path )
55
+ # no need to try the other uris if one of them works.
56
+ return handle_result ( test_path , result ) if result
56
57
end
57
58
end
58
59
0 commit comments