Skip to content

Commit 5ff8a58

Browse files
committed
Make sure linux payloads produce /bin/sh
1 parent 8a13dc5 commit 5ff8a58

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

spec/msfvenom_spec.rb

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,30 @@
137137

138138
end
139139

140-
context "building an elf with linux/x86/shell_bind_tcp" do
141-
let(:args) { %w! -f elf -p linux/x86/shell_bind_tcp ! }
142-
# We're not encoding, so should be testable here
143-
it "should contain /bin/sh" do
144-
output = venom.generate_raw_payload
145-
# usually push'd, so it's not all strung together
146-
output.should include("/sh")
147-
output.should include("/bin")
140+
[
141+
{ :format => "elf", :arch => "x86" },
142+
{ :format => "raw", :arch => "x86" },
143+
{ :format => "elf", :arch => "armle" },
144+
{ :format => "raw", :arch => "armle" },
145+
{ :format => "elf", :arch => "ppc" },
146+
{ :format => "raw", :arch => "ppc" },
147+
{ :format => "elf", :arch => "mipsle" },
148+
{ :format => "raw", :arch => "mipsle" },
149+
].each do |format_hash|
150+
format = format_hash[:format]
151+
arch = format_hash[:arch]
152+
153+
context "building #{format} with linux/#{arch}/shell_bind_tcp" do
154+
let(:args) { %W! -f #{format} -p linux/#{arch}/shell_bind_tcp ! }
155+
# We're not encoding, so should be testable here
156+
it "should contain /bin/sh" do
157+
output = venom.generate_raw_payload
158+
# usually push'd, so it's not all strung together
159+
output.should include("/sh")
160+
output.should include("/bin")
161+
end
148162
end
149-
end
150163

151-
context "with a raw linux/x86/shell_bind_tcp" do
152-
let(:args) { %w! -f raw -p linux/x86/shell_bind_tcp ! }
153-
# We're not encoding, so should be testable here
154-
it "should contain /bin/sh" do
155-
output = venom.generate_raw_payload
156-
# usually push'd, so it's not all strung together
157-
output.should include("/sh")
158-
output.should include("/bin")
159-
end
160164
end
161165

162166
end
@@ -175,21 +179,23 @@
175179

176180
context "without required datastore option" do
177181
# Requires LHOST
178-
let(:args) { %w!-f exe -p windows/shell_reverse_tcp ! }
182+
let(:args) { %w!-f exe -p windows/shell_reverse_tcp! }
179183
it "should fail validation" do
180184
expect { venom.generate }.to raise_error(Msf::OptionValidateError)
181185
end
182186
end
183187

184188
@platform_format_map.each do |plat, formats|
185189
formats.each do |format_hash|
190+
format = format_hash[:format]
191+
arch = format_hash[:arch]
186192
# Need a new context for each so the let() will work correctly
187-
context "with format=#{format_hash[:format]} platform=#{plat} arch=#{format_hash[:arch]}" do
193+
context "with format=#{format} platform=#{plat} arch=#{arch}" do
188194
# This will build executables with no payload. They won't work
189195
# of course, but at least we can see that it is producing the
190196
# correct file format for the given arch and platform.
191-
let(:args) { %W! -p - -f #{format_hash[:format]} -a #{format_hash[:arch]} --platform #{plat} ! }
192-
it "should print a #{format_hash[:format]} to stdout" do
197+
let(:args) { %W! -p - -f #{format} -a #{arch} --platform #{plat} ! }
198+
it "should print a #{format} to stdout" do
193199
venom.generate
194200
output = stdout.string
195201
verify_bin_fingerprint(format_hash, output)

0 commit comments

Comments
 (0)