Ramen Internet Worm Analysis
Max Vision <vision@whitehats.com> Abstract Ramen is an Internet worm that targets Redhat Linux 6.2 and Redhat Linux 7.0 servers, and propagates by: scanning for vulnerabilities present in the default configuration, exploiting the vulnerable services, then copying itself to the newly compromised servers. Ramen will overwrite all index.html files on local and mounted filesystems and will send an email to a remote email address revealing that the target system has been compromised (to whoever can access the email account). However, this has limited use since the worm closes the remote vulnerabilities that it used to compromise the system and does not appear to leave a direct backdoor into the system. The worm also removes the tcpwrappers access control list, but this does not yield direct remote access to the attacker. Contents
Thanks and Credits Credit is due to Mihai Moldovanu and Daniel Martin for their initial descriptions and capture of the ramen worm in the wild. Daniel was also kind enough to forward me a copy of the worm for my own analysis. Some of this present analysis may be duplicate work, but was necessary for me to completely and accurately document the function of this worm. Thanks also to Vacuum and Dragos for sending their copies, which I confirmed to be identical strains of the worm. Special thanks to Lance Spitzner for early feedback that made this analysis much more readable. Also, this analysis would not have been completed as quickly nor as gracefully if not for the excellent engineering talents behind several software projects, including but not limited to VMware, Ethereal, and Snort.
Ramen History and Composition Ramen.tgz
is a UNIX worm written by (an) unknown author(s), who seems to have collected
a patchwork of exploit scripts and wrapped them around a modified version
of the Synscan vulnerability scanner. The worm package is copied from system
to system in an tgz (tar and gzip) archive bundle. The following files
are found in the ramen.tgz
archive:
Security patches have been available from Redhat to address each of the remote exploits employed by the worm since October 2000. Each of the remote exploits have been widely published in public forums and web sites. Despite the availability of patches and widespread exploitation of these vulnerable services, a very large number of Redhat 6.2 and Redhat 7.0 servers remain deployed in their default configurations. Redhat released a second edition of Redhat 7.0 called respin that included a fixed version of LPRng, so most of the new installations since October have been resistant to these exploits by default. Another interesting aspect of the worm package is that the author left unexplained or inefficient code in place. For example, the wu-ftpd exploit used in this worm does not work against a default install of Redhat 6.2. Either the worm author misconfigured the exploit, or he/she used the "script kiddie" crippled version. Also two copies of the exploit are included for Redhat 6.2, but the file wu62 is not referenced or used anywhere by the worm. In the bd62.sh file the worm tries to secure the system by killing rpc.statd, but also tries to kill rpc.rstatd, a process name that does not exist. start.sh creates the files .w and .l but then start62.sh or start7.sh just delete and then recreate them immediately afterward. start62.sh and start7.sh were identical, and could have been merged into start.sh. Much of the functionality of the worm could have been greatly optimized, and there was no apparent attempt at stealth whatsoever. Another possible clue as the author of the worm is that the worm sends emails to gb31337@yahoo.com and gb31337@hotmail.com. This is remarkably similar to the Millennium worm which sent email to trax31337@hotmail.com. Mihai Moldovanu found an encrypted string in each of the worm executables that may be a password, it is "bl3h". So far I've been unable to trigger it or spend enough time to reverse engineer the software to see where it's being used.
Ramen Infection/Propagation Cycle The ramen worm has a simple propagation mechanism and will continue spreading until the processes are killed or the machine is rebooted. Upon reboot, the worm will launch again and attack more systems, however if your /tmp is cleared on reboot then the /tmp/ramen.tgz will have been deleted and the worm will no longer propagate (yet it will continue to scan and compromise hosts). The output of the scanner is diverted into separate log files for Redhat 6.2 targets versus Redhat 7.0 targets. In my lab environment I set up 192.168.0.23 as a host infected with the worm, and 10.0.0.23 as a potential target. Both servers were Redhat Linux 6.2 in the default server configuration. I prepped the 192.168.0.23 host appropriately to simulate infection. To get the worm to run I had to setup a bogus DNS server to support required resolver calls (synscan won't send a "finish" packet to www.microsoft.de unless it can resolve to an IP. Also wu-ftpd won't give a banner unless it can resolve the connecting IP. /etc/hosts is not good enough for the latter.) There were other similar problems and solutions but nothing of consequence to the propagation method of the worm. For all intents and purposes this was a live attack. Before we get into the details, here are links to the entire capture
in case you want to follow along. You can use Snort, Ethereal, or another
protocol analyzer to read the libpcap binary:
The worm starts its life cycle when the ramen.tgz package is extracted
to the /usr/src/.poop
directory, and the ./start.sh
script is run. Keep this in mind, as we will come full-circle back to this
point on the target host, where the same condition will be met and the
worm will continue its life. So this also describes the starting environment
I created for the worm on 192.168.0.23.
start.sh is a shell script that prepares the local system to act as an attacker, as well as several functions.
"Hackers looooooooooooooooove noodles" and a picture of a package of Ramen noodles. this does not seem to be benefit the attacker, and is perhaps the most senseless act committed by the worm. start62.sh is a small shell script that launches the three attack processes, scan.sh, hackl.sh, and hackw.sh. The scan.sh script picks a random class b to scan, then launches a modified Synscan against those addresses. The hackl.sh and hackw.sh scripts basically watch the output files generated by Synscan and act against any IP addresses that are dropped in the log files. The first network activity caused by the worm is the Synscan probe of
the random class b address space. In my lab setup I crippled the randb
program to always return 10.0.0. I chose to use the 10.0.0.0/24 class c
space only to reduce clutter in the logs - the logistics are the same.
Synscan sent SYN+FIN tcp packets to each address in the 10.0.0 range, using
the source and destination port 21. The target machine running a Redhat
Linux 6.2 default server install was at address 10.0.0.23. A packet trace
of this successful probe follows:
The full packet trace for the Synscan ftp port scan of the target network:
breakout-synscan.txt
Synscan finds the 10.0.0.23 target system responsive to its probe. Next
Synscan connects to the system to grab the FTP banner and determine if
the system is a Redhat 6.2 or 7.0 server. This happens in parallel with
the port sweep above. The following is a printable session breakout of
the FTP banner grab.
The packet traces for the ftp banner grab: breakout-ftpbanner.txt
This banner grab retrieves a keyword that the modified Synscan software
is looing for indication that it is the default wu-ftp 2.6.0(1) provided
with Redhat 6.2 (by default). It is probably keying off of the compiled
datestamp "Mon Feb 28". Synscan adds the IP to the Redhat 6.2 file, called
".w". The script hackw.sh
has been tailing this file waiting for an IP to attack, now it has a target,
so it springs into action and launches the wu-ftp and statdx exploits against
the target.
The packet traces for this unsuccessful ftp attack: breakout-ftpexploit-failed.txt
The attacker didn't configure the wu-ftp exploit correctly, as it fails to compromise the Redhat 6.2 (zoot) server. The hackw.sh script tries the rpc.statd strings format exploit right after the wu-ftp attack. This exploit is successfull and executes portbinding shellcode that causes a suid root shell to listen at port 39168 on the target. The packet traces for the successful rpc.statd probe and exploit: breakout-statd-exploit.txt
At about this time Synscan is finished up scanning the 10.0.0.0/24 range
and it uses a unique method of communicating this fact to the parent process
- it sends a probe to www.microsoft.de from port 31337 to port 80. Note
that I added "10.9.9.9 www.microsoft.de" to the /etc/hosts
file on the target since my testing was on a private network that could
not access the public internet. Without this tweak, Synscan would hang
on the dns lookup (Trivia: it actually does the lookup before it scans
for some reason).
libpcap binary format: breakout-microsofthello.gz The rpc.statd exploit created a backdoor on the victim at port 39168.
The following printable session shows the commands sent to the target,
which effectively pull the worm across from the attacker system (the asp
webserver runs at port 27374), launches the worm on the target host, and
sends a silly email to email accounts at hotmail.com and yahoo.com.
The packet traces for the backdoor command session: breakout-commandsviaexploit.txt
Note that although an email is "sent" here, I don't have a packet trace because sendmail deferred the email with the sensible warning "no route to host". I recommend against trying to sniff all of your email just to watch for the username "gb31337@" in an outgoing email - there are so many better ways to detect this worm that it's really a waste of CPU on your IDS. The last transaction that we see over the network is the new victim
connecting back to the attacker at port 27374 to download their copy of
the worm. This port is set by the inetd or xinetd configuration in the
worm scripts. They currently use the servicename "asp", which in Redhat
6.2 /etc/services correlates to port 27374.
The packet traces for the ramen.tgz retrieval from asp webserver: breakout-getworm-session.txt
The ramen.tgz worm package is extracted and run on the remote host, and the life cycle begins anew (see diagram).
Prevention The ramen worm finds target hosts by connecting to the ftp server and grabbing the banner text. So by changing the ftp banner, one can effectively render a system immune to this strain of the worm. A more permanent and reasonable solution is to upgrade all system daemons that contain remote vulnerabilities. Ironically, being infected by the worm once should effectively immunize the server, since the worm deletes or disables the same vulnerable services that it exploits. Redhat lists the following errata as available to patch the affected Redhat Linux servers. Commands to update and effectively close these vulnerabilities on Redhat
Linux 6.2 server:
Commands to update and effectively close these vulnerabilities on Redhat
Linux 7.0 server:
Detection (local host) The following logs are generated on the target host after the Ramen
worm attacks. Note the *time warp* that occurs for the ftpd log entries
- eight hours into the future. I don't know what causes this yet, but it's
noteworthy for folks interested in forensics! Timestamps of interested
are highlighted in bold.
The following filesystem irregularities are attributable to the Ramen worm.
The following processes appear on a Redhat Linux system that is infected
with the Ramen worm.
The following arachNIDS rules can be used in the Snort IDS to detect this worm on your network. Synscan probes are already detected using the arachNIDS ruleset: http://whitehats.com/info/IDS441
The wu-ftp exploit attempt can now be detected using arachNIDS rule:
http://whitehats.com/info/IDS458
The rpc.statd strings format exploit was already detected using the
arachNIDS ruleset: http://whitehats.com/info/IDS442
The LPRng exploit can be detected using the arachNIDS ruleset: http://whitehats.com/info/IDS457
Synscan's unique www.microsoft.de message can be detected using arachNIDS
rule: http://whitehats.com/info/IDS459
The asp webserver used by the Ramen worm can be detected by arachNIDS
rule: http://whitehats.com/info/IDS460
and http://whitehats.com/info/IDS461
Incident Recovery Once your computer has been compromised by the ramen worm, you will need to clean up several trouble spots to restore the system.
Incident Reporting It is very likely that the source address that is attacking your network is another victim in the propagation of the worm. Therefore, it would be much better to report the information to your CERT, and let them do their job of coordinating the attack trend information, versus trying to contact the owner of the machine that attacked you. This is a judgment call that you or your corporate security policy may dictate, but please remain calm and courteous when dealing with other admin involved in an attack. They may not yet be aware that their system was compromised. If you were vulnerable, then you can thank the worm author (if he/she is found) for closing severe remote root vulnerabilities in your network. You may also throttle him/her for overwriting your index.html files, but that's your call. If you were not vulnerable and were just probed - then stop complaining and get back to work. No, really, probes are harmless - log it and move on, there are more important things in life.
References "Ramen Worm Analysis" by Mihai Moldovanu, http://tfm.profm.ro/index.html "Ramen Worm" writeup by Daniel Martin, http://members.home.net/dtmartin24/ramen_worm.txt.gz "Synscan" vulnerability scanner by Psychoid, http://www.psychoid.lam3rz.de/synscan.html "Multiple Vendor LPRng User-Supplied Format String Vulnerability", http://www.securityfocus.com/bid/1712
"Wu-Ftpd Remote Format String Stack Overwrite Vulnerability", http://www.securityfocus.com/bid/1387
"Multiple Linux Vendor rpc.statd Remote Format String Vulnerability",
http://www.securityfocus.com/bid/1480
"Incidents Mailing List", http://www.securityfocus.com/templates/archive.pike?list=75 "Redhat Errata", http://www.redhat.com/support/errata/ Local links, provided for educational use only:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||