2012-01-12 16:31:06 +00:00
|
|
|
# autocrawler.rc
|
|
|
|
# Author: m-1-k-3 (Web: http://www.s3cur1ty.de / Twitter: @s3cur1ty_de)
|
|
|
|
|
2012-01-12 16:33:39 +00:00
|
|
|
# This Metasploit RC-File could be used to crawl webapps automatically
|
2012-01-12 16:31:06 +00:00
|
|
|
# it uses the allready discovered webservers - "services -s http" / "services -s https"
|
2012-01-12 16:33:39 +00:00
|
|
|
# you could use db_nmap or http_version for discovering the werbservers
|
2012-01-12 16:31:06 +00:00
|
|
|
# some basic jobhandling to not kill our own machine is included - check the maxjobs and threadspercrawler variables
|
|
|
|
|
|
|
|
<ruby>
|
2012-01-13 09:41:53 +00:00
|
|
|
if (framework.datastore['VERBOSE'] == "true") #we look in the global datastore for a global VERBOSE option and use it
|
2012-01-14 11:17:04 +00:00
|
|
|
verbose = 1 #true
|
2012-01-13 09:41:53 +00:00
|
|
|
else
|
2012-01-14 11:17:04 +00:00
|
|
|
verbose = 0
|
2012-01-13 08:11:48 +00:00
|
|
|
end
|
|
|
|
|
2012-01-14 11:17:04 +00:00
|
|
|
threadspercrawler = "4" #check this ... now its default
|
2012-01-12 16:31:06 +00:00
|
|
|
|
2012-03-13 07:33:22 +00:00
|
|
|
# Test and see if we have a database connected
|
|
|
|
begin
|
|
|
|
framework.db.hosts
|
|
|
|
rescue ::ActiveRecord::ConnectionNotEstablished
|
|
|
|
print_error("Database connection isn't established")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-01-12 16:31:06 +00:00
|
|
|
def jobwaiting() #thread handling for poor guys ...
|
|
|
|
maxjobs=15 #throttling if we get too much jobs
|
|
|
|
while(framework.jobs.keys.length >= maxjobs)
|
|
|
|
::IO.select(nil, nil, nil, 2.5)
|
|
|
|
print_error("waiting for finishing some modules... active jobs: #{framework.jobs.keys.length} / threads: #{framework.threads.length}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
framework.db.workspace.hosts.each do |host|
|
|
|
|
host.services.each do |serv|
|
|
|
|
next if not serv.host
|
2014-10-17 16:58:11 +00:00
|
|
|
next if (serv.state != Msf::ServiceState::Open)
|
2012-01-12 16:31:06 +00:00
|
|
|
next if (serv.name !~ /http/)
|
|
|
|
|
2012-01-14 11:17:04 +00:00
|
|
|
if(verbose == 1)
|
2012-01-13 08:11:48 +00:00
|
|
|
print_line("IP: #{host.address}")
|
|
|
|
print_line("OS: #{host.os_name}")
|
|
|
|
print_line("Servicename: #{serv.name}")
|
|
|
|
print_line("Service Port: #{serv.port.to_i}")
|
|
|
|
print_line("Service Protocol: #{serv.proto}")
|
2012-01-12 16:31:06 +00:00
|
|
|
end
|
|
|
|
run_single("use auxiliary/scanner/http/crawler")
|
|
|
|
run_single("set MAX_THREADS #{threadspercrawler}")
|
|
|
|
run_single("set RHOST #{host.address}")
|
|
|
|
run_single("set RPORT #{serv.port.to_i}")
|
|
|
|
if(serv.name == "https")
|
|
|
|
run_single("set SSL true")
|
|
|
|
else
|
|
|
|
run_single("set SSL false")
|
|
|
|
end
|
2012-01-14 11:17:04 +00:00
|
|
|
if(verbose == 1)
|
2012-01-12 16:31:06 +00:00
|
|
|
run_single("set VERBOSE true")
|
|
|
|
run_single("run -j")
|
|
|
|
else
|
|
|
|
run_single("run -j -q")
|
|
|
|
end
|
|
|
|
run_single("back")
|
|
|
|
jobwaiting()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
</ruby>
|