#######################################################################

                             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
Platforms:    Windows
Bug:          integer overflow
Exploitation: remote, versus server
Date:         21 Mar 2011 (found 08 Jan 2011)
Author:       Luigi Auriemma
              e-mail: aluigi@autistici.org
              web:    aluigi.org


#######################################################################


1) Introduction
2) Bug
3) The Code
4) Fix


#######################################################################

===============
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 industrys first and only fully scalable suite of
OPC, SNMP, BACnet and Web-enabled HMI and SCADA applications."


#######################################################################

======
2) 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 0xdae and 0xdb0 that make use of the function
0044C6B0 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.

Vulnerable code:
  0044C7C8  |.  E8 A3A9FCFF   CALL 00417170                 ; get 32bit
  0044C7CD  |.  8B07          MOV EAX,DWORD PTR DS:[EDI]
  0044C7CF  |.  85C0          TEST EAX,EAX
  0044C7D1  |.^ 74 C5         JE SHORT 0044C798
  0044C7D3  |.  C1E0 02       SHL EAX,2                     ; * 4
  0044C7D6  |.  50            PUSH EAX
  0044C7D7  |.  E8 DCA90500   CALL <JMP.&MFC71U.#265>       ; malloc
  0044C7DC  |.  8B0F          MOV ECX,DWORD PTR DS:[EDI]
  0044C7DE  |.  C1E1 02       SHL ECX,2                     ; * 4
  0044C7E1  |.  51            PUSH ECX
  0044C7E2  |.  8947 04       MOV DWORD PTR DS:[EDI+4],EAX
  0044C7E5  |.  E8 CEA90500   CALL <JMP.&MFC71U.#265>       ; malloc


#######################################################################

===========
3) The Code
===========


http://aluigi.org/poc/genesis_iof.zip

  genesis_iof 7 SERVER


#######################################################################

======
4) Fix
======


No fix.


#######################################################################
