rex-powershell 0.1.93 → 0.1.96

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 264ef895e51a24ebc9faec44d558f16f4d7324e75dc7b9c7f9c5ce504b14eaea
4
- data.tar.gz: 79a682962f60136c0189156715dd190e2d4573c64851a601ab05f4d1e2a15db8
3
+ metadata.gz: 533b355fdb313b3ea465af07001b7f0e660cbe9692a5fe61347fb0c259970c00
4
+ data.tar.gz: 7c21738e84b817fad4ca0b4498cd9e47d5a73933063d7b5b56766d3b95daafcc
5
5
  SHA512:
6
- metadata.gz: 6f2ba77f0172164a76f00607cccf083c63b163dc321df4f0c40d49397bc269e18b13282a3f5f91807423e3eecfaf289c623d1a516a4c7831c2faaade17686c2f
7
- data.tar.gz: 116b6339f8c82e719915c7359d34845f0ab140fa14f61934ad5359567b1c67fdbf9940f62e19828ff596904d2e308e40428c7be59c816f25218fd9a06f3281aa
6
+ metadata.gz: 2d9088c3d6160de7008882c2a335f8449c09628f42eeb3140e5a33aca0609c95bd2a628b142c878940059e2e01350ab817769069c02ba838c6ebe9483833de8d
7
+ data.tar.gz: 7498366f191e68ff7413413677521b28f8add5f8b5d65edb9049c776a8c568708b32abca9ed2efdd8a05e9b7a44430fb022f37daa608dcf4ef2a31ffb2d6dda5
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- CN
1
+ g
2
+ >�\�*<�#���-̥80iu�.�����&HK�30dn�ZrX\�ꑓ��M�L������V4���9h�q��A0�M�u��pP�����a�w�sXyw��s��x��UMyp̓���f��'>B]��m���_��i���X"*��S�����A��)&�σH.4��u7 a��l�P����$Q�rK�]`�Ŧ�
@@ -17,10 +17,10 @@ jobs:
17
17
  fail-fast: true
18
18
  matrix:
19
19
  ruby:
20
- - 2.5
21
20
  - 2.6
22
21
  - 2.7
23
22
  - 3.0
23
+ - 3.1
24
24
  test_cmd:
25
25
  - bundle exec rspec
26
26
 
@@ -293,11 +293,11 @@ EOS
293
293
  # @return [String] Powershell command line with payload
294
294
  def self.cmd_psh_payload(pay, payload_arch, template_path, opts = {})
295
295
  if opts[:encode_inner_payload] && opts[:encode_final_payload]
296
- fail RuntimeError, ':encode_inner_payload and :encode_final_payload are incompatible options'
296
+ fail Exceptions::PowershellError, ':encode_inner_payload and :encode_final_payload are incompatible options'
297
297
  end
298
298
 
299
299
  if opts[:no_equals] && !opts[:encode_final_payload]
300
- fail RuntimeError, ':no_equals requires :encode_final_payload option to be used'
300
+ fail Exceptions::PowershellError, ':no_equals requires :encode_final_payload option to be used'
301
301
  end
302
302
 
303
303
  psh_payload = case opts[:method]
@@ -310,7 +310,7 @@ EOS
310
310
  when 'msil'
311
311
  Rex::Powershell::Payload.to_win32pe_psh_msil(template_path, pay)
312
312
  else
313
- fail RuntimeError, 'No Powershell method specified'
313
+ fail Exceptions::PowershellError, 'No Powershell method specified'
314
314
  end
315
315
 
316
316
  if opts[:exec_rc4]
@@ -405,7 +405,7 @@ EOS
405
405
  end
406
406
 
407
407
  if command.length > 8191
408
- fail RuntimeError, 'Powershell command length is greater than the command line maximum (8192 characters)'
408
+ fail Exceptions::PowershellCommandLengthError, 'Powershell command length is greater than the command line maximum (8192 characters)'
409
409
  end
410
410
 
411
411
  command
