Skip to content

Commit

Permalink
Add db_exploit plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Feb 9, 2019
1 parent 7f0c1a1 commit 4e90c95
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions mad-metasploit-plugins/db_exploit.rb
@@ -0,0 +1,104 @@
#
# search exploit (db-exploit)
#

require 'fileutils'
require 'optparse'

module Msf
class Plugin::DB_Exploit < Msf::Plugin
class DB_ExploitCommandDispatcher
include Msf::Ui::Console::CommandDispatcher

def name
"DB-Exploit"
end

def commands
{
'db_exploit_search' => "Search Exploits",
'db_exploit_import' => "Import exploit to Msf",
'db_exploit_help' => "Displays help",
}
end

def cmd_openvas_help()
print_status("db_exploit_help Display this help")
print_status("db_exploit_search Search exploit")
print_status("db_exploit_import Import exploit to Msf")
end

# Verify the database is connected and usable
def database?
if !(framework.db and framework.db.usable)
return false
else
return true
end
end

# Verify there is an active Searchsploit connection
def searchsploit?
if @ov
return true
else
print_error("Searchsploit is not installed. Please install searchsploit.")
return false
end
end

def args?(args, min=1, max=nil)
if not max then max = min end
if (args.length < min or args.length > max or args[0] == "-h")
return false
end

return true
end

def cmd_db_exploit_search(*args)
search = args.join(" ")
output = `searchsploit #{search}`
puts "#{output}"
end

def cmd_db_exploit_import(*args)
path = "#{Dir.home}s/.msf4/modules/exploits/"
path += File.dirname("#{args[0]}")
FileUtils.mkdir_p(path) unless File.exists?(path)
system ("cp /opt/exploit-database/platforms/#{args[0]} #{Dir.home}/.msf4/modules/exploits/#{args[0]}")
print_status("Exploit imported, relad Metasploit!")
end

end # End SearchSploit class

#------------------------------
# Plugin initialization
#------------------------------

def initialize(framework, opts)
super
add_console_dispatcher(DB_ExploitCommandDispatcher)
print_status("Welcome to Searchsploit integration to Metasploit.")
print_status
print_status("DB_Exploit integration requires a Searchsploit.")
print_status("For additional commands use db_exploit_help.")
print_status
@ov = nil
@formats = nil
@debug = nil
end

def cleanup
remove_console_dispatcher('DB-Exploit')
end

def name
"DB-Exploit"
end

def desc
"Integrates with the Searchsploit - open source exploit database"
end
end
end

0 comments on commit 4e90c95

Please sign in to comment.