Justniffer
justniffer is a TCP packet sniffer. It can log network traffic in a 'standard' (web server like) or in a customized way. It can also log response times, useful for tracking network services performances (e.g. web server, application server, etc.). It can capture HTTP traffic and rebuild HTTP file.
Main differences from other sniffers
Most of the sniffers are divided into two categories, packet an text sniffers. Both suffer from incompleteness of information that may be collected and analyzed
- Packet sniffers collect too much data, such as packet headers details, and they make easy to analize low level network problem (such as tcp retrasmissions, or ip fragmentation) but make hard-working and time wasting to analize more high level details ( such as content correctness, keep-alive issues, connection timeouts, response time, etc)
- Textmode sniffers usually rebuild TCP stream but cannot collect low level information such as timestamps. They often rebuild the tcp flow in a too simplistic way and fail when dealing with complex TCP/IP issues (reordering, retransmission, reassemlbying, etc). TCP reassembling and reordering is a complex exercise, and require a deep knowledge of TCP/IP protocol and long experience in the field. Usually,they are useful for pure grabbing content from network traffic.
Justniffer was born to help in toubleshooting perfomance in network tcp based services : HTTP, JDBC, RTSP, SIP, SMTP, IMAP, POP, LDAP, etc.
It can collect low and hight level protocol and performance info reconstructing the tcp flow in a reliable way using portions of the Linux Kernel code. Precisely, it uses a slightly modified version of the libnids libraries that already include a modified version of linux kernel code in a more reusable way.
You can extend traffic analisys with external scripts (bash, python, or any executable). An example is provided: justniffer-grab-http-trafficscript uses justniffer to saves files (images, text, html pages, javascript, flash, video, etc) captured from HTTP traffic.
Justniffer can generate logs in a customizable way. For example it can mimic the apache access_log
| TCP flow rebuild | very reliable: it can reorder, reassemble tcp segments and ip fragments using portions of the Linux kernel code |
| Logging | text mode: can be customized |
| Extensibility | by any executable, such as bash, python, perl scripts, ELF executable, etc. |
| Performance measurement | it can collect many information on performances: connection time, close time, request time , response time, close time, etc. |
Examples
Example 1
Example 2
Example 3
GET /doc/maint-guide/ch-upload.en.html HTTP/1.1
Host: www.debian.org
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8)
Gecko/2009032711 Ubuntu/8.10 (intrepid) Firefox/3.0.8
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en,it;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.debian.org/doc/maint-guide/
If-Modified-Since: Wed, 22 Apr 2009 19:36:31 GMT
If-None-Match: "400d604-3014-46829e160adc0"
Cache-Control: max-age=0
HTTP/1.1 304 Not Modified
Date: Wed, 22 Apr 2009 20:38:51 GMT
Server: Apache
Connection: Keep-Alive
Keep-Alive: timeout=15, max=100
ETag: "400d604-3014-46829e160adc0"
Expires: Thu, 23 Apr 2009 20:38:51 GMT
Cache-Control: max-age=86400
Example 4
Example 5
tcpdump command example: tcpdump -w /tmp/file.cap -s 0 -i ath0
Example 6
Example 7
Example 8
#!/bin/bash
# myscript.sh
# example script (print all lines containing "href" string)
while read inputline
do
anchors=`echo "$inputline" | grep href`
if [ "$anchors" != "" ]; then
echo $anchors;
fi;
done
Example 9
220 plecno.com ESMTP Postfix (Ubuntu)
EHLO unknown.localnet
250-plecno.com
250-PIPELINING
250-SIZE
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM:<oreste.notelli@plecno.com> SIZE=1079
RCPT TO:<oreste.notelli@gmail.com>
DATA
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
From: Oreste Notelli <oreste.notelli@plecno.com>
Organization: Plecno
To: oreste.notelli@gmail.com
Subject: test
Date: Wed, 22 Apr 2009 22:46:16 +0200
User-Agent: KMail/1.11.2 (Linux/2.6.27-8-generic; KDE/4.2.2; i686;
; )
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="Boundary-00=_ZI47J3FTNXn+25g"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200904222246.17292.oreste.notelli@plecno.com>
--Boundary-00=_ZI47J3FTNXn+25g
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
test
--Boundary-00=_ZI47J3FTNXn+25g
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta name="qrichtext" content="1" />
<style type="text/css">p, li { white-space: pre-wrap;
}</style>
</head>
<body style=" font-family:'DejaVu Sans'; font-size:8pt;
font-weight:400; font-style:normal;">
<p>
test
</p>
</body>
</html>
--Boundary-00=_ZI47J3FTNXn+25g--
.
250 2.0.0 Ok: queued as 33E7235C21A
QUIT
221 2.0.0 Bye
Example 10
the url from the request header by the regular expression [^\s]*[\s]*([^\s]*)
and the content type from the response header by the regular expression Content-Type:(\s)*([^\r]*)
Install
On Ubuntu ( 11.04 / 11.10 / 12.04)
$ sudo apt-get install add-apt-repository
$ sudo add-apt-repository ppa:oreste-notelli/ppa
$ sudo apt-get update
$ sudo apt-get install justniffer
Other Ubuntus
Download the .deb file from the file repository and install it:
$ sudo apt-get install gdebi-core
$ sudo gdebi justniffer-x.x.deb
Other Distributions
be sure you have installed third-party tools and libraries:
patch
tar
autotools
make
libc6
libpcap0.8
g++
gcc
libboost-iostreams
libboost-program-options
libboost-regex
unpacked the source package, type:
$ ./configure
$ make
$ make install
Copyright (c) 2007-2011 Plecno s.r.l. All Rights Reserved info@plecno.com via Giovio 8, 20144 Milano, Italy Released under the terms of the GPLv3 or later Author: Oreste Notelli < oreste.notelli at plecno.com >