forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes large-string expansion in JSObfu.
- Loading branch information
Showing
3 changed files
with
181 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
require 'rex/exploitation/jsobfu' | ||
|
||
describe Rex::Exploitation::JSObfu::Scope do | ||
|
||
subject(:scope) do | ||
described_class.new() | ||
end | ||
|
||
describe '#random_var_name' do | ||
subject(:random_var_name) { scope.random_var_name } | ||
|
||
it { should be_a String } | ||
it { should_not be_empty } | ||
|
||
it 'is composed of _, $, alphanumeric chars' do | ||
20.times { expect(scope.random_var_name).to match(/\A[a-zA-Z0-9$_]+\Z/) } | ||
end | ||
|
||
it 'does not start with a number' do | ||
20.times { expect(scope.random_var_name).not_to match(/\A[0-9]/) } | ||
end | ||
|
||
context 'when a reserved word is generated' do | ||
let(:reserved) { described_class::RESERVED_KEYWORDS.first } | ||
let(:random) { 'abcdef' } | ||
let(:generated) { [reserved, reserved, reserved, random] } | ||
|
||
before do | ||
scope.stub(:random_string) { generated.shift } | ||
end | ||
|
||
it { should eq random } | ||
end | ||
|
||
context 'when a non-unique random var is generated' do | ||
let(:preexisting) { 'preexist' } | ||
let(:random) { 'abcdef' } | ||
let(:generated) { [preexisting, preexisting, preexisting, random] } | ||
|
||
before do | ||
scope.stub(:random_string) { generated.shift } | ||
scope[preexisting] = 1 | ||
end | ||
|
||
it { should eq random } | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters