You are on page 1of 7

hunt(1) - Linux man page Hunt hunt - Network security auditing tool.

Synopsis hunt [-V] [-v] [-i interface] Description This manual page documents briefly the hunt command. This manual page was writte n for the Debian GNU/Linux distribution because the original program does not ha ve a manual page. Instead, it has documentation in the GNU Info format; see belo w. Read First Please make sure you KNOW what you are doing before using hunt. It is recommende d that you should test how it behaves on some test connections and then use it w isely. Overview Hunt is a program for intruding into a connection, watching it and resetting it. It has several features, which I didn't find in any product like Juggernaut or T-sight that inspired me in my development. I found Juggernaut not flexible enou gh for further development so I started from scratch (see FEATURES and DESIGN OV ERVIEW). Note that hunt is operating on Ethernet and is best used for connection s which can be watched through it. However, it is possible to do something even for hosts on another segments or hosts that are on switched ports. The hunt does n't distinguish between local network connections and connections going to/from Internet. It can handle all connections it sees. Connection hijacking is aimed primarily at the telnet or rlogin traffic but it c an be used for another traffic too. The reset, watching, arp, ... features are c ommon to all connections. Features Connection Management * Setting what connections you are interested in. * Detecting an ongoing connection (not only SYN started). * Normal active hijacking with the detection of the ACK storm. * ARP spoofed/Normal hijacking with the detection of successful ARP spoof. * Synchronization of the true client with the server after hijacking (so that th e connection don't have to be reset). * Resetting connection. * Watching connection. Daemons * Reset daemon for automatic connection resetting. * ARP spoof/relayer daemon fo r ARP spoofing of hosts with the ability to relay all packets from spoofed hosts . * MAC discovery daemon for collecting MAC addresses. * Sniff daemon for loggin g TCP traffic with the ability to search for a particular string. Host Resolving * Deferred host resolving through dedicated DNS helper servers. Packet Engine * Extensible packet engine for watching TCP, UDP, ICMP and ARP traffic. * Collec ting TCP connections with sequence numbers and the ACK storm detection. Misc * Determining which hosts are up. Switched Environment * Hosts on switched ports can be spoofed, sniffed and hijacked too. Command Line Parameters -V Print Version -v Verbose (print pids of created threads) -i interface Listen on this interface. Default is eth0 Technical Explanation Let me explain some technical issues which I use in hunt and which are essential for understanding how it works and what you should expect. The important terms are IP spoofing, ARP spoofing and ACK storm. Even if you are familiar with them, you can get some new information.

IP spoofing You set the packet source address to the IP address of the host you pretend to b e. ARP spoofing You set the packet source hardware address (source MAC address) to the address o f the host you pretend to be. Simple Active Attack against TCP connections - It is a well known type of attack in which you send a packet with spoofed IP addresses and possibly also with spoofed ARP addresses (true MAC addresses of client and server - not fake ones as explained further). In this way, you can force a command to the stream b ut you are likely to receive the ACK storm (as explained further) unless the ori ginal client host of the connection is running Linux. ARP spoofing I use this term also for forcing the remote host to think that the host I want t o be has a different MAC address so the remote host sends replies to that MAC ad dress and the original client host is not able to receive them (but hunt is watc hing carefully and handles all consequences) (Explaining how to force a host on the network to think that the other host has a different MAC I leave as an exerc ise - I encourage you to read the source code). Please note that I use the term ARP spoofing instead of the term ARP forcing or something like that. So don't be confused, if I say ARP spoofing, I mean using some MAC address of a host or jus t some fake MAC address. Note that ARP spoofing (with my meaning to force some M AC) doesn't work on Solaris2.5 because it has expiration timers on ARP entries s o you can't easily force Solaris to drop an ARP entry. The entry usually expires after 20min or less (but you have a chance to force it and hunt supports this m ode). The expiration timers on Solaris are set by: ndd -set /dev/ip ip_ire_flush_interval 60000 /* 1 min */ ndd -set /dev/arp arp_cleanup_interval 60 /* 1 min */ I encourage you to ask your netadmin to set the above values on all Solaris mach ines. The Win95/NT4sp3, Linux2.0, OSF1 V4.0, HP-UX10.20 are not protected in thi s way so you can easily use the described technique on them (actually, they have timers, but they are not operating like in Solaris; in fact, only Solaris is th e exception). Actually, hunt uses this technique such that it wants to force a f ake MAC of the server to the client and a fake MAC of the client to the server. Then both the server and the client are sending packets to that faked MACs (and hunt can of course handle them). However, it is sufficient that only one host ha s a fake MAC of the other host. The ACK storm can't occur in this situation eith er. So you can use this technique even if one end is Solaris and the other isn't . You will just succeed in the other host and that is enough. So the only proble m is when the connection is between two Solaris machines. However, if there is a ny root connection ongoing you can easily push the commands suggested above with out ARP spoofing to the connection and alter the expiration timers of the ARP ca che. ACK Storm The ACK storm is caused by majority of TCP stacks (!!! Linux2.0 is an exception !!!). Let's imagine that you send some data to an ongoing connection to the serv er (as if sent by the client - with expected seq. numbers, ... ). The server res ponds with the acknowledgment of the data you sent but this acknowledgment is re ceived by the original client too. But from the original client point of view, t he server has acknowledged data that doesn't exist on the client. So something s trange occurred and the original client sends the "right" sequence number with A CK to the server. But the TCP rules say that it is required to generate an immed iate acknowledgment when an out-of-order segment is received. This ACK should no t be delayed. So the server sends the acknowledgment of non-existent data to the client again. And the client responses, ... Only if the source host of the conn ection is Linux then the ACK storm doesn't occur. Note that if you use ARP spoof ing (forcing) then the ACK storm can't come because one or both ends will send p ackets with fake MACs and those packets are received by hunt rather than by the other host. Connection Reset

With a single properly constructed packet you can reset the connection (RST flag in TCP header). Of course, you have to know the sequence number but it is not a problem for hunt which is watching all the time. You can reset server, client, or both. When you reset only one end the other end is reset when it tries to sen d data to the first host which will response with RST because of the connection reset on it. Connection sniffing/watching The simplest thing you can do is to silently sit in you chair and watch hunt out put about any connection which you choose from the list. Connection Synchronization Well, that's one of the main features of hunt. If you put some data to the TCP s tream (through simple active attack or ARP spoofing), you desynchronize the stre am from the server/original client point of view. After some work done on that c onnection you can just reset it or you can try to synchronize both original ends again. That is not an easy task. The user on the client is prompted to type som e chars and some chars are sent to the client and server. The main goal of all s tuff is to synchronize the sequence numbers on both client and server again. Switch/Segment traffic rerouting With ARP spoofing you can even force switch so that it will send you the traffic for hosts on another segment/switched port. This is because a switch will think that the MAC belongs to your port. Be careful if your switch has some security policy and MACs have been explicitly set up on a per port basis - but in fact I don't ever see such a configuration on "ordinary" network. ARP-relay daemon Don't be confused. I use this term for hunt daemon which is responsible for inse rting packets to the network (rerouting) of all data it receives from ARP spoofe d hosts. Switched environment Well, the hunt is now capable of watching and hijacking hosts that are on switch ed ports. In common you can't watch the hosts traffic on switched ports but if y ou first ARP spoof them (with ARP spoof daemon menu) you are able to look at the connections that are between that hosts. First you do arp spoof and the hosts w ill send you the traffic and from that time you can list the connections between them, then you can watch and hijack them. It is commonly accepted that the swit ches protect your connections again inside intruders and spoofers. Well, that is still true for carefully setuped switches. The switches that are plugged to the LAN without any port security configuration are useless in the job to protect y our LAN. Design Overview The development model is based on a packet engine (hunt.c) which runs in its own thread and captures packets from the network. The packet engine collects inform ation of TCP connections/starting/termination, sequence numbers, and MAC address es. It collects the MACs and seq. numbers from the server point of view and sepa rate MACs and seq. numbers from the client point of view. So it is prepared for hijacking. This information (seq. num., MAC, Modules can register functions with the packet engine which are then invoked whe n new packets are received. A module function determines if the module is intere sted in a packet or not and can place the packet in a module specific list of pa ckets. A module function can also send some packet to the network if it is desir able to do it very fast. The module (usually in some other thread so it needs to be scheduled to be run) then gets packets from the list and analyzes them. In t his way, you can easily develop modules which perform various activities. Packets to be sent as a response to the network are described by structures so y ou don't have to care about some default fields or checksums. At this time, func tions for TCP, ICMP and ARP traffic are already prepared. (UDP is missing becaus e I don't use it in any module) A separate set of daemons is used for host resolving (DNS). That is because the gethostbyname/gethostbyname_r function is protected by mutex (As far as I know it was so two years ago - I didn't try it now) so you can't run it truly parall el in a multithreaded environment. Therefore, the commonly used workaround is to

fire up some helper daemons through fork which will run gethostbyname. User Environment Well, the user environment isn't graphical but I believe that you will like it. In the title of all menus is some status information about hunt. First, there is an indication with which menu you are working. Second, the number of packets re ceived by hunt is shown. Hunt pre-allocates some buffers for packets; the status of free and allocated buffers is displayed as the third value. The number of fr ee buffers is low for a high loaded network or the ACK storm or if you have poor hardware. In my case, for example, the numbers 63/64 were normally indicated me aning that only one buffer was used, but after the ACK storm, I have something l ike 322/323. Note that the buffers once allocated are not freed. The low number of free buffers can also mean some bug in hunt but I think I carefully debugged all modules to this kind of bug. The last indicator reports which daemons (actua lly threads) are running. They are: R - reset daemon, Y - arp relayer, S - sniff er, M - MAC discoverer. If you switch on the verbose option you get additional i nformation about how many packets were dropped - they were fragments (see the bu gs) or were malformed, and how many packets belong to other protocols than TCP, UDP, ICMP and ARP. In the prompt for user input is indicator that will tell you through '*' char thathunt added new connection(s) to the connection list since l ast connection listening. General interface In all menus the x key works as escape. The network mask is denoted by the ip_ad dress/mask notation where mask is the number of 1's on the left side of the netw ork mask. For example, means everything and means onl y that host. For most modules is used: l) list items a) add item m) modify item d) delete item They will be referred in this text as l) a) m) d) List/Watch/Reset connection You can obtain the list of connections tracked by the hunt packet engine. Which connections are tracked is specified in the options menu. You can interactively watch or reset these connections. You can also perform hijacking on them (next t wo menu items). ARP/Simple hijack ARP/Simple hijack offers you an interactive interface for the insertion of data to the selected connection. You can perform ARP spoofing for both connection end s, for only one end or you can not to do it at all. If you don't do ARP spoofing then you probably receive the ACK storm after typing the first char. When you d o ARP spoofing, it is checked if it succeeds. If not, you are prompted if you wa nt to wait until it succeeds (you can interrupt this waiting through CTRL-C of c ourse). After inserting some data to the connection you type CTRL-] and then you can synchronize or reset the connection. If you choose synchronization, the use r is prompted to type some chars and after he does so the connection will be in the synchronous state. You can interrupt the synchronization process with CTRL-C and then you can reset the connection. Note that CTRL-C is used widely for inte rrupting an ongoing process. The CTRL-] (like telnet) is used for finishing the interactive insertion of data to the connection. The ARP/Simple hijack doesn't a utomatically reset the connection after it detects the ACK storm so you have to do it yourself. Note also that ARP/Simple hijack works with the ARP relayer (as described further) so that other connections are not affected. Normally, if you ARP spoof two servers then the ARP/Simple hijack handles only one selected conne ction between these two hosts but other connections between these two hosts look like they freeze. If you start the ARP relayer, then these other connections ar e handled and rerouted through. So other connections from one spoofed host to th e other are not affected at all. It is recommended to run ARP relayer if you do ARP hijacking of two servers. Note that if you ARP spoof (force) some client MAC to the server then only connections going from the server to that client are af

