Home→Blog→Research→March 07 2012→The Mystery of the Duqu Framework→3
While analyzing the components of Duqu, we discovered an interesting anomaly in the main component that is responsible for its business logics, the Payload DLL. We would like to share our findings and ask for help identifying the code.
At first glance, the Payload DLL looks like a regular Windows PE DLL file compiled with Microsoft Visual Studio 2008 (linker version 9.0). The entry point code is absolutely standard, and there is one function exported by ordinal number 1 that also looks like MSVC++. This function is called from the PNF DLL and it is actually the “main” function that implements all the logics of contacting C&C servers, receiving additional payload modules and executing them. The most interesting is how this logic was programmed and what tools were used.
The code section of the Payload DLL is common for a binary that was made from several pieces of code. It consists of “slices” of code that may have been initially compiled in separate object files before they were linked in a single DLL. Most of them can be found in any C++ program, like the Standard Template Library (STL) functions, run-time library functions and user-written code, except the biggest slice that contains most of C&C interaction code.
Layout of the code section of the Payload DLL file
This slice is different from others, because it was not compiled from C++ sources. It contains no references to any standard or user-written C++ functions, but is definitely object-oriented. We call it the Duqu Framework.
The code that implements the Duqu Framework has several distinctive properties:
All objects are instances of some class, we identified 60 classes. Each object is constructed with a “constructor” function that allocates memory, fills in the function table and initializes members.
Constructor function for the linked list class.
The layout of each object depends on its class. Some classes appear to have binary compatible function tables but there is no indication that they have any common parent classes (like in other OO languages). Furthermore, the location of the function table is not fixed: some classes have it at offset 0 of the instance, but some does not.
Layout of the linked list object. First 10 fields are pointers to member functions.
Objects are destroyed by corresponding “destructor” functions. These functions usually destroy all objects referenced by member fields and free any memory used.

