Methodology for Reverse-Engineering Malware. This paper, written in 2001, once one of the first public documents that discussed tools and techniques useful for understanding inner workings of malware such as viruses, worms, and trojans. This paper acted as the launching point for a SANS course on analyzing malicious software ; if you’re interested in this topic, take a look at that training option. (You can download the PDF file of the paper.
if you wish. The paper below describes an approach to setting up inexpensive and flexible laboratory environment using virtual workstation software such as VMware, and demonstrates the process of reverse engineering a trojan using a range of system monitoring tools in conjunction with a disassembler and a debugger. Portions of this document were submitted to SANS GIAC to fulfill GCIH certification requirements.
This paper attempts to document an approach to reverse engineering malicious software. The reason for highlighting the process itself, instead of concentrating solely on specifics of the program is two-fold. First, there are still many unanswered questions about the particular trojan discussed in this write-up (srvcp.
Include 'win32ax.inc' section '.data' data readable writeable i dd 0 j dd 0 IpTempPath db MAX_PATH dup( 0) IpCommand db '/c copy ', 0 new db 0 section '.code' eScan Internet Security Suite 14: Malware detected Kaspersky Internet Security 2014: HEUR: Trojan. Total Defense Internet Security: OK. Скачать Audio Splitter Utility 18.104.22.168 / Аудио / Мой компьютер / Каталог программ. Crack MDB Password / Версии программы / Каталог программ - GoldSoft.ru Скачать TDS- 3 Trojan Defence Suite 3.2.1 / Антивирусы / Мой компьютер. Taxi Racer London 2 serial by PiZZA · Taxi Racer Tazion SecureKeys COM v2. 0 keygen by ACME · TBack Pro TDS- 3 Trojan Defense Suite v3. 2.0 by tC.
exe); positioning our findings as comprehensive analysis would be misleading at best. Second, repeatable forensics steps should assist members of the defense community in developing a structured approach to understanding inner-workings of malicious software. In the process of analyzing the trojan we have become impressed with programming efforts that attackers are willing to go through to create resilient and flexible malware. As the result of these efforts, the process of reverse engineering the program was time consuming yet fulfilling.
We hope that our discussion will encourage security professionals to improve upon methodology suggested in this paper, and possibly fill in the gaps in our understanding of this particular trojan. We would like to thank Joe Abrams for his insights regarding the trojan’s assembly code, as well as for explaining the context of its existence in the wild. Many thanks to Slava Frid, who helped us in stepping through particularly cryptic areas of the program’s code, and for making his mind available for our picking. Also, we thank Doug Kahler for sharing with us the trojan along with his observations.
Finally, thanks to Jeremy Gaddis for bringing this trojan to the attention of the defense community. Background Information. A variant of the srvcp. exe trojan, discussed in this document, was brought to the attention of the defense community by Jeremy L. Gaddis on 8 June 2000. In his posting to the Incidents mailing list, Jeremy reported noticing inbound connection attempts to TCP port 113 from an unknown host on the Internet, as well as unauthorized outbound connection attempts to a remote server on destination TCP port 6667. JLG Investigating the incident, Jeremy discovered the trojan’s ties to an Internet Relay Chat (IRC) network, as described in his message:.
Knowing that 6667 is an often used port for IRC servers, I started up an IRC client and connected to that host. It was indeed an IRC server. A quick check showed 4 users online with the “Real Name” field set to “Im trojaned”, one of which was my IP address. For those not familiar with IRC, let us mention that IRC can be viewed as a network of interlinked servers that allows users to hold real-time online conversations. Participants of a conversation typically join a channel devoted to a particular topic or interest. This is accomplished by having the user’s IRC client connect to a server that participates in the desired IRC peering network. When a user types a message meant to be seen by channel participants, it is relayed to the IRC server, and the server resends the message to participating clients, as specified in the Request for Comments (RFC) document 1459.
2. Конфигурирование файлов Kes10win.kpd и Kes10win.Kud 3. Список программ, несовместимых с Kaspersky Endpoint Security 10 для. [CSC-STD-002-85, 1985], Department of Defense, «Password Management DDN MGT Bulletin #43, DDN Network Information Center, 3 November 1988. Unix Security», O'Reilly & Associates, ISBN 0 -937175-72- 2, Май 1991. Viruses, Worms, and Trojan Horses», Van Nostrand Reinhold, NY, 1990.
RFC1459. A few days after Jeremy’s initial message, Brandon Kittler also relayed his experience regarding this trojan in his posting to the mailing list on 10 June 2000. BK Brandon supplied details regarding the location of the program’s executable and the associated registry entry. Based on his observations and examination of strings present in the executable, some of which are shown in Figure 1-1, he concluded that the trojan was able to receive commands potentially dangerous commands via IRC:. Brandon also pointed out that the program listened on port 113 for Ident requests, and crashed when it received requests that did not follow the Ident protocol. The Ident service, whose protocol is defined in RFC 1413, allows a remote server to determine the login name of the user who initiated a TCP connection to the server. RFC1413 In an attempt to control system abuse, many IRC servers do not accept IRC connections unless the connecting user’s identity can be reconfirmed through the use of the Ident protocol.
Additional information regarding the program’s behavior was reported by Doug Kahler a couple of days later on 12 June 2001. DK Doug mentioned that he ran into a similar trojan a few months earlier, and pointed out that at the time the program attempted to connect to an IRC server on the EFnet network to join a channel named “ #mikag ” with the key “ soup “. Doug also wrote:. Just joined the channel today, and there are 55 people in there with nicks of random letters and numbers. I assume they are all infected. Doug would later be kind enough to search through his archives and share with us a copy of the trojan that he based his analysis on. This was critically helpful for our research, since the executable posted to the mailing list in the beginning of the thread turned out to be a benign copy of what seemed to be a Windows screen saver.
As Nick FitzGerald pointed out in a message to the Incidents mailing list on 13 June 2001, the program seemed to be a variant of the relatively unknown Tasmer trojan. NF Nick confirmed that in his experience the trojan joined an IRC channel, and could be “remotely controlled via private messaging over IRC. ” According to Nick, some Tasmer variants were suspected of having distributed password cracking capabilities, and possible Denial of Service (DoS) attack agents.
Anti-virus vendors did not provide much information about this particular trojan, and later examination of virus databases disclosed lack of documented details regarding the trojan’s capabilities, probably due to its relatively low profile. Since the discussion on the Incidents mailing list in June 2001, the trojan did not seem to catch the public’s eye, and has remained relatively unexplored. However, our interest in this program was rekindled after a recent posting to the mailing list by Pete Schmitt on 10 March 2001. PS His brief description of the trojan that has infected his computer seemed to match the one discussed on the mailing list eight moths earlier. Pete also observed that the trojan attempted to connect to an IRC server using the name of “ Joe Blow ,” which later allowed us to tie this incident to another variant of this trojan. Our research methodology and findings are documented in the following pages. Controlled Environment.
To facilitate efficient, inexpensive, and reliable research process, reverse engineers of malicious software should have access to controlled laboratory environment that is flexible and unobtrusive. In our research, we have come to rely on virtual workstation software available from VMware, Inc.
VMware works by providing hardware emulation and virtual networking services, and allowed us to set up completely independent installations of operating systems on a single machine. With VMware, multiple operating systems can run simultaneously, and each virtual machine “is equivalent to a PC, since it has a complete, unmodified operating system, a unique network address, and a full complement of hardware devices. ” VM1. When setting up our laboratory environment, we installed VMware on a 500MHz laptop computer running Windows 2000 Professional with 20GB disk space and 256MB RAM.
We decided to use a laptop, even though similarly priced desktop machines would offer much more computing power, to keep our laboratory as portable and lightweight as possible. Wishing to have a range of operating systems available for research, we created three virtual machines running within VMware: Red Hat Linux 7. 0, Windows 98 Second Edition, and Windows NT 4. 0 Workstation Service Pack 6a. Each guest operating system was allocated 1. 6GB disk space and 64MB RAM, which was sufficient for our purposes. Because VMware emulates hardware, each guest operating system had to be installed in a way consistent with typical installation procedures.
Figure 2-1 below illustrates our setup running two virtual machines simultaneously within the host operating system. While each guest operating system was able to operate independently of each other, VMware allowed us to interconnect virtual machines using a virtual network that was completely enclosed within the hosting machine and did not have the ability to communicate with the outside world.
To enable this functionality when using Windows 2000 as the host operating systems, we had to manually create a virtual host-only adapter by following directions from the VMware support site. VM2 The adapter was assigned an IP address in a private RFC 1918 range, to ensure that it would not conflict with any of our existing connections. RFC1918. As part of the host-only adapter installation, VMware also installed a DHCP server service, dedicated to giving out IP addresses to hosts on the virtual network. To ensure that the virtual network is truly isolated from physical interfaces of the laptop, we installed ZoneAlarm Pro on the hosting machine, which offered us a comforting layer of protection, and warned us of any packets trying to leave the laboratory environment. This precaution, however, cannot guarantee complete isolation for the environment. Ideally, the VMware host should not be connected to a production network, and should be considered as dispensable as the virtual machines themselves.
Figure 2-2 below illustrates virtual network infrastructure that resided within our laptop. One of the advantages of using VMware instead of physically separate systems is the ability to backup and restore full systems in a matter of minutes. Each virtual machine is implemented using a several self-contained files located in the program’s VMs subdirectory.
Backing up the system can be accomplished by making a copy of the files that are used by VMware to represent the virtual machine. This is particularly useful when analyzing unknown malware, where unless the system is brought to a known state, repeated interactions with the virus or trojan might taint the environment. Additionally, the ease of making copies of virtual machines allows engineers to maintain a number of instances of an operating system with different patch levels. Despite the high degree of isolation provided by VMware, there is some interaction between guest operating systems and the hosting machine.
In particular, VMware provides VMware Tools drivers, which, when installed on a virtual machine will allow the user to move the mouse pointer between guest operating systems and the hosting machine. Additionally, the drivers allow virtual machines to share access to the hosting machine’s clipboard. These features are enabled from within virtual machines, and the hosting system does not seem to be able to disable them. This means that it is possible to craft a targeted attack against a user of a VMware-based laboratory that will achieve some level of access to the hosting system from within a virtual machine. Behavioral Patterns. One of the ways to understand the threat associated with a malicious software specimen is to begin by examining its behavior in a controlled environment. This typically involves running the agent in a laboratory and studying its actions as it interacts with computer resources and responds to the various stimuli.
VMware-based laboratory environment described in the previous chapter allowed us to use a single screen to monitor malware from perspectives of different systems. We used a combination of process, disk, registry, and network monitoring tools to study the trojan’s activity on a specific machine, as well as its attempts to connect to other systems. We were able to direct the trojan to laboratory machines when it attempted to communicate with systems on the Internet, so that we could replicate native environment for the trojan while maintaining full control over its interactions with the world. We found freeware tools offered by Systernals to be very useful when monitoring the trojan’s behavior.
Specifically, we used Filemon for Windows NT/9x to observe which files the trojan attempted to access on the local system. SI1 Similarly, Regmon for Windows NT/9x provided us with the ability to monitor registry-related read and write activity.
SI2 Additionally, the TCPView Pro utility, which costs $69, allowed us to obtain detailed listings of all TCP and UDP connections on the system, and tied network endpoints to processes that established them. WI. We used Winalysis, a program produced by SFullerton. com to detect changes made to the system by the trojan. SF Winalysis allowed us to create a baseline of the pristine system, and compare it to the system’s state after the trojan ran. Using Winalysis in conjunction with monitoring tools from Systernals allowed us to be relatively certain that we would detect the trojan’s affect on the file system.
Winalysis costs $25 per copy for Windows 98/ME, and $35 per copy for Windows NT/2000, and is able to detect changes to the system’s registry and file system. While Winalysis does not offer the level of detail and robustness associated with a more popular forensics tool Tripwire, TR its low price and ease of use made it a useful addition to our toolkit. Malware may create temporary files as it executes, and delete them before the program exists. In this scenario Winalysis is unlikely to report evanescent existence of the transient file, while Filemon will report that it was created and deleted, but will not recover the file’s contents. To account for this possibility we used the Undelete utility, available from Executive Software for around $45. ES Undelete replaces the native Windows Recycle Bin with a Recovery Bin, which is able to capture all deleted files, even those deleted by non-GUI processes.
Unfortunately, at the time of this writing Undelete is only available for Windows NT/2000. We relied on Snort, a freely distributed lightweight intrusion detection system, to monitor traffic on the laboratory network.
SN Even though Snort is typically used to automatically detect network-based attacks, we only utilized its built-in sniffing capabilities to obtain details about network communications by invoking the program using the “ snort -v -d ” command, which told it to enter verbose mode and to capture data payload of packets. We preferred a Snort-based sniffer to other network capture utilities because of Snort’s availability for Windows as well as UNIX operating systems, its large deployment base, as well as text-based logs and controls. VMware comes with a tool called vnetsniffer, which can run on the hosting operating system and display network traffic between virtual machines, as well as between the hosting machine and its guests. However, the extent of information supplied by the program would not be sufficient for detailed forensics analysis. Even when executed with the “ /e ” switch, vmnetsniffer only logs packet size, source IP and MAC addresses, transport protocol type, as well as ARP and ICMP message types when appropriate.
This is considerably less exhaustive than information provided by Snort, and most importantly lacks packet data payload. For network monitoring purposes, the VMware virtual laboratory network can be considered to be hub-based, since every machine on the network is able to see all network traffic when its network interface is in promiscuous mode. However, the exception to this rule is the hosting operating system itself, which is only able to see traffic originating or targeting itself. To see all virtual network traffic from the hosting machine, one has no choice but to use the vmnetsniffer tool. To obtain the desired level of packet details, we monitored the network by running Snort on our Linux-based laboratory machine, which allowed us to see all virtual network traffic. Behavioral analysis described in the previous section concentrates on external aspects of malware as it interacts with its environment, but does not provide sufficient insight into the inner workings of the program. We utilized a debugger in conjunction with a disassembler to attempt reverse engineering the trojan’s executable, since we did not have the luxury of looking at its source code.
This process relied on the disassembler to understand the basic structure of the program, and proceeded by stepping through it with the debugger to study the trojan’s workflow and to peak at its runtime memory contents. We used DataRescue IDA Pro disassembler to decompose the trojan into assembly instructions. IDA Pro Standard can be purchased for $299 from the company’s Web site. DR1 Before purchasing the program, one might take advantage of its limited evaluation version, which is available for free and might prove to be sufficiently useful during early stages of the analysis.
DR2 DataRescue also provides IDA Pro Freeware, which is actually version 3. 85B of the software, and lacks a Windows-based GUI that we found to be very useful in the newer versions of the program. DR3 During our analysis we also relied on the Intel Architecture Software Developer’s Manual for explanation of assembly instructions that we were not familiar with. IN.
Because assembly is a low-level language, we encountered difficulties understanding the flow of the trojan’s code without stepping through it with SoftICE, a powerful debugger that can be purchased as part of NuMega SoftICE Driver Suite for Windows 9x/NT/2000 for $999. NM We had the debugger running in the background of the laboratory system where we launched the trojan. Knowing the general structure of the trojan from its disassembled code as well as from system and registry calls intercepted by Systernals tools, we were able to set SoftICE breakpoints on code sections that seemed particularly interesting. Breakpoints allowed us to automatically invoke the debugger at specific workflow branches, and eliminated the need to step through every instruction in the trojan’s program.
Once lauched, SoftICE ran in the background until invoked through the “ Ctrl-D ” key combination or until some program triggered a previously set breakpoint. C4N We usually set a breakpoint by executing the “ bpx ” command on the SoftICE command line by supplying an API function name or an instruction address as a parameter. We used the F10 key when in SoftICE to step through the program one step at a time while executing function calls as a single step, and the F8 key to execute every instruction as an individual step.
MT Finally, completing the list of our most frequently used SoftICE directives, is the “ d ” command, which displayed memory contents at a specific address or at a location stored in a particular register. We installed SoftICE on Windows NT 4. 0 and Windows 98 laboratory machines. Initially we had concerns over stability of the program when running in VMware environment. In particular, machines would sometimes freeze and fail to start when SoftICE was activated. However, most of the problems went away once we removed VMware video drivers from these virtual machines and installed standard Windows VGA video drivers in 640×480 mode with 16 colors. Under Windows NT we started SoftICE manually using the “ net start ntice ” command.
Under Windows 98 we ran into problems trying to start the program manually, and had the system automatically launch it upon boot-up. Another useful tool in our arsenal was the “ strings ” program, available in most UNIX distributions. This utility can extract text strings from executables, which is often helpful for assessing the program’s purpose and mechanics.
A strings snapshot of malware is considerably shorter than a complete listing of its disassembled code, but, of course, it is not as thorough. Similar functionality is available for Windows from the BinText program, which is freely distributed by Foundstone. FS BinText is a bit more flexible than most of its UNIX alternatives, and supports a range of advanced filtering options. Finally, we used Perl as the scripting engine for automating minor tasks related to the analysis.
For instance, we were able to model the decryption fragment of the trojan’s code from assembly using a flexible routine implemented in Perl. Perl is built into most UNIX distributions, and is freely available for Windows platforms from ActiveState, which distributes it under the ActivePerl label. AS.
Trojan Architecture. Local System Interaction. Before launching the srvcp. exe trojan on our Windows NT 4. 0 laboratory machine, we enabled all monitoring tools that we had in our possession. We placed the srvcp. exe file in the arbitrarily chosen location on the local file system and ran the program.
It went quietly into the background, and besides adding the “ srvcp. exe ” process to the process list, did not register any behavior that could be observed with a naked eye. We could see activity associated with the executable being logged by our monitoring utilities, and killed the srvcp. exe process after it lived for approximately 10 seconds. Examination of activity logs revealed behavior consistent with the discussion in the “unknown trojan” thread on the Incidents mailing list, which we discussed in the Background Information section of this document. After the trojan was killed, we used Winalysis to scan the system for file system and registry changes.
The program flagged several modifications related to normal Windows activity, and specified that the following registry key was created with the value of “ srvcp. exe “: “ HKLMSOFTWAREMicrosoft WindowsCurrentVersionRunService Profiler “.
This configured the system to attempt launching the trojan every time Windows started up. Note that the full path to the trojan’s executable was not specified, which indicates that the author assumed that srvcp.
exe would be in the path. This suggests that we did not possess the trojan’s distribution mechanism, which would have either modified the system’s path, or copied srvcp. exe into a directory that was in the path by default, such as C:WINNT.
In our case, the executable file remained in C:Download, and no new files were created, which meant that the trojan would not start upon system boot-up. Filemon and Regmon logs confirmed Winalysis findings. Figure 3-1 below illustrates creation of the trojan’s registry key as witnessed by Regmon. (We manually highlighted relevant lines on the screen snapshot for emphasis. ) Later experiments established that this key is set every time the trojan is executed, even if it has been created earlier.
Note that Regmon does not display the value of the registry key—to obtain that information we had to either look at the registry using the regedit. exe utility, or compare system state using Winalysis. According to Regmon, the trojan also queried ServicesWinSock2 and ServicesTcp registry keys, which is typical for an executable utilizing TCP/IP for network communications. As demonstrated in Figure 3-2 below, Filemon reported that the trojan attempted to access the C:WINNTSystem32gus. ini file, which was not found on this system. Under Windows NT the request used the “ IRP_MJ_CREATE ” call with the option “ Open “, while in later experiments under Windows 98 Filemon simply labeled the request as “ Read “.
In both cases, the trojan continued to function even though the file was not found. Further in the document we discuss the role of the gus.
ini file. Furthermore, Filemon, captured access attempts to C:WINNTSystem32crtdll. dll, which provides function calls such as fopen, fclose, and fscanf. Additionally, the trojan read msafd. dll, wshtcpip. dll, and rnr20. dll.
Finally, the trojan read the hosts file, probably as part of the domain name resolution process that we have witnessed using Snort, as discussed in the next section. Communication Protocols. Before launching the trojan on one of our laboratory machines, we configured the Linux machine to monitor network communications using Snort running in verbose mode. Because the VMware virtual network has hub-like properties, this system was able to capture all packets traveling across the laboratory network. Figure 3-3 below illustrates a Domain Name Service (DNS) request issued by the Windows NT machine running the srvcp.
exe. We configured the Windows NT machine to use the VMware hosting system 172. 16. 98. 1 as the DNS server, even though it was not running DNS software. An attempt to resolve irc.
mcs. net is consistent with the behavior reported by Filemon, which registered the trojan’s requests to read the local hosts file. Rather than bringing up a DNS server on the laboratory network, we added an entry to the infected machine’s hosts file that resolved irc. mcs. net to 172. 16. 198.
129. The purpose of this configuration step was to redirect the trojan to a server under our control so that we could observe the nature of the connection that the program would make to the system whose name it was trying to resolve.
Manipulating DNS records in laboratory environment was trivial in this case; had the trojan’s author hard-coded an IP address into the program, we would have had to configure local routing tables and network parameters to redirect traffic to our system. As demonstrated in Figure 3-4 below, the trojan attempted to connect to port 6667 on the system it thought was irc. mcs. net. This was not surprising, since port 6667 is commonly used for IRC communications, and is consistent with the host name and nature of irc. mcs.
net, which is a popular EFnet IRC server. Note that our server responded with a RST packet to the trojan’s SYN packet requesting the connection, because our server was not listening on port 6667. In response to observed behavior, we installed and configured ircd-hybrid software IS on the Linux machine 172.
16. 198. 129 to provide IRC services to the trojan. After starting the trojan again, we were able to monitor its conversation with our IRC server. As shown in Figure 3-5 below, the trojan attempted to log in to the IRC channel “ #daFuck ” using the nickname “ mikey “. In this case the period in front of the “ JOIN ” command matches its “ 0A ” hexadecimal counterpart, which represents the new line character. The way in which the trojan connected to IRC is slightly different from the reports discussed earlier in the Background Information section of this document.
In particular, Jeremy reported that the trojan’s real name on the channel was “ Im trojaned “, while in our case the real name was set to “ fight me, pussy “. In both instances the names were suggestive of abuse, and it is possible that we were looking at a mutated version of the program. Additionally, Doug observed the trojan joining the channel “ #mikag “. In our case, we see a possible tie between Doug’s channel name “ # mik ag ” and our nickname “ mik ey “, even though our specimen joined a different channel. Later analysis, discussed further in our document, established a connection between the channel name and contents of the gus. ini file.
Several packets after the trojan connected to the IRC server, we observed an Ident request from the server to the workstation running the trojan. The Ident mechanism is typically used by UNIX systems to obtain the name of the user who initiated a TCP connection. TCPView running on the infected machine reported that the trojan was listening on TCP port 113 typically used by Ident services, and Figure 3-6 below shows the program’s Ident response. After this exchange the trojan was logged into the IRC server, as seen in the following response to the “ /who #daFuck ” command executed on our IRC server: “ #daFuck mikey H@ CaTiRk@172. 16.
198. 131 (fight me, pussy) “. Ident functionality was built into the trojan most likely to increase the likelihood of successfully connecting to an IRC server, since many IRC servers do not accept connections whose identity cannot be confirmed through the Ident mechanism. As soon as the trojan answered the Ident request, it stopped listening on TCP port 113, probably to avoid remote detection with a port scanner, as well as to simplify the flow of the program’s code. Repeated launches of the trojan indicated that it generated the username reported via Ident in a pseudo-random manner.
For instance, some of the other generated names were “ MdSxJy “, “ HsSdLhG “, “ IyKw “, “ FgX ” and “ Ce “. After joining the desired channel, the trojan continuously issued the “ NICK mikey ” command approximately every three seconds. This is demonstrated in Figure 3-7 below. (For clarity we did not include corresponding ACK packets from the IRC server. Once the trojan joined the IRC channel, it remained connected, supposedly waiting for commands from its operator via the chat session.
The nature of these communications is discussed further in the Code Analysis section of this document. The program also participated in periodic “ PING ” – “ PONG ” message exchanges as defined in the IRC protocol to ensure that the IRC client is alive. In one of our experiments we launched two instances of the trojan simultaneously, one running on the Windows NT laboratory machine, and the other on the Windows 98 system. The first instance to connect to the IRC server acquired the nickname of “ mikey “.
When the second instance connected, however, it was not allowed to use the same name, since the IRC protocol requires that nicknames be unique on the same IRC network. As illustrated in Figure 3-8 below, this forced the trojan to generate a different nickname for itself in a pseudo-random manner. (In the network trace, the name “ irc. ticklabs. com ” is the hostname we assigned to our Linux laboratory machine.
) In this scenario both instances of the trojan continued attempting to acquire the same nickname by issuing the “ NICK mikey ” command every three seconds. Multiple instances of the trojan seemed to be designed to ensure that at least one of them possessed the name “ mikey “. If the trojan instance that held that name were to disconnect from the IRC server, another instance of the program would pick up the name within at most three seconds. The more instances of the trojan were connected, the greater the likelihood that one of them would be called “ mikey “. As suggested by Doug Kahler in his e-mail correspondence with us, one of the purposes of this trojan might be to reserve the nickname for its operator, or to prevent someone from obtaining it. Possibly the program’s author can communicate with it via IRC messages to command the trojan to release the name so that the person may obtain it.
One of our experiments was aimed at examining the nature of communications between a potential attacker and multiple instances of the trojan. IRC is a wonderful channel for centrally controlling an army of distributed attack agents, which is one of the reasons that trojans such as srvcp. exe are often hypothesized to have distributed denial of service capabilities.
The attacker has the ability to communicate with multiple trojan instances by issuing a single command on the IRC channel, leaving it up to the server to relay the message to connected trojans. This nature of IRC communications makes it difficult to trace the attack to its origin. Additionally, IRC offers the ability to communicate with each instance of the trojan individually via private messages. Both one-to-many, as well as one-to-one IRC messages are implemented using the “ PRIVMSG ” command from the underlying IRC protocol, as demonstrated in Figure 3-9 below. (We removed irrelevant packets from the trace for clarity purposes. ) The first two packets are carrying a message meant to be seen by all channel participants; this message was submitted by simply typing “ hi all ” at the IRC client’s prompt. Our nickname was set to “ attacker “, our real name was “ lzeltser “, and we were connected from “ 127.
1 “. The server can be seen sending the message individually to each instance of the trojan, identified by different destination IP addresses. The third packet is carrying a message meant to be seen only by the instance of the trojan that possessed the nickname “ mikey “; this message was sent by typing “ /msg mikey just for you ” at the IRC client’s prompt.
In either case, we were unable to elicit any response from the trojan by sending it IRC messages; analysis of the program’s code later revealed the need to encrypt commands in a proper manner in order for trojan to understand them. As discussed earlier in the document, the trojan attempted to read the gus. ini file from the system directory upon start-up. When we placed the gus. ini file into the system directory, Filemon showed that the trojan successfully opened and read the file.
Using Snort that was running on the Linux laboratory machine we were able to observe that the trojan attempted to connect to TCP port 6666 on the IRC server, instead of TCP port 6667 used earlier. This connection attempt failed because our server was not listening on this port. As shown in Figure 3-10 below, we observed that the trojan then attempted to resolve host names of several IRC servers. (We removed TCP retry packets from the trace for clarity.
) The trojan continued to attempt resolving a number of other hostnames that seemed to be associated with IRC until we killed the process. In response to observed behavior, we configured the IRC daemon on our server to listen on TCP port 6666. Once the trojan was restarted, Snort logs showed that the program connected to the IRC server on TCP port 6666. However, as illustrated in Figure 3-11 below, the trojan now joined the channel “ #mikag ” with the key “ soup “. Before we made gus.
ini available to the trojan, it used a different channel name, and did not supply a channel key. (A key is sometimes used on IRC to restrict access to a channel. ) In fact, the trojan’s behavior now matched observations reported by Doug and described earlier in the Background Information section of this document. When searching the Web for information relating to the srvcp. exe trojan we came across a paper by Joe Abrams, in which he analyzed several code sections from one of the variants of this trojan. Joe pointed out a number of strings embedded in the trojan’s executable that were encrypted with an XOR-based algorithm, and described a way to decrypt them.
JA1 Even though most of the strings mentioned in the paper were absent from our copy of the executable, Joe decrypted one of the strings to have a clear text value of “ gus. ini “. Additionally, one of the deciphered values was “ joeblow “, which suggested that Joe’s version of the trojan was similar to the one reported by Pete Schmitt in the posting discussed in the Background Information of this document.
To understand the decryption algorithm so that we could decipher strings embedded in our copy of srvcp. exe, we loaded the executable into the IDA Pro disassembler. (The reader may wish to refer to the program’s assembly code by looking at our Adobe Acrobat print-out of the disassembled program. ) Following Joe’s analysis, we searched for the string “ nhl*pwf “, which according to him was the encrypted value of “ gus. ini “. This brought us to a section of code presented in Figure 3-12 below.
In this section the program repeatedly pushes to the stack a string that looks encrypted and calls the same routine, which suggests that “ sub_4012C6 ” might be a decryption routine. Joe described this process as well, although his data offsets did not match ours, probably because of subtle differences in versions of the srvcp. exe executable. By following Joe’s analysis of the decryption process, and by looking through its assembly code in IDA Pro, we were able to create a Perl-based routine that mimicked its counterpart in the trojan’s code. The assembly routine was labeled in IDA Pro as “ sub_4012C6 ” and started at the “ text:004012C6 ” offset. Our Perl routine to decrypt embedded strings is presented in Figure 3-13 below.
The routine obtains the length of the encrypted string, and then iterates through it backwards by XOR’ing the ordinal value of each character with its position from the right of the encrypted string. One of the ways to ensure that our implementation of the routine works properly was to decrypt the “ nhl*pwf ” string present in ours as well as Joe’s version of the executable, and make sure that the resulted value is “ gus.
ini “. Our Perl routine was invoked using the format of “ &decryptEmbeddedString($encryptedString) ” and returned the deciphered string. One of the ways to obtain plain-text versions of embedded strings was to call our Perl routine on each string that the program passed through its “ sub_4012C6 ” routine. Additionally, to ensure that we have not missed any encrypted strings, we parsed srvcp. exe using the UNIX-based strings program, and used a Perl script to automatically attempt deciphering each string. We then looked through the resulted list of strings to manually single out those that seemed to be English-based. The combination of both approaches resulted in decrypted strings presented in Figure 3-14 below.