fected. Other connections from the server to other machines are untouched. Simple hijack Simple hijack allows you to insert a command to the data stream of the connectio n. When you insert the command, hunt waits for it to complete up to a certain ti meout and if the ACK storm doesn't occur, you are prompted for the next command. After that, you can synchronize or reset the connection. Note that you can use the interactive interface to simple hijack when you use ARP/simple hijack withou t ARP spoofing but if you use full interactive interface of ARP/simple hijack wi thout ARP spoofing you are likely to get the ACK storm immediately after typing the first char. So this mode of hijacking is useful when you have to deal with t he ACK storm because it sends your data to the connection in a single packet. Wh en the ACK storm is in progress it is very hard to deliver other packets from hu nt to the server as the network and server are congested. Daemons I call them daemons but they are actually threads. All daemons can be started an d stooped. Don't be surprised when you insert or modify some rule in a daemon an d it does nothing. The daemon is not running - you have to start it. All daemons are by default stopped even though you can alter the configuration. Common comm ands in the daemons menu are: s) start the daemon k) stop the daemon l) list configuration items a) add config. item m) modify config. item d) delete config. item Reset daemon This daemon can be used to perform automatic resets of ongoing connections that hunt can see. You can describe which connections should be terminated by giving src/dst host/mask and src/dst ports. The SYN flag off means that all specified c onnections should be terminated (even ongoing). The SYN flag on means that only newly started connections are reset. So the connections that are in progress are not affected. Don't forget to start the daemon. ARP daemon Here you can do ARP spoofing of hosts. You enter src and dst addresses and desir ed srcMAC. The dst is then forced to think that src has srcMAC. You can use some fake MAC or better MAC of host that is currently down. You just want that the h osts will send you all the data (so you can even look at packets that are on a d ifferent segment or switched port that you will not normally see) The ARP module looks carefully for packets which will break ARP spoofing of hosts and handle t hem but you can even specify the refresh interval for ARP spoofing but it is not necessary to do it. Set the refresh interval only if you are experienced with s ome bad or strange behavior of spoofed hosts. Also there is the possibility to t est the hosts for successful spoof with the ability to force that spoof - it is recommended to test the ARP spoof if something looks like it is wrong or the com puter doesn't send the traffic to the hunt. The force option is handful if the f irst spoofing packets are discarded with switch so if you are running hunt again st hosts on switched ports you can try to run the force mode by example for 10s and then break it with CTRL-C if the spoof continues to fail. The ARP relayer da emon is used to perform ARP relaying of ARP spoofed connections. When you insert some ARP spoof of hosts the ARP spoofing is performed immediately even if the r elayer isn't running!!!. But if the ARP spoofing succeeds, the connections will look like they freeze. For rerouting (not IP routing !) these connections throug h yourhunt you need to start the ARP relayer. The relayer works well with ARP/si mple hijack so once you have hosts ARP spoofed with ARP relaying you can easily do ARP/simple hijack which will detect that the hosts are already ARP spoofed an d takes over the connection immediately. With this technique you can easily beco me man in the middle from the beginning of the connection even though your host with hunt isn't an IP gateway. I encourage you to write other application specif ic protocol handlers for the man in the middle attack as it is really simple wit h this framework.

