1
+ ##
2
+ # This file is part of the Metasploit Framework and may be subject to
3
+ # redistribution and commercial restrictions. Please see the Metasploit
4
+ # web site for more information on licensing and terms of use.
5
+ # http://metasploit.com/
6
+ ##
7
+
1
8
require 'msf/core'
2
9
3
10
class Metasploit3 < Msf ::Auxiliary
@@ -29,22 +36,28 @@ def run
29
36
username = datastore [ 'USERNAME' ]
30
37
password = datastore [ 'PASSWORD' ]
31
38
32
- uri = normalize_uri ( datastore [ 'TARGETURI' ] )
33
- res = send_request_cgi ( {
34
- 'uri' => uri ,
35
- 'method' => datastore [ 'HTTP_METHOD' ] ,
36
- 'authorization' => basic_auth ( username , password ) ,
37
- 'headers' => {
38
- 'Cookie' => 'Whatever?'
39
- }
39
+ uri = normalize_uri ( target_uri . path )
40
+ res = send_request_cgi ( {
41
+ 'uri' => uri ,
42
+ 'method' => datastore [ 'HTTP_METHOD' ] ,
43
+ 'authorization' => basic_auth ( username , password ) ,
44
+ 'headers' => {
45
+ 'Cookie' => 'Whatever?'
46
+ }
40
47
} )
41
48
42
49
if res . nil?
43
50
print_error ( "No response for #{ target_host } " )
44
51
return nil
45
52
end
46
53
47
- temp = JSON . parse ( res . body )
54
+ begin
55
+ temp = JSON . parse ( res . body )
56
+ rescue JSON ::ParserError
57
+ print_error ( "Unable to parse JSON" )
58
+ return
59
+ end
60
+
48
61
results = JSON . pretty_generate ( temp )
49
62
50
63
if ( res . code == 200 )
@@ -58,8 +71,8 @@ def run
58
71
print_error ( "Received #{ res . code } - Not Found to #{ target_host } :#{ rport } " )
59
72
print_error ( "Response from server:\n \n #{ results } \n " )
60
73
else
61
- print_status ( "#{ res . code } " )
62
- print_status ( "#{ results } " )
74
+ print_status ( "Received #{ res . code } " )
75
+ print_line ( "#{ results } " )
63
76
end
64
77
65
78
if res and res . code == 200 and res . headers [ 'Content-Type' ] and res . body . length > 0
@@ -68,9 +81,5 @@ def run
68
81
else
69
82
print_error ( "Failed to save the result" )
70
83
end
71
-
72
- rescue ::Exception => e
73
- print_error ( "Error: #{ e . to_s } " )
74
- return nil
75
84
end
76
85
end
0 commit comments