Use random id generator appropriately
Powershell::Script includes a random generator (@rig) which can produce non repeating randomized identifiers to be used as var names within the PSH code. Unwrap script handling in powershell env stager to instantate a method-local Powershell::Script object and access its :rig to generate identifiers.bug/bundler_fix
parent
0d0dbaab60
commit
6d5e0b93d3
|
@ -141,14 +141,15 @@ module Powershell
|
||||||
#
|
#
|
||||||
def stage_psh_env(script)
|
def stage_psh_env(script)
|
||||||
begin
|
begin
|
||||||
encoded_expression = encode_script(read_script(script))
|
ps_script = read_script(script)
|
||||||
|
encoded_expression = encode_script(ps_script)
|
||||||
cleanup_commands = []
|
cleanup_commands = []
|
||||||
# Add entropy to script variable names
|
# Add entropy to script variable names
|
||||||
script_var = Rex::Text.rand_text_alpha(6)
|
script_var = ps_script.rig.generate(4)
|
||||||
decscript = Rex::Text.rand_text_alpha(6)
|
decscript = ps_script.rig.generate(4)
|
||||||
scriptby = Rex::Text.rand_text_alpha(6)
|
scriptby = ps_script.rig.generate(4)
|
||||||
scriptbybase = Rex::Text.rand_text_alpha(6)
|
scriptbybase = ps_script.rig.generate(4)
|
||||||
scriptbybasefull = Rex::Text.rand_text_alpha(6)
|
scriptbybasefull = ps_script.rig.generate(4)
|
||||||
|
|
||||||
if (encoded_expression.size > 14999 && compress_script(encoded_expression).size > 14999)
|
if (encoded_expression.size > 14999 && compress_script(encoded_expression).size > 14999)
|
||||||
print_error("Script size: #{encoded_expression.size} This script requres a stager")
|
print_error("Script size: #{encoded_expression.size} This script requres a stager")
|
||||||
|
@ -156,7 +157,7 @@ module Powershell
|
||||||
print_good("Loading " + arr.count.to_s + " chunks into the stager.")
|
print_good("Loading " + arr.count.to_s + " chunks into the stager.")
|
||||||
vararray = []
|
vararray = []
|
||||||
arr.each_with_index do |slice, index|
|
arr.each_with_index do |slice, index|
|
||||||
variable = Rex::Text.rand_text_alpha(8)
|
variable = ps_script.rig.generate(5)
|
||||||
vararray << variable
|
vararray << variable
|
||||||
indexval = index+1
|
indexval = index+1
|
||||||
vprint_good("Loaded stage:#{indexval}")
|
vprint_good("Loaded stage:#{indexval}")
|
||||||
|
|
Loading…
Reference in New Issue