Teacher
Professional
- Messages
- 2,669
- Reaction score
- 829
- Points
- 113
Hello, cyberstalkers! Hello, random carders. In a previous article, we talked about what shell code is and how it is used by hackers. In today's article, you will learn how to detect shellcode on a compromised machine.
Go:
Hackers who value their freedom and reputation write shellcodes using techniques that hide their attack. For example, a typical intrusion detection system (IDS) typically scans all incoming network traffic for a structure specific to the shellcode.
If IDS finds such a structure, the packet containing this signature is destroyed before it reaches its destination. However, the weak point of IDS in this case is that if the traffic is encoded, then it will not be possible to recognize it. Now do you understand why encryption is so valuable?
How to detect shellcode
To analyze the sample, we will need certain tools:
- IDA Pro (with plugins)
- Ollydbg
- PEiD (with Krypto ANALyzer)
Well, let's get started! First of all, we open the PEiD and load our sample there. Everything is as expected, no surprises. However, we remember that we are dealing with cryptography in malvari code, so we will try to run the Krypto ANALyzer plugin (it must be preloaded in PEiD). And here's what we see: signatures are detected.
Let's move on. We open IDA Pro and load the sample there, bypassing a lot of windows and uninformative information, pay attention to the resource table... Yes, there is nothing striking here either.
Perhaps we can try our luck in finding network activity? Hmm ... We launch Process Explorer, then select the process started by our malware, go to "Properties", click the Strings tab and simultaneously launch the Wireshark network shark. In the packet analysis window, you can find a GET request for a web resource http://www.practicalmalwareanalysis.com. The data on the Strings tab of the Process Explorer utility and the data extracted from the Wireshark package matched.
Let's go back to the IDA Pro disassembler. On the graphic diagram, we notice some interesting lines: the subroutine @0x00401300 loads a certain resource in binary form and applies the XOR operation for a certain value ‘;’. In the following screenshot, this is very clearly visible.
Below is a screenshot of the window from IDA Pro, where the instructions for XOR encryption are highlighted in yellow.
And we have a natural question: what key (cipher) is used for encoding and what exactly does it encode? Remembering what we found earlier, we can conclude that the‘; ' key is intended to decode a string containing the URL http://www.practicalmalwareanalysis.com.
So, we have determined which encryption algorithm is used and what data it encrypts. It's time to connect plugins that will help us with decoding. We will use the signature search tools FindCrypt2, Krypto ANALyzer, and IDA Entropy Plugin to identify other encoding mechanisms.
The KANAL plugin detected four addresses using characters from the string ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/. What do you think it's like? Yes, yes, my friend, you thought correctly — this set of characters is an alphabet, from which permutations are then made.
What about network traffic?It is encoded using the Base64 algorithm. Below is a screenshot from the OllyDbg debugger that illustrates the encoded strings.
And here is a screenshot from the same debugger, containing instructions that are responsible for the coding process itself.
Somewhere in the code, there is a function responsible for decoding information using the Base64 algorithm, and it is located at address 0x004010B1.
Let's look at this code in the diagram from IDA Pro. The key encoding characteristics are highlighted in yellow, namely: the maximum message length is 12 characters. In the algorithm description, the maximum length in Base64 is 16 bytes.
That's all for today. You're well done if you were able to read this article to the end, and it would be great if you could now repeat all the lab work without peeking.
Our series of articles on reverse engineering for beginners ends here. Of course, we have only covered the most basic and key aspects of malware analysis, and there are still a lot of topics worth talking about. You can continue this topic indefinitely and probably even write a whole book.
I hope, cyberstalkers, you were interested and now you know how to detect shellcode. You've learned something new and now you can imagine what it's like to work as a virus analyst.