Member functions can be referenced by the object’s function table (like “virtual” functions in C++) or they can be called directly. In most object-oriented languages, member functions receive the “this” parameter that references the instance of the object, and there is a calling convention that defines the location of the parameter – either in a register, or in stack. This is not the case for the Duqu Framework classes – they can receive “this” parameter in any register or in stack.
Member function of the linked list, receives “this” parameter on stack
The layout and implementation of objects in the Duqu Framework is definitely not native to C++ that was used to program the rest of the Trojan. There is an even more interesting feature of the framework that is used extensively throughout the whole code: it is event driven.
There are special objects that implement the event-driven model:
This event-driven model resembles Objective C and its message passing features, but the code does not have any direct references to the language, neither does it look like compiled with known Objective C compilers.
Event-driven model of the Duqu Framework
Every thread context object can start a “main loop” that looks for and processes new items in the lists. Most of the Duqu code follow the same principle: create an object, bind several callbacks to internal or external events and return. Callback handlers are then executed by the event monitor object that is created within each thread context.
Here is an example pseudocode for a socket object:
After having performed countless hours of analysis, we are 100% confident that the Duqu Framework was not programmed with Visual C++. It is possible that its authors used an in-house framework to generate intermediary C code, or they used another completely different programming language.
We would like to make an appeal to the programming community and ask anyone who recognizes the framework, toolkit or the programming language that can generate similar code constructions, to contact us or drop us a comment in this blogpost. We are confident that with your help we can solve this deep mystery in the Duqu story.
|
2012 Mar 09, 15:39
Re: object oriented C I agree. As I see it, the lack of rigid consistency suggests this is an object-oriented C framework with function pointers: Edited by Wladimir, 2012 Mar 09, 16:23 |
|
2012 Mar 09, 15:41
Magic software The code looks similar to the one used in the Magic Software eDeveloper solution (now known as UniPaas). |
|
2012 Mar 09, 15:54
Re: That code looks familiar It's easier to figure this out if you consider vendor sourcing. The work was probably done by a government. And, whether the software was sourced through a US agency or whether a US agency itself was the creator, the net result is the same: you're looking for a major GSA-contracted firm who A) has clearance, B) has a compiler team, C) has a track record of providing similar product to the US government, and D) has a compiler codebase that looks kind of unfamiliar and not mainstream. |
|
2012 Mar 09, 15:59
Definitely not a Lisp I haven't seen much of the Duqu code except for what is posted here, and I would appreciate more to have a better opinion. But from what I see, I can say this definitely is not a Lisp or any related language (Python, JS, Ruby, younameit). |
|
2012 Mar 09, 15:59
|
|
2012 Mar 09, 16:09
|
|
2012 Mar 09, 16:20
Simple Object Orientation (for C) It seems someone over at reddit (http://www.reddit.com/r/ReverseEngineering/) hit the jackpot: the code snippets look _very_ similar to what this would produce: |
|
2012 Mar 09, 17:10
Re: Simple Object Orientation (for C) If this is so, what benefits do you think the author was after? |
|
2012 Mar 09, 17:55
|
|
2012 Mar 09, 18:30
|
|
2012 Mar 09, 18:50
Other C/C++ compiler? Isnt it possible that the original language is still C/C++, but the code generation is done by something else than MSC++/Visual Studio? |
|
2012 Mar 09, 18:50
New Compiler Probably it's LISP with a re-edited compiler that changed the syntaxis of the commands for new ones |
|
2012 Mar 09, 18:57
Re: Other C/C++ compiler? I have seen how GCC works internally and its ABI (for a number of different versions) and I can confirm that the Duqu code is definatly not generated by GCC. I dont know how other C++ compilers work but the things I see in the ASM (like where the pointers to the functions go, the way the "this" pointer is passed etc) do not suggest C++ to me but something else entirely. (such as the aforementioned "object-oriented" frameworks for C that exist) |
|
2012 Mar 09, 19:07
Re: Other C/C++ compiler? I'm 99% sure the machine code was generated by MSVC. It's something you get a feel with experience, but I can point out two things that are quite characteristic of MSVC: 1) it uses esi as the first candidate for temporary storage; 2) "pop ecx" instead of "add esp, 4". |
|
2012 Mar 09, 19:16
Compiler list? Is there a public list you are keeping of languages/compilers that you have been able to check against? Edited by MJB, 2012 Mar 09, 19:32 |
|
2012 Mar 09, 20:11
Forth ? In Forth it is possible to create its own instructions, to add them to the core, to recompile core, program the robots, etc... http://en.wikipedia.org/wiki/Forth_(programming_language) |
|
2012 Mar 09, 20:14
This is definitely brainfuck! This is definitely brainfuck! |
|
2012 Mar 09, 20:58
|
|
2012 Mar 09, 20:59
|
|
2012 Mar 09, 21:46
|
|
2012 Mar 09, 22:13
Re: Re: New Compiler I had a HP48G (hewlett packard calculator) that used something similar for programming |
|
2012 Mar 09, 23:55
Compile PHP? could it be compiled PHP with (newish) Traits? that would explain a global $this even in attached sections. |
|
2012 Mar 10, 00:03
Re: Simple Object Orientation (for C) SOO may be the correct answer! But there are still two things to figure out: |
|
2012 Mar 10, 00:08
Re: Re: I think it's a Tcl (Incr Tcl). Its look's like assembler, but it is a object language. |
|
2012 Mar 10, 00:11
Re: Re: Other C/C++ compiler? igorsk, thanks for the hint. It turns out that almost the same code can be produced by the MSVC compiler for a "hand-made" C class. This means that a custom OO C framework is the most probable answer to our question. |
|
2012 Mar 10, 00:14
Tcl language I think that is a Tcl or Incr Tcl language. It look's like assembler, but is objective. |
|
2012 Mar 10, 00:57
Maybe Pic language It's look like Pic Language but it's strange cause this language is only for transistor programmation... |
|
2012 Mar 10, 01:55
|
|
2012 Mar 10, 02:34
Wild guess I'm gonna take a wild guess and say it was coded in C and compiled with the WDK in the IDE, Visual Studio. The author could have enable /FAs flag. Took the .ASM file(s) and recompiled the .ASM file(s) again with the WDK in Visual Studio. Edited by juryben, 2012 Mar 10, 08:40 |
|
2012 Mar 10, 02:40
What about quantum leaps framework ? |
Analysis
Blog