Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
Change Wpxf.load_module to use the database to fetch the class name
Browse files Browse the repository at this point in the history
  • Loading branch information
rastating committed Jun 17, 2018
1 parent 2492618 commit 0cc5a87
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
14 changes: 4 additions & 10 deletions modules/modules.rb
Expand Up @@ -18,16 +18,10 @@ def self.build_module_list(namespace, folder_name = '')
end
end

def self.load_module(name)
match = name.match(/^(auxiliary|exploit)\//i)
raise 'Invalid module path' unless match

type = match.captures[0]
list = type == 'auxiliary' ? Wpxf::Auxiliary.module_list : Wpxf::Exploit.module_list

mod = list.find { |p| p[:name] == name }
raise "\"#{name}\" is not a valid module" if mod.nil?
mod[:class].new
def self.load_module(path)
mod = Models::Module.first(path: path)
raise "\"#{path}\" is not a valid module" if mod.nil?
Object.const_get(mod.class_name).new
end

module Auxiliary
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/cli/autocomplete_spec.rb
Expand Up @@ -15,6 +15,20 @@

before :each, 'setup subject' do
allow(subject).to receive(:context).and_return(nil)

Models::Module.create(
path: 'exploit/shell/admin_shell_upload',
type: 'exploit',
name: 'Admin Shell Upload',
class_name: 'Wpxf::Exploit::AdminShellUpload'
)

Models::Module.create(
path: 'auxiliary/dos/load_scripts_dos',
type: 'auxiliary',
name: 'WordPress "load-scripts.php" DoS',
class_name: 'Wpxf::Auxiliary::LoadScriptsDos'
)
end

describe '#setup_auto_complete' do
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/cli/modules_spec.rb
Expand Up @@ -13,6 +13,20 @@
allow(subject).to receive(:puts)
allow(subject).to receive(:indent_cursor).and_call_original
allow(subject).to receive(:print_table)

Models::Module.create(
path: 'exploit/shell/admin_shell_upload',
type: 'exploit',
name: 'Admin Shell Upload',
class_name: 'Wpxf::Exploit::AdminShellUpload'
)

Models::Module.create(
path: 'auxiliary/dos/load_scripts_dos',
type: 'auxiliary',
name: 'WordPress "load-scripts.php" DoS',
class_name: 'Wpxf::Auxiliary::LoadScriptsDos'
)
end

describe '#new' do
Expand Down

0 comments on commit 0cc5a87

Please sign in to comment.