Sniff daemon The purpose of the sniff daemon is to log specified packets. The sniff daemon ca n also search for a simple pattern (string) in the data stream (see the bugs sec tion). You can specify which connection you are interested in, where to search ( src, dst, both), what do you want to search, how many bytes you want to log, fro m what direction (src, dst, both) and to what file should the daemon write. All logged files are stored in the .sniff directory. The default file name for loggi ng is composed of the host and port names. In the options submenu you can set,0 (as new-lines or as hex num.). how to log new lines ( MAC discovery daemon This daemon is used to collect MAC addresses corresponding to the specified IP r ange. You can enter the time after which the daemon will try collecting again (d efault is 5min). Host up menu The host up module determines which hosts are up (with TCP/IP stack). You just s pecify the IP range and that space is then searched for running hosts. It is cap able to determine which hosts have network interface in promiscuous mode. The pr omiscuous mode usually shows that the host is running some kind of sniffer/netwo rk analyzer. Options menu In the options menu you can tune different things: l) a) m) d) List/Add/Mod/Del Connection Policy Entry First of all you can select which connections should be tracked. The default set ting is to look at telnet connections from all hosts but you can adjust this beh avior by the specification of src/dst address/mask src/dst port pairs. With comm ands: l) a) m) d) you set what you are interested in. c) Connection Listening Properties You can set whether the sequence numbers and MACs of ongoing connections will be displayed during connec tion listening. h) Host Resolving You can turn on resolving of hosts to their names. As the resolving is deferred you don't get the names of hosts immediately. Just try to list connections sever al times and you will see the hosts names. (I used this deferred approach becaus e I didn't want any delay of interface that the resolving can cause). r) Reset ACK Storm Timeout This timeout is used in simple hijack to automatically reset the connection afte r the ACK storm is detected. Note that you can receive the ACK storm even in arp /simple hijack in case you don't perform ACK spoofing of any host. s) Simple Hijack Timeout For Next cmd Simple hijack has not an interactive connection interface. That means you write the whole command which will be inserted into the connection data stream. If no data is transferred through the connection up to this timeout, you are prompted for the next command. q) ARP Request/Reply Packets Number of request or reply packets hunt will send when it is doing arp spoofing. t) ARP Request Spoof Through Request Option whether hunt will send ARP spoof request or ARP spoof reply when it recei ves broadcasted ARP request which will break ARP spoof. w) Switched Environment Some optimization for switched environment. It works perfectly for non switched environment also.

