Skip to content

Commit b4b59aa

Browse files
committed
Add guards against empty payloads
1 parent 099b824 commit b4b59aa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: lib/rex/text.rb

+6
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)