Skip to content

Commit 7f34133

Browse files
David MaloneyDavid Maloney
authored andcommitted
Land rapid7#7067, bcook's rex tools fix
this pr fixes rex requires in the various tools that were disrupted by the new gemification of rex
2 parents 054ac5a + 85937ab commit 7f34133

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

lib/rex.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ module Rex
3838
LogSource = "rex"
3939
end
4040

41+
#
42+
# REX Gems
43+
#
44+
# Text manipulation library for things like generating random string
45+
require 'rex/text'
46+
# Library for Generating Randomized strings valid as Identifiers such as variable names
47+
require 'rex/random_identifier'
48+
# library for creating Powershell scripts for exploitation purposes
49+
require 'rex/powershell'
50+
# Library for processing and creating Zip compatbile archives
51+
require 'rex/zip'
52+
# Library for parsing offline Windows Registry files
53+
require 'rex/registry'
54+
# Library for parsing Java serialized streams
55+
require 'rex/java'
56+
4157
# Generic classes
4258
require 'rex/constants'
4359
require 'rex/exceptions'

tools/exploit/find_badchars.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
1414
end
1515

16+
gem 'rex-text'
17+
1618
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
1719
require 'msfenv'
1820

@@ -112,7 +114,7 @@ def debug_buffer(name, buf)
112114
translated << ln.chomp[10,47].gsub!(/(-| )/, '')
113115
end
114116
from_dbg = Rex::Text.hex_to_raw(translated)
115-
117+
116118
when "gdb"
117119
translated = ''
118120
from_dbg.each_line do |ln|

tools/exploit/metasm_shell.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
2121
end
2222

23+
gem 'rex-text'
24+
2325
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
2426
require 'msfenv'
2527

@@ -40,7 +42,7 @@ def usage
4042
$stderr.puts("\nUsage: #{$0} <options>\n" + $args.usage)
4143
exit
4244
end
43-
45+
4446
$args = Rex::Parser::Arguments.new(
4547
"-a" => [ true, "The architecture to encode as (#{@Arch.sort.collect{|a| a + ', ' }.join.gsub(/\, $/,'')})"],
4648
"-e" => [ true, "The endianess to encode as (#{@Endian.sort.collect{|a| a + ', ' }.join.gsub(/\, $/,'')})" ],

tools/exploit/pattern_create.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
99
$LOAD_PATH.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
1010

11+
gem 'rex-text'
12+
1113
require 'optparse'
1214

1315
module PatternCreate
@@ -72,7 +74,6 @@ def run
7274
begin
7375
driver.run
7476
rescue ::StandardError => e
75-
elog("#{e.class}: #{e.message}\n#{e.backtrace * "\n"}")
7677
$stderr.puts "[x] #{e.class}: #{e.message}"
7778
$stderr.puts "[*] If necessary, please refer to framework.log for more details."
7879
end

tools/exploit/pattern_offset.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
99
$LOAD_PATH.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
1010

11+
gem 'rex-text'
12+
1113
require 'optparse'
1214

1315
module PatternOffset
@@ -140,7 +142,6 @@ def run
140142
begin
141143
driver.run
142144
rescue ::StandardError => e
143-
elog("#{e.class}: #{e.message}\n#{e.backtrace * "\n"}")
144145
$stderr.puts "[x] #{e.class}: #{e.message}"
145146
$stderr.puts "[*] If necessary, please refer to framework.log for more details."
146147

tools/exploit/psexec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
1010
end
1111

12+
gem 'rex-text'
13+
1214
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
1315
require 'msfenv'
1416

@@ -67,7 +69,7 @@ def dcerpc_bind(handle, csocket, csimple, cuser, cpass)
6769
opts['smb_pass'] = cpass
6870
opts['frag_size'] = 512
6971
opts['smb_client'] = csimple
70-
72+
7173
Rex::Proto::DCERPC::Client.new(handle, csocket, opts)
7274
end
7375

@@ -131,7 +133,7 @@ def dcerpc_call(function, stub = '', timeout=nil, do_recv=true)
131133
exit(1)
132134
end
133135

134-
136+
135137

136138
fname = Rex::Text.rand_text_alpha(8) + ".exe"
137139
sname = Rex::Text.rand_text_alpha(8)

tools/modules/update_payload_cached_sizes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
1515

16+
gem 'rex-text'
17+
1618
require 'rex'
1719
require 'msf/ui'
1820
require 'msf/base'

tools/password/cpassword_decrypt.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838
end
3939

4040
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
41+
42+
gem 'rex-text'
43+
4144
require 'msfenv'
4245
require 'rex'
4346

44-
4547
class CPassword
4648

4749
#
@@ -128,4 +130,4 @@ def print_good(msg='')
128130
else
129131
print_good("The decrypted AES password is: #{pass}")
130132
end
131-
end
133+
end

0 commit comments

Comments
 (0)