Skip to content

Instantly share code, notes, and snippets.

@ziluvatar
Created January 30, 2014 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ziluvatar/8713455 to your computer and use it in GitHub Desktop.
Save ziluvatar/8713455 to your computer and use it in GitHub Desktop.
Linux command to sniff a port in console
#sudo apt-get install tcpflow
sudo tcpflow -i any -C -e port <port>
@ziluvatar
Copy link
Author

I can use this as well: tcpdump -s 0 -A 'tcp and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'

@ziluvatar
Copy link
Author

  1. To monitor HTTP traffic including request and response headers and message body:

tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

  1. To monitor HTTP traffic including request and response headers and message body from a particular source:

tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

  1. To monitor HTTP traffic including request and response headers and message body from local host to local host:

tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo

  1. To only include HTTP requests, modify “tcp port 80” to “tcp dst port 80” in above commands
  2. Capture TCP packets from local host to local host

tcpdump -i lo

Source: https://sites.google.com/site/jimmyxu101/testing/use-tcpdump-to-monitor-http-traffic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment