Stuxnet is now on GitHub
github.com
github.com
Unfortunately, the decompiler output doesn't convey much as it stands, unless you like sorting through pages and pages of
local199 = local191;
local203 = local191 + 0x6f02418d;
local3 = proc2(0x10021238, param1, param2, param9, param5); /* Warning: also results in local190 */
local208 = local3;
local209 = local190;
local211 = local203;
That being one of the more interesting sections; there are stretches with dozens of lines in a row of the form "localfoo = localbar".It does seem to suggest, at least, that this dump didn't have the actual source.
[1] http://crowdleaks.org/hbgary-wanted-to-suppress-stuxnet-rese...
That said... I wonder how useful would github be as a collaborative decompilation space - grab a file, annotate / simplify as much as possible, send pull request, repeat...
Does anybody have a good reference for how decompilers work? When converting assembly to C by hand I always went through multiple passes (not necessarily in this order): first a literal pass that looked a lot like this dump with gotos and variables named after registers, then I'd identify if/else and switch blocks, then I'd convert any reverse gotos into a while loop, convert while loops into for loops, identify data structures, duplicate lines that had been optimized to a single reference with jmps, etc.
Also, you have specific idioms for popular compilers (vc, gcc, icc, borland) and value propagation. You could even include an SMT solver to identify constraints and propagate the range to child basic blocks.
http://www.zynamics.com/bincrowd.html
The plugin is open source and the community server is free.
if (*(int*)(local2 + global0) == 0x4550) {
local5 = *(unsigned short*)(local2 + global0 + 20);
Either local2 or global0 are pointers to a structure. Neither is detected. Most sensible decompilers would change the names and just make it `local5 = global0[local2].blah` instead. Advanced decompilers also can avoid gotos in almost any case. It also uses function calls without parameters or output, assuming some stack layout probably.It's a really really bad output, not a result of obscured compilation.
Stating the function type explicitly also helps it display the right arguments given to it. This output could be significantly improved if the assembly version were available as well.
The idea works well enough if you just want get optimized asm though. http://events.ccc.de/congress/2010/Fahrplan/events/4096.en.h...
Truly obfuscated code will just plain cause the Hex-Rays decompiler to crash, producing absolutely no output at all.
You can certainly get Hex-rays to output confusing information on purpose without actually targeting it. If this was obfuscated, you'd expect that would be much more likely.
what does that even mean? nonsensical.
"Here are some emails that show this company was planning to use Stuxnet"
Stuxnet is a distributed bot. It can be commanded. The post is saying this company planned to do that.
I don't know whether that's true or not but it seems easy to understand.
*(int*)local6 = *(int*)local5;
local5++;
local6++;
Either the memcpy code is strangely broken, or the decompiler is putting int * where it means char *.[¹] See full code at https://github.com/Laurelai/decompile-dump/blob/master/outpu... and same for proc20: https://github.com/Laurelai/decompile-dump/blob/master/outpu...
There is nothing new to see here. A quick Google search for "stuxnet.zip" reveals other samples, undamaged by some PR whoring idiot running it through IDA.
Has anyone suggested using Github as a social space to work on decompiling malware before? Github has some potential to be a unique space to work on this sort of problem in a collaborative setting. The story is that someone thought of that.
As for the title, I'll forgive it just as I'd forgive any other nascent Github project stating its goal rather than its present state in the link. The point is to get interested people working on it together.
Decompiler output is nice to glance at quickly, but as demonstrated elsewhere in the thread, it is only of superficial benefit when faced with even remotely complex code. For example, it cannot discover a struct's fields - they must be manually inferred and input into IDA before decompilation. A mess will result on trying to merge the output from a run with this information with a run that did not have it.
There are tools already in use for collaborative disassembly over the Internet, but a Github repo containing auto-generated source is not one of them. For all intents and purposes, it looks like someone's made minimal use of the IDA GUI without much clue for what they're doing. That's why I called it a PR stunt.
http://boomerang.sourceforge.net/
This github project is pretty much useless for those who want to learn about Stuxnet. Better to load the binary into IDA Freeware instead.
Stuxnet does appear to be an unusually large project (base classes, ungainly modular structure) for malware. This reinforces what I said earlier about its lack of stealth for the payload.
http://rdist.root.org/2011/01/17/stuxnet-is-embarrassing-not...
It does not appear to be sophisticated in any way except for its payload, which some evidence seems to claim was carefully constructed (e.g., with a PLC testbed). The "embarrassing" fact I was referring to in the above post is that its lack of stealth revealed its payload to the world, and no competent intelligence agency has that goal if the purpose of the worm itself is to do some damage.
Perhaps the worm is a way to draw the heat off the real deployment method. Or it is industrial sabotage gone awry. There is still not enough evidence to come to any conclusions on it, except this is not what an eleet cyberweapon would look like if you were to find one.
cyber-warfare is the shit now - and everyone wants a piece of that cake. (even if it means mixing 0days with ex-javacoders)
"WARNING: CHLLCode::appendTypeIdent: declaring type void as int for param2"
http://www.google.com/codesearch?as_q=WARNING%3A+CHLLCode%3A...
http://boomerang.sf.net/ is clearly what was used.
Unfortunately there's still a lot decompilers can't do, mostly compiler tricks (e.g. storing a pointer to the middle of a structure instead of its beginning, and using negative offsets to access other struct members [3] - this is usually obvious when looking at it, but HexRays can't make sense of it so it falls back to raw pointer math).
[1] http://www.hex-rays.com/ [2] http://img824.imageshack.us/img824/1188/hexrayscpp.png [3] https://github.com/Laurelai/decompile-dump/blob/master/outpu...
module Hello where
main = print "Hello world!"
and run "ghc -fvia-C -keep-hc-files Hello.hs". Compilation may fail with linker errors, but today we don't care about that. We just want to look at the resulting Hello.hc file, which is the C representation of the Haskell, and generally looks like: II_(rhG_closure);
II_(si4_closure);
FN_(Hello_main_entry) {
FB_
if ((W_)(((W_)Sp - 0x10UL) < (W_)SpLim)) goto _cip;
Hp=Hp+2;
if ((W_)((W_)Hp > (W_)HpLim)) goto _cip;
Hp[-1] = (W_)&stg_CAF_BLACKHOLE_info;
;EF_(newCAF);
{void (*ghcFunPtr)(void *);
and so on for quite a while longer. Passing this through a compile and decompile step might actually clean it up a bit....Seriously, it is one of the biggest open-source C codebases out there, with thousands of hackers working on it. And the result is very good, as the majority of the internet is running on it.
"I've looked at the source and there are pieces that are good and pieces that are not. A whole bunch of random people have contributed to this source, and the quality varies drastically." -Ken Thompson
The linux kernel works very well but does "just working" necessarily mean that that is the only way have it function. "It works" doesn't mean its good code.
I did not look at the code very closely but one goto I saw seemed to point from the main loop into a function. Which to me seems like an odd use, a use that can easily be avoided.
That's because you have not yet programmed enough / read enough programs.
> I did not look at the code very closely but one goto I saw seemed to point from the main loop into a function. Which to me seems like an odd use, a use that can easily be avoided.
Goto from one function to another? Not possible in standard C. If this was written in C it is most probable that compiler optimisation caused the direct jump. Even if you were not indeed talking of something like that you missed the obvious that compilation optimisation and imperfection of the decompilator are the far more probable cause of presence of curious goto.
You could also have noticed the far more interesting use of cast of char* to function pointer which are then called. Did the original programmer wrote this mess? Hint: probably not too...
As for the quality of the source code of the Linux kernel, well, apart from if you work on safety critical software (in which case it's like comparing apples to carrots anyway, because they are far more important differences to general purpose software than the mere presence or absence of gotos) I doubt you've seen a lot of far better code.
Indeed I even doubt you could advance reasonable reason for why goto should be 100% banished in all situation, especially when doing dynamic allocation or resources. Maybe you don't even have ever read the original Dijsktra's paper or the Knuth's paper http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pd... (curiously (or not) it's the case for many cargo cult goto haters even for just the orinal Dijkstra's paper)
At the base level, programs are nothing but gotos strung together. Everything else is added at a higher layer.
Also, critiquing the coding style of decompiled output is particularly missing the point. But at least the brace style is consistent, right? Almost as if it were rigidly generated by a tool from another source of input, rather than by a human, no?