@@ -14,70 +14,61 @@ def initialize(info = {})
14
14
super ( update_info ( info ,
15
15
'Name' => 'CouchDB Enum Utility' ,
16
16
'Description' => %q{
17
- Send a "send_request_cgi()" to enumerate databases and your values on CouchDB (Without authentication by default)
17
+ This module enumerates databases and your values on CouchDB
18
+ (without authentication by default). It uses the REST API
19
+ in order to make it.
18
20
} ,
19
- 'Author' => [ 'espreto <robertoespreto[at]gmail.com>' ] ,
21
+ 'References' =>
22
+ [
23
+ [ 'URL' , 'https://wiki.apache.org/couchdb/HTTP_database_API' ]
24
+ ] ,
25
+ 'Author' => [ 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' ] ,
20
26
'License' => MSF_LICENSE
21
27
) )
22
28
23
29
register_options (
24
30
[
25
31
Opt ::RPORT ( 5984 ) ,
26
32
OptString . new ( 'TARGETURI' , [ true , 'Path to list all the databases' , '/_all_dbs' ] ) ,
27
- OptEnum . new ( 'HTTP_METHOD' , [ true , 'HTTP Method, default GET' , 'GET' , [ 'GET' , 'POST' , 'PUT' , 'DELETE' ] ] ) ,
28
33
OptString . new ( 'USERNAME' , [ false , 'The username to login as' ] ) ,
29
34
OptString . new ( 'PASSWORD' , [ false , 'The password to login with' ] )
30
35
] , self . class )
31
- end
36
+ end
32
37
33
38
def run
34
39
username = datastore [ 'USERNAME' ]
35
40
password = datastore [ 'PASSWORD' ]
36
41
37
- uri = normalize_uri ( target_uri . path )
38
- res = send_request_cgi ( {
39
- 'uri' => uri ,
40
- 'method' => datastore [ 'HTTP_METHOD' ] ,
41
- 'authorization' => basic_auth ( username , password ) ,
42
- 'headers' => {
43
- 'Cookie' => 'Whatever?'
44
- }
45
- } )
46
-
47
- if res . nil?
48
- print_error ( "No response for #{ target_host } " )
49
- return nil
50
- end
51
-
52
42
begin
43
+ res = send_request_cgi ( {
44
+ 'uri' => normalize_uri ( target_uri . path ) ,
45
+ 'method' => 'GET' ,
46
+ 'authorization' => basic_auth ( username , password )
47
+ } )
48
+
53
49
temp = JSON . parse ( res . body )
54
- rescue JSON ::ParserError
55
- print_error ( "Unable to parse JSON " )
50
+ rescue :: Rex :: ConnectionRefused , :: Rex :: HostUnreachable , JSON ::ParserError => e
51
+ print_error ( "#{ peer } - The following Error was encountered: #{ e . class } " )
56
52
return
57
53
end
58
54
59
- results = JSON . pretty_generate ( temp )
55
+ if res . code == 200 && res . headers [ 'Server' ] =~ /CouchDB/
60
56
61
- if ( res . code == 200 )
62
- print_good ( "#{ target_host } :#{ rport } -> #{ res . code } " )
63
- print_good ( "Response Headers:\n \n #{ res . headers } " )
64
- print_good ( "Response Body:\n \n #{ results } \n " )
65
- elsif ( res . code == 403 ) # Forbidden
66
- print_error ( "Received #{ res . code } - Forbidden to #{ target_host } :#{ rport } " )
67
- print_error ( "Response from server:\n \n #{ results } \n " )
68
- elsif ( res . code == 404 ) # Not Found
69
- print_error ( "Received #{ res . code } - Not Found to #{ target_host } :#{ rport } " )
70
- print_error ( "Response from server:\n \n #{ results } \n " )
71
- else
72
- print_status ( "Received #{ res . code } " )
73
- print_line ( "#{ results } " )
74
- end
57
+ print_status ( 'Enumerating...' )
58
+ results = JSON . pretty_generate ( temp )
59
+ print_good ( "Found:\n \n #{ results } \n " )
60
+
61
+ path = store_loot (
62
+ 'couchdb.enum' ,
63
+ 'text/plain' ,
64
+ rhost ,
65
+ results ,
66
+ 'CouchDB Enum'
67
+ )
75
68
76
- if res and res . code == 200 and res . headers [ 'Content-Type' ] and res . body . length > 0
77
- path = store_loot ( "couchdb.enum.file" , "text/plain" , rhost , res . body , "CouchDB Enum Results" )
78
- print_status ( "Results saved to #{ path } " )
69
+ print_good ( "#{ peer } - File saved in: #{ path } " )
79
70
else
80
- print_error ( "Failed to save the result " )
71
+ print_error ( "#{ peer } - Unable to enum, received \" #{ res . code } \" " )
81
72
end
82
73
end
83
74
end
0 commit comments