Skip to content

Commit f56eac7

Browse files
author
HD Moore
committed
Cosmetic cleanup and binary mode read for powershell script
1 parent 82fe480 commit f56eac7

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

modules/payloads/singles/cmd/windows/powershell_bind_tcp.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ def generate
4848
lport = datastore['LPORT']
4949
lhost = datastore['LHOST']
5050

51-
template_path = File.join(
52-
Msf::Config.data_directory,
53-
'exploits',
54-
'powershell',
55-
'powerfun.ps1')
56-
57-
script_in = File.read(template_path)
51+
template_path = ::File.join( Msf::Config.data_directory, 'exploits', 'powershell','powerfun.ps1')
52+
script_in = ""
53+
::File.open(template_path, "rb") do |fd|
54+
script_in << fd.read(fd.stat.size)
55+
end
5856
script_in << "\npowerfun -Command bind"
5957

6058
mods = ''

modules/payloads/singles/cmd/windows/powershell_reverse_tcp.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ def generate
4848
lport = datastore['LPORT']
4949
lhost = datastore['LHOST']
5050

51-
template_path = File.join(
52-
Msf::Config.data_directory,
53-
'exploits',
54-
'powershell',
55-
'powerfun.ps1')
51+
template_path = ::File.join( Msf::Config.data_directory, 'exploits', 'powershell','powerfun.ps1')
52+
script_in = ""
53+
::File.open(template_path, "rb") do |fd|
54+
script_in << fd.read(fd.stat.size)
55+
end
5656

57-
script_in = File.read(template_path)
5857
script_in << "\npowerfun -Command reverse"
5958

6059
mods = ''

modules/payloads/singles/windows/powershell_bind_tcp.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def initialize(info = {})
5353
def command_string
5454
lport = datastore['LPORT']
5555

56-
template_path = File.join(
57-
Msf::Config.data_directory,
58-
'exploits',
59-
'powershell',
60-
'powerfun.ps1')
56+
template_path = ::File.join( Msf::Config.data_directory, 'exploits', 'powershell','powerfun.ps1')
57+
script_in = ""
58+
::File.open(template_path, "rb") do |fd|
59+
script_in << fd.read(fd.stat.size)
60+
end
6161

6262
script_in = File.read(template_path)
6363
script_in << "\npowerfun -Command bind"

modules/payloads/singles/windows/powershell_reverse_tcp.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ def command_string
5454
lport = datastore['LPORT']
5555
lhost = datastore['LHOST']
5656

57-
template_path = File.join(
58-
Msf::Config.data_directory,
59-
'exploits',
60-
'powershell',
61-
'powerfun.ps1')
62-
63-
script_in = File.read(template_path)
57+
template_path = ::File.join( Msf::Config.data_directory, 'exploits', 'powershell','powerfun.ps1')
58+
script_in = ""
59+
::File.open(template_path, "rb") do |fd|
60+
script_in << fd.read(fd.stat.size)
61+
end
6462
script_in << "\npowerfun -Command reverse"
6563

6664
mods = ''

0 commit comments

Comments
 (0)