Skip to content

Commit cc5b852

Browse files
author
us3r777
committed
Fixed spec for lib/msf/http/jboss
Revert commit abdd72e. Added some spec for lib/msf/http/jboss/deployment_file_repository_scripts
1 parent 283e830 commit cc5b852

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

lib/msf/http/jboss/deployment_file_repository_scripts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def head_stager_jsp(stager_base, stager_jsp_name)
4242
#
4343
# @param app_base [String] The name of the WAR app to write.
4444
# @return [String] The JSP stager.
45-
def stager_jsp(app_base, encoded_payload)
45+
def stager_jsp_with_payload(app_base, encoded_payload)
4646
decoded_var = Rex::Text.rand_text_alpha(8+rand(8))
4747
file_path_var = Rex::Text.rand_text_alpha(8+rand(8))
4848
jboss_home_var = Rex::Text.rand_text_alpha(8+rand(8))

modules/exploits/multi/http/jboss_deploymentfilerepository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def exploit
120120
}).to_s
121121

122122
encoded_payload = Rex::Text.encode_base64(war_data).gsub(/\n/, '')
123-
stager_contents = stager_jsp(app_base, encoded_payload)
123+
stager_contents = stager_jsp_with_payload(app_base, encoded_payload)
124124
# Depending on the type on the verb we might use a second stager
125125
if http_verb == "POST" then
126126
print_status("Deploying stager for the WAR file")

spec/lib/msf/http/jboss/scripts_spec.rb renamed to spec/lib/msf/http/jboss/bean_shell_scripts_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'msf/core'
55
require 'msf/http/jboss'
66

7-
describe Msf::HTTP::JBoss::Scripts do
7+
describe Msf::HTTP::JBoss::BeanShellScripts do
88
subject do
99
mod = ::Msf::Exploit.new
1010
mod.extend Msf::HTTP::JBoss
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#-*- coding:binary -*-
2+
require 'spec_helper'
3+
4+
require 'msf/core'
5+
require 'msf/http/jboss'
6+
7+
describe Msf::HTTP::JBoss::DeploymentFileRepositoryScripts do
8+
subject do
9+
mod = ::Msf::Exploit.new
10+
mod.extend Msf::HTTP::JBoss
11+
mod.send(:initialize)
12+
mod
13+
end
14+
15+
describe "#stager_jsp_with_payload" do
16+
it "returns the JSP stager" do
17+
expect(subject.stager_jsp_with_payload('metasploit', 'payload')).to include('System.getProperty("jboss.server.home.dir");')
18+
end
19+
20+
it "uses the provided application name" do
21+
expect(subject.stager_jsp_with_payload('metasploit', 'payload')).to include('"/deploy/" + "metasploit.war";')
22+
end
23+
24+
it "uses the provided payload" do
25+
expect(subject.stager_jsp_with_payload('metasploit', 'payload')).to include('"payload";')
26+
end
27+
end
28+
29+
describe "#head_stager_jsp" do
30+
it "returns the head JSP stager" do
31+
expect(subject.head_stager_jsp('stager_base', 'jsp_name')).to include('System.getProperty("jboss.server.home.dir");')
32+
end
33+
34+
it "uses the provided base name" do
35+
expect(subject.head_stager_jsp('stager_base', 'jsp_name')).to include('"/deploy/management/" + "stager_base.war/"')
36+
end
37+
end
38+
39+
end

0 commit comments

Comments
 (0)