tshark -i en1 -z proto,colinfo,http.request.uri,http.request.uri -R http.request.uri

trace http requests with tshark

trace http requests on the specified interface. uses the amazing tshark tool (http://www.wireshark.org/docs/man-pages/tshark.html)
Sample Output
Capturing on eth0
 10.782367 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx/ HTTP/xxxxx.1   http.request.uri == "/xxxxx/"
 14.362057 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.css HTTP/xxxxx.1   http.request.uri == "/xxxxx.css"
 14.512157 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.css HTTP/xxxxx.1   http.request.uri == "/xxxxx.css"
 14.527458 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.css HTTP/xxxxx.1   http.request.uri == "/xxxxx.css"
 23.481113 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.481165 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.481179 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.631256 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.636404 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.gif HTTP/xxxxx.1   http.request.uri == "/xxxxx.gif"
 23.646674 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.657191 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx/ HTTP/xxxxx.1   http.request.uri == "/xxxxx/"
 23.672339 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.jpg HTTP/xxxxx.1   http.request.uri == "/xxxxx.jpg"
 23.681375 XX.XX.XX.XX -> XX.XX.XX.XX HTTP GET /xxxxx.png HTTP/xxxxx.1   http.request.uri == "/xxxxx.png"
 39.723847 XX.XX.XX.XX -> XX.XX.XX.XX HTTP POST /xxxxx/getxredirectxhost HTTP/xxxxx.1  (application/octet-stream)  http.request.uri == "/xxxxx/getxredirectxhost"

0
By: lele
2011-04-05 14:18:35

These Might Interest You

  • This command allows to follow up a trace on SDP (CS5.2), at the same time as the trace records are stored in the file with "raw" format. Trace files in native format are useful to filter the records before to translation from '|' to '\n'. Example: grep -v OP_GET <raw-records>.trace | tr '|' '\n' Show Sample Output


    0
    tail -1f /var/opt/fds/logs/TraceEventLogFile.txt.0 | grep <msisdn> | tee <test-case-id>.trace | tr '|' '\n'
    neomefistox · 2014-08-21 19:29:07 0
  • This captures traffic on a remote machine with tshark, sends the raw pcap data over the ssh link, and displays it in wireshark. Hitting ctrl+C will stop the capture and unfortunately close your wireshark window. This can be worked-around by passing -c # to tshark to only capture a certain # of packets, or redirecting the data through a named pipe rather than piping directly from ssh to wireshark. I recommend filtering as much as you can in the tshark command to conserve bandwidth. tshark can be replaced with tcpdump thusly: ssh root@example.com tcpdump -w - 'port !22' | wireshark -k -i -


    30
    ssh root@server.com 'tshark -f "port !22" -w -' | wireshark -k -i -
    markdrago · 2009-12-17 23:03:24 2
  • Nginx (and other webservers like Apache) can be awkward to trace. They run as root, then switch to another user once they're ready to serve web pages. They also have a "master" process and multiple worker processes. The given command finds the process IDs of all Nginx processes, joins them together with a comma, then traces all of them at once with "sudo strace." System trace output can be overwhelming, so we only capture "networking" output. TIP: to kill this complex strace, do "sudo killall strace". Compare with a similar command: http://www.commandlinefu.com/commands/view/11918/easily-strace-all-your-apache-processes Show Sample Output


    1
    sudo strace -e trace=network -p `pidof nginx | sed -e 's/ /,/g'`
    shavenwarthog · 2016-01-28 18:48:16 0
  • Simple command to trace a DNS query from the root all the way to the authoritative servers.


    4
    dig +trace google.com
    duxklr · 2010-09-03 18:57:29 0
  • This utilizes the Requests and BeautifulSoup libraries in Python to retrieve a user page on commandlinefu, parse it (error-tolerant) and extract all the lines of the following format: gzip * To print them, a list comprehension is used to iterate over the values, and join() is called on a newline character. Show Sample Output


    2
    python -c "import requests; from bs4 import BeautifulSoup; print '\n'.join([cmd.text for cmd in BeautifulSoup(requests.get('http://www.commandlinefu.com/commands/by/${USER}').content, 'html.parser').find_all('div','command')])"
    funky · 2015-08-22 21:32:36 0
  • #_connects src_IP dst_IP When_It_Happened_Secs Show Sample Output


    -1
    tshark -qr [cap] -z conv,tcp | awk '{printf("%s:%s:%s\n",$1,$3,$10)}' | awk -F: '{printf("%s %s %s\n",$1,$3,substr($5,1,length($5)-10))}' | sort | uniq -c | sort -nr
    knassery · 2012-10-16 06:39:01 0

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: