I decided on the "SWORD" malware sample from the APT1 section. This was described as a single-sourced remote command utility, so I figured it would be a good little one to start the blog off with. Initially I just ran strings across it to see if there was anything there of interest. As strings is basically the lowest hanging fruit in malware analysis, I didn't expect to find anything that I would have been able to take to responders and say "You'll need to look for this." If only. What I was really looking for were any strings that weren't explicitly helpful (i.e., appear random or gibbereish) but could potentially be used by the binary to do something interesting. Here are the strings of interest that I found in the binary.
Random Strings and Misspellings |
Random Strings Seen Used |
- Start at the numeric row, and press every key from right to left
- Retype the numeric row, this time holding the Shift key
- Repeat until the last row is typed, skipping the control keys
- Remove the &"\{}
There is Another String! |
The Interesting Bit |
So, first strchr calls determines where in the "keyboard" string is the first character of String 3 located. Then, if the location is equal to zero, then the program throws an error. Otherwise, it will check again (the second strchr call) and store in esi. This segment then goes on to grab the first character in the "fox" string, and determine where it is located in the "keyboard" string (the third strchr call). This leaves with the following values stored in memory:
- Location of the first character of String 3 in the "keyboard" string
- The first character of the "fox" string
- Location of the first character of the "fox" string in the "keyboard" string
Just after the "jnz short loc_4010D4" call we see the logic that subtracts the strchr(keyboard, fox[0]) value from the strchr(keyboard, String3[0]) value. Then the program grabs the value in the "keyboard" string at the position resultant from the previous subtraction. So the ending location that the program is looking for can be written like this:
value = keyboard[strchr(keyboard, String3[0]) - strchr(keyboard, fox[0])]
Knowing that, I decided to knock up a quick version of the logic (without the error checking) just to see what the value would be before going through debugging it. I decided to do it in python, because I hadn't used it in a while and why not? This is what I came up with:
So, we run this real quick to see what we come up with and...
Yep. There is the IP address and port number used by this binary (remember it only talks to one location). Checking in debugging and by detonating this binary confirms what we are seeing from running our script.
There are the callouts to the same IP address and port that we determined from our script! Now, we could have gotten this IP and port by dynamic analysis, and we could have determined that two of the strings were used in the binary. Some analysts would continue on either due to time constraints, or satisfied that indicators were found. However, by actually looking into why and how these strings are used, we can be confident in using those strings in yara rules that could help us distinguish the presence of this malware in the future. Ideally, we would want to determine the commonality of these string between multiple samples, but I only had one sample of this malware. However, we could create something like the following as a starting rule:
Yara Rule for Given Indicators |
So, when you get asked by someone "Why did you use these strings for your signature?", you will have an answer. =)
[EDIT: 06.19.14 - Fixed yara rule to include the "wide" and "ascii" modifiers]
No comments:
Post a Comment