@@ -0,0 +1,16 @@
1
+ # -*- coding: binary -*-
2
+
3
+ module Rex
4
+ module Powershell
5
+ module Exceptions
6
+
7
+ class PowershellError < RuntimeError
8
+ end
9
+
10
+ class PowershellCommandLengthError < PowershellError
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -67,7 +67,7 @@ module Powershell
67
67
  # Deobfuscate a Powershell literal string value that was previously obfuscated by #scate_string_literal.
68
68
  #
69
69
  # @param [String] string The obfuscated Powershell expression to deobfuscate.
70
- # @raises [RuntimeError] If the string can not be deobfuscated, for example because it was randomized using a
70
+ # @raises [Exceptions::PowershellError] If the string can not be deobfuscated, for example because it was randomized using a
71
71
  # different routine, then an exception is raised.
72
72
  # @return [String] The string literal value.
73
73
  def self.descate_string_literal(string)
@@ -79,14 +79,14 @@ module Powershell
79
79
  format = Regexp.last_match(0)
80
80
  format_args = string[format.length..-1].strip
81
81
  unless format_args =~ /-f\s*('.',\s*)*('.')/
82
- raise RuntimeError.new('The obfuscated string structure is unsupported')
82
+ raise Exceptions::PowershellError, 'The obfuscated string structure is unsupported'
83
83
  end
84
84
  format_args = format_args[2..-1].strip.scan(/'(.)'/).map { |match| match[0] }
85
85
  string = format[1...-1].strip
86
86
  end
87
87
 
88
88
  unless string =~ /^'.*'$/
89
- raise RuntimeError.new('The obfuscated string structure is unsupported')
89
+ raise Exceptions::PowershellError, 'The obfuscated string structure is unsupported'
90
90
  end
91
91
  string = string.gsub(/'\s*\+\s*'/, '') # process all concatenation operations
92
92
  unless format_args.nil? # process all format string operations
@@ -146,7 +146,7 @@ module Powershell
146
146
  elsif @code =~ /FromBase64String(\((?>[^)(]+|\g<1>)*\))/
147
147
  encoded_stream = Obfu.descate_string_literal(Regexp.last_match(1))
148
148
  else
149
- raise RuntimeError, 'Failed to identify the base64 data'
149
+ raise Exceptions::PowershellError, 'Failed to identify the base64 data'
150
150
  end
151
151
 
152
152
  # Decode and decompress the string
@@ -157,7 +157,7 @@ module Powershell
157
157
  begin
158
158
  @code = Rex::Text.zlib_inflate(unencoded)
159
159
  rescue Zlib::DataError => e
160
- raise RuntimeError, 'Invalid compression'
160
+ raise Exceptions::PowershellError, 'Invalid compression'
161
161
  end
162
162
  end
163
163
 
@@ -48,7 +48,7 @@ module Powershell
48
48
 
49
49
  # Close open file
50
50
  fd.close
51
- rescue Errno::ENAMETOOLONG, Errno::ENOENT
51
+ rescue Errno::ENAMETOOLONG, Errno::ENOENT, Errno::EINVAL
52
52
  # Treat code as a... code
53
53
  @code = code.to_s.dup # in case we're eating another script
54
54
  end
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Powershell
3
- VERSION = "0.1.93"
3
+ VERSION = "0.1.96"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # -*- coding: binary -*-
2
2
  require 'rex/powershell/version'
3
+ require 'rex/powershell/exceptions'
3
4
  require 'rex/powershell/output'
4
5
  require 'rex/powershell/parser'
5
6
  require 'rex/powershell/obfu'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-powershell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.93
4
+ version: 0.1.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2021-09-03 00:00:00.000000000 Z
96
+ date: 2022-04-07 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
@@ -189,6 +189,7 @@ files:
189
189
  - data/templates/to_mem_rc4.ps1.template
190
190
  - lib/rex/powershell.rb
191
191
  - lib/rex/powershell/command.rb
192
+ - lib/rex/powershell/exceptions.rb
192
193
  - lib/rex/powershell/function.rb
193
194
  - lib/rex/powershell/obfu.rb
194
195
  - lib/rex/powershell/output.rb
metadata.gz.sig CHANGED
Binary file