1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00
metasploit-framework/scripts/resource/port_cleaner.rb
2012-01-17 12:16:22 -06:00

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>