|
| 1 | +#-*- coding:binary -*- |
| 2 | +require 'spec_helper' |
| 3 | + |
| 4 | +require 'msf/core' |
| 5 | +require 'msf/http/jboss' |
| 6 | + |
| 7 | +describe Msf::HTTP::JBoss::BeanShellScripts 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 "#generate_bsh" do |
| 16 | + |
| 17 | + end |
| 18 | + |
| 19 | + describe "#stager_jsp" do |
| 20 | + it "returns the JSP stager" do |
| 21 | + expect(subject.stager_jsp('metasploit')).to include('System.getProperty("jboss.server.home.dir");') |
| 22 | + end |
| 23 | + |
| 24 | + it "uses the provided application name" do |
| 25 | + expect(subject.stager_jsp('metasploit')).to include('"/deploy/" + "metasploit.war";') |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + describe "#create_file_bsh" do |
| 30 | + it "returns the Bean Shell script" do |
| 31 | + expect(subject.create_file_bsh({})).to include('String jboss_home = System.getProperty("jboss.server.home.dir");') |
| 32 | + end |
| 33 | + |
| 34 | + context "when options are provided" do |
| 35 | + let(:opts) do |
| 36 | + { |
| 37 | + :file => 'file', |
| 38 | + :dir => 'dir', |
| 39 | + :contents => 'contents' |
| 40 | + } |
| 41 | + end |
| 42 | + |
| 43 | + it { expect(subject.create_file_bsh(opts)).to include('String location = jboss_home + "/deploy/file";')} |
| 44 | + it { expect(subject.create_file_bsh(opts)).to include('"/deploy/dir").mkdir()')} |
| 45 | + it { expect(subject.create_file_bsh(opts)).to include('String val = "contents";')} |
| 46 | + end |
| 47 | + end |
| 48 | + |
| 49 | + describe "#delete_files_bsh" do |
| 50 | + it "returns the Bean Shell script" do |
| 51 | + expect(subject.delete_files_bsh({})).to include('String jboss_home = System.getProperty("jboss.server.home.dir");') |
| 52 | + end |
| 53 | + |
| 54 | + context "when filenames are provided" do |
| 55 | + let(:opts) do |
| 56 | + { |
| 57 | + 'one' => '/tmp/one', |
| 58 | + 'two' => '/tmp/two' |
| 59 | + } |
| 60 | + end |
| 61 | + |
| 62 | + it { expect(subject.delete_files_bsh(opts)).to include('new File(jboss_home + "/deploy//tmp/one").delete();')} |
| 63 | + it { expect(subject.delete_files_bsh(opts)).to include('new File(jboss_home + "/deploy//tmp/two").delete();')} |
| 64 | + end |
| 65 | + end |
| 66 | + |
| 67 | +end |
0 commit comments