18,19c18,25
< # 05-May-2004, ver 0.94  (check for new versions, http://www.brendangregg.com)
< #			 (or run a web search for "chaosreader")
---
> # 11-Sep-2011, ver 0.95
> # 24-Sep 2011, ver 0.95b
> # 04-Jan 2012, ver 0.95c
> # 10-Jan 2012, ver 0.95d
> # 15-Mar 2013, ver 0.95e
> # (http://www.brendangregg.com/chaosreader.html seems to be outdated.
> # E-mail to the address brendan@sun.com mentioned on that web site returned
> # with an error.)
32c38
< # USAGE: chaosreader [-aehikqrvxAHIRTUXY] [-D dir] 
---
> # USAGE: chaosreader [-adehiknqrvxAHIRTUXY] [-D dir]
45a52
> #    -d, --preferdns       # Show DNS names instead of IP addresses
63a71
> #    -n, --names           # Include hostnames in hyperlinked HTTPlog (HTML)
199c207
< # SEE ALSO: ethereal (GUI packet viewer), dsniff (sniffing toolkit)
---
> # SEE ALSO: wireshark (GUI packet viewer), dsniff (sniffing toolkit)
201a210,211
> #            Copyright (c) 2008 Indian Larry.
> #            Copyright (c) 2011, 2012, 2013 Jens Lechtenbörger.
203,206c213,216
< #  This program is free software; you can redistribute it and/or
< #  modify it under the terms of the GNU General Public License
< #  as published by the Free Software Foundation; either version 2
< #  of the License, or (at your option) any later version. 
---
> # This program is free software: you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation, either version 3 of the License, or
> # (at your option) any later version.
214,215c224
< #  along with this program; if not, write to the Free Software Foundation, 
< #  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
---
> # along with this program.  If not, see <http://www.gnu.org/licenses/>.
217,219c226,228
< #  (http://www.gnu.org/copyleft/gpl.html)
< #
< # Author: Brendan Gregg  [Sydney, Australia]
---
> # Authors: Brendan Gregg      [Sydney, Australia]
> #          Indian Larry       [http://refrequelate.blogspot.com/]
> #          Jens Lechtenbörger [Münster, Germany]
241c250,283
< 
---
> #
> # 11-Sep-2011, Jens Lechtenbörger:
> # - Switch from GPLv2 to GPLv3
> # - Integrate diff from
> #   http://refrequelate.blogspot.com/2008/07/more-de-chunking-chaosreader-patch.html
> #   to reassemble chunked HTTP transfers.
> # - Parse linux cooked captures, which result from listening on "any"
> #   interface.  (Chaosreader0.94 does not produce any output for such
> #   pcap files.)
> # - Use HTTP content-type to identify file types such as HTML, XML,
> #   Javascript, CSS; use those types for better file extensions than
> #   "data".
> # - Uncompress gzip'ed data.
> # - Add new command line switch to show host names in HTTPlog and to
> #   create href-links from HTTPlog rows to the corresponding rows in
> #   the table on index.html.
> # - Several minor improvements (see comments with "JL:").
> #
> # 24-Sep-2011, Jens Lechtenbörger:
> # - More systematic Content-Type handling based on MIME types.
> # - More image types included in Image Report based on MIME types.
> #
> # 4-Jan-2012, Jens Lechtenbörger:
> # - Parsing of DNS replies to show names instead of IP addresses (new
> #   command line switch -d) and to save DNS replies as text files.
> #
> # 10-Feb-2012, Jens Lechtenbörger:
> # - Use file magic (again) to detect MIME type if HTTP's Content-Type is
> #   application/octet-stream.  (Some Web servers report images incorrectly.)
> #
> # 15-Mar-2013, Jens Lechtenbörger:
> # - Create additional HTTP log file in text format.  This file contains one
> #   line per GET request, which shows the referer (if present) and indicates
> #   whether cookies have been send in the request or received in the reply.
244a287,288
> use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
> use Net::DNS::Packet;
316c360,361
< 
---
> &Set_MIME_Types(); #JL
> &Set_DNS(); #JL
861a907,911
> 	    # JL: Try linux cooked capture
> 	    ($lptype,$lladdr_type,$lladdr_len,
> 	     $ether_src,$ll_dummy,$ether_type,$ether_data) =
> 		unpack('nnnH12nH4a*',$packet_data) unless $decoded;
> 	    if ($ether_type ne "0800") {
863a914
> 	}
1342a1394,1398
> 	# JL: DNS parsing
> 	if (($udp_src_port == 53) || ($udp_dest_port == 53)) {
> 	    &Process_DNS($udp_data, $session_id);
> 	}
> 
1630c1686,1688
< 	$Index{HTML}[$number] = "<tr><td><i>$number.</i></td>" .
---
> 	# JL: Added id attribute as link target
> 	$Index{HTML}[$number] = "<tr id=\"$number\">" .
> 	 "<td><i>$number.</i></td>" .
1758c1816
< 		&Process_HTTP($session_id);
---
> 		&Process_HTTP($session_id,$number);
1902a1961,1964
> 	if ($Arg{prefer_dns}) {
> 	    $ip_src = &Get_Name_For_IP($ip_src);
> 	    $ip_dest = &Get_Name_For_IP($ip_dest);
> 	}
1996a2059,2062
> 	if ($service == 53) {
> 	        &Save_DNS_File($session_id,$number);
> 	}
> 
2160a2227,2250
> # JL: Process_DNS - DNS processing.  Look for DNS replies and store
> #     names for IP addresses into %DNS.
> #
> sub Process_DNS {
> 	my $data = shift;
> 	my $session_id = shift;
> 
> 	my $dns = Net::DNS::Packet->new(\$data);
> 
> 	unless ($dns) {
> 	    #print "Failed to create Net::DNS::Packet!\n";
> 	    return;
> 	}
> 
> 	$UDP{id}{$session_id}{DNS} = $dns->string;
> 	foreach my $rr ($dns->answer) {
> 	    if ($rr->type eq "A") {
> 		$DNS{$rr->address} = $rr->name;
> 	    }
> 	}
> }
> 
> 
> 
2162a2253
> # JL: Added host parameter
2165c2256
< 	my ($junk,$var,$value,$term,$data,$request,$site,$post,$get,$reply);
---
> 	my ($junk,$var,$value,$term,$data,$request,$host,$site,$post,$get,$reply);
2173a2265
> 	my $number = shift;
2220a2313,2318
> 		### JL: Get the host string, referer, and cookies.
> 		($host) = $request =~ /\sHost:\s(\S*)\s/is;
> 		($referer) = $request =~ /\sReferer:\s(\S*)/is;
> 		($cookie) = $request =~ /\sCookie:\s(\S*)/is;
> 		($setcookie) = $reply =~ /\sSet-Cookie:\s(\S*)/is;
> 
2224a2323,2326
> 		        # JL: Prefer hostname over IP address
> 		        if ($Arg{httplog_html}) {
> 			    $site = "http://${host}$site";
> 			} else {
2226a2329
> 		}
2230,2231c2333,2335
< 		($type) = $reply =~ /Content-Type:\s(\S*)/s;
< 		($size) = $reply =~ /Content-Length:\s(\S*)/s;
---
> 		# JL: Be careful to use case insensitive matching
> 		($type) = $reply =~ /Content-Type:\s(\S*)/is;
> 		($size) = $reply =~ /Content-Length:\s(\S*)/is;
2233a2338
> 
2238,2241c2343,2349
< 		 sprintf("%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s\n",
< 		 int($time),(($time - int($time))*1000),($duration*1000),
< 		 $src,$result,$status,$size,"GET",$site,"-","NONE","",
< 		 "-",$type);
---
> 			Print_Log_Line($number,$time,$duration,
> 				$src,$dest,$result,$status,$size,
> 				"GET",$site,"-","NONE","","-",$type);
> 		$HTTPtxtlog{time}{$time} =
> 			Print_TxtLog_Line($number,$time,
> 				$referer,$cookie,$setcookie,
> 				"GET",$site);
2250a2359,2363
> 		### JL: Get the host string, referer, and cookies.
> 		($host) = $request =~ /\sHost:\s(\S*)\s/is;
> 		($referer) = $request =~ /\sReferer:\s(\S*)/is;
> 		($cookie) = $request =~ /\sCookie:\s(\S*)/is;
> 		($setcookie) = $reply =~ /\sSet-Cookie:\s(\S*)/is;
2254,2255c2367,2368
< 		($type) = $reply =~ /Content-Type:\s(\S*)/s;
< 		($size) = $reply =~ /Content-Length:\s(\S*)/s;
---
> 		($type) = $reply =~ /Content-Type:\s(\S*)/is;
> 		($size) = $reply =~ /Content-Length:\s(\S*)/is;
2262,2265c2375,2381
< 		 sprintf("%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s\n",
< 		 int($time),(($time - int($time))*1000),($duration*1000),
< 		 $src,$result,$status,$size,"POST",$site,"-","NONE","",
< 		 "-",$type);
---
> 		    Print_Log_Line($number,$time,$duration,
> 				   $src,$dest,$result,$status,$size,
> 				   "POST",$site,"-","NONE","","-",$type);
> 		$HTTPtxtlog{time}{$time} =
> 			Print_TxtLog_Line($number,$time,
> 				$referer,$cookie,$setcookie,
> 				"GET",$site);
2569c2685
< 		print "Chaosreader ver 0.94\n\n";
---
> 		print "Chaosreader ver 0.95e\n\n";
2648c2764
< <a href="httplog.text"><font color="blue"><b>HTTP Proxy Log</b></font></a> 
---
> <a href="$Arg{httplog_name}"><font color="blue"><b>HTTP Proxy Log</b></font></a>
2934a3051,3102
> # JL: Print a line for the HTTPlog
> #
> sub Print_Log_Line {
> 	my $number = shift;
>         my $time = shift;
> 	my $duration = shift;
> 	my $src = shift;
> 	my $dest = shift;
> 	my $result = shift;
> 	my $status = shift;
> 	my $size = shift;
> 	my $method = shift;
> 	my $site = shift;
> 	my $type = shift;
> 
> 	if ($Arg{httplog_html}) {
> 	    sprintf("<pre><a href=\"index.html#%d\">%d</a>" .
> 		    " %9d.%03d %6d " .
> 		    "%-15s %-15s %s/%03d %d %s %s %s %s%s/%s %s</pre><br/>\n",
> 		    $number,$number,
> 		    int($time),(($time - int($time))*1000),($duration*1000),
> 		    $src,$dest,$result,$status,$size,
> 		    $method,$site,"-","NONE","","-",$type);
> 	} else {
> 	    sprintf("%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s\n",
> 		    int($time),(($time - int($time))*1000),($duration*1000),
> 		    $src,$result,$status,$size,
> 		    $method,$site,"-","NONE","","-",$type);
> 	}
> }
> 
> # JL: Print a line for the new text HTTPlog
> #
> sub Print_TxtLog_Line {
> 	my $number = shift;
>         my $time = shift;
> 	my $referer = shift;
> 	my $cookie = shift;
> 	my $setcookie = shift;
> 	my $method = shift;
> 	my $site = shift;
> 
> 	($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime($time);
> 	$referer = "Referer: " . $referer if $referer ne "";
> 	$cookie = "Cookie sent." if $cookie ne "";
> 	$setcookie = "Sets cookie." if $setcookie ne "";
> 	sprintf("%-4s %02d:%02d:%02d %s %s %s %s %s\n",
> 		$number,$hour,$minute,$second,
> 		$method,$site,$referer,$cookie,$setcookie);
> }
> 
> 
2942c3110,3111
< 	#  Create HTTPlog.text
---
> 	#  Create httplog file
>         # JL: Don't use hardcoded filename
2944,2945c3113
< 	open(FILE,">httplog.text") || die "ERROR29: creating HTTP log: $!\n";
< 
---
>         open(FILE,">$Arg{httplog_name}") || die "ERROR29: creating HTTP log: $!\n";
2950a3119,3126
> 
>         open(FILE,">$Arg{httplog_txt}") || die "ERROR29: creating HTTP text log: $!\n";
> 
> 	foreach $time (sort { $a <=> $b }(keys (%{$HTTPtxtlog{time}}))) {
> 		print FILE $HTTPtxtlog{time}{$time};
> 	}
> 
> 	close FILE;
2962a3139
> 	elsif ($data =~ /^.PNG/) 	        { $type = "png"; } # JL
2969a3147
> 	elsif ($data =~ /<?xml/i) 		{ $type = "xml"; } # JL
2981,2984c3159,3160
< 	return 1 if ($ext eq "jpeg");
< 	return 1 if ($ext eq "gif");
< 
< 	return 0;
---
> 	# JL: Use MIME types.
> 	return ($ext_types{$ext} eq "image");
5354a5531,5547
> 		### JL: Chunk Check, patch from http://refrequelate.blogspot.com/2008/07/more-de-chunking-chaosreader-patch.html
> 		if ( $http_header =~ /Transfer-Encoding: chunked/ ) {
> 		    my $new_http_data="";
> 		    my $chunksize=-1;
> 		    my $pos=0;
> 		    until ($chunksize==0) {
> 			my $eolpos=index($http_data,"\r\n",$pos);
> 			$chunksize=hex(substr($http_data,$pos,$eolpos - $pos));
> 			$pos=($eolpos+2);
> 			if ($chunksize > 0) {
> 			    $new_http_data.=substr($http_data,$pos,$chunksize);
> 			}
> 			$pos+=($chunksize+2);
> 		    }
> 		    $http_data=$new_http_data;
> 		}
> 
5356c5549
< 		$http_type = &File_Type($http_data);
---
> 		my $http_type = &File_Type($http_data);
5359a5553,5577
> 		### JL: Check for known MIME type in Content-Type
> 		my ($content_type) = $http_header =~ /Content-Type:\s+(\S*)/is;
> 		my $file_extension = "";
> 		if ($content_type ne "") {
> 		    for my $pattern ( keys %mime_types ) {
> 			my $value = $mime_types{$pattern};
> 			if ( $content_type =~ /$pattern/i ) {
> 			    $file_extension = $value;
> 			    last;
> 			}
> 		    }
> 		    if ($file_extension eq "bin") {
> 			# Not too specific.  Some HTTP servers return images
> 			# with Content-Type: application/octet-stream.
> 			# Prefer http_type then...
> 			if ($http_type ne "data") {
> 			    $file_extension = $http_type;
> 			}
> 		    }
> 		    elsif ($file_extension eq "") {
> 			print "Unkown Content-Type $content_type.";
> 			print "  May want to extend MIME types.\n";
> 		    }
> 		}
> 
5361,5362c5579,5586
< 	        $filename = "session_${numtext}.part_$parttext${ext}." .
< 		 "$http_type";
---
> 		# JL: Create filename based on Content-Type
> 	        my $filename = "session_${numtext}.part_$parttext${ext}";
> 		if ($file_extension ne "") {
> 		    $filename .= ".$file_extension";
> 		}
> 		if ( ($file_extension eq "") or ($http_type eq "gz") ) {
> 		    $filename .= ".$http_type";
> 		}
5368a5593,5603
> 		### JL: gz decompressing
> 		if ( $http_type eq "gz" ) {
> 		    my $gunzipped = substr($filename, 0, length($filename) - 3);
> 		    my $gunzip_failed = 0;
> 		    gunzip $filename => $gunzipped
> 			or $gunzip_failed = 1;
> 		    if ( $gunzip_failed == 0 ) {
> 			$filename = $gunzipped;
> 		    }
> 		}
> 
5375c5610,5611
< 		if (&Is_Image($http_type)) {
---
> 		if (&Is_Image($http_type) or
> 		    &Is_Image($file_extension)) { # JL: Also check file ext.
5431a5668,5691
> # Save_DNS_File - Save DNS file.
> #
> sub Save_DNS_File {
> 	my ($filename);
> 	my $session_id = shift;
> 	my $number = shift;
> 	my $numtext = sprintf("%04d",$number);
> 	my $text = $UDP{id}{$session_id}{DNS};
> 
> 	### Output
>         $filename = "session_${numtext}.domain.txt";
> 	open (OUT,">$filename") || die "ERROR52: file create, $filename: $!\n";
> 	print OUT $text;
> 	close OUT;
> 
> 	### Global Vars
> 	my $length = length($text);
> 	$Index{HTML}[$number] .= "<li><a href=\"$filename\">$filename</a>" .
> 	 " $length bytes</li>\n";
> 	$Index{Text}[$number] .= sprintf("%-4s %-45s %-10s %8s bytes\n",
> 	 '"' , "   $filename","",$length);
> }
> 
> 
5509a5770,5778
> # Retrieve DNS name for IP address based on DNS traffic of this capture.
> #
> sub Get_Name_For_IP {
>     my $ip_addr = shift;
>     if (defined $DNS{$ip_addr}) {
> 	return $DNS{$ip_addr};
>     }
>     return $ip_addr;
> }
5578a5848,5851
> 		if ($Arg{prefer_dns}) {
> 		    $ip_src = &Get_Name_For_IP($ip_src);
> 		    $ip_dest = &Get_Name_For_IP($ip_dest);
> 		}
5581a5855,5858
> 	        if ($Arg{prefer_dns}) {
> 		    $ip_src = &Get_Name_For_IP($ip_src);
> 		    $ip_dest = &Get_Name_For_IP($ip_dest);
> 		}
6177a6455,6815
> # JL: Initialize Hostnames for IP addresses
> sub Set_DNS {
>     %DNS = (
> 	"192.168.178.1" => "fritz.box"
> 	)
> }
> 
> # JL: Set_MIME_Types - create hash of MIME types and file extensions.
> sub Set_MIME_Types {
>     # Initialize with types seen in the wild but not covered below.
>     %mime_types = (
> 	"application/binary" => "binary",
> 	"application/ocsp-response" => "ocsp",
> 	"application/pln" => "pln", # bahn.de schedule
> 	"application/vnd.google.safebrowsing-update" => "safebrowsing-update",
> 	"application/vnd.google.safebrowsing-chunk" => "safebrowsing-chunk",
> 	"application/vnd.ms-sync.wbxml" => "mssync", # MS ActiveSync
> 	"application/x-protobuffer" => "protobuffer", # google
> 	"application/x-smd" => "smd", # MapDroyd boundary
> 	"(application|text)/((x-)?javascript|(x-)?js)" => "js",
> 	"(application|text)/json" => "json",
> 	"image/bmp" => "bmp",
> 	"image/vnd.microsoft.icon" => "ico",
> 	"image/x-gif" => "gif",
> 	"(image/x-)?jp(e)?g" => "jpeg",
> 	"image/x-png" => "png",
> 	"text/xml" => "xml");
>     # Following created with:
>     # grep -o -P "^(text|application|audio|image|video).*\t+([a-z0-9]+)" /etc/mime.types > mime.types
>     $raw_mime_types = <<END;
> application/andrew-inset			ez
> application/annodex				anx
> application/atom+xml				atom
> application/atomcat+xml				atomcat
> application/atomserv+xml			atomsrv
> application/bbolin				lin
> application/cap					cap
> application/cu-seeme				cu
> application/davmount+xml			davmount
> application/dsptype				tsp
> application/ecmascript				es
> application/futuresplash			spl
> application/hta					hta
> application/java-archive			jar
> application/java-serialized-object		ser
> application/java-vm				class
> application/javascript				js
> application/m3g					m3g
> application/mac-binhex40			hqx
> application/mac-compactpro			cpt
> application/mathematica				nb
> application/msaccess				mdb
> application/msword				doc
> application/mxf					mxf
> application/octet-stream			bin
> application/oda					oda
> application/ogg					ogx
> application/pdf					pdf
> application/pgp-keys				key
> application/pgp-signature			pgp
> application/pics-rules				prf
> application/postscript				ps
> application/rar					rar
> application/rdf+xml				rdf
> application/rss+xml				rss
> application/rtf					rtf
> application/smil				smi
> application/xhtml+xml				xhtml
> application/xml					xml
> application/xspf+xml				xspf
> application/zip					zip
> application/vnd.android.package-archive		apk
> application/vnd.cinderella			cdy
> application/vnd.google-earth.kml+xml		kml
> application/vnd.google-earth.kmz		kmz
> application/vnd.mozilla.xul+xml			xul
> application/vnd.ms-excel			xls
> application/vnd.ms-pki.seccat			cat
> application/vnd.ms-pki.stl			stl
> application/vnd.ms-powerpoint			ppt
> application/vnd.oasis.opendocument.chart			odc
> application/vnd.oasis.opendocument.database			odb
> application/vnd.oasis.opendocument.formula			odf
> application/vnd.oasis.opendocument.graphics			odg
> application/vnd.oasis.opendocument.graphics-template		otg
> application/vnd.oasis.opendocument.image			odi
> application/vnd.oasis.opendocument.presentation			odp
> application/vnd.oasis.opendocument.presentation-template	otp
> application/vnd.oasis.opendocument.spreadsheet			ods
> application/vnd.oasis.opendocument.spreadsheet-template		ots
> application/vnd.oasis.opendocument.text				odt
> application/vnd.oasis.opendocument.text-master			odm
> application/vnd.oasis.opendocument.text-template		ott
> application/vnd.oasis.opendocument.text-web			oth
> application/vnd.openxmlformats-officedocument.spreadsheetml.sheet		xlsx
> application/vnd.openxmlformats-officedocument.spreadsheetml.template		xltx
> application/vnd.openxmlformats-officedocument.presentationml.presentation	pptx
> application/vnd.openxmlformats-officedocument.presentationml.slideshow		ppsx
> application/vnd.openxmlformats-officedocument.presentationml.template		potx
> application/vnd.openxmlformats-officedocument.wordprocessingml.document		docx
> application/vnd.openxmlformats-officedocument.wordprocessingml.template		dotx
> application/vnd.rim.cod				cod
> application/vnd.smaf				mmf
> application/vnd.stardivision.calc		sdc
> application/vnd.stardivision.chart		sds
> application/vnd.stardivision.draw		sda
> application/vnd.stardivision.impress		sdd
> application/vnd.stardivision.math		sdf
> application/vnd.stardivision.writer		sdw
> application/vnd.stardivision.writer-global	sgl
> application/vnd.sun.xml.calc			sxc
> application/vnd.sun.xml.calc.template		stc
> application/vnd.sun.xml.draw			sxd
> application/vnd.sun.xml.draw.template		std
> application/vnd.sun.xml.impress			sxi
> application/vnd.sun.xml.impress.template	sti
> application/vnd.sun.xml.math			sxm
> application/vnd.sun.xml.writer			sxw
> application/vnd.sun.xml.writer.global		sxg
> application/vnd.sun.xml.writer.template		stw
> application/vnd.symbian.install			sis
> application/vnd.visio				vsd
> application/vnd.wap.wbxml			wbxml
> application/vnd.wap.wmlc			wmlc
> application/vnd.wap.wmlscriptc			wmlsc
> application/vnd.wordperfect			wpd
> application/vnd.wordperfect5.1			wp5
> application/x-123				wk
> application/x-7z-compressed			7z
> application/x-abiword				abw
> application/x-apple-diskimage			dmg
> application/x-bcpio				bcpio
> application/x-bittorrent			torrent
> application/x-cab				cab
> application/x-cbr				cbr
> application/x-cbz				cbz
> application/x-cdf				cdf
> application/x-cdlink				vcd
> application/x-chess-pgn				pgn
> application/x-cpio				cpio
> application/x-csh				csh
> application/x-debian-package			deb
> application/x-director				dcr
> application/x-dms				dms
> application/x-doom				wad
> application/x-dvi				dvi
> application/x-httpd-eruby			rhtml
> application/x-font				pfa
> application/x-freemind				mm
> application/x-futuresplash			spl
> application/x-gnumeric				gnumeric
> application/x-go-sgf				sgf
> application/x-graphing-calculator		gcf
> application/x-gtar				gtar
> application/x-hdf				hdf
> application/x-httpd-php				phtml
> application/x-httpd-php-source			phps
> application/x-httpd-php3			php3
> application/x-httpd-php3-preprocessed		php3p
> application/x-httpd-php4			php4
> application/x-httpd-php5			php5
> application/x-ica				ica
> application/x-info				info
> application/x-internet-signup			ins
> application/x-iphone				iii
> application/x-iso9660-image			iso
> application/x-jam				jam
> application/x-java-jnlp-file			jnlp
> application/x-jmol				jmz
> application/x-kchart				chrt
> application/x-killustrator			kil
> application/x-koan				skp
> application/x-kpresenter			kpr
> application/x-kspread				ksp
> application/x-kword				kwd
> application/x-latex				latex
> application/x-lha				lha
> application/x-lyx				lyx
> application/x-lzh				lzh
> application/x-lzx				lzx
> application/x-maker				frm
> application/x-mif				mif
> application/x-ms-wmd				wmd
> application/x-ms-wmz				wmz
> application/x-msdos-program			com
> application/x-msi				msi
> application/x-netcdf				nc
> application/x-ns-proxy-autoconfig		pac
> application/x-nwc				nwc
> application/x-object				o
> application/x-oz-application			oza
> application/x-pkcs7-certreqresp			p7r
> application/x-pkcs7-crl				crl
> application/x-python-code			pyc
> application/x-qgis				qgs
> application/x-quicktimeplayer			qtl
> application/x-redhat-package-manager		rpm
> application/x-ruby				rb
> application/x-sh				sh
> application/x-shar				shar
> application/x-shockwave-flash			swf
> application/x-silverlight			scr
> application/x-stuffit				sit
> application/x-sv4cpio				sv4cpio
> application/x-sv4crc				sv4crc
> application/x-tar				tar
> application/x-tcl				tcl
> application/x-tex-gf				gf
> application/x-tex-pk				pk
> application/x-texinfo				texinfo
> application/x-troff				t
> application/x-troff-man				man
> application/x-troff-me				me
> application/x-troff-ms				ms
> application/x-ustar				ustar
> application/x-wais-source			src
> application/x-wingz				wz
> application/x-x509-ca-cert			crt
> application/x-xcf				xcf
> application/x-xfig				fig
> application/x-xpinstall				xpi
> audio/amr					amr
> audio/amr-wb					awb
> audio/amr					amr
> audio/amr-wb					awb
> audio/annodex					axa
> audio/basic					au
> audio/flac					flac
> audio/midi					mid
> audio/mpeg					mpga
> audio/mpegurl					m3u
> audio/ogg					oga
> audio/prs.sid					sid
> audio/x-aiff					aif
> audio/x-gsm					gsm
> audio/x-mpegurl					m3u
> audio/x-ms-wma					wma
> audio/x-ms-wax					wax
> audio/x-pn-realaudio				ra
> audio/x-realaudio				ra
> audio/x-scpls					pls
> audio/x-sd2					sd2
> audio/x-wav					wav
> image/gif					gif
> image/ief					ief
> image/jpeg					jpeg
> image/pcx					pcx
> image/png					png
> image/svg+xml					svg
> image/tiff					tiff
> image/vnd.djvu					djvu
> image/vnd.wap.wbmp				wbmp
> image/x-canon-cr2				cr2
> image/x-canon-crw				crw
> image/x-cmu-raster				ras
> image/x-coreldraw				cdr
> image/x-coreldrawpattern			pat
> image/x-coreldrawtemplate			cdt
> image/x-corelphotopaint				cpt
> image/x-epson-erf				erf
> image/x-icon					ico
> image/x-jg					art
> image/x-jng					jng
> image/x-ms-bmp					bmp
> image/x-nikon-nef				nef
> image/x-olympus-orf				orf
> image/x-photoshop				psd
> image/x-portable-anymap				pnm
> image/x-portable-bitmap				pbm
> image/x-portable-graymap			pgm
> image/x-portable-pixmap				ppm
> image/x-rgb					rgb
> image/x-xbitmap					xbm
> image/x-xpixmap					xpm
> image/x-xwindowdump				xwd
> text/cache-manifest				manifest
> text/calendar					ics
> text/css					css
> text/csv					csv
> text/h323					323
> text/html					html
> text/iuls					uls
> text/mathml					mml
> text/plain					asc
> text/richtext					rtx
> text/scriptlet					sct
> text/texmacs					tm
> text/tab-separated-values			tsv
> text/vnd.sun.j2me.app-descriptor		jad
> text/vnd.wap.wml				wml
> text/vnd.wap.wmlscript				wmls
> text/x-bibtex					bib
> text/x-boo					boo
> text/x-c++hdr					h
> text/x-c++src					c
> text/x-chdr					h
> text/x-component				htc
> text/x-csh					csh
> text/x-csrc					c
> text/x-dsrc					d
> text/x-diff					diff
> text/x-haskell					hs
> text/x-java					java
> text/x-literate-haskell				lhs
> text/x-moc					moc
> text/x-pascal					p
> text/x-pcs-gcd					gcd
> text/x-perl					pl
> text/x-python					py
> text/x-scala					scala
> text/x-setext					etx
> text/x-sh					sh
> text/x-tcl					tcl
> text/x-tex					tex
> text/x-vcalendar				vcs
> text/x-vcard					vcf
> video/3gpp					3gp
> video/annodex					axv
> video/dl					dl
> video/dv					dif
> video/fli					fli
> video/gl					gl
> video/mpeg					mpeg
> video/mp4					mp4
> video/quicktime					qt
> video/ogg					ogv
> video/vnd.mpegurl				mxu
> video/x-flv					flv
> video/x-la-asf					lsf
> video/x-mng					mng
> video/x-ms-asf					asf
> video/x-ms-wm					wm
> video/x-ms-wmv					wmv
> video/x-ms-wmx					wmx
> video/x-ms-wvx					wvx
> video/x-msvideo					avi
> video/x-sgi-movie				movie
> video/x-matroska				mpv
> END
>     %ext_types = ();
>     foreach $line (split(/\n/, $raw_mime_types)) {
> 	my ($mime_type, $extension) = split(/\t+/, $line);
> 	# Beware.  "+" needs to be escaped in patterns.
> 	$mime_type =~ s/\+/\\\+/g;
> 	$mime_types{$mime_type} = $extension;
> 	my ($type, $sub_type) = split(/\//, $mime_type);
> 	# We check whether we already have a value for this extension.
> 	# We don't care if application is overwritten.
> 	if ((defined $ext_types{$extension}) &&
> 	    ($ext_types{$extension} ne $type) &&
> 	    ($ext_types{$extension} ne "application")) {
> 	    print "$extension already has $ext_types{$extension}.";
> 	    print "Should now become $type.  Fix mime.types?\n"
> 	}
> 	else {
> 	    $ext_types{$extension} = $type;
> 	}
>     }
> }
> 
> 
6302a6941,6944
> 	$Arg{prefer_dns} = 0; # JL: Prefer DNS names over IP addresses?
> 	$Arg{httplog_html} = 0; # JL: Should we create HTTPlog in HTML?
> 	$Arg{httplog_name} = "httplog.text"; # JL: Old default as variable
> 	$Arg{httplog_txt} = "httplog.txt";   # JL: New text format
6312a6955
> 				"d|preferdns" => \$opt_d, # JL: new option
6316a6960
> 				"n|names" => \$opt_n, # JL: new option
6365a7010,7012
> 	$Arg{prefer_dns} = 1 if $opt_d;
> 	$Arg{httplog_html} = 1 if $opt_n;
> 	$Arg{httplog_name} = "httplog.html" if $opt_n;
6521c7168
<         print "USAGE: chaosreader [-aehikqrvxAHIRTUXY] [-D dir] 
---
>         print "USAGE: chaosreader [-adehiknqrvxAHIRTUXY] [-D dir]
6545c7192
<         print "Version 0.94, 01-May-2004
---
>         print "Version 0.95e, 15-Mar-2013
6547c7194
< USAGE: chaosreader [-aehikqrvxAHIRTUXY] [-D dir] 
---
> USAGE: chaosreader [-adehiknqrvxAHIRTUXY] [-D dir]
6560a7208
>    -d, --preferdns       # Show DNS names instead of IP addresses
6578a7227
>    -n, --names           # Include hostnames in hyperlinked HTTPlog (HTML)
