- IDA Pro
- Lab19-02.exe SHA256: 3ba837e827a5a20cf51ec82972b5e5fe028708932bfe1e58fd1224ef2fe5bb75
- Detection Rate: 32/56
- Analyzed on 2016-06-04
Compilation Date: 2011-03-02 04:10:40
- View report here
The file Lab19-02.exe contains a piece of shellcode that will be injected into
another process and run. Analyze this file.
1. What process is injected with the shellcode?
Firing up IDA Pro we can immediately see that a function is called to create a new process and thereafter injecting shellcode into it.
To see the arguments passed into the GetProcessID function (refer to 0x4013DE) we can set a breakpoint in ollydbg.
From figure 2, we can see that iexplore.exe path is passed into a function. The function then use this path to CreateProcess.
2. Where is the shellcode located?
To find the shellcode, i would first try to find the function call responsible for writing the shellcode into the remote process. WriteProcessMemory is a good place to start.
At address 0x00401230, we can see a function with a lpbuffer argument passed in along with the buffer size and a process id. It is not hard to guess that this function is responsible for opening a handle to the remote process and eventually writing payload into it. We would just need to trace who called this function to find out where is the shellcode located.
Seems like we have found the shellcode @0x407030. Lets take a peek at the shellcode =) as shown below… Press “C” to convert the bytes to code.
3. How is the shellcode encoded?
Looking at the shellcodes in Figure 6, we can see that the author is using the “call” trick (as seen in step 2) to get the address of the shellcode. Analyzing the codes, we can that the shellcodes from 0x407048 onwards are decoded using XOR with 0xE7.
4. Which functions does the shellcode manually import?
To analyze the shellcode, we can either extract the shellcode and run it using sctest or you can choose to use a simple trick that I be showing to break in the newly created process.
- First break at WriteProcessMemory function
- Before the memory is written into the remote process we change the first byte of the shellcode (0x407030) to 0xCC (breakpoint)
- Attach debugger to the newly created IEXPLORE.exe
- Resume Lab19-02.exe in ollydbg
- The IEXPLORE.exe will break on executing the injected shellcode
On analyzing the shellcode, you will come across a function that is responsible for manually importing the following functions. You may also wish to break at CALL instructions in the shellcodes to trace where in the memory are the address coming from.
5. What network hosts does the shellcode communicate with?
We set a breakpoint @ connect and analzye the SockAddr struct passed to it.
sin_port = 0x3412 = 13330
sin_addr = 0xC0A8C802 = 192.168.200.2
6. What does the shellcode do?
Reverse shell(cmd.exe) to 192.168.200.2:13330. We can see that the shellcode executes CreateProcessA after connecting to the remote IP.
The following figure is a internal setup to see how the malware would behave on successful connection to the IP & port. As we have expected, a reverse shell connection is established.