Mystery of Duqu Programming Language Solved 97
wiredmikey writes "Earlier this month, researchers from Kaspersky Lab reached out to the security and programming community in an effort to help solve a mystery related to 'Duqu,' the Trojan often referred to as 'Son of Stuxnet,' which surfaced in October 2010. The mystery rested in a section of code written an unknown programming language and used in the Duqu Framework, a portion of the Payload DLL used by the Trojan to interact with Command & Control (C&C) servers after the malware infected system. Less than two weeks later, Kaspersky Lab experts now say with a high degree of certainty that the Duqu framework was written using a custom object-oriented extension to C, generally called 'OO C' and compiled with Microsoft Visual Studio Compiler 2008 (MSVC 2008) with special options for optimizing code size and inline expansion."
Re: (Score:1)
Quick, get Sydney Bristow on the case! I hear she's married to Daredevil now, so I guess he... well actually, that might be a hindrance to the whole thing.
Well that was disappointing. (Score:1)
Re:Well that was disappointing. (Score:5, Funny)
Re: (Score:2)
I was disappointed too. I figured it was written in Python or Ruby on Rails.
*/sarcasm*
Re: (Score:2)
Re: (Score:2)
H-1B (Score:2)
Just means the Aliens made MSVC 2008.
Then what country were they from?
Re: (Score:2)
Of course they do. The government just doesn't want you to know- so they made this bit up about being written in C.
Sure they do, the Stonecutters hide them (Score:2)
Who keeps Atlantis off the maps?
Who keeps the Martians under wraps?
We Do, We Do...
Let's See It (Score:1)
Re:Let's See It (Score:5, Informative)
Re: (Score:2, Interesting)
You know, I wonder if the antivirus suites of the future will be able to see stuff like this being written. Like "oh no, he is using emacs/vi and writing a php injection script - perhaps this is something we should look into specifically". I don't think heuristics of this sort would be any more onerous than the deep sort of file scanning that antivirus suites already do.
As an aside, Kaspersky is fantastic and aside from a small hiccup a year or two ago where they lost some CC data (and handled it pretty wel
Re: (Score:3)
This is already done to a large degree, at least with what matters in binary code. The "Script kiddie" tools are extremely well documented. This goes way back in time to when a tool came out called (I hope I'm remembering the name right) VCL or Virus Creation Labratory. It became pretty easy to determine VCL based code and the tool set pretty much evaporated.
What editor you use is really unimportant. The compiler is what counts, and the compiler never sees your editor.
Re: (Score:1)
You know, I wonder if the antivirus suites of the future will be able to see stuff like this being written. Like "oh no, he is using emacs/vi and writing a php injection script - perhaps this is something we should look into specifically"
I can't imagine that someone with enough technical ability to create the "mystery" Duqu code isn't already doing their development in a sandboxed VM with no AV apps installed. I doubt it's worth the time on the AV companies' part to attempt to detect the act of malware actually being written.
Re: (Score:1)
You know, I wonder if the antivirus suites of the future will be able to see stuff like this being written. Like "oh no, he is using emacs/vi and writing a php injection script - perhaps this is something we should look into specifically".
Real programmers use cat anyway :).
Re: (Score:2)
(For some of my customers, I tell them to immediately call me on a red light. Makes my job easier lol.)
Does it play that old "red light spells danger - can't hold out much longer" song to reinforce the point?
Because that would be like a bucket full of awesome.
Re: (Score:3)
The 'mystery' involved has nothing to do with the actual code. The actual code itself is probably not really all that advanced.
The reverse compiler UnStux says the program is called Hello World.
Re: (Score:2)
If this keeps up.... (Score:3)
Source Code? (Score:4, Insightful)
Re:Source Code? (Score:5, Informative)
Re: (Score:1)
In this case, there were clear signs of an object-oriented approach (data and functions were located around each other in memory, which is not likely to happen in non-OO languages, etc).
I agree with the gist of your statement, but I don't think the OOP source-level organization of "data close to methods" is reflected in the generated machine code or the intermediate assembly. I'd wager data would be placed in non-executable memory segments, far from where the code ('text') resides. When you print out values of pointers you can often recognize what lives on the stack, what is heap-based data and what is a function pointer just by looking at address ranges.
Re:Source Code? (Score:5, Informative)
Re: (Score:3)
The GP's question was something else - how did they initially tell it was _not_ regular C (as that obviously lacks the fingerprint of OO techniques of C++). Or if it didn't look like regular C or anything else, why didn't they just assume it was written in assembly, or some other rare machine code generating language like Common Lisp?
Re:Source Code? (Score:5, Informative)
They did open the lines up for suggestions, and some community members suggested that it looked like OO C. How did they know? They probably had experience using and debugging OO C, if I had to guess. There were also plenty of people who said that it definitely wasn't compiler X or language Y from their own experiences. The article links to this discussion: http://www.securelist.com/en/blog/677/The_mystery_of_Duqu_Framework_solved [securelist.com]
But about discovering the specifics of the truth? It's probably like you alluded to in your comment - fingerprinting the machine code. It would take a while, but you could come up with fingerprints for a great many various compilers and features. You could do that for Common Lisp, too. (In fact, someone DID suggest for them to look at various LISP dialects.) It has taken long enough that such a scenario - having a good library of fingerprints - is believable. Given a scanner with a dictionary of fingerprints, one could reasonably say that you either have hand-assembled machine code made to mimic another language, or that you have code generated by a very specific language and compiler. If nothing in your library of fingerprints matched, assuming you had a good handle on hand-assembling machine code, you could look and see if it smells like such a beast. It would be tremendously laborious to hand-assemble code to make it look like a specific compiler generated it, and why would you do that in the first place? I fail to see the benefit when you could just use that compiler. If you were trying to throw off the analysts with a false positive match, there would still be a ton of mysterious data that still needs examination.
Think about DNA analysis. We can look at our DNA and determine some chunks of it came from virus, and that some of it is "junk" that serves no purpose.
Also think about image analysis like OCR or various captcha-breaking software. You can map images to characters with a program, and detect anomalies and known signatures.
Then there is heuristic antivirus scanning. It knows enough to find some previously unthought-of malicious code, even if it does sometimes generate false positives.
So why not apply those techniques to machine code, and see what you get? If multiple methods give you similar results, you would be onto something, I imagine.
Re: (Score:1)
By putting out a public call like that they created a forest of opinions from all over the internet, perfect for a tree that wanted to help but didn't want to get chopped down as a result.
Re: (Score:2)
Think about DNA analysis. We can look at our DNA and determine some chunks of it came from virus, and that some of it is "junk" that serves no purpose.
Except that it's recently been discovered that more of that "junk" has a purpose than we thought...
Re: (Score:2)
How did they deduce it was an unknown programming language? By looking at the compiled machine code? How could they tell this wasn't just regular C?
I suppose that you could possibly tell what compiler was used by the arrangement of the machine code, but I still don't see what the point is. Who cares if it was written in assembly language, C or Atari Basic?
Re:Source Code? (Score:5, Insightful)
Re: (Score:3)
Because knowing the compiler and version helps analysis - each compiler tends to emit code for the same statement very differently. By knowing the compiler, its idiosyncracies in the way it emits code is understood and it makes reversing the assembly back to C much easier.
Analyszing assembly code is d
Re:Source Code? (Score:5, Interesting)
To tag along - it's hard to tell data from code, and it helps the decompiling app to detect what is code vs. data if it knows which compiler created it.
It looks like the original blog used IDA Pro, which has library signatures for different compilers. It can identify functions and auto-comment the code, making disassembly easier. Auto-identify stack variables and keep track of them through lots of PUSH and POP and RETURN X statements, it's quite powerful.
In this case, IDA probably gave a lot of erroneous warnings or disassembled data or refused to disassemble code, requiring lots of manual work. The classes apparently were done inconsistently, making it hard to even write a plug-in to automatically detect them (scripts exist to identify MSVC objects through their RTTI properties, and do a decent job identifying non-RTTI classes, but this would not work with this code).
http://www.hex-rays.com/products/ida/index.shtml [hex-rays.com]
When reverse engineering, and your tool basically says "WTF do I do with this?" it's one of those moments where you want to know how the attacker made it.
Is it hand-rolled? Or a new attack creation kit that script kiddies can cobble something together using?
And "unknown language" was not a really good way to describe it. "Unrecognized output" would have been better. The assumption is that a language like C would compile to a C-like syntax, C++ would do things differently. But it could have been just C++ with an unknown compiler.
Re: (Score:2, Insightful)
Here is an perfect example -- a friend of mine was taking a CS course and the assembly code the prof provided was absolute shit -- a perfect example of how to NOT write co
Likewise: (Score:1)
This is +1, Normal? Come on. This is a worthless comment, a waste of space.
Re: (Score:2)
> This is a worthless comment, a waste of space.
Your tips for coding and what you learnt from reverse engineering are where again?
Re: (Score:1)
The other guy said it. I enjoyed your comment and found it interesting, and thought it was lame that some stupid A.C. crapped all over it with a one line throwaway insult.
Re:Source Code? (Score:4, Informative)
It's only a clue, not an answer. But it's one data point more than they had before. And they need somewhere to start looking for the author.
OO C is very interesting. C++ developers are a dime a dozen (OK, it's 2012, we're four for a quarter.) And you can't swing a dead cat around here without hitting a C coder. But OO C developers are a subset of a subset of people. Nobody who sets out to write a virus for the first time says "I should download a four year old compiler for a language I know nothing about and start writing my virus." They don't read in their copy of "Virus Creation Lab for Dummies" book where it says to torrent a copy of Visual Studio 2008, then download some GNU OO C framework for it. This is a tool that a limited set of experts uses for their day jobs. Possibly it's something a laid off software engineer would still have on his home machine. It might be code generated by a custom library that some gaming house wrote for their own internal stuff, and that by pattern matching with commercial software products they might be able to find the company of origin. They can go back and figure out who they fired in the last three years, and who now is driving the Ferrari. Maybe there's an OO C Google Group this guy participates in. Maybe he published a bogus "please help me with my homework" question on stackoverflow, and they can match some source code to some object code.
Or maybe it doesn't help find the guy today, but tomorrow if they haul a potential perpetrator before a judge, they can provide as corroborating evidence to the jury that the person who wrote this code was very specialized in his knowledge of this esoteric tool, and the defendant worked with this tool every day.
Whatever that clue might be, it could be useful knowledge to someone hunting down the author. Either way, it certainly has value.
Re:Source Code? (Score:5, Insightful)
There are certain characteristics to the way C++ behaves (the manner in which you pass parameters, etc). Mainly, through having looked at lots and lots of code samples, they can say what they expect the compiled code to look like. If they know C++ compiled code looks like x, regular C looks like y, and this looked like z, it can't be C. Essentially, the code did things you simply can't do in C++ or C (even Objective C) by itself. The problem is, that method only allows you to compare to known languages. More details here [securelist.com].
It's basically like identifying an animal by footprint. Once you know a deer leaves a certain kind of footprint, you can identify more deer by examining footprints. But you can't identify an unknown animal that way: if you haven't seen a given footprint before, you won't know what animal it is, only what general characteristics it has (weight, etc.)
Re: (Score:3)
so bigfoot is real... that's what you're trying to say?
bigfoot is indeed real, unless declared integer.
Re: (Score:1)
Re: (Score:2)
Thank you for the laugh I desperately needed this morning!
Re: (Score:2)
You're talking about the ABI [wikipedia.org] between objects, correct?
Microsoft's Big Chance (Score:5, Funny)
A well publicized article featuring Microsoft Development products of all things, I think they should use that PR in their Microsoft Visual Studio Ads...
Re: (Score:2)
Code it like you own it!
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I don't think the article implied that this framework was pre-existing or not. They don't know. It could have been a custom written framework to help the author(s) specifically build this virus. Rudimentary OO C frameworks are easy enough to write from scratch.
What they saw was a regular pattern common across many different functions in the binary, which suggested that the same source was used to create it throughout the code. And if the source code is that regular, either the author is a serial copy-pa
I don't understand the fuss about the language (Score:2)
If you can disassemble it then who cares whether it was written in OO C , C++ or Logo? I don't see why it mattered so much. Just follow the assembler.
Re:I don't understand the fuss about the language (Score:4, Informative)
They are trying to do the forensics. If you know the tools used, you have a much better idea where to look for the people who did it. It was almost certainly NOT a matter of determining what it was doing, they wanted to figure something out that would help them track it back to the source.
infective c? (Score:1)
Objective C but then for the MS platform?
Re: (Score:2)
Lambda the Ultimate (Score:2)
Here is an older post about it: http://lambda-the-ultimate.org/node/4476 [lambda-the-ultimate.org]
Old-school or new-school? (Score:4, Insightful)
FTFA:
Why did the authors of Duqu use OO C? While there is no easy explanation why OO C was used instead of C++ for the Duqu Framework, Kaspersky experts say there are two reasonable causes that support its use [More control over the code & Extreme portability]. These two reasons indicate that the code was written by a team of experienced ‘old-school’ developers
Why OO C? Because it worked, because they new how to use it, because they knew it would throw Kaspersky for a loop, because they thought it was cool. There are many many reasons and they do not all have to be logical.
Kaspersky experts might want to consider that the programming wheel of life may have turned and that what was once old-school is now new-school. Whose to say that the under-estimated script-kiddies cannot grow up to be formidable adults with a whole new bag of tricks?
Re: (Score:2, Informative)
OO C is not Objective-C.
Re: (Score:2)
Occam's razor. The simplest answer is usually correct. That drives an awful lot of investigations.
Despite the twists and turns that you see in TV crime dramas, most real world bad guys aren't quite that clever at hiding all of their tracks. Sure, they're going to hide the obvious ones they know they're leaving. They will use hacked proxies to deliver their code. They'll use sophisticated command and control networks to make sure nobody can track them back to the actual box making the inputs. They'll h
What's the animal (Score:5, Funny)
For O'Reilly's "Mastering Duqu"?
Re:What's the animal (Score:5, Funny)
It's a picture of Palpatine holding onto his nutsack.
Re: (Score:1)
I'm confused (Score:2)
Why does this matter? If it is a compiled program it is just a bunch of instructions. If the OS lets the instructions to run it doesn't much matter what compiler/language was used other than how efficiently it will do the crap it is told too.
Re: (Score:1)
Because it gives hints about the _people_ that wrote it.
Re: (Score:2)
Hmm, that they had access to a Windows PC and knew how to code in C? That is pretty much every software developer.
Re: (Score:2)
As a couple of others have stated, it is important in identifying who may be behind the code. "Authors" in certain parts of the world tend to use a certain set of tools for financial fraud, another group uses a different set of tools for industrial espionage, yet others may use either set of tools to mimic these groups while they do plain old espionage for a nation state.
As a defender, you probably are more worried about one group than the others. A small startup data mining firm is probably more worried
Re: (Score:2)
If you know the libraries that a program is using, it can make it easier to reverse engineer.
Re: (Score:2)
Ah good point. I suppose too if the skills are rare enough just knowing the programming language might narrow it down enough to get to the few likely cuplrits.
Or the most obvious alternative... (Score:1)
The code was written by someone with some very serious Assembler skills.
ANYTHING that can be written in any higher level language can be written in Assembler and that is an indisputable fact.
Re: (Score:3)
It was too consistent to be compiler intrinsics, but not consistent enough to be straight assembly. That's the impression I got from the original blog post.
No question it would have been possible, but given the rest of the code was compiled in MSVC it made sense that some sort of macro, framework, toolkit, or something was in between the course and the output.
Re: (Score:1)
The bizarre claims by Kaspersky about how Duqu's authors had invented their own language were patently idiotic
It could well be that the Duqu authors wrote a macro language framework on top of C, for tighter code generation, greater control, the ability to easily add trace statements and/or experimental code during development runs, make it more difficult to trace to a specific commercial compiler, etc.
Re: (Score:1)
Anyone who uses C for a significant project writes their own framework on top of C. Sometimes those frameworks grow into gargantuan monstrosities, like glib, gtk, of libevent 2.0.
Smart programmers write minimalist frameworks that do simple, straight-forward things: simple object containers, simple event loops, etc, that can be reused without the cost of extra baggage. Extra baggage just gets in the way, because for highly specialized applications you will inevitably need to hack and refactor your libraries.
It was smart to use a different language.. (Score:2)
If you rolled your own language with its own grammar, you can be secure in the fact that *even* deep analysis will not yield any clues, not atleast by the c
Re: (Score:2)
Here go two links just in case you are interested in knowing more about this Navajo code talk [wikipedia.org] and the men [navajocodetalkers.org] that helped "secure" communications in the Pacific.
Re: (Score:1)