y) ARP Spoof With My MAC Set the originating MAC address of sent spoofed ARP to my (hunt) ethernet MAC sometimes helps in switched environment. e) Learn MAC From IP Traffic You can enable that MAC addresses will be learned from all IP traffic not just f rom ARP. p) Number Of Printed Lines Per Page In Listening Self explanatory v) Verbose On/Off Self explanatory Tested Environment HUNT program requirements: * Linux >= 2.2 * Glibc with linuxthreads * Ethernet Tested hosts: Linux 2.0, Linux 2.1, Linux 2.2, Solaris 2.5.1, NT4sp3/4, Win95, OSF V4.0D, HPUX 10.20, IRIX 6.2 Tested network equipment: BayNetworks 28115, 28200, 300 switches 3Com SuperStack II 3000, 1000 switches Security Notes Please note the already known truth that telnet and similar programs which send passwords in clear text are vulnerable to the described attacks. Programs using one time passwords are also easily attacked and in fact they are useless if some one can run a program like hunt. Only full encrypted traffic isn't vulnerable to these attacks but note that you can become a man in the middle if you use ARP s poofing (forcing) without the ACK storm and you can try to do something. Also un configured switch doesn't protect you from sniffing or hijacking. It is necessar y to carefully configure port security on the switches in order to protect the c omputers on the switched ports. Detecting attacks isn't an easy task. For ARP spoofing there are tools which can detect it. The ACK storm is detectable by some sophisticated network analyzers (you can detect the pattern of the ACK storm or the statistics of ACKs without d ata). If you run hunt on your network you can detect the ACK storm because the h unt can detect the ACK storm pattern. Performance Note Make sure you are running hunt on idle machine with sufficient power (I used PII -233 with 128MB RAM) and without any other packet analyzer because if you use ad vanced features like arp spoofing or hijacking hunt needs to reply fast with it' s own packets inserted into the traffic on the network. Download This software can be found at or at Known Bugs * some structures are poorly locked through mutexes * if you watch connection then some escape sequences from that connection can in fluent your terminal. Note that your terminal is named "Linux" ("xterm" - if you run it from X, ...) but the escape sequences are for the client side terminal w hich may or may not be Linux so you can get some mess. * sniff is not capable to search for a pattern which crosses the packet boundary . That means it can't search for a pattern of the user typed input as this input is usually transferred with 1B data long packets. * hunt doesn't support defragmentation so the IP fragments have to be dropped.