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

Commit 7ce2ca5

Browse files
committed
Merged development into master
2 parents 94aef4c + 76ecd5d commit 7ce2ca5

22 files changed

+483
-88
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ Lint/UnusedMethodArgument:
4848
Description: 'A number of classes will contain unused parameters for documentation purposes.'
4949
Exclude:
5050
- 'lib/wpxf/**/*'
51+
52+
Style/ClassVars:
53+
Enabled: false
54+
Description: 'There are genuine use cases for using class vars.'

.yardopts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
--exclude lib/wpxf/net/typhoeus_helper.rb
22
--exclude lib/wpxf/net/http_options.rb
33
--exclude payloads/socket_helper.rb
4+
--exclude lib/wpxf/core.rb
5+
46
lib/wpxf/**/*.rb

data/json/commands.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"data": [
3+
{
4+
"cmd": "back",
5+
"desc": "Change the context of the session back to it was before loading the current module."
6+
},
7+
{
8+
"cmd": "check",
9+
"desc": "Check if the currently loaded module can be used against the specified target."
10+
},
11+
{
12+
"cmd": "clear",
13+
"desc": "Clear the screen."
14+
},
15+
{
16+
"cmd": "gset [option] [value]",
17+
"desc": "Set the [value] of [option] globally, so it is used by the current and future modules."
18+
},
19+
{
20+
"cmd": "gunset [option]",
21+
"desc": "Unset a global [option] set with the gset command."
22+
},
23+
{
24+
"cmd": "help",
25+
"desc": "Shows this information."
26+
},
27+
{
28+
"cmd": "info",
29+
"desc": "Display information about the currently loaded module."
30+
},
31+
{
32+
"cmd": "quit",
33+
"desc": "Exit the WordPress Exploit Framework prompt."
34+
},
35+
{
36+
"cmd": "run",
37+
"desc": "Run the currently loaded module."
38+
},
39+
{
40+
"cmd": "set [option] [value]",
41+
"desc": "Set the [value] of [option] for the currently loaded module."
42+
},
43+
{
44+
"cmd": "search [keywords]",
45+
"desc": "Search for modules that contain one or more of the specified [keywords]"
46+
},
47+
{
48+
"cmd": "show advanced",
49+
"desc": "Show the advanced options of the currently loaded module."
50+
},
51+
{
52+
"cmd": "show auxiliary",
53+
"desc": "Show the list of available auxiliary modules."
54+
},
55+
{
56+
"cmd": "show exploits",
57+
"desc": "Show the list of available exploits."
58+
},
59+
{
60+
"cmd": "show options",
61+
"desc": "Show the basic options of the currently loaded module."
62+
},
63+
{
64+
"cmd": "unset [option]",
65+
"desc": "Unset an [option] set with the set command."
66+
},
67+
{
68+
"cmd": "use [module_path]",
69+
"desc": "Loads the specified module into the current context."
70+
}
71+
]
72+
}

env.rb

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
require 'colorize'
2+
require 'date'
3+
require 'json'
4+
require 'require_all'
5+
require 'time'
6+
require 'typhoeus'
7+
require 'zip'
8+
19
wpxfbase = __FILE__
210

311
while File.symlink?(wpxfbase)
@@ -9,45 +17,11 @@
917
$LOAD_PATH.unshift(File.join(app_path, 'lib'))
1018
$LOAD_PATH.unshift(File.join(app_path, 'modules'))
1119

12-
require 'colorize'
13-
require 'date'
14-
require 'json'
15-
require 'require_all'
16-
require 'time'
17-
require 'typhoeus'
18-
require 'zip'
19-
2020
require 'wpxf/core'
2121
require 'wpxf/utility/body_builder'
2222
require 'wpxf/utility/text'
2323
require 'wpxf/utility/reference_inflater'
24-
2524
require_relative 'github_updater'
2625

27-
module Wpxf
28-
def self.data_directory=(val)
29-
@@data_directory = val
30-
end
31-
32-
def self.data_directory
33-
@@data_directory
34-
end
35-
36-
def self.app_path=(val)
37-
@@app_path = val
38-
end
39-
40-
def self.app_path
41-
@@app_path
42-
end
43-
44-
def self.change_stdout_sync(enabled)
45-
original_setting = STDOUT.sync
46-
STDOUT.sync = true
47-
yield(enabled)
48-
STDOUT.sync = original_setting
49-
end
50-
end
51-
5226
Wpxf.app_path = app_path
5327
Wpxf.data_directory = File.join(app_path, 'data/')

lib/cli/auto_complete.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ def build_cmd_list
4141
permitted_commands.each { |c| cmds[c] = {} }
4242
Wpxf::Auxiliary.module_list.each { |m| cmds['use'][m] = {} }
4343
Wpxf::Exploit.module_list.each { |m| cmds['use'][m] = {} }
44-
cmds['show'] = { 'options' => {}, 'advanced' => {} }
44+
cmds['show'] = {
45+
'options' => {},
46+
'advanced' => {},
47+
'exploits' => {},
48+
'auxiliary' => {}
49+
}
4550
cmds
4651
end
4752

lib/cli/console.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def commands_without_output
2626

2727
def permitted_commands
2828
%w(use back set show quit run unset check info gset gunset search clear
29-
reload)
29+
reload help)
3030
end
3131

3232
def initialize
@@ -90,15 +90,15 @@ def correct_number_of_args?(command, args)
9090
end
9191

