home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / n_z / phun2.002 < prev    next >
Encoding:
Text File  |  2003-06-11  |  16.5 KB  |  320 lines

  1. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. =               Volume 1 , P/HUN Issue #2 , Phile #2 of 9                     =
  3. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  4.  
  5.                      A REPORT ON THE INTERNET WORM
  6.  
  7.                                Bob Page
  8.                           University of Lowell
  9.                       Computer Science Department
  10.  
  11.                             November 7, 1988
  12.  
  13.      [Because of the many misquotes the media have been giving,
  14.      this report is Copyright (c) Bob Page, all rights reserved.
  15.      Permission is granted to republish this ONLY if you republish
  16.      it in its entirety.]
  17.  
  18. Here's the scoop on the "Internet Worm".  Actually it's not a virus -
  19. a virus is a piece of code that adds itself to other programs,
  20. including operating systems.  It cannot run independently, but rather
  21. requires that its "host" program be run to activate it.  As such, it
  22. has a clear analog to biologic viruses -- those viruses are not
  23. considered live, but they invade host cells and take them over, making
  24. them produce new viruses.
  25.  
  26. A worm is a program that can run by itself and can propagate a fully
  27. working version of itself to other machines.  As such, what was loosed
  28. on the Internet was clearly a worm.
  29.  
  30. This data was collected through an emergency mailing list set up by
  31. Gene Spafford at Purdue University, for administrators of major
  32. Internet sites - some of the text is included verbatim from that list.
  33. Mail was heavy since the formation of the list; it continues to be on
  34. Monday afternoon - I get at least 2-3 messages every hour.  It's
  35. possible that some of this information is incomplete, but I thought
  36. you'd like to know what I know so far.
  37.  
  38. The basic object of the worm is to get a shell on another machine so
  39. it can reproduce further.  There are three ways it attacks: sendmail,
  40. fingerd, and rsh/rexec.
  41.  
  42.  
  43. THE SENDMAIL ATTACK:
  44.  
  45. In the sendmail attack, the worm opens a TCP connection to another
  46. machine's sendmail (the SMTP port), invokes debug mode, and sends a
  47. RCPT TO that requests its data be piped through a shell.  That data, a
  48. shell script (first-stage bootstrap) creates a temporary second-stage
  49. bootstrap file called x$$,l1.c (where '$$' is the current process ID).
  50. This is a small (40-line) C program.
  51.  
  52. The first-stage bootstrap compiles this program with the local cc and
  53. executes it with arguments giving the Internet hostid/socket/password
  54. of where it just came from.  The second-stage bootstrap (the compiled
  55. C program) sucks over two object files, x$$,vax.o and x$$,sun3.o from
  56. the attacking host.  It has an array for 20 file names (presumably for
  57. 20 different machines), but only two (vax and sun) were compiled in to
  58. this code.  It then figures out whether it's running under BSD or
  59. SunOS and links the appropriate file against the C library to produce
  60. an executable program called /usr/tmp/sh - so it looks like the Bourne
  61. shell to anyone who looked there.
  62.  
  63.  
  64. THE FINGERD ATTACK:
  65.  
  66. In the fingerd attack, it tries to infiltrate systems via a bug in
  67. fingerd, the finger daemon.  Apparently this is where most of its
  68. success was (not in sendmail, as was originally reported).  When
  69. fingerd is connected to, it reads its arguments from a pipe, but
  70. doesn't limit how much it reads.  If it reads more than the internal
  71. 512-byte buffer allowed, it writes past the end of its stack.  After
  72. the stack is a command to be executed ("/usr/ucb/finger") that
  73. actually does the work.  On a VAX, the worm knew how much further from
  74. the stack it had to clobber to get to this command, which it replaced
  75. with the command "/bin/sh" (the bourne shell).  So instead of the
  76. finger command being executed, a shell was started with no arguments.
  77. Since this is run in the context of the finger daemon, stdin and
  78. stdout are connected to the network socket, and all the files were
  79. sucked over just like the shell that sendmail provided.
  80.  
  81.  
  82. THE RSH/REXEC ATTACK:
  83.  
  84. The third way it tried to get into systems was via the .rhosts and
  85. /etc/hosts.equiv files to determine 'trusted' hosts where it might be
  86. able to migrate to.  To use the .rhosts feature, it needed to actually
  87. get into people's accounts - since the worm was not running as root
  88. (it was running as daemon) it had to figure out people's passwords.
  89. To do this, it went through the /etc/passwd file, trying to guess
  90. passwords.  It tried combinations of: the username, the last, first,
  91. last+first, nick names (from the GECOS field), and a list of special
  92. "popular" passwords:
  93.  
  94. aaa          cornelius        guntis      noxious    simon
  95. academia      couscous        hacker      nutrition    simple
  96. aerobics      creation        hamlet      nyquist    singer
  97. airplane      creosote        handily      oceanography    single
  98. albany          cretin        happening      ocelot    smile
  99. albatross     daemon        harmony      olivetti    smiles
  100. albert          dancer        harold      olivia    smooch
  101. alex          daniel        harvey      oracle    smother
  102. alexander     danny        hebrides      orca        snatch
  103. algebra          dave        heinlein      orwell    snoopy
  104. aliases          december        hello      osiris    soap
  105. alphabet      defoe        help      outlaw    socrates
  106. ama          deluge        herbert      oxford    sossina
  107. amorphous     desperate        hiawatha      pacific    sparrows
  108. analog          develop        hibernia      painless    spit
  109. anchor          dieter        honey      pakistan    spring
  110. andromache    digital        horse      pam        springer
  111. animals          discovery        horus      papers    squires
  112. answer          disney        hutchins      password    strangle
  113. anthropogenic dog        imbroglio      patricia    stratford
  114. anvils          drought        imperial      penguin    stuttgart
  115. anything      duncan        include      peoria    subway
  116. aria          eager        ingres      percolate    success
  117. ariadne          easier        inna      persimmon    summer
  118. arrow          edges        innocuous      persona    super
  119. arthur          edinburgh        irishman      pete        superstage
  120. athena          edwin        isis      peter        support
  121. atmosphere    edwina        japan      philip    supported
  122. aztecs          egghead        jessica      phoenix    surfer
  123. azure          eiderdown        jester      pierre    suzanne
  124. bacchus          eileen        jixian      pizza        swearer
  125. bailey          einstein        johnny      plover    symmetry
  126. banana          elephant        joseph      plymouth    tangerine
  127. bananas          elizabeth        joshua      polynomial    tape
  128. bandit          ellen        judith      pondering    target
  129. banks          emerald        juggle      pork        tarragon
  130. barber          engine        julia      poster    taylor
  131. baritone      engineer        kathleen      praise    telephone
  132. bass          enterprise    kermit      precious    temptation
  133. bassoon          enzyme        kernel      prelude    thailand
  134. batman          ersatz        kirkland      prince    tiger
  135. beater          establish        knight      princeton    toggle
  136. beauty          estate        ladle      protect    tomato
  137. beethoven     euclid        lambda      protozoa    topography
  138. beloved          evelyn        lamination      pumpkin    tortoise
  139. benz          extension        larkin      puneet    toyota
  140. beowulf          fairway        larry      puppet    trails
  141. berkeley      felicia        lazarus      rabbit    trivial
  142. berliner      fender        lebesgue      rachmaninoff    trombone
  143. beryl          fermat        lee          rainbow    tubas
  144. beverly          fidelity        leland      raindrop    tuttle
  145. bicameral     finite        leroy      raleigh    umesh
  146. bob          fishers        lewis      random    unhappy
  147. brenda          flakes        light      rascal    unicorn
  148. brian          float        lisa      really    unknown
  149. bridget          flower        louis      rebecca    urchin
  150. broadway      flowers        lynne      remote    utility
  151. bumbling      foolproof        macintosh      rick        vasant
  152. burgess          football        mack      ripple    vertigo
  153. campanile     foresight        maggot      robotics    vicky
  154. cantor          format        magic      rochester    village
  155. cardinal      forsythe        malcolm      rolex        virginia
  156. carmen          fourier        mark      romano    warren
  157. carolina      fred        markus      ronald    water
  158. caroline      friend        marty      rosebud    weenie
  159. cascades      frighten        marvin      rosemary    whatnot
  160. castle          fun        master      roses        whiting
  161. cat          fungible        maurice      ruben        whitney
  162. cayuga          gabriel        mellon      rules        will
  163. celtics          gardner        merlin      ruth        william
  164. cerulean      garfield        mets      sal        williamsburg
  165. change          gauss        michael      saxon        willie
  166. charles          george        michelle      scamper    winston
  167. charming      gertrude        mike      scheme    wisconsin
  168. charon          ginger        minimum      scott        wizard
  169. chester          glacier        minsky      scotty    wombat
  170. cigar          gnu        moguls      secret    woodwind
  171. classic          golfer        moose      sensor    wormwood
  172. clusters      gorgeous        morley      serenity    yaco
  173. coffee          gorges        mozart      sharks    yang
  174. coke          gosling        nancy      sharon    yellowstone
  175. collins          gouge        napoleon      sheffield    yosemite
  176. commrades     graham        nepenthe      sheldon    zap
  177. computer      gryphon        ness      shiva        zimmerman
  178. condo          guest        network      shivers
  179. cookie          guitar        newton      shuttle
  180. cooper          gumption        next      signature
  181.  
  182. [I wouldn't have picked some of these as "popular" passwords, but
  183. then again, I'm not a worm writer.  What do I know?]
  184.  
  185. When everything else fails, it opens /usr/dict/words and tries every
  186. word in the dictionary.  It is pretty successful in finding passwords,
  187. as most people don't choose them very well.  Once it gets into
  188. someone's account, it looks for a .rhosts file and does an 'rsh'
  189. and/or 'rexec' to another host, it sucks over the necessary files into
  190. /usr/tmp and runs /usr/tmp/sh to start all over again.
  191.  
  192.  
  193. Between these three methods of attack (sendmail, fingerd, .rhosts)
  194. it was able to spread very quickly.
  195.  
  196.  
  197. THE WORM ITSELF:
  198.  
  199. The 'sh' program is the actual worm.  When it starts up it clobbers
  200. its argv array so a 'ps' will not show its name.  It opens all its
  201. necessary files, then unlinks (deletes) them so they can't be found
  202. (since it has them open, however, it can still access the contents).
  203. It then tries to infect as many other hosts as possible - when it
  204. sucessfully connects to one host, it forks a child to continue the
  205. infection while the parent keeps on trying new hosts.
  206.  
  207. One of the things it does before it attacks a host is connect to the
  208. telnet port and immediately close it.  Thus, "telnetd: ttloop: peer
  209. died" in /usr/adm/messages means the worm attempted an attack.
  210.  
  211. The worm's role in life is to reproduce - nothing more.  To do that it
  212. needs to find other hosts.  It does a 'netstat -r -n' to find local
  213. routes to other hosts & networks, looks in /etc/hosts, and uses the
  214. yellow pages distributed hosts file if it's available.  Any time it
  215. finds a host, it tries to infect it through one of the three methods,
  216. see above.  Once it finds a local network (like 129.63.nn.nn for
  217. ulowell) it sequentially tries every address in that range.
  218.  
  219. If the system crashes or is rebooted, most system boot procedures
  220. clear /tmp and /usr/tmp as a matter of course, erasing any evidence.
  221. However, sendmail log files show mail coming in from user /dev/null
  222. for user /bin/sed, which is a tipoff that the worm entered.
  223.  
  224. Each time the worm is started, there is a 1/15 chance (it calls
  225. random()) that it sends a single byte to ernie.berkeley.edu on some
  226. magic port, apparently to act as some kind of monitoring mechanism.
  227.  
  228.  
  229. THE CRACKDOWN:
  230.  
  231. Three main 'swat' teams from Berkeley, MIT and Purdue found copies of
  232. the VAX code (the .o files had all the symbols intact with somewhat
  233. meaningful names) and disassembled it into about 3000 lines of C.  The
  234. BSD development team poked fun at the code, even going so far to point
  235. out bugs in the code and supplying source patches for it!  They have
  236. not released the actual source code, however, and refuse to do so.
  237. That could change - there are a number of people who want to see the
  238. code.
  239.  
  240. Portions of the code appear incomplete, as if the program development
  241. was not yet finished.  For example, it knows the offset needed to
  242. break the BSD fingerd, but doesn't know the correct offset for Sun's
  243. fingerd (which causes it to dump core); it also doesn't erase its
  244. tracks as cleverly as it might; and so on.
  245.  
  246. The worm uses a variable called 'pleasequit' but doesn't correctly
  247. initialize it, so some folks added a module called _worm.o to the C
  248. library, which is produced from:
  249.         int pleasequit = -1;
  250. the fact that this value is set to -1 will cause it to exit after one
  251. iteration.
  252.  
  253. The close scrutiny of the code also turned up comments on the
  254. programmer's style.  Verbatim from someone at MIT:
  255.     From disassembling the code, it looks like the programmer
  256.     is really anally retentive about checking return codes,
  257.     and, in addition, prefers to use array indexing instead of
  258.     pointers to walk through arrays.
  259.  
  260. Anyone who looks at the binary will not see any embedded strings -
  261. they are XOR'ed with 81 (hex).  That's how the shell commands are
  262. imbedded.  The "obvious" passwords are stored with their high bit set.
  263.  
  264. Although it spreads very fast, it is somewhat slowed down by the fact
  265. that it drives the load average up on the machine - this is due to all
  266. the encryptions going on, and the large number of incoming worms from
  267. other machines.
  268.  
  269. [Initially, the fastest defense against the worm is is to create a
  270. directory called /usr/tmp/sh.  The script that creates /usr/tmp/sh
  271. from one of the .o files checks to see if /usr/tmp/sh exists, but not
  272. to see if it's a directory.  This fix is known as 'the condom'.]
  273.  
  274.  
  275. NOW WHAT?
  276.  
  277. None of the ULowell machines were hit by the worm.  When BBN staffers
  278. found their systems infected, they cut themselves off from all other
  279. hosts.  Since our connection to the Internet is through BBN, we were
  280. cut off as well.  Before we were cut off, I received mail about the
  281. sendmail problem and installed a patch to disable the feature the worm
  282. uses to get in through sendmail.  I had made local modifications to
  283. fingerd which changed the offsets, so any attempt to scribble over the
  284. stack would probably have ended up in a core dump.
  285.  
  286. Most Internet systems running 4.3BSD or SunOS have installed the
  287. necessary patches to close the holes and have rejoined the Internet.
  288. As you would expect, there is a renewed interest in system/network
  289. security, finding and plugging holes, and speculation over what
  290. will happen to the worm's creator.
  291.  
  292. If you haven't read or watched the news, various log files have named
  293. the responsible person as Robert Morris Jr., a 23-year old doctoral
  294. student at Cornell.  His father is head of the National Computer
  295. Security Center, the NSA's public effort in computer security, and has
  296. lectured widely on security aspects of UNIX.
  297.  
  298. Associates of the student claim the worm was a 'mistake' - that he
  299. intended to unleash it but it was not supposed to move so quickly or
  300. spread so much.  His goal (from what I understand) was to have a
  301. program 'live' within the Internet.  If the reports that he intended
  302. it to spread slowly are true, then it's possible that the bytes sent
  303. to ernie.berkeley.edu were intended to monitor the spread of the
  304. worm.  Some news reports mentioned that he panicked when, via some
  305. "monitoring mechanism" he saw how fast it had propagated.
  306.  
  307. A source inside DEC reports that although the worm didn't make much
  308. progress there, it was sighted on several machines that wouldn't be
  309. on its normal propagation path, i.e. not gateways and not on the same
  310. subnet.  These machines are not reachable from the outside.  Morris
  311. was a summer intern at DEC in '87.  He might have included names or
  312. addresses he remembered as targets for infesting hidden internal
  313. networks.  Most of the DEC machines in question belong to the group he
  314. worked in.
  315.  
  316. The final word has not been written - I don't think the FBI have even
  317. met with this guy yet.  It will be interesting to see what happens.
  318.  
  319.  
  320.