rex 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rex.rb +1 -0
- data/lib/rex/arch.rb +5 -0
- data/lib/rex/arch/x86.rb +19 -5
- data/lib/rex/arch/zarch.rb +17 -0
- data/lib/rex/compat.rb +5 -4
- data/lib/rex/constants.rb +3 -1
- data/lib/rex/encoder/alpha2/alpha_mixed.rb +70 -9
- data/lib/rex/encoder/alpha2/alpha_upper.rb +67 -8
- data/lib/rex/exploitation/cmdstager.rb +1 -0
- data/lib/rex/exploitation/cmdstager/certutil.rb +115 -0
- data/lib/rex/exploitation/cmdstager/echo.rb +6 -3
- data/lib/rex/exploitation/egghunter.rb +1 -1
- data/lib/rex/google/geolocation.rb +68 -0
- data/lib/rex/io/bidirectional_pipe.rb +0 -4
- data/lib/rex/java/serialization.rb +2 -0
- data/lib/rex/java/serialization/decode_error.rb +11 -0
- data/lib/rex/java/serialization/encode_error.rb +11 -0
- data/lib/rex/java/serialization/model.rb +2 -0
- data/lib/rex/java/serialization/model/annotation.rb +3 -3
- data/lib/rex/java/serialization/model/block_data.rb +3 -3
- data/lib/rex/java/serialization/model/block_data_long.rb +3 -3
- data/lib/rex/java/serialization/model/class_desc.rb +6 -6
- data/lib/rex/java/serialization/model/contents.rb +17 -10
- data/lib/rex/java/serialization/model/field.rb +12 -11
- data/lib/rex/java/serialization/model/long_utf.rb +3 -3
- data/lib/rex/java/serialization/model/new_array.rb +22 -23
- data/lib/rex/java/serialization/model/new_class.rb +57 -0
- data/lib/rex/java/serialization/model/new_class_desc.rb +15 -16
- data/lib/rex/java/serialization/model/new_enum.rb +5 -5
- data/lib/rex/java/serialization/model/new_object.rb +22 -17
- data/lib/rex/java/serialization/model/proxy_class_desc.rb +109 -0
- data/lib/rex/java/serialization/model/reference.rb +4 -4
- data/lib/rex/java/serialization/model/stream.rb +7 -7
- data/lib/rex/java/serialization/model/utf.rb +3 -3
- data/lib/rex/json_hash_file.rb +94 -0
- data/lib/rex/logging/log_sink.rb +1 -0
- data/lib/rex/logging/sinks/timestamp_flatfile.rb +21 -0
- data/lib/rex/parser/appscan_nokogiri.rb +13 -23
- data/lib/rex/parser/fs/ntfs.rb +10 -5
- data/lib/rex/parser/nmap_nokogiri.rb +3 -1
- data/lib/rex/parser/openvas_nokogiri.rb +70 -73
- data/lib/rex/parser/winscp.rb +108 -0
- data/lib/rex/parser/x509_certificate.rb +92 -0
- data/lib/rex/payloads.rb +0 -1
- data/lib/rex/payloads/meterpreter/config.rb +154 -0
- data/lib/rex/payloads/meterpreter/uri_checksum.rb +136 -0
- data/lib/rex/post/meterpreter.rb +1 -1
- data/lib/rex/post/meterpreter/client.rb +26 -3
- data/lib/rex/post/meterpreter/client_core.rb +387 -75
- data/lib/rex/post/meterpreter/extensions/android/android.rb +127 -37
- data/lib/rex/post/meterpreter/extensions/android/tlv.rb +46 -25
- data/lib/rex/post/meterpreter/extensions/extapi/extapi.rb +4 -0
- data/lib/rex/post/meterpreter/extensions/extapi/ntds/ntds.rb +39 -0
- data/lib/rex/post/meterpreter/extensions/extapi/pageant/pageant.rb +44 -0
- data/lib/rex/post/meterpreter/extensions/extapi/tlv.rb +9 -0
- data/lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb +16 -1
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +1 -1
- data/lib/rex/post/meterpreter/extensions/python/python.rb +114 -0
- data/lib/rex/post/meterpreter/extensions/python/tlv.rb +21 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/dir.rb +17 -14
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +33 -12
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/mount.rb +57 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb +3 -3
- data/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb +3 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +2 -0
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb +16 -3
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry.rb +29 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_subsystem/registry_key.rb +5 -1
- data/lib/rex/post/meterpreter/extensions/stdapi/tlv.rb +18 -6
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +2 -2
- data/lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb +34 -36
- data/lib/rex/post/meterpreter/packet.rb +29 -0
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +20 -7
- data/lib/rex/post/meterpreter/ui/console.rb +1 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb +230 -72
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +544 -34
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb +188 -57
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/kiwi.rb +115 -93
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb +1 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/mimikatz.rb +1 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/elevate.rb +49 -15
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb +11 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/python.rb +187 -0
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +324 -133
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +52 -2
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +68 -65
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +9 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam.rb +113 -118
- data/lib/rex/post/meterpreter/ui/console/interactive_channel.rb +3 -0
- data/lib/rex/powershell.rb +62 -0
- data/lib/rex/powershell/command.rb +359 -0
- data/lib/rex/{exploitation/powershell → powershell}/function.rb +0 -2
- data/lib/rex/{exploitation/powershell → powershell}/obfu.rb +0 -2
- data/lib/rex/{exploitation/powershell → powershell}/output.rb +11 -5
- data/lib/rex/{exploitation/powershell → powershell}/param.rb +0 -2
- data/lib/rex/powershell/parser.rb +182 -0
- data/lib/rex/powershell/payload.rb +78 -0
- data/lib/rex/{exploitation/powershell → powershell}/psh_methods.rb +16 -2
- data/lib/rex/{exploitation/powershell → powershell}/script.rb +2 -4
- data/lib/rex/proto/dcerpc/client.rb +6 -6
- data/lib/rex/proto/dcerpc/exceptions.rb +26 -0
- data/lib/rex/proto/http/client.rb +3 -3
- data/lib/rex/proto/http/client_request.rb +0 -5
- data/lib/rex/proto/http/response.rb +86 -0
- data/lib/rex/proto/ipmi/utils.rb +30 -26
- data/lib/rex/proto/kerberos/client.rb +1 -1
- data/lib/rex/proto/kerberos/model/kdc_request.rb +2 -2
- data/lib/rex/proto/rfb/client.rb +8 -3
- data/lib/rex/proto/rfb/constants.rb +1 -1
- data/lib/rex/proto/rmi.rb +2 -0
- data/lib/rex/proto/rmi/decode_error.rb +10 -0
- data/lib/rex/proto/rmi/exception.rb +10 -0
- data/lib/rex/proto/rmi/model.rb +5 -0
- data/lib/rex/proto/rmi/model/call.rb +4 -4
- data/lib/rex/proto/rmi/model/call_data.rb +137 -0
- data/lib/rex/proto/rmi/model/dgc_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/element.rb +26 -11
- data/lib/rex/proto/rmi/model/output_header.rb +4 -4
- data/lib/rex/proto/rmi/model/ping.rb +2 -2
- data/lib/rex/proto/rmi/model/ping_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/protocol_ack.rb +2 -2
- data/lib/rex/proto/rmi/model/return_data.rb +5 -5
- data/lib/rex/proto/rmi/model/return_value.rb +124 -0
- data/lib/rex/proto/rmi/model/unique_identifier.rb +77 -0
- data/lib/rex/proto/steam.rb +3 -0
- data/lib/rex/proto/steam/message.rb +125 -0
- data/lib/rex/proto/tftp/client.rb +35 -14
- data/lib/rex/random_identifier_generator.rb +2 -0
- data/lib/rex/ropbuilder.rb +1 -1
- data/lib/rex/socket/parameters.rb +9 -0
- data/lib/rex/socket/ssl_tcp.rb +25 -41
- data/lib/rex/socket/ssl_tcp_server.rb +10 -21
- data/lib/rex/sslscan/result.rb +20 -1
- data/lib/rex/text.rb +241 -55
- data/lib/rex/ui/output.rb +0 -3
- data/lib/rex/ui/subscriber.rb +0 -10
- data/lib/rex/ui/text/color.rb +9 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +1 -0
- data/lib/rex/ui/text/output.rb +15 -4
- data/lib/rex/ui/text/output/file.rb +1 -0
- data/lib/rex/ui/text/output/stdio.rb +0 -16
- data/lib/rex/ui/text/shell.rb +3 -0
- data/lib/rex/ui/text/table.rb +85 -19
- data/lib/rex/user_agent.rb +118 -0
- data/rex.gemspec +2 -2
- metadata +41 -14
- data/lib/rex/exploitation/powershell.rb +0 -62
- data/lib/rex/exploitation/powershell/parser.rb +0 -183
- data/lib/rex/payloads/meterpreter.rb +0 -2
- data/lib/rex/payloads/meterpreter/patch.rb +0 -136
data/lib/rex/ui/output.rb
CHANGED
data/lib/rex/ui/subscriber.rb
CHANGED
|
@@ -56,16 +56,6 @@ module Subscriber
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
#
|
|
60
|
-
# Wraps user_output.print_debug
|
|
61
|
-
#
|
|
62
|
-
def print_debug(msg='')
|
|
63
|
-
if (user_output)
|
|
64
|
-
print_blank_line if user_output.prompting?
|
|
65
|
-
user_output.print_debug(msg)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
59
|
#
|
|
70
60
|
# Wraps user_output.print_warning
|
|
71
61
|
#
|
data/lib/rex/ui/text/color.rb
CHANGED
|
@@ -75,6 +75,15 @@ module Color
|
|
|
75
75
|
str.gsub!(/%und/, pre_color+colorize('underline')+post_color)
|
|
76
76
|
str.gsub!(/%bld/, pre_color+colorize('bold')+post_color)
|
|
77
77
|
str.gsub!(/%clr/, pre_color+colorize('clear')+post_color)
|
|
78
|
+
# Background Color
|
|
79
|
+
str.gsub!(/%bgblu/, pre_color+colorize('on_blue')+post_color)
|
|
80
|
+
str.gsub!(/%bgyel/, pre_color+colorize('on_yellow')+post_color)
|
|
81
|
+
str.gsub!(/%bggrn/, pre_color+colorize('on_green')+post_color)
|
|
82
|
+
str.gsub!(/%bgmag/, pre_color+colorize('on_magenta')+post_color)
|
|
83
|
+
str.gsub!(/%bgblk/, pre_color+colorize('on_black')+post_color)
|
|
84
|
+
str.gsub!(/%bgred/, pre_color+colorize('on_red')+post_color)
|
|
85
|
+
str.gsub!(/%bgcyn/, pre_color+colorize('on_cyan')+post_color)
|
|
86
|
+
str.gsub!(/%bgwhi/, pre_color+colorize('on_white')+post_color)
|
|
78
87
|
|
|
79
88
|
str
|
|
80
89
|
end
|
data/lib/rex/ui/text/output.rb
CHANGED
|
@@ -55,10 +55,6 @@ class Output < Rex::Ui::Output
|
|
|
55
55
|
print_line("%bld%grn[+]%clr #{msg}")
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def print_debug(msg = '')
|
|
59
|
-
print_line("%bld%cya[!]%clr #{msg}")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
58
|
def print_status(msg = '')
|
|
63
59
|
print_line("%bld%blu[*]%clr #{msg}")
|
|
64
60
|
end
|
|
@@ -78,6 +74,21 @@ class Output < Rex::Ui::Output
|
|
|
78
74
|
def reset
|
|
79
75
|
end
|
|
80
76
|
|
|
77
|
+
def puts(*args)
|
|
78
|
+
args.each do |argument|
|
|
79
|
+
line = argument.to_s
|
|
80
|
+
print_raw(line)
|
|
81
|
+
|
|
82
|
+
unless line.ends_with? "\n"
|
|
83
|
+
# yes, this is output, but `IO#puts` uses `rb_default_rs`, which is
|
|
84
|
+
# [`$/`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/io.c#L12168-L12172),
|
|
85
|
+
# which is [`$INPUT_RECORD_SEPARATOR`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/lib/English.rb#L83)
|
|
86
|
+
print_raw($INPUT_RECORD_SEPARATOR)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
81
92
|
end
|
|
82
93
|
|
|
83
94
|
end
|
|
@@ -71,22 +71,6 @@ class Output::Stdio < Rex::Ui::Text::Output
|
|
|
71
71
|
end
|
|
72
72
|
alias_method :write, :print_raw
|
|
73
73
|
|
|
74
|
-
def puts(*args)
|
|
75
|
-
args.each do |argument|
|
|
76
|
-
line = argument.to_s
|
|
77
|
-
write(line)
|
|
78
|
-
|
|
79
|
-
unless line.ends_with? "\n"
|
|
80
|
-
# yes, this is output, but `IO#puts` uses `rb_default_rs`, which is
|
|
81
|
-
# [`$/`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/io.c#L12168-L12172),
|
|
82
|
-
# which is [`$INPUT_RECORD_SEPARATOR`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/lib/English.rb#L83)
|
|
83
|
-
write($INPUT_RECORD_SEPARATOR)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
nil
|
|
88
|
-
end
|
|
89
|
-
|
|
90
74
|
def supports_color?
|
|
91
75
|
case config[:color]
|
|
92
76
|
when true
|
data/lib/rex/ui/text/shell.rb
CHANGED
|
@@ -178,6 +178,9 @@ module Shell
|
|
|
178
178
|
input.prompt.gsub!(/%J/, framework.jobs.length.to_s)
|
|
179
179
|
input.prompt.gsub!(/%L/, Rex::Socket.source_address("50.50.50.50"))
|
|
180
180
|
input.prompt.gsub!(/%D/, ::Dir.getwd)
|
|
181
|
+
if framework.db.active
|
|
182
|
+
input.prompt.gsub!(/%W/, framework.db.workspace.name)
|
|
183
|
+
end
|
|
181
184
|
self.init_prompt = input.prompt
|
|
182
185
|
end
|
|
183
186
|
|
data/lib/rex/ui/text/table.rb
CHANGED
|
@@ -72,8 +72,10 @@ class Table
|
|
|
72
72
|
self.prefix = opts['Prefix'] || ''
|
|
73
73
|
self.postfix = opts['Postfix'] || ''
|
|
74
74
|
self.colprops = []
|
|
75
|
+
self.scterm = /#{opts['SearchTerm']}/mi if opts['SearchTerm']
|
|
75
76
|
|
|
76
77
|
self.sort_index = opts['SortIndex'] || 0
|
|
78
|
+
self.sort_order = opts['SortOrder'] || :forward
|
|
77
79
|
|
|
78
80
|
# Default column properties
|
|
79
81
|
self.columns.length.times { |idx|
|
|
@@ -112,7 +114,7 @@ class Table
|
|
|
112
114
|
if (is_hr(row))
|
|
113
115
|
str << hr_to_s
|
|
114
116
|
else
|
|
115
|
-
str << row_to_s(row)
|
|
117
|
+
str << row_to_s(row) if row_visible(row)
|
|
116
118
|
end
|
|
117
119
|
}
|
|
118
120
|
|
|
@@ -128,10 +130,9 @@ class Table
|
|
|
128
130
|
str = ''
|
|
129
131
|
str << ( columns.join(",") + "\n" )
|
|
130
132
|
rows.each { |row|
|
|
131
|
-
next if is_hr(row)
|
|
133
|
+
next if is_hr(row) || !row_visible(row)
|
|
132
134
|
str << ( row.map{|x|
|
|
133
135
|
x = x.to_s
|
|
134
|
-
|
|
135
136
|
x.gsub(/[\r\n]/, ' ').gsub(/\s+/, ' ').gsub('"', '""')
|
|
136
137
|
}.map{|x| "\"#{x}\"" }.join(",") + "\n" )
|
|
137
138
|
}
|
|
@@ -174,7 +175,10 @@ class Table
|
|
|
174
175
|
raise RuntimeError, 'Invalid number of columns!'
|
|
175
176
|
end
|
|
176
177
|
fields.each_with_index { |field, idx|
|
|
178
|
+
# Remove whitespace and ensure String format
|
|
179
|
+
field = field.to_s.strip
|
|
177
180
|
if (colprops[idx]['MaxWidth'] < field.to_s.length)
|
|
181
|
+
old = colprops[idx]['MaxWidth']
|
|
178
182
|
colprops[idx]['MaxWidth'] = field.to_s.length
|
|
179
183
|
end
|
|
180
184
|
}
|
|
@@ -187,21 +191,26 @@ class Table
|
|
|
187
191
|
# If the supplied index is an IPv4 address, handle it differently, but
|
|
188
192
|
# avoid actually resolving domain names.
|
|
189
193
|
#
|
|
190
|
-
def sort_rows(index=sort_index)
|
|
194
|
+
def sort_rows(index = sort_index, order = sort_order)
|
|
191
195
|
return if index == -1
|
|
192
196
|
return unless rows
|
|
193
197
|
rows.sort! do |a,b|
|
|
194
198
|
if a[index].nil?
|
|
195
|
-
-1
|
|
199
|
+
cmp = -1
|
|
196
200
|
elsif b[index].nil?
|
|
197
|
-
1
|
|
201
|
+
cmp = 1
|
|
198
202
|
elsif Rex::Socket.dotted_ip?(a[index]) and Rex::Socket.dotted_ip?(b[index])
|
|
199
|
-
Rex::Socket::addr_atoi(a[index]) <=> Rex::Socket::addr_atoi(b[index])
|
|
203
|
+
cmp = Rex::Socket::addr_atoi(a[index]) <=> Rex::Socket::addr_atoi(b[index])
|
|
200
204
|
elsif a[index] =~ /^[0-9]+$/ and b[index] =~ /^[0-9]+$/
|
|
201
|
-
a[index].to_i <=> b[index].to_i
|
|
205
|
+
cmp = a[index].to_i <=> b[index].to_i
|
|
206
|
+
elsif a[index].kind_of?(IPAddr) && a[index].kind_of?(IPAddr) && a[index].ipv6? && b[index].ipv4?
|
|
207
|
+
cmp = 1
|
|
208
|
+
elsif a[index].kind_of?(IPAddr) && b[index].kind_of?(IPAddr) && a[index].ipv4? && b[index].ipv6?
|
|
209
|
+
cmp = -1
|
|
202
210
|
else
|
|
203
|
-
a[index] <=> b[index] # assumes otherwise comparable.
|
|
211
|
+
cmp = a[index] <=> b[index] # assumes otherwise comparable.
|
|
204
212
|
end
|
|
213
|
+
order == :forward ? cmp : -cmp
|
|
205
214
|
end
|
|
206
215
|
end
|
|
207
216
|
|
|
@@ -215,6 +224,51 @@ class Table
|
|
|
215
224
|
#
|
|
216
225
|
# Returns new sub-table with headers and rows maching column names submitted
|
|
217
226
|
#
|
|
227
|
+
#
|
|
228
|
+
# Flips table 90 degrees left
|
|
229
|
+
#
|
|
230
|
+
def drop_left
|
|
231
|
+
tbl = self.class.new(
|
|
232
|
+
'Columns' => Array.new(self.rows.count+1,' '),
|
|
233
|
+
'Header' => self.header,
|
|
234
|
+
'Indent' => self.indent)
|
|
235
|
+
(self.columns.count+1).times do |ti|
|
|
236
|
+
row = self.rows.map {|r| r[ti]}.unshift(self.columns[ti]).flatten
|
|
237
|
+
# insert our col|row break. kind of hackish
|
|
238
|
+
row[1] = "| #{row[1]}" unless row.all? {|e| e.nil? || e.empty?}
|
|
239
|
+
tbl << row
|
|
240
|
+
end
|
|
241
|
+
return tbl
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
#
|
|
245
|
+
# Build table from CSV dump
|
|
246
|
+
#
|
|
247
|
+
def self.new_from_csv(csv)
|
|
248
|
+
# Read in or keep data, get CSV or die
|
|
249
|
+
if csv.is_a?(String)
|
|
250
|
+
csv = File.file?(csv) ? CSV.read(csv) : CSV.parse(csv)
|
|
251
|
+
end
|
|
252
|
+
# Adjust for skew
|
|
253
|
+
if csv.first == ["Keys", "Values"]
|
|
254
|
+
csv.shift # drop marker
|
|
255
|
+
cols = []
|
|
256
|
+
rows = []
|
|
257
|
+
csv.each do |row|
|
|
258
|
+
cols << row.shift
|
|
259
|
+
rows << row
|
|
260
|
+
end
|
|
261
|
+
tbl = self.new('Columns' => cols)
|
|
262
|
+
rows.in_groups_of(cols.count) {|r| tbl << r.flatten}
|
|
263
|
+
else
|
|
264
|
+
tbl = self.new('Columns' => csv.shift)
|
|
265
|
+
while !csv.empty? do
|
|
266
|
+
tbl << csv.shift
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
return tbl
|
|
270
|
+
end
|
|
271
|
+
|
|
218
272
|
def [](*col_names)
|
|
219
273
|
tbl = self.class.new('Indent' => self.indent,
|
|
220
274
|
'Header' => self.header,
|
|
@@ -243,10 +297,18 @@ class Table
|
|
|
243
297
|
attr_accessor :columns, :rows, :colprops # :nodoc:
|
|
244
298
|
attr_accessor :width, :indent, :cellpad # :nodoc:
|
|
245
299
|
attr_accessor :prefix, :postfix # :nodoc:
|
|
246
|
-
attr_accessor :sort_index # :nodoc:
|
|
300
|
+
attr_accessor :sort_index, :sort_order, :scterm # :nodoc:
|
|
247
301
|
|
|
248
302
|
protected
|
|
249
303
|
|
|
304
|
+
#
|
|
305
|
+
# Returns if a row should be visible or not
|
|
306
|
+
#
|
|
307
|
+
def row_visible(row)
|
|
308
|
+
return true if self.scterm.nil?
|
|
309
|
+
row_to_s(row).match(self.scterm)
|
|
310
|
+
end
|
|
311
|
+
|
|
250
312
|
#
|
|
251
313
|
# Defaults cell widths and alignments.
|
|
252
314
|
#
|
|
@@ -272,14 +334,15 @@ protected
|
|
|
272
334
|
last_idx = nil
|
|
273
335
|
columns.each_with_index { |col,idx|
|
|
274
336
|
if (last_col)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
337
|
+
# This produces clean to_s output without truncation
|
|
338
|
+
# Preserves full string in cells for to_csv output
|
|
339
|
+
padding = pad(' ', last_col, last_idx)
|
|
340
|
+
nameline << padding
|
|
341
|
+
remainder = padding.length - cellpad
|
|
342
|
+
remainder = 0 if remainder < 0
|
|
281
343
|
barline << (' ' * (cellpad + remainder))
|
|
282
344
|
end
|
|
345
|
+
|
|
283
346
|
nameline << col
|
|
284
347
|
barline << ('-' * col.length)
|
|
285
348
|
|
|
@@ -308,7 +371,6 @@ protected
|
|
|
308
371
|
if (idx != 0)
|
|
309
372
|
line << pad(' ', last_cell.to_s, last_idx)
|
|
310
373
|
end
|
|
311
|
-
# line << pad(' ', cell.to_s, idx)
|
|
312
374
|
# Limit wide cells
|
|
313
375
|
if colprops[idx]['MaxChar']
|
|
314
376
|
last_cell = cell.to_s[0..colprops[idx]['MaxChar'].to_i]
|
|
@@ -328,8 +390,12 @@ protected
|
|
|
328
390
|
# some text and a column index.
|
|
329
391
|
#
|
|
330
392
|
def pad(chr, buf, colidx, use_cell_pad = true) # :nodoc:
|
|
331
|
-
|
|
332
|
-
|
|
393
|
+
# Ensure we pad the minimum required amount
|
|
394
|
+
max = colprops[colidx]['MaxChar'] || colprops[colidx]['MaxWidth']
|
|
395
|
+
max = colprops[colidx]['MaxWidth'] if max.to_i > colprops[colidx]['MaxWidth'].to_i
|
|
396
|
+
remainder = max - buf.length
|
|
397
|
+
remainder = 0 if remainder < 0
|
|
398
|
+
val = chr * remainder
|
|
333
399
|
|
|
334
400
|
if (use_cell_pad)
|
|
335
401
|
val << ' ' * cellpad
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# A helper module for using and referencing comming user agent strings.
|
|
5
|
+
#
|
|
6
|
+
module Rex::UserAgent
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# List from https://techblog.willshouse.com/2012/01/03/most-common-user-agents/
|
|
10
|
+
# This article was updated on July 11th 2015. It's probably worth updating this
|
|
11
|
+
# list over time.
|
|
12
|
+
#
|
|
13
|
+
# This list is in the order of most common to least common.
|
|
14
|
+
#
|
|
15
|
+
COMMON_AGENTS = [
|
|
16
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
17
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
18
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
19
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.6.3 (KHTML, like Gecko) Version/8.0.6 Safari/600.6.3',
|
|
20
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
21
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
22
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
23
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
24
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
25
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
26
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',
|
|
27
|
+
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
28
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12',
|
|
29
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
30
|
+
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
31
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
32
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
|
|
33
|
+
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
34
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
35
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
|
|
36
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.125 Safari/537.36',
|
|
37
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
38
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
39
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.17 (KHTML, like Gecko) Version/8.0.5 Safari/600.5.17',
|
|
40
|
+
'Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
41
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
|
|
42
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
|
|
43
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
44
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.6.3 (KHTML, like Gecko) Version/7.1.6 Safari/537.85.15',
|
|
45
|
+
'Mozilla/5.0 (iPad; CPU OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F69 Safari/600.1.4',
|
|
46
|
+
'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko',
|
|
47
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
|
|
48
|
+
'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
49
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
50
|
+
'Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4',
|
|
51
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.17 (KHTML, like Gecko) Version/8.0.6 Safari/600.6.3',
|
|
52
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.81 Chrome/43.0.2357.81 Safari/537.36',
|
|
53
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
54
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
55
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
56
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0',
|
|
57
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
58
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
|
|
59
|
+
'Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
60
|
+
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
|
61
|
+
'Mozilla/5.0 (Windows NT 6.1; rv:39.0) Gecko/20100101 Firefox/39.0',
|
|
62
|
+
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
|
|
63
|
+
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
64
|
+
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
65
|
+
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
|
|
66
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.4.10 (KHTML, like Gecko) Version/8.0.4 Safari/600.4.10',
|
|
67
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.11 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.11',
|
|
68
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/6.1.6 Safari/537.78.2',
|
|
69
|
+
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
70
|
+
'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
71
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18',
|
|
72
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0',
|
|
73
|
+
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
74
|
+
'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
75
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
76
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.10 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.10',
|
|
77
|
+
'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
78
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
79
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
|
|
80
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36',
|
|
81
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36',
|
|
82
|
+
'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0',
|
|
83
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Firefox/38.0',
|
|
84
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
85
|
+
'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.7.0',
|
|
86
|
+
'Mozilla/5.0 (iPad; CPU OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4',
|
|
87
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36',
|
|
88
|
+
'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
89
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
|
|
90
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16',
|
|
91
|
+
'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0',
|
|
92
|
+
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
|
|
93
|
+
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0',
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Pick a random agent from the common agent list.
|
|
98
|
+
#
|
|
99
|
+
def self.random
|
|
100
|
+
COMMON_AGENTS.sample
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# Choose the agent with the shortest string (for use in payloads)
|
|
105
|
+
#
|
|
106
|
+
def self.shortest
|
|
107
|
+
@@shortest_agent ||= COMMON_AGENTS.min { |a, b| a.size <=> b.size }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Choose the most frequent user agent
|
|
112
|
+
#
|
|
113
|
+
def self.most_common
|
|
114
|
+
COMMON_AGENTS[0]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
data/rex.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
APP_NAME = "rex"
|
|
4
|
-
VERSION = "2.0.
|
|
4
|
+
VERSION = "2.0.9"
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = APP_NAME
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.description = "Rex provides a variety of classes useful for security testing and exploit development."
|
|
12
12
|
s.license = "BSD"
|
|
13
13
|
s.authors = ["HD Moore", "Jacob Hammack"]
|
|
14
|
-
s.email = ["
|
|
14
|
+
s.email = ["x@hdm.io", "jacob.hammack@hammackj.com"]
|
|
15
15
|
s.files = Dir['rex.gemspec'] + Dir['examples/**'] + Dir['lib/rex.rb'] + Dir['lib/**/*']
|
|
16
16
|
s.require_paths = ["lib"]
|
|
17
17
|
s.extra_rdoc_files = ["README.markdown"]
|