News for hackers. Stuff that matters.
Re:A tcpdump tutorial and primer by tptacek on Friday February 28, 2014 @01:12PM (#7320415)
I. Love. Tcpdump. Once in a blue moon I'll boot up Wireshark, but it's pretty rare that there's a protocol question I need to answer that I can't answer faster with tcpdump -A.
Re:A tcpdump tutorial and primer by jswanson on Saturday March 01, 2014 @08:28AM (#7324138)
If you're on a server that doesn't have an X environment set up for wireshark, you can use tcpdump to spit to a file:

   -w     Write the raw packets to file rather than parsing and printing them out.  They can later be printed with the -r option.  Standard output is used if file is ``-''.  See pcap-savefile(5) for a description of the file format.
--

You can then open this file in wireshark on your desktop for easier analysis if you wish.

Re:A tcpdump tutorial and primer by gatehouse on Saturday March 01, 2014 @01:03PM (#7325303)
Yeah, I do this all the time also with -s0 (saves all data traffic as well). You need some kind of filter because of all the traffic, but you can see everything afterwards. Easy to use wireshark to show TCP streams reconstructed: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvFollowT... .
Re:A tcpdump tutorial and primer by est on Saturday March 01, 2014 @07:53AM (#7324077)
Hmm, how about display TCP payload only, capture SSL without ssldump, filter packets by process id?
Re:A tcpdump tutorial and primer by danielweber on Saturday March 01, 2014 @09:49AM (#7324367)
It feels like ssldump has been abandoned and is horribly out-of-date. Is anybody maintaining it these days?
Re:A tcpdump tutorial and primer by tptacek on Saturday March 01, 2014 @12:11PM (#7325064)
I use ssldump all the time; I don't think it's actively maintained, but it's not like it's broken. (The author of ssldump is one of the chairs of the TLS WG).
Re:A tcpdump tutorial and primer by danielweber on Saturday March 01, 2014 @07:58PM (#7327094)
Last time I used it (quite a few months ago) it wasn't recognizing about half the fields in the SSL negotiation. It wasn't useless, but aside from its decryption-capabilities[1] wireshark had it beat because it could recognize and parse nearly all the fields.

[1] Wireshark might have that, but I haven't checked. I like to keep diversity in the tools I use.

Re:A tcpdump tutorial and primer by coolsunglasses on Friday February 28, 2014 @06:51PM (#7322343)
tcpdump is one of my pet responses when people ask me why I still use terminal-based tooling.
Re:A tcpdump tutorial and primer by suprjami on Friday February 28, 2014 @05:49PM (#7322077)
I guess it depends what you are trying to do. As someone who uses packet captures almost every day to solve other people's problems, all I want to see is an unfiltered binary capture file on the right interface, which I'll then go thru with tshark or Wireshark.

I think learning to build effective display filters in those tools is more useful than learning to use a capture tool in complex ways.

This can apply to troubleshooting your own problems too, as you can then inspect things in your own time and gather evidence to present later, and even use a capture file to replay traffic.

Re:A tcpdump tutorial and primer by jweir on Friday February 28, 2014 @03:05PM (#7321106)
If you want to program with tcpdump check out its libary, pcap.

http://www.tcpdump.org/pcap.html

Lately I have been playing with a Go interface to it, https://github.com/miekg/pcap

Great tool, and lots of fun.

Re:A tcpdump tutorial and primer by hoggle on Friday February 28, 2014 @05:05PM (#7321867)
Also for node programmers there is https://github.com/mranney/node_pcap I remember doing some pcap C programming some years ago but node with its streaming nature and powerful js derived abstractions is just so much more satisfying to me, simply less boilerplate and tons of fun - don't fall too far down the well.. then again it's Saturday tomorrow! ;)
Re:A tcpdump tutorial and primer by codygman on Saturday March 01, 2014 @01:30AM (#7323383)
For those who want a functional(ish?) and strongly typed interface to tcpdump, hackage has the answer:

http://hackage.haskell.org/package/pcap-0.2/docs/Network-Pca...

Re:A tcpdump tutorial and primer by lightblade on Sunday March 02, 2014 @01:27PM (#7330112)
Which one came first? Tcpdump or pcap?
Re:A tcpdump tutorial and primer by Thaxll on Friday February 28, 2014 @01:56PM (#7320714)
To send tcpdump output to your local Wireshark:

ssh -c arcfour root@myserver tcpdump -nn -U -s0 -w - 'not port 22' | wireshark -k -i -

Re:A tcpdump tutorial and primer by e12e on Saturday March 01, 2014 @12:13PM (#7325074)
I'd think you'd do well to stay away from RC4 for ssh as well as SSL/TLS?
Re:A tcpdump tutorial and primer by irickt on Friday February 28, 2014 @12:06PM (#7319980)
Re:A tcpdump tutorial and primer by lightblade on Friday February 28, 2014 @02:02PM (#7320751)
Awesome! I always wanted a command-line alternative to wireshark. I learned about tcpdump about a year ago, but the amount of options is a little off putting. I'm glad this guide came along.
Re:A tcpdump tutorial and primer by MichaelGG on Friday February 28, 2014 @02:09PM (#7320788)
Command-line alternative to wireshark is tshark. tshark is much more capable, since you can use all the well-made Wireshark protocol dissectors.
Re:A tcpdump tutorial and primer by tacoman on Friday February 28, 2014 @03:05PM (#7321101)
tshark also has a fabulous ring buffer feature that lets you run captures continuously while chunking the files up into manageable sizes.

e.g. -b filesize:100000 -b files:200 -w somefile

This will make a ring buffer of 200 * 100MB files.

After typing this, I realized this may have limited use cases, but I use it almost every day.

Re:A tcpdump tutorial and primer by sgrossman on Friday February 28, 2014 @10:00PM (#7322931)
If you are on a system that doesn't have tshark, tcpdump provides the same functionality via the -C <file_size_in_MB> -W <num_files> flags.

e.g. -C 100 -W 200 -w somefile will get you the same circular ring of 200 100MB files.

Also, don't forget to add the -s 0 flag if you want to get the entire payload.

Re:A tcpdump tutorial and primer by scott_karana on Friday February 28, 2014 @04:46PM (#7321717)
It's a great ad-hoc solution for monitoring types of traffic. I've used it too. :-)
Re:A tcpdump tutorial and primer by gwu78 on Saturday March 01, 2014 @02:22PM (#7325694)
Correct me if I'm wrong, but hasn't tcpdump had several buffer overflows in the past?

Personally I prefer multilog + pflogd + some other tool to examine the pcap file.

My old favorite is nc-data -d. The entire program fits on one page.

od or xxd -c1 |cut -d: -f2 will work too.

ngrep is fussy about interface types but I use that too.

Filters for nc-data output can be written in lex, sed, awk, lua, whatever.

I've even experimented with snobol4 and spitbol on packets since the output format of nc-data is so simple.

Re:A tcpdump tutorial and primer by danielweber on Friday February 28, 2014 @02:40PM (#7320958)
Who else remembers when tcpdump kept on refusing to put a "see raw packet" option because you might use it to steal passwords?

Those were the days. Now all I can complain about is that you need root permissions on OpenBSD merely to read a capture file.

Re:A tcpdump tutorial and primer by minimax on Friday February 28, 2014 @03:31PM (#7321268)
you need root permissions on OpenBSD merely to read a capture file.

How does that even work? It seems like if you can read the file there is nothing stoping you from trying to parse its contents.

Re:A tcpdump tutorial and primer by danielweber on Friday February 28, 2014 @04:54PM (#7321775)
It's in the binary. You can bring your own /usr/sbin/tcpdump if you wish. If this seems like an incredibly low bar to you, I agree.
Re:A tcpdump tutorial and primer by joeblau on Friday February 28, 2014 @09:30PM (#7322865)
This is a great tool for getting free wi-fi if you know what you're doing and can change your MAC address.
Re:A tcpdump tutorial and primer by bananas on Friday February 28, 2014 @03:55PM (#7321427)
Just what I needed. Been writing an SSDP stack with the aid of wireshark and it's been painful. I'm on OSX so it's been a case of frigging around with XQuartz as much as anything else. tcpdump is just pleasure and power compared to wireshark.
Re:A tcpdump tutorial and primer by anth1y on Friday February 28, 2014 @02:01PM (#7320739)
I use this tutorial all the time when I'm trying to debug MTA issues.
Re:A tcpdump tutorial and primer by purple_horse on Saturday March 01, 2014 @09:59PM (#7327498)
One of my favs:

tcpdump -i int -n -w - -l -s 1500 | strings

Re:A tcpdump tutorial and primer by jacksoncage on Friday February 28, 2014 @01:40PM (#7320623)
tcpdump for the win!