Skip to content

Commit 50dfac9

Browse files
author
shellster
committed
Merge pull request #2 from Meatballs1/psh_fix
Add guards against empty payloads
2 parents 099b824 + b4b59aa commit 50dfac9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/rex/text.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ def self.to_java(str, name = "shell")
202202
# Converts a raw string to a powershell byte array
203203
#
204204
def self.to_powershell(str, name = "buf")
205+
return "[Byte[]]$#{name} = ''" if str.nil? or str.empty?
206+
205207
code = str.unpack('C*')
206208
buff = "[Byte[]]$#{name} = 0x#{code[0].to_s(16)}"
207209
1.upto(code.length-1) do |byte|
@@ -219,6 +221,8 @@ def self.to_powershell(str, name = "buf")
219221
# Converts a raw string to a vbscript byte array
220222
#
221223
def self.to_vbscript(str, name = "buf")
224+
return "#{name}" if str.nil? or str.empty?
225+
222226
code = str.unpack('C*')
223227
buff = "#{name}=Chr(#{code[0]})"
224228
1.upto(code.length-1) do |byte|
@@ -238,6 +242,8 @@ def self.to_vbscript(str, name = "buf")
238242
# Converts a raw string into a vba buffer
239243
#
240244
def self.to_vbapplication(str, name = "buf")
245+
return "#{name} = Array()" if str.nil? or str.empty?
246+
241247
code = str.unpack('C*')
242248
buff = "#{name} = Array("
243249
maxbytes = 20

0 commit comments

Comments
 (0)