Live data from Hacker News

Tcpdump Examples

hackertarget.com

31–40 of 41 posts

Re: Tcpdump Examples

#31

Earlier quoted context omitted.

You are doing it wrong if you are "reading through a long man page".

What is the „correct“ way? (real question, I am curious)

Might I also suggest apropose.

> https://en.m.wikipedia.org/wiki/Apropos_(Unix)

Also, of course see:

> http://www.man7.org/linux/man-pages/man1/apropos.1.html

Re: Tcpdump Examples

#32
post #25

tshark is supposed to be a tcpdump alternative but it seems tcpdump is still dominant on the command line these days.

tshark always hogs my RAM and eventually crashes on > 4GB pcaps. I'd love to have a solution for this.

Re: Tcpdump Examples

#33

Earlier quoted context omitted.

Lots of tools can do this. I use mitmproxy personally. You can easily customize it by using it as a python library.

Looks like this requires me to redirect all traffic through a proxy server. This sounds very different from what I want to do. I don't want to change the data path in any way. I just want to listen in.

If you've already terminated SSL, you can do this easily by using iptables nflog rule to duplicate traffic and send it to mitmproxy. Or you can setup a transparent proxy (but sounds like that violates your requirement). Either way, if SSL is not terminated you're not going to be able to do much.

Re: Tcpdump Examples

#34
post #32
post #25

tshark is supposed to be a tcpdump alternative but it seems tcpdump is still dominant on the command line these days.

tshark always hogs my RAM and eventually crashes on > 4GB pcaps. I'd love to have a solution for this.

Try dumpcap [0], also part of the Wireshark suite. It's the back-end engine used by the Wireshark GUI as well as tshark. tshark tracks state for streams the same way the GUI will and eats your RAM, whereas dumpcap is a dumb siphon (with filtering).

0: https://www.wireshark.org/docs/man-pages/dumpcap.html

Re: Tcpdump Examples

#35
I am always amazed at how many people have heard of tcpdump but how few seem to have heard of tcpflow

https://linux.die.net/man/1/tcpflow

If you are looking to do TCP level protocol analysis it is one of the simplest and easiest linux command line tools out there.

It's biggest strength is that it can take a payload split over multiple packets and spit it out as a file with the whole payload

Re: Tcpdump Examples

#36
post #19

Earlier quoted context omitted.

I have always had to use -nn to not translate ports. If what you say is true, it must be recent.

I've always used -nn (or -n -n), it's really annoying - usually I want to resolve IPs, but not ports.

Really annoying, in the common case you don't want /etc/services names since they're always wrong for the ephemeral >1024 client side port. Also, not to be confused with `lsof -n -P`!

Re: Tcpdump Examples

#37

I use tcpdump continuously to analyse multiple RTP feeds coming in to our edge network. Found all sorts of issues with it, including packet reordering in Cisco and mikrotik routers (shouldn't be a problem with rtp - but tell that to ateme decoders), actual packet loss on juniper srx, and of course minor outages on international and even local links on the order of 100-200ms of loss. Packet stream is dumped into some…

Any links to something similar, sounds really interesting.

BTW I really recommend unbuffer from expect, if you are using tcpdump and pipes.

Re: Tcpdump Examples

#38
NetEng here, I'm usually troubleshooting lower layer issues (Ethernet, MPLS, IP) than HTTP however, tcpdump is one of my go-to tools every time.

If anyone is interested I've made some notes here: https://null.53bits.co.uk/index.php?page=tcpdump-notes

For example, imagine spanning/mirroring a 10G backbone link, how many people are pinging 8.8.8.8 all the time. I can ping with a specific DSCP value set to isolate my pings from anyone elses, looking into the reported issue of 8.8.8.8 latency, then apply a filter to tcpdump on my mirrored port that matches ICMP traffic to a specific IP, with a specific DSCP value, inside specific L3 VPN (specific MPLS labels) etc.

sudo tcpdump -nlASX -s 65535 -vvv -i eth3 '(mpls 52634 and (ip and (ip[1] & 0xfc) >> 2 > 0x01) and host 11.22.33.44 and icmp)'

I love tcpdump's filtering capabilities.

Re: Tcpdump Examples

#39

NetEng here, I'm usually troubleshooting lower layer issues (Ethernet, MPLS, IP) than HTTP however, tcpdump is one of my go-to tools every time. If anyone is interested I've made some notes here: https://null.53bits.co.uk/index.php?page=tcpdump-notes For example, imagine spanning/mirroring a 10G backbone link, how many people are pinging 8.8.8.8 all the time. I can ping with a specific DSCP value set to isolate my pi…

You build your own huge website and don't have an About page? How could someone interested in what you're doing contact you?

Re: Tcpdump Examples

#40
post #10
post #2

Good stuff, thanks for sharing. I always forget you can do indexing into the packet itself as in tcp[((tcp[12:1] & 0xf0) >> 2):4]. Also sometimes I reach for ngrep if it is installed: https://github.com/jpr5/ngrep/blob/master/EXAMPLES.md

This is one of my favorite oneliners: sudo stdbuf -oL -eL /usr/sbin/tcpdump -A -s 10240 \ "tcp port 4080 and (((ip[2:2] - ((ip[0]&0xf) >2)) != 0)" | \ grep -a --line-buffered ".+(GET |HTTP\/|POST )|^[A-Za-z0-9-]+: " | \ perl -nle 'BEGIN{$|=1} { s/.*?(GET |HTTP\/[0-9.]* |POST )/\n$1/g; print }'

fyi you should be able to use tcpdump -l instead of calling stdbuf.
Post reply on HN