Skip to content

Commit

Permalink
Merge pull request #2 from Meatballs1/psh_fix
Browse files Browse the repository at this point in the history
Add guards against empty payloads
  • Loading branch information
shellster committed Aug 24, 2013
2 parents 099b824 + b4b59aa commit 50dfac9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/rex/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def self.to_java(str, name = "shell")
# Converts a raw string to a powershell byte array
#
def self.to_powershell(str, name = "buf")
return "[Byte[]]$#{name} = ''" if str.nil? or str.empty?

code = str.unpack('C*')
buff = "[Byte[]]$#{name} = 0x#{code[0].to_s(16)}"
1.upto(code.length-1) do |byte|
Expand All @@ -219,6 +221,8 @@ def self.to_powershell(str, name = "buf")
# Converts a raw string to a vbscript byte array
#
def self.to_vbscript(str, name = "buf")
return "#{name}" if str.nil? or str.empty?

code = str.unpack('C*')
buff = "#{name}=Chr(#{code[0]})"
1.upto(code.length-1) do |byte|
Expand All @@ -238,6 +242,8 @@ def self.to_vbscript(str, name = "buf")
# Converts a raw string into a vba buffer
#
def self.to_vbapplication(str, name = "buf")
return "#{name} = Array()" if str.nil? or str.empty?

code = str.unpack('C*')
buff = "#{name} = Array("
maxbytes = 20
Expand Down

0 comments on commit 50dfac9

Please sign in to comment.