How to capture ICAP headers with tcpdump

tcpdump -A -s 10240 'tcp port 1344 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(REQMOD |RESPMOD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(REQMOD |RESPMOD )/\n\1/g'
Human readable representation of the headers of an ICAP request, using tcpdump
Sample Output
Date: Thu, 28 May 2015 16:23:55 GMT 
Service: MyDLP ICAP Server 
Connection: keep-alive 
ISTag: "mydlp-icap-rocks" 
Encapsulated: null-body=0 

REQMOD icap://10.232.14.49:1344/REQMOD ICAP/1.0 
Preview: 10 
Host: 10.232.14.49 
X-ICAP-Version: 1.0 
Allow: 204 
X-ICAP-Client: ST ICAP Client v.1.0 
Encapsulated: req-hdr=0, req-body=427 
X-Date: 05-28-2015 
Content-Type: text/plain, charset=ISO-8859-1 
X-Classification: HIGHLY_CONFIDENTIAL 
X-Approval-Given: 1 
Host: sthost 
Content-Length: 6 
X-Timestamp: 19:23:55.596 
Content-Disposition: attachment; filename="body_wap.txt" 
X-Sender-Email: idod@sofia-pso.tumbleweed.com 
X-Recipient-List: idod@sofia-pso.tumbleweed.com 
X-Summary-Description: fdsfds 
X-Application-Owner: fdsfsd 

0
By: idodekov
2015-05-29 12:58:27

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: