Exploit-DB #17019
Description: RealPlayer 14.0.1.633 - Heap Overflow
Type: dos
Platform: windows
Date: 2011-03-21
Author: Luigi Auriemma

Exploit:
#######################################################################

                             Luigi Auriemma

Application:  RealPlayer
              http://www.real.com
Versions:     <= 14.0.1.633
Platforms:    Windows, Macintosh OSX, Linux, Symbian, Palm
Bug:          heap overflow
Exploitation: remote
Date:         21 Mar 2011 (found 17 Feb 2011)
Author:       Luigi Auriemma
              e-mail: aluigi@autistici.org
              web:    aluigi.org


#######################################################################


1) Introduction
2) Bug
3) The Code
4) Fix


#######################################################################

===============
1) Introduction
===============


RealPlayer is an ugly media player developed by RealNetwork and used
mainly for its browser's plugin supporting the proprietary file formats
of its developer.


#######################################################################

======
2) Bug
======


Classical heap overflow during the handling of the IVR files caused by
the allocation of a certain amount of data (frame size) decided by the
attacker and the copying of another arbitrary amount on the same
buffer.
From rvrender.dll (base address 63AE0000):

  63AF5C70  /$ 55                 PUSH EBP
  63AF5C71  |. 8BEC               MOV EBP,ESP
  63AF5C73  |. 83EC 20            SUB ESP,20
  63AF5C76  |. 8B55 08            MOV EDX,DWORD PTR SS:[EBP+8]
  63AF5C79  |. 56                 PUSH ESI
  63AF5C7A  |. 57                 PUSH EDI
  63AF5C7B  |. 8B7A 04            MOV EDI,DWORD PTR DS:[EDX+4]
  63AF5C7E  |. 8A07               MOV AL,BYTE PTR DS:[EDI]      ; byte at offset 0x7800 of the PoC
  63AF5C80  |. 24 E0              AND AL,0E0
  63AF5C82  |. 33F6               XOR ESI,ESI
  63AF5C84  |. 894D F8            MOV DWORD PTR SS:[EBP-8],ECX
  63AF5C87  |. 3C E0              CMP AL,0E0                    ; (byte & 0xe0) == 0xe0
  63AF5C89  |. 0F85 46010000      JNZ rvrender.63AF5DD5
  63AF5C8F  |. 8B0A               MOV ECX,DWORD PTR DS:[EDX]    ; 32bit value at offset 0x77f8 (allocation)
  63AF5C91  |. 47                 INC EDI
  63AF5C92  |. 83E9 01            SUB ECX,1
  63AF5C95  |. 8975 FC            MOV DWORD PTR SS:[EBP-4],ESI
  63AF5C98  |. 8975 E8            MOV DWORD PTR SS:[EBP-18],ESI
  63AF5C9B  |. C745 EC 01000000   MOV DWORD PTR SS:[EBP-14],1
  63AF5CA2  |. 894D F0            MOV DWORD PTR SS:[EBP-10],ECX
  63AF5CA5  |. 0F84 38010000      JE rvrender.63AF5DE3
  63AF5CAB  |. 53                 PUSH EBX
  63AF5CAC  |. 8D6424 00          LEA ESP,DWORD PTR SS:[ESP]
  63AF5CB0  |> 57                 /PUSH EDI
  63AF5CB1  |. 8D4D FC            |LEA ECX,DWORD PTR SS:[EBP-4]
  63AF5CB4  |. 51                 |PUSH ECX
  63AF5CB5  |. 8D55 E8            |LEA EDX,DWORD PTR SS:[EBP-18]
  63AF5CB8  |. 52                 |PUSH EDX
  63AF5CB9  |. E8 92010000        |CALL rvrender.63AF5E50
  63AF5CBE  |. 03F8               |ADD EDI,EAX
  63AF5CC0  |. 8945 E4            |MOV DWORD PTR SS:[EBP-1C],EAX
  63AF5CC3  |. 66:0FB607          |MOVZX AX,BYTE PTR DS:[EDI]
  63AF5CC7  |. 0FB7C8             |MOVZX ECX,AX
  63AF5CCA  |. 83C4 0C            |ADD ESP,0C
  63AF5CCD  |. 84C9               |TEST CL,CL
  63AF5CCF  |. 79 0D              |JNS SHORT rvrender.63AF5CDE
  63AF5CD1  |. 83E1 7F            |AND ECX,7F
  63AF5CD4  |. 894D F4            |MOV DWORD PTR SS:[EBP-C],ECX
  63AF5CD7  |. B8 01000000        |MOV EAX,1
  63AF5CDC  |. EB 1E              |JMP SHORT rvrender.63AF5CFC
  63AF5CDE  |> 66:0FB64F 01       |MOVZX CX,BYTE PTR DS:[EDI+1]
  63AF5CE3  |. C1E0 08            |SHL EAX,8
  63AF5CE6  |. 66:0BC8            |OR CX,AX
  63AF5CE9  |. BA FF7F0000        |MOV EDX,7FFF
  63AF5CEE  |. 66:23CA            |AND CX,DX
  63AF5CF1  |. 0FB7C1             |MOVZX EAX,CX                 ; 16bit at offset 0x7805
  63AF5CF4  |. 8945 F4            |MOV DWORD PTR SS:[EBP-C],EAX
  63AF5CF7  |. B8 02000000        |MOV EAX,2
  63AF5CFC  |> 0FB7D8             |MOVZX EBX,AX
  63AF5CFF  |. 6A 18              |PUSH 18
  63AF5D01  |. 03FB               |ADD EDI,EBX
  63AF5D03  |. E8 FC120000        |CALL <JMP.&MSVCR90.operator new>
  63AF5D08  |. 8BF0               |MOV ESI,EAX
  63AF5D0A  |. 83C4 04            |ADD ESP,4
  63AF5D0D  |. 85F6               |TEST ESI,ESI
  63AF5D0F  |. 74 7F              |JE SHORT rvrender.63AF5D90
  63AF5D11  |. 8B4D FC            |MOV ECX,DWORD PTR SS:[EBP-4]
  63AF5D14  |. 51                 |PUSH ECX
  63AF5D15  |. 8B4D F8            |MOV ECX,DWORD PTR SS:[EBP-8]
  63AF5D18  |. E8 D3F2FFFF        |CALL rvrender.63AF4FF0
  63AF5D1D  |. 85C0               |TEST EAX,EAX
  63AF5D1F  |. 75 0B              |JNZ SHORT rvrender.63AF5D2C
  63AF5D21  |. 56                 |PUSH ESI
  63AF5D22  |. E8 E3120000        |CALL <JMP.&MSVCR90.operator delete>
  63AF5D27  |. 83C4 04            |ADD ESP,4
  63AF5D2A  |. 33F6               |XOR ESI,ESI
  63AF5D2C  |> 8B55 F8            |MOV EDX,DWORD PTR SS:[EBP-8]
  63AF5D2F  |. 8B0A               |MOV ECX,DWORD PTR DS:[EDX]
  63AF5D31  |. 8B01               |MOV EAX,DWORD PTR DS:[ECX]
  63AF5D33  |. 8B40 0C            |MOV EAX,DWORD PTR DS:[EAX+C]
  63AF5D36  |. 8D55 E0            |LEA EDX,DWORD PTR SS:[EBP-20]
  63AF5D39  |. 52                 |PUSH EDX
  63AF5D3A  |. FFD0               |CALL EAX
  63AF5D3C  |. 8946 04            |MOV DWORD PTR DS:[ESI+4],EAX
  63AF5D3F  |. 85C0               |TEST EAX,EAX
  63AF5D41  |. 74 4D              |JE SHORT rvrender.63AF5D90
  63AF5D43  |. 8B4D 08            |MOV ECX,DWORD PTR SS:[EBP+8]
  63AF5D46  |. 66:8B51 0C         |MOV DX,WORD PTR DS:[ECX+C]
  63AF5D4A  |. 66:8956 0C         |MOV WORD PTR DS:[ESI+C],DX
  63AF5D4E  |. 0FB755 F4          |MOVZX EDX,WORD PTR SS:[EBP-C]
  63AF5D52  |. 0351 08            |ADD EDX,DWORD PTR DS:[ECX+8]
  63AF5D55  |. 837D EC 00         |CMP DWORD PTR SS:[EBP-14],0
  63AF5D59  |. 8956 08