metasploit-framework/scripts/resource/port_cleaner.rc

31 lines
828 B
Plaintext
Raw Normal View History

2012-01-13 15:26:57 +00:00
# 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>
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-13 15:26:57 +00:00
counter = 0
framework.db.hosts.each do |host|
host.services.each do |serv|
next if not serv.host
2012-03-13 07:33:22 +00:00
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}")
2012-01-13 15:26:57 +00:00
counter = counter + 1
2012-03-13 07:33:22 +00:00
next
end
end
2012-01-13 15:26:57 +00:00
end
print_line("")
print_line("cleaned #{counter} closed ports")
print_line("")
</ruby>