Книга: Practical Malware Analysis: The Hands-On Guide to Dissecting Malicious Software
Назад: Lab 20-1 Solutions
Дальше: Lab 20-3 Solutions

.

00401500                 push    ebp 00401501                 mov     ebp, esp 00401503                 sub     esp, 198h 00401509                 mov     [ebp+wVersionRequested], 202h 00401512                 lea     eax, [ebp+WSAData] 00401518                 push    eax             ; lpWSAData 00401519                 mov     cx, [ebp+wVersionRequested] 00401520                 push    ecx             ; wVersionRequested 00401521                call    WSAStartup 00401526                 mov     [ebp+var_4], eax 00401529                 push    100h            ; namelen 0040152E                push    offset name     ; name 00401533                call    gethostname 00401538                 push    0               ; int 0040153A                 push    offset FileName ; "C:\\*" 0040153F                call    sub_401000 00401544                 add     esp, 8 00401547                 xor     eax, eax 00401549                 mov     esp, ebp 0040154B                 pop     ebp 0040154C                 retn    10h

is executed.

.

This code references the object stored in var_148, and then calls the first pointer in the virtual function pointer table. This code is the same whether a .pdf or .doc object is created, but the function called differs for different types of objects.

We saw earlier that the code could create one of three different objects:

We’ll first check the function to be called for a pdf object. We navigate to the virtual function table at 0x4060D8 and find that the function being called starts at 0x401380. We see that it calls InternetOpen to initialize an Internet connection, and then calls InternetConnect to establish an FTP connection to ftp.practicalmalwareanalysis.com. Then we see it changes the current directory to pdfs and uploads the current file to the remote server. We can now rename the function pdfObject_UploadFile. We also look at the function for docObject and see that it executes nearly the same steps, except that it changes the directory to the docs directory.

Finally, we look at the virtual function table for the otherObject to find the upload function for otherObject at 0x401370. This function does very little, and we can conclude that only .doc and .pdf files are uploaded by this malware.

The malware author implemented virtual functions to allow this code to be easily modified or extended in order to add support for different file types simply by implementing a new object and changing the part of the code where the object is created.

To test this code, we can add directories named docs and pdfs to our FTP server, and allow anonymous write access to them. When we rerun our malicious code, we see that it uploads every .pdf and .doc file from the victim’s computer to these directories, naming each file with the victim’s hostname and an ID number.

sss
sss

© RuTLib.com 2015-2018