home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / hir / hir8 / hir8-9.txt < prev    next >
Encoding:
Text File  |  2002-05-27  |  8.1 KB  |  171 lines

  1.                                  HiR 8
  2. -]]])))}}}>>> Packet Sniffing Techniques For The Novice User <<<{{{((([[[-
  3.                                  by Axon
  4.  
  5. Ahh, the wonderful world of packet sniffing.  You may or may not have done
  6. this before...
  7.  
  8. "Sniffing" is the process of putting your computer's network card into
  9. what's called "promiscuous mode".  It will read all packets that it sees
  10. (whereas normally it only reads the packets that have its address on it).
  11. After the card is placed in this mode, a sniffer will track packets
  12. (usually parsing the useful data out of the packet and writing it to a log
  13. file onto the hard disk).  This is a really good way of doing a few things
  14. on a network:
  15.  
  16.     o Gathering traffic information, looking for lan stations that are
  17.       abusing bandwidth.
  18.  
  19.     o Actually looking at the data inside the packets to see what
  20.       files people are downloading with FTP, watching telnet sessions,
  21.       and even watching their usernames and passwords.
  22.  
  23.     o Getting a general Idea of where most of the packets are coming
  24.       from and going to, as a troubleshooting measure.
  25.  
  26. There are sniffing programs for almost every platform.  My favorite
  27. platform is linux, as it is already my Operating System of choice, and  
  28. there are quite a few really easy to use sniffers for it.  These include:
  29. tcpdump, sniffit, iptraf, and linsniffer.  Those are what I use the most.
  30. My favorite floppy-linux distribution, Trinux, comes with sniffit, iptraf,
  31. and linsniffer.  Almost every "big" linux distro (Red Hat, Debian,
  32. Caldera, etc) comes with tcpdump, although you might have to select a
  33. special option to have it installed automatically.
  34.  
  35. Tcpdump is probably the hardest of the three to learn how to use.  It
  36. mostly dumps raw tcp packets out to standard output (or wherever you
  37. redirect it to).  It has other options, too, but overall, it's difficult
  38. to use for the beginner.  I'll focus more on the other two.
  39.  
  40. Linsniffer is quite possiby the most evil of the sniffers I've mentioned.
  41. All it does is get passwords.  It looks for http passwords, telnet
  42. passwords, ftp passwords, and mail passwords.  It does a pretty good job,
  43. but really lacks an "ethical" use.  You can get linsniffer (or any of
  44. these sniffers) wherever you can find linux software (places like sunsite,
  45. which is now metalab.unc.edu).  All you do is run "linsniffer" as root.
  46. It will not display any output. Everything it finds will be placed in a
  47. file called "tcp.log" in the directory you were in when you started
  48. linsniffer.
  49.  
  50. Sniffit is extremely cute.  It's harder to find passwords with it, but if
  51. your goal has nothing to do with you finding passwords, and more to do
  52. with watching who is connected to what, and maybe even watching the actual
  53. connection, this is for you.  With Sniffit, I have many times been
  54. successful in watching the exact telnet screen of people that are on my
  55. segment.  You can redirect the sniffed output to another virual console,
  56. and that console becomes the telnet screen of the person whom you are
  57. sniffing.  You see what they type, what they get back, you watch them read
  58. their e-mail with pine, as if their ghost was sitting there using your
  59. screen.
  60.  
  61. Iptraf isn't really a "sniffer" by industry terms, but it still uses
  62. promiscuous mode to operate, Therefore I call it a "sniffer".  Iptraf will
  63. break down the traffic stream into chunks for you, so you can see exactly
  64. what kind of packets are being exchanged, how big they are, and where they
  65. are coming from and going to.  This proghram is not good for looking at
  66. the actual data inside the packet, but it's great for finding out who is
  67. hogging the bandwidth, and what they're hogging it with.
  68.  
  69. As far as snifgfing on other platforms... For Windows 95 and 98 There is
  70. also a plugin for the ever-famous back-orifice program that does
  71. sniffing, called "Butt Sniffer".  There is also a non-plugin version that
  72. just runs in an MS-Dos window under Windows 95/98.  This is probably the
  73. best Windows 9x sniffer I've seen, and it's worth looking into.  It's
  74. available through www.cultdeadcow.com under the backorifice page
  75. somewhere.  Shoutouts to the author, Mudge (who kicked ass at DefCon) =]
  76.  
  77. ------------------------------------------------------------------------------
  78.  
  79. So, if it's so easy to just watch what's going on on the local network,
  80. there must be loads of people doing it, right?  Well, the paranoid would
  81. say so, but in actuality, there isn't probably a whole lot of it going on.
  82. I'm not saying that there isn't ANY.  So if there's even the possibility
  83. that it's there, how would one stay protected from the evils of
  84. sniffing?
  85.  
  86. Well, the apostols (a spanish hacking group, if memory serves correctly)
  87. has a few really good products.  (One being QueSO, a remote tcp/ip
  88. fingerprinter for detecting what OS is being run on a remote machine),
  89. but the one we focus on here is "NEtwork Promiscuous Ethernet Detector"
  90. (or "neped").  It only runs on UNIX/Linux (that I know of.  It's not
  91. directly compileable on windows, but I'm not much of a programmer.  It
  92. might be easy to do).  I Wrote a small shell script that uses neped as a
  93. core to take action when promiscuous mode is detected.
  94.  
  95. sniffdetect.sh is configureable and can run a shell script or a program
  96. once as soon as sniffing is detected, and will run another program or
  97. script as soon as it sees the sniffing has stopped.  It can be used to
  98. stop services on your system, e-mail an administrator, page someone, or
  99. even to shut down the machine (although I don't know why you would want
  100. to do such a thing).  I set it up to blast the IP and MAC address of the
  101. sniffing machine to my pager, and to tell me that sniffing has ceased when
  102. it stops detecting the runnuing sniffers (I wrote some paging software
  103. that sends out alpha pages to me from the command line to do this).  In
  104. theory, It's very possible to make something that will launch a
  105. counter-attack/Denial of Service against the sniffing machine, but I'm not
  106. really a believer in that method.  Here's my shell script.
  107.  
  108. sniffdetect.sh:
  109. -------------begin-------------------------------------------------------
  110. #!/bin/sh
  111. ## Cheap-ass promiscuous mode watcher/action-taker
  112. ## Written by axon 
  113. ##
  114. ## Requires "NEtwork Promiscuous Ethernet Detector" (neped.c)
  115. ## ftp://apostols.org/AposTools/snapshots/neped/neped.c
  116. ##
  117. ## This program must be run as root, or neped must be set-uid root.
  118. ##
  119. #########################################################################
  120. ##
  121. ## Config Options!
  122. ##
  123. ######
  124.                         # Command or shell script that's run when promisc.
  125. promisccmd="promisc.sh" # mode card is found.  This might shut down a
  126.                         # service, or e-mail an administrator.  Up to you.
  127.                         # (you must write a promisc.sh script or change
  128.                         # this variable)
  129.  
  130.                                 # Command or shell script that's run when
  131. nopromisccmd="nopromisc.sh"     # promisc. mode ceases.  This might page
  132.                                 # an administrator or restart a service.
  133.                                 # (you must write a nopromisc.sh script or
  134.                                 # change this variable)
  135. while true
  136. do
  137. while true
  138. do
  139.                                 # Counts number of lines
  140. neped=`neped eth0 | wc -l`      # that are returned
  141.                                 # by neped.
  142.  
  143. if [ $neped -gt 8 ];then        # This runs the command of your
  144. $promisccmd                     # choice when promisc. mode
  145. break                           # is detected
  146.  
  147. neped eth0|grep "*>" >> promisc.log  # appends output of neped to promisc.log
  148.  
  149. fi
  150. done
  151. while true
  152. do
  153.                                 # Counts number of lines
  154. neped=`neped eth0 | wc -l`      # that are returned
  155.                                 # by neped.
  156.  
  157. if [ $neped = 8 ];then          # This runs the command of your
  158. $nopromisccmd                   # choice when promisc. mode
  159. break                           # ceases
  160. fi
  161. done
  162. done
  163. ----------------end sniffdetect.sh------------------------------------------
  164.  
  165. I hope that this gives you the edge that you need.  This was in no way a
  166. very elaborate "sniffing how-to".  You can go anywhere to get that sort of
  167. information.  This was focused more on how it works, and what tools are
  168. used to do it, and how to protect yourself from the world of packet
  169. sniffers.
  170.  
  171.