From 52432ef482dbdb2e7fb1d52d9da7307b0b329d14 Mon Sep 17 00:00:00 2001 From: Joe Vennix Date: Wed, 9 Apr 2014 16:54:02 -0500 Subject: [PATCH] Use tiny var names by default. --- lib/rex/exploitation/jsobfu.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/rex/exploitation/jsobfu.rb b/lib/rex/exploitation/jsobfu.rb index 79086243aa..1e9743f6ad 100644 --- a/lib/rex/exploitation/jsobfu.rb +++ b/lib/rex/exploitation/jsobfu.rb @@ -74,14 +74,16 @@ class JSObfu @rand_gen = Rex::RandomIdentifierGenerator.new( :max_length => 15, :first_char_set => Rex::Text::Alpha+"_$", - :char_set => Rex::Text::AlphaNumeric+"_$" + :char_set => Rex::Text::AlphaNumeric+"_$", + :min_length => 1 ) end # @return [String] a unique random var name that is not a reserved keyword def random_var_name + len = 1 loop do - text = random_string + text = @rand_gen.generate(len) unless has_key?(text) or RESERVED_KEYWORDS.include?(text) or BUILTIN_VARS.include?(text) @@ -89,6 +91,7 @@ class JSObfu self[text] = nil return text end + len += 1 end end @@ -97,15 +100,10 @@ class JSObfu super or (@parent and @parent.has_key?(key)) end - # @return [String] a random string - def random_string - @rand_gen.generate - end - end # - # The maximum length of a string that will be passed through + # The maximum length of a string that can be passed through # #transform_string without being chopped up into separate # expressions and concatenated #