Exploit-DB #17023
Description: iconics genesis32 and genesis64 - Multiple Vulnerabilities
Type: dos
Platform: windows
Date: 2011-03-22
Author: Luigi Auriemma

Exploit:
Sources:
http://aluigi.org/adv/genesis_1-adv.txt
http://aluigi.org/adv/genesis_2-adv.txt
http://aluigi.org/adv/genesis_3-adv.txt
http://aluigi.org/adv/genesis_4-adv.txt
http://aluigi.org/adv/genesis_5-adv.txt
http://aluigi.org/adv/genesis_6-adv.txt
http://aluigi.org/adv/genesis_7-adv.txt
http://aluigi.org/adv/genesis_8-adv.txt
http://aluigi.org/adv/genesis_9-adv.txt
http://aluigi.org/adv/genesis_10-adv.txt
http://aluigi.org/adv/genesis_11-adv.txt
http://aluigi.org/adv/genesis_12-adv.txt
http://aluigi.org/adv/genesis_13-adv.txt

Advisory Archive: https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/17023-adv.tar.gz (iconics_genesis_adv.tar.gz)
PoC Archive: https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/17023-poc.tar.gz (iconics_genesis_poc.tar.gz)

#######################################################################

                             Luigi Auriemma

Application:  Iconics GENESIS32 and GENESIS64
              http://www.iconics.com/Home/Products/HMI-and-SCADA/GENESIS32.aspx
              http://www.iconics.com/Home/Products/HMI-and-SCADA/GENESIS64.aspx
Versions:     GENESIS32 <= 9.21
              GENESIS64 <= 10.51
              GenBroker.exe and GenBroker64.exe are the same version on
              both the softwares: 9.21.201.01
Date:         21 Mar 2011 (found 08 Jan 2011)
Author:       Luigi Auriemma
              e-mail: aluigi@autistici.org
              web:    aluigi.org

#######################################################################

===============
1) Introduction
===============

Iconics Genesis is a SCADA HMI solution used worldwide with customers
that go from Beijing Traffic Control Center to the Pentagon and even
Poste Italiane ("Case Studies" source).

Informations from the vendor's website:
"GENESIS32™ is the industry’s first and only fully scalable suite of
OPC, SNMP, BACnet and Web-enabled HMI and SCADA applications."

#######################################################################

Freeing of Arbitrary Memory:

======
Bug
======

GenBroker is a Windows service running on port 38080.

The addresses and code snippets reported here are referred to GENESIS32
9.2.

The service is affected by multiple freeing of initialized memory
pointers and arbitrary locations because:
- the functions that store the strings pointers read from the client
  automatically break the reading loop when the end of the packet is
  reached
- these functions use malloc instead of calloc so the memory is not
  cleared
- the functions that free the arrays don't know if and when the reading
  process stopped and so they call free() over all the elements
  specified by the attacker in his packet

The exploitability of these vulnerabilities depends by how the attacker
has corrupted the memory for forcing the freeing of arbitrary locations
through the sending of valid packets before the malformed one.
The service is multi-thread so there are many chances of exploitation.

The following is the full list of vulnerable opcodes and the read/free
functions to monitor (referred to version 9.2):

1) opcode 0x4b0:
    read loop: 0044ACC0 and 0044AD04
    free loop: 004446B0

2) opcode 0x4b2:
    read loop: 0044B360
    free loop: 004428F0

3) opcode 0x4b5:
    read loop: 0044C560
    free loop: 00443090

4) function 0044C6B0 used by opcodes 0xDAE and 0xDB0.
    read loop: 0044c800
    free loop: 00443160

5) opcodes 0x1BBC and 0x1BBD:
    read loop: 0044ca90
    free loop: 004432a0

#######################################################################

===========
The Code
===========

http://aluigi.org/poc/genesis_1.zip
https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/17023-1.zip (genesis_1.zip)

#######################################################################

Remote Integer Overflow:

======
Bug
======

GenBroker is a Windows service running on port 38080.

The addresses and code snippets reported here are referred to GENESIS32
9.2.

The service is affected by an integer overflow vulnerability during the
handling of the opcodes 3f0, 138F,1390,1391,1392,1393,
1394, 1C86, 89a,89b, 450,451,454,455, 1C20,1C24 that make use of the
function 0044d1c0.

The problem is caused by the allocation of the memory needed for the
creation of an array trusting the number of elements passed by the
client.

The resulting memory corruptions (like direct registry calls, memory
locations calls, writing of data in arbitrary locations and so on)
allow code execution.

Fields in the packet:
  the format of the packets depend by the relative opcodes, the
  function 0044d1c0 reads a 32bit before the one used for the
  allocation.

Vulnerable code:
  0044D2A2  |.  E8 C99EFCFF   CALL 00417170                 ; get 32bit
  0044D2A7  |.  8D4424 1C     LEA EAX,DWORD PTR SS:[ESP+1C]
  0044D2AB  |.  50            PUSH EAX
  0044D2AC  |.  8BCE          MOV ECX,ESI
  0044D2AE  |.  E8 BD9EFCFF   CALL 00417170
  0044D2B3  |.  8B4C24 10     MOV ECX,DWORD PTR SS:[ESP+10]
  0044D2B7  |.  8D14CD 000000>LEA EDX,DWORD PTR DS:[ECX*8]  ; * 8
  0044D2BE  |.  52            PUSH EDX
  0044D2BF  |.  E8 F49E0500   CALL <JMP.&MFC71U.#265>       ; malloc


#######################################################################

===========
The Code
===========

http://aluigi.org/poc/genesis_iof.zip
https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/17023-2.zip (genesis_iof.zip)

  genesis_iof 1 SERVER

#######################################################################

Remote Integer Overflow:

======
Bug
======

GenBroker is a Windows service running on port 38080.

The addresses and code snippets reported here are referred to GENESIS32
9.2.

The service is affected by an integer overflow vulnerability during the
handling