Skip to content

Commit 7bf6377

Browse files
committed
Land rapid7#3663 - Add specs for Rex::Exploitation::EncryptJS
2 parents dc95b01 + 3dae6ee commit 7bf6377

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding:binary -*-
2+
require 'spec_helper'
3+
4+
require 'rex/exploitation/encryptjs'
5+
6+
describe Rex::Exploitation::EncryptJS do
7+
8+
let(:code) { "var test = 'metasploit';" }
9+
let(:key) { 'secret' }
10+
let(:signature) { 'metasploit' }
11+
let(:loader_signature) { 'location.search.substring(1);' }
12+
let(:loader_key_words) { ['exploit', 'encoded', 'pass', 'decoded'] }
13+
14+
describe ".encrypt" do
15+
it "returns an String" do
16+
expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to be_an(String)
17+
end
18+
19+
it "returns the JavaScript loader code" do
20+
expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to include(loader_signature)
21+
end
22+
23+
it "encrypts the code" do
24+
expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to_not include(signature)
25+
end
26+
27+
it "obfuscates the loader" do
28+
loader_key_words.each do |key_word|
29+
expect(Rex::Exploitation::EncryptJS.encrypt(code, key)).to_not include(key_word)
30+
end
31+
end
32+
33+
end
34+
35+
end

0 commit comments

Comments
 (0)