My hacking project over the holiday is a network analyzer app for Mac OS X, which is similar in style and function to Wireshark, but it is written using the Cocoa frameworks. I considered just writing a Cocoa GUI for the existing Wireshark code, but that seems a little too hard, since Wireshark looks too closely tied to GTK.
Also, Wireshark doesn’t quite function like I want it to, when it comes to privileged access: when I want to run Wireshark or Ethereal (via DarwinPorts) I usually have to run it as root, which I don’t like doing, and using X11 on OS X works, but isn’t as nice. So, what Network Analyzer does is use the Security framework on OS X to gain privilege to read the packet filter interface, then forks off a helper program that does the actual packet sniffing. This works pretty well, since you only have to authenticate as administrator when doing the capture, not when looking at a capture.
The program can now capture traffic, and load previously-captured traffic. My TODO list is:
- Implement packet decoding, and finish the UI for handling it. I’d like to support the same packet-decoder plugins that Wireshark does, but I’m not sure how easy that will be. And, I’d like it if you could write decoder plugins in Objective-C.
- Allow capture files to be saved. The App uses the NSDocument framework, so this is pretty easy; I just haven’t gotten around to it yet.
- Add sensible copy support; like, you select some packets, or parts of them, and are able to copy the raw packet data selected into the clipboard. An alternative copy command for copying hex data would be nice, too.
- Add multiple packet selection. This way you can select multiple packets, and copy them as above.
- Make a better icon, and finish the toolbar.
This has been a fun project, so far. I like hacking with Xcode, because it makes so many tedious things really easy. If you are curious, check out the code. This is pre-alpha, so the functionality is pretty limited.
Update: I’ve made a binary release of the current functionality. This is not a complete program yet, but it should show the UI direction I’m working toward.