From 4ffd16691864bcb34603d782f11e4ec971963057 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 Date: Mon, 18 Aug 2014 11:31:36 -0500 Subject: [PATCH] Add specs for Rex::Exploitation::EncryptJS --- spec/lib/rex/exploitation/encryptjs_spec.rb | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/lib/rex/exploitation/encryptjs_spec.rb diff --git a/spec/lib/rex/exploitation/encryptjs_spec.rb b/spec/lib/rex/exploitation/encryptjs_spec.rb new file mode 100644 index 0000000000..c3db14b508 --- /dev/null +++ b/spec/lib/rex/exploitation/encryptjs_spec.rb @@ -0,0 +1,35 @@ +# -*- coding:binary -*- +require 'spec_helper' + +require 'rex/exploitation/encryptjs' + +describe Rex::Exploitation::EncryptJS do + + let(:code) { "var test = 'metasploit';" } + let(:key) { "secret" } + let(:signature) { "metasploit" } + let(:loader_signature) { "location.search.substring(1);" } + let(:loader_key_words) { ['exploit', 'encoded', 'pass', 'decoded'] } + + describe "Rex::Exploitation::EncryptJS.encrypt" do + it "returns an String" do + expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to be_an(String) + end + + it "returns the JavaScript loader code" do + expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to include(loader_signature) + end + + it "encrypts the code" do + expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to_not include(signature) + end + + it "obfuscates the loader" do + loader_key_words.each do |key_word| + expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to_not include(key_word) + end + end + + end + +end