gethostbyname
. Some versions of IDA Pro double-count cross-references: p
is a reference because it is being called, and r
is a reference because it is a “read” reference (since it is call dword ptr [...]
for an import, the CPU must read the import and then call into it). Examining the cross-reference list closely, you can see that gethostbyname
is called by five separate functions.var_
. The freeware version of IDA Pro counts only 20 local variables, so the version you are using may detect a slightly different number of local variables. The parameters are labeled and referenced with positive offsets, and we see that IDA Pro has recognized one parameter for the function labeled arg_0
.sub_10004E79
. We see that this function calls GetSystemDefaultLangID
and send
. This information tells us that the function likely sends the language identifier over a network socket, so we can right-click the function name and give it a more meaningful name, such as send_languageID
.The start and end address should correspond to the start of DllMain
—specifically, 0x1000D02E. Because we care only about the cross-references from DllMain
, we select a recursion depth of 1 to display only the functions that DllMain
calls directly. shows the resulting graph. (The API calls are seen in gray.) To see all functions called at a recursive depth of 2, follow the same steps and select a recursion depth of 2. The result will be a much larger graph, which even shows a recursive call back to DllMain
.
socket
. Right-clicking each of the numbers and selecting Use Symbolic Constant presents a dialog listing all of the constants that IDA Pro has for a particular value. In this example, the number 2 corresponds to AF_INET
, which is used for setting up an IPv4 socket; 1 stands for SOCK_STREAM
, and 6 stands for IPPROTO_TCP
. Therefore, this socket will be configured for TCP over IPv4 (commonly used for HTTP).Found Virtual
Machine
in the code after a comparison.As referenced by question 18, we jump our cursor to 0x1001D988 using the G key. Here, we see what looks like random bytes of data and nothing readable. As suggested, we run the Python script provided by selecting File ▸ Script File and selecting the Python script, shown in the following listing.
sea = ScreenEA() ❶ for i in range(0x00,0x50): b = Byte(sea+i) decoded_byte = b ^ 0x55 ❷ PatchByte(sea+i,decoded_byte)
At ❶, the script grabs the current location of the cursor, for use as an offset to decode the data. Next, it loops from 0 to 0x50 and grabs the value of each byte using the call to Byte
. It takes each byte and XORs it with 0x55
at ❷. Finally, it patches the byte in the IDA Pro display without modifying the original file. You can easily customize this script for your own use.
After the script runs, we see that the data at 0x1001D988 has been changed to something more readable. We can turn this into an ASCII string by pressing the A key on the keyboard with the cursor at 0x1001D988. This reveals the string xdoor is this backdoor, string decoded for Practical Malware Analysis Lab :)1234
.