2010-05-08 03:47:06 +00:00
|
|
|
# $Id$
|
2011-10-23 11:56:13 +00:00
|
|
|
# $Revision: $
|
2010-05-08 03:47:06 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#Options and Option Parsing
|
|
|
|
opts = Rex::Parser::Arguments.new(
|
|
|
|
"-h" => [ false, "Help menu." ]
|
|
|
|
)
|
|
|
|
var_names = []
|
|
|
|
var_names << registry_enumvals("HKEY_CURRENT_USER\\Volatile Environment")
|
|
|
|
var_names << registry_enumvals("HKEY_CURRENT_USER\\Environment")
|
|
|
|
var_names << registry_enumvals("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment")
|
|
|
|
|
2010-05-08 04:23:07 +00:00
|
|
|
def list_env_vars(var_names)
|
2010-05-08 03:47:06 +00:00
|
|
|
print_status("Getting all System and User Variables")
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => "Enviroment Variable list",
|
|
|
|
'Indent' => 1,
|
|
|
|
'Columns' =>
|
|
|
|
[
|
|
|
|
"Name",
|
|
|
|
"Value"
|
|
|
|
])
|
|
|
|
var_names.flatten.each do |v|
|
|
|
|
tbl << [v,@client.fs.file.expand_path("\%#{v}\%")]
|
|
|
|
end
|
|
|
|
print("\n" + tbl.to_s + "\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
opts.parse(args) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
print_line "Meterpreter Script for extracting a list of all System and User environment variables."
|
|
|
|
print_line(opts.usage)
|
|
|
|
raise Rex::Script::Completed
|
|
|
|
|
|
|
|
end
|
2010-05-08 04:23:07 +00:00
|
|
|
}
|
2010-09-09 16:09:27 +00:00
|
|
|
if client.platform =~ /win32|win64/
|
|
|
|
list_env_vars(var_names)
|
|
|
|
else
|
|
|
|
print_error("This version of Meterpreter is not supported with this Script!")
|
|
|
|
raise Rex::Script::Completed
|
|
|
|
end
|