Archive for December, 2007

Corny arrest headlines

Thursday, December 20th, 2007

With one of the corniest titles you’ll see (Pinch authors Pinched), the Kaspersky blog in Russia stated that the original authors of the Pinch trojan have been arrested:
“Today Nikolay Patrushev, head of the Federal Security Services, announced the results of the measures taken to combat cyber crime in 2007.
Among other information, it was announced that it had been established who was the author of the notorious Pinch Trojan – two Russian virus writers called Ermishkin and Farkhutdinov. The investigation will soon be completed and taken to court.”

Maybe this focus by the Federal Security Services helps explain some of the motivations for the Russian Business Network’s moves to China and Central America.

The arrest themselves are a pretty big deal, along the lines of the more recent Zotob author’s and distributor’s arrests. According to the KAV log:
The arrest of the Pinch authors is on a level with the arrests of other well known virus writers such as the author of NetSky and Sasser, and the authors of the Chernobyl and Melissa viruses.”

Interestingly, it seems that the author of the Pinch code and the distributors that use it to infect millions of computers are different people. Here is another take on the announcement:
“FSB Chief, Patrushev, reported that FSB has arrested Ermishkin and Farkhutdinov, who created and deployed the Pinch trojan into tens of millions of PCs around the world.”
The assembly source that I’ve seen from version 1.0 contains a different name, “Alex”. The two recently arrested most likely used the code to create and infect systems, and most likely were not the original author. We’ll look for corrections in reports.

Cisco Annual Security Report

Thursday, December 20th, 2007

Joining the bandwagon of future tellers, Cisco recently read the collective palm of malcode writers and cybercriminals everywhere and released what they saw in their annual security report.

Seriously though, the report takes perspective on some pretty massive themes and is a worthwhile read for security managers and other interested users. It provides “an overview of the combined security intelligence of the entire Cisco organization”, which is an interesting statement in itself, knowing that the company has over 60,000 full time employees and lots of contracted and outsourced staff.
I like its structure and layout, but you’ll still find a lot of questionable statements in its details, so end users might be pretty well confused by some of the key statements.
Malware activity gets stuffed under the Vulnerability section. Their crystal ball tells us What to Expect in 2008, partly based on what they have not seen in the past (disregarding the golden rule that absence of evidence is not evidence of absence in the security arena):
“More malware may execute in system memory, not on hard drives.”
Huh? I can’t remember the last time a piece of malware, or any code for that matter, executed on the hard drive, instead of in the CPU and memory. And what about caching or paging?

Ok, we can get past that statement. The point seems to be that “more” malcode may run on systems without ever touching users’ hard drives: “Malware attacking rootkits that executed entirely in system memory emerged in 2007. As average RAM size continues to increase in the coming year, these strategies will likely grow in popularity”.
Imho, not exactly. These strategies have been around for a long time in the underground and cybercriminal coding communities, but it hasn’t been a money maker — Aphex’s downloader circa 1999 is an example. The key feature was that it downloaded any content to memory from a remote location (like a web server) and executed the content in memory without the content ever touching the disk. I am sure his was not the first, but he was one of the first from the shadier side of the underground to develop and publicly release a reliable loading technique like this one on his website. The downloader, and its scanner evasion techniques, just weren’t needed at the time. Problems from using the technique had nothing to do with the size of physical memory on the victim system. But there were easier methods of detection evasion.
Kinda confusing.

Anyways, enough of my nitpicking, it is an interesting read with a fine list of key recommendations, predictions, and some exposure to their collected data from 2007. I’ll get through more of the malware section and update this post with notes about what I really like in the report.

Shellcode analysis — download n’ exec

Tuesday, December 18th, 2007

In a previous post, I mentioned that we could use c code to analyze some shellcode currently being posted in the wild by malicious web site operators.

These malicious websites are delivering malware by exploiting several Windows based vulnerabilities. The websites attack visitors by targeting vulnerabilities in .ani file parsing, .wmf file parsing, and rtsp content-type string parsing in the QuickTime plugin.

In our labs, we visit these web sites with vulnerable systems, allowing the pages to compromise the systems. We then analyze the techniques being used. Let’s take a quick look at a major part of the attack — the shellcode within the delivered malformed wmf file. We’ll take a look at the low level data content of the malformed file itself:

After seeing a lot of these malformed files, you can spot the shellcode right away. I did in the above image after a quick visual scan, but sometimes details of the file format need to be known to find the shellcode on the first try.
We copy out the string of shellcode hex data into a c-style string, like this one:
“\x83\xec\x10\xd9\xee\xd9\x74\x24\xf4\x58\x33\xc9\xb1\xdb…”

I copy it into the buffer in the c file from the previous post, and the assignment will look like this:
unsigned char shellcode[] = “\x83\xec\x10\xd9\xee\xd9\x74\x24\xf4\x58\x33\xc9\xb1…”

I compile it using gcc, but you can use the cl.exe Microsoft compiler if you would like — whatever c compiler should be fine. I’ve never seen a problem with substituting one for another:
C:\sh\>gcc sh3ll.c -o sh3ll.exe

The compiler emits an expected warning that can be ignored, and now we have an executable to work with. We’ll run it in Olly to its entry point, and then search for the beginning of the shellcode string in memory. When we find it, we’ll set a memory access break point on that memory location and then let the process run to that point by hitting f9.
When the debugger arrives at this starting point for the shellcode, the debugger shows us a very strange listing — “jno” instruction followed by a bunch of “cnq” instructions? The listing looks very strange:

We hit f7 a few times and notice “xor byte ptr ds:[eax+12], 99″, followed by a loopd instruction that takes us back to a few lines prior. This loop is an xor decoder loop, implemented in this shellcode because we are exploiting BoF, and usually that means we are attacking a string handling flaw. Any “00″ or null bytes in the code will likely crash the code, as explained in chaps 3, 7, 9.
We also notice that ecx is set to “0xdbh” at 0040200e, meaning that this loop will decode the subsequent 219 bytes of data:

We can continue stepping through the code with f7, watching the decoding taking place, until ecx decrements to zero. When it finishes, we step through a bit more slowly.
Stepping into the instructions with f7 now reveals the code searching for kernel32’s location in the process space using the common and reliable technique of parsing the PEB and its module initialization linked lists. It then searches for LoadLibraryA, ExitThread, and WinExec win32 api calls. It loads urlmon and finds URLDownloadToFileA. These calls all tell us that this shellcode’s functionality is download and execute — and we can observe the url strings that the code is communicating with.
Download and execute shellcode like this happens to be some of the most prevalent shellcode that we see served up by malicious web sites.

Hope that you learned a few things about the sorts of techniques we can use to analyze shellcode and its behaviors. Let me know what you think of it!