Skip to content

Commit cd755b0

Browse files
committed
update powershell specs for rex-powershell 0.1.77
1 parent 43b67fe commit cd755b0

File tree

7 files changed

+22
-25
lines changed

7 files changed

+22
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 1501
13+
CachedSize = 1518
1414

1515
include Msf::Payload::Single
1616
include Rex::Powershell::Command

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 1509
13+
CachedSize = 1526
1414

1515
include Msf::Payload::Single
1616
include Rex::Powershell::Command

modules/payloads/singles/windows/powershell_bind_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
###
1616
module MetasploitModule
1717

18-
CachedSize = 1501
18+
CachedSize = 1518
1919

2020
include Msf::Payload::Windows::Exec
2121
include Rex::Powershell::Command

modules/payloads/singles/windows/powershell_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
###
1616
module MetasploitModule
1717

18-
CachedSize = 1509
18+
CachedSize = 1526
1919

2020
include Msf::Payload::Windows::Exec
2121
include Msf::Payload::Windows::Powershell

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
###
1616
module MetasploitModule
1717

18-
CachedSize = 1501
18+
CachedSize = 1518
1919

2020
include Msf::Payload::Windows::Exec_x64
2121
include Rex::Powershell::Command

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
###
1616
module MetasploitModule
1717

18-
CachedSize = 1509
18+
CachedSize = 1526
1919

2020
include Msf::Payload::Windows::Exec_x64
2121
include Msf::Payload::Windows::Powershell

spec/lib/msf/core/exploit/powershell_spec.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,9 @@ def decompress(code)
313313
subject.datastore['Powershell::method'] = 'msil'
314314
subject.options.validate(subject.datastore)
315315
end
316-
it 'should raise an exception' do
317-
except = false
318-
begin
319-
subject.cmd_psh_payload(payload, arch)
320-
rescue RuntimeError
321-
except = true
322-
end
323-
expect(except).to be_truthy
316+
it 'should generate a command line' do
317+
code = subject.cmd_psh_payload(payload, arch)
318+
expect(decompress(code).include?('System.Reflection.MethodInfo')).to be_truthy
324319
end
325320
end
326321

@@ -396,10 +391,10 @@ def decompress(code)
396391
end
397392
end
398393

399-
context 'when use single quotes' do
400-
it 'should wrap in single quotes' do
401-
code = subject.cmd_psh_payload(payload, arch, {:use_single_quotes => true})
402-
expect(code.include?(' -c \'')).to be_truthy
394+
context 'when wrap double quotes' do
395+
it 'should wrap in double quotes' do
396+
code = subject.cmd_psh_payload(payload, arch, {:wrap_double_quotes => true})
397+
expect(code.include?(' -c "')).to be_truthy
403398
end
404399
end
405400
end
@@ -449,7 +444,8 @@ def decompress(code)
449444
[:sta, true],
450445
[:noprofile, true],
451446
[:windowstyle, "hidden"],
452-
[:command, "Z"]
447+
[:command, "Z"],
448+
[:wrap_double_quotes, true]
453449
]
454450

455451
permutations = (0..command_args.length).to_a.combination(2).map{|i,j| command_args[i...j]}
@@ -464,20 +460,21 @@ def decompress(code)
464460
opts[:shorten] = false
465461
long_args = subject.generate_psh_args(opts)
466462

467-
opt_length = opts.length - 1
468-
469463
expect(short_args).not_to be_nil
470464
expect(long_args).not_to be_nil
471-
expect(short_args.count('-')).to eql opt_length
472-
expect(long_args.count('-')).to eql opt_length
473465
expect(short_args[0]).not_to eql " "
474466
expect(long_args[0]).not_to eql " "
475467
expect(short_args[-1]).not_to eql " "
476468
expect(long_args[-1]).not_to eql " "
477469

478470
if opts[:command]
479-
expect(long_args[-10..-1]).to eql "-Command Z"
480-
expect(short_args[-4..-1]).to eql "-c Z"
471+
if opts[:wrap_double_quotes]
472+
expect(long_args[-12..-1]).to eql "-Command \"Z\""
473+
expect(short_args[-6..-1]).to eql "-c \"Z\""
474+
else
475+
expect(long_args[-10..-1]).to eql "-Command Z"
476+
expect(short_args[-4..-1]).to eql "-c Z"
477+
end
481478
end
482479
end
483480
end

0 commit comments

Comments
 (0)