Add specs for new methods.

bug/bundler_fix
Joe Vennix 2014-03-02 20:23:20 -06:00
parent 6825fd2486
commit b458b8ad63
3 changed files with 32 additions and 2 deletions

View File

@ -57,8 +57,8 @@ class Network
# @param [Hash] opts the options hash # @param [Hash] opts the options hash
# @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true. # @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true.
# @return [String] javascript code to perform a POST of the specified params # @return [String] javascript code to build and submit a form that POSTs the params
def self.ajax_post(opts={}) def self.form_post(opts={})
should_obfuscate = opts.fetch(:obfuscate, true) should_obfuscate = opts.fetch(:obfuscate, true)
js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "form_post.js")) js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "form_post.js"))

View File

@ -16,7 +16,13 @@ describe Rex::Exploitation::Js::Network do
js = Rex::Exploitation::Js::Network.ajax_post js = Rex::Exploitation::Js::Network.ajax_post
js.should =~ /function postInfo/ js.should =~ /function postInfo/
end end
end
context ".form_post" do
it "should load the postForm javascript" do
js = Rex::Exploitation::Js::Network.form_post
js.should =~ /function postForm/
end
end end
end end

View File

@ -216,6 +216,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("bar=baz") str.should include("bar=baz")
str.should include("frobnicate=the froozle?") str.should include("frobnicate=the froozle?")
end end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("foo[]=bar") }
it { should include("bar=baz") }
it { should include("frobnicate=the froozle?") }
end
end end
context "with 'encode_params'" do context "with 'encode_params'" do
@ -227,6 +235,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("bar=baz") str.should include("bar=baz")
str.should include("frobnicate=the%20froozle%3f") str.should include("frobnicate=the%20froozle%3f")
end end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("foo%5b%5d=bar") }
it { should include("bar=baz") }
it { should include("frobnicate=the%20froozle%3f") }
end
end end
context "and 'uri_encode_mode' = hex-all" do context "and 'uri_encode_mode' = hex-all" do
@ -237,6 +253,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("%62%61%72=%62%61%7a") str.should include("%62%61%72=%62%61%7a")
str.should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") str.should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f")
end end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("%66%6f%6f%5b%5d=%62%61%72") }
it { should include("%62%61%72=%62%61%7a") }
it { should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") }
end
end end
describe "#to_s" do describe "#to_s" do