9292
def on_event_emitted(event)
93-
if !event[:verbose] || context.verbose?
94-
if event[:type] == :table
95-
indent_cursor(2) do
96-
print_table event[:rows], true
97-
end
98-
else
99-
handlers = { error: 'print_bad', success: 'print_good', info: 'print_info', warning: 'print_warning' }
100-
send(handlers[event[:type]], event[:msg])
93+
return unless !event[:verbose] || context.verbose?
94+
95+
if event[:type] == :table
96+
indent_cursor(2) do
97+
print_table event[:rows], true
10198
end
99+
else
100+
handlers = { error: 'print_bad', success: 'print_good', info: 'print_info', warning: 'print_warning' }
101+
send(handlers[event[:type]], event[:msg])
102102
end
103103
end
104104

lib/cli/help.rb

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,37 @@ def show_advanced_options
5252
end
5353
end
5454

55+
def help
56+
commands_file = Wpxf::DataFile.new('json', 'commands.json')
57+
data = JSON.parse(commands_file.content)['data']
58+
data.unshift('cmd' => 'Command', 'desc' => 'Description')
59+
indent_cursor 2 do
60+
print_table data
61+
end
62+
end
63+
64+
def show_exploits
65+
results = search_modules(['exploit/'])
66+
print_good "#{results.length} Exploits"
67+
print_module_table results
68+
end
69+
70+
def show_auxiliary
71+
results = search_modules(['auxiliary/'])
72+
print_good "#{results.length} Auxiliary Modules"
73+
print_module_table results
74+
end
75+
5576
def show(target)
56-
if target.eql?('options')
57-
show_options
58-
elsif target.eql?('advanced')
59-
show_advanced_options
77+
handlers = {
78+
'options' => 'show_options',
79+
'advanced' => 'show_advanced_options',
80+
'exploits' => 'show_exploits',
81+
'auxiliary' => 'show_auxiliary'
82+
}
83+
84+
if handlers[target]
85+
send(handlers[target])
6086
else
6187
print_bad("\"#{target}\" is not a valid argument")
6288
end

lib/cli/module_info.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ def print_module_summary
2424
end
2525

2626
def print_references
27-
if context.module.module_references
28-
print_std('References:')
29-
indent_cursor do
30-
context.module.module_references.each do |ref|
31-
print_std Wpxf::Utility::ReferenceInflater.new(ref[0]).inflate(ref[1])
32-
end
27+
return unless context.module.module_references
28+
print_std('References:')
29+
indent_cursor do
30+
context.module.module_references.each do |ref|
31+
print_std Wpxf::Utility::ReferenceInflater.new(ref[0]).inflate(ref[1])
3332
end
3433
end
3534
end

lib/cli/modules.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ def search_modules(args)
5454
results
5555
end
5656

57+
def print_module_table(modules)
58+
modules = modules.sort_by { |k| k[:path] }
59+
modules.unshift(path: 'Module', title: 'Title')
60+
puts
61+
indent_cursor 2 do
62+
print_table(modules)
63+
end
64+
end
65+
5766
def search(*args)
5867
results = search_modules(args)
5968

6069
if !results.empty?
6170
print_good "#{results.length} Results for \"#{args.join(' ')}\""
62-
results = results.sort_by { |k| k[:path] }
63-
results.unshift(path: 'Module', title: 'Title')
64-
puts
65-
indent_cursor 2 do
66-
print_table(results)
67-
end
71+
print_module_table results
6872
else
6973
print_bad "No results for \"#{args.join(' ')}\""
7074
end

lib/wpxf/core.rb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,44 @@
1-
require 'wpxf/namespaces'
1+
# The root namespace.
2+
module Wpxf
3+
# The namespace for WordPress mixins and classes.
4+
module WordPress
5+
end
6+
7+
# The namespace for network related mixins and classes.
8+
module Net
9+
end
10+
11+
# The namespace for version generation mixins and classes.
12+
module Versioning
13+
end
14+
15+
# The namespace for utility classes and modules.
16+
module Utility
17+
end
18+
19+
def self.data_directory=(val)
20+
@@data_directory = val
21+
end
22+
23+
def self.data_directory
24+
@@data_directory
25+
end
26+
27+
def self.app_path=(val)
28+
@@app_path = val
29+
end
30+
31+
def self.app_path
32+
@@app_path
33+
end
34+
35+
def self.change_stdout_sync(enabled)
36+
original_setting = STDOUT.sync
37+
STDOUT.sync = true
38+
yield(enabled)
39+
STDOUT.sync = original_setting
40+
end
41+
end
242

343
require 'wpxf/core/data_file'
444
require 'wpxf/core/options'

lib/wpxf/core/payload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def escape_single_quotes(val)
3636
end
3737

3838
# Generate a random variable name.
39-
# @return [String] a random name beetween 1 and 9 alpha characters.
39+
# @return [String] a random name beetween 5 and 20 alpha characters.
4040
def random_var_name
4141
Utility::Text.rand_alpha(rand(5..20))
4242
end

lib/wpxf/namespaces.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/wpxf/net/http_options.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module Wpxf
22
module Net
33
# Provides access to various HTTP based options.
44
module HttpOptions
5-
private
6-
75
HTTP_OPTION_HOST = StringOption.new(
86
name: 'host',
97
desc: 'Address of the target host.',

lib/wpxf/net/http_server.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ def http_server_bind_port
4141
# @param path [String] the path requested.
4242
# @param params [Hash] the query string parameters.
4343
# @param headers [Hash] the HTTP headers.
44-
# @return [String] the response body to send to the client.
44+
# @return [String, Hash] if a string is returned, it will be used as the response body
45+
# to send to the client. If a {Hash} is returned, it should contain the keys:
46+
# * +:body+ - the body text of the response.
47+
# * +:type+ - the MIME type of the response.
48+
# * +:headers+ - a {Hash} of header keys and values.
4549
def on_http_request(path, params, headers)
4650
end
4751

0 commit comments

Comments
 (0)