23 lines
731 B
Ruby
23 lines
731 B
Ruby
# portcleaner.rc
|
|
# Author: m-1-k-3 (Web: http://www.s3cur1ty.de / Twitter: @s3cur1ty_de)
|
|
|
|
# This Metasploit RC-File could be used to clean up your metasploit database from closed ports
|
|
|
|
<ruby>
|
|
counter = 0
|
|
framework.db.hosts.each do |host|
|
|
host.services.each do |serv|
|
|
next if not serv.host
|
|
if (serv.state != ServiceState::Open)
|
|
print_line("cleaning closed services (Port: #{serv.port.to_i} / Host: #{host.address})")
|
|
run_single("services -d -p #{serv.port.to_i} -r #{serv.proto} #{host.address}")
|
|
counter = counter + 1
|
|
next
|
|
end
|
|
end
|
|
end
|
|
print_line("")
|
|
print_line("cleaned #{counter} closed ports")
|
|
print_line("")
|
|
</ruby>
|