Networked printers are cool

In lieu of actual content, I give you a fake commercial:

80386 clone: $2500
Paying university tuition to teach yourself how to use the above: $20,000
Getting paid to rickroll a group of co-workers' insecure networked printers: priceless.

The downside was I lost sanity points when one of them recognized what I’d done, and started singing at me.  Remember folks, just because the printer has an ACL doesn’t mean that ACL is respected.

Suricata and pf_ring on RHEL 5.5

I wanted to evaluate Suricata in its recommended configuration, using libpcap linked against the pf_ring library.  But there are a lot of READMEs out there, a lot of them referring to older versions of pf_ring, and the pf_ring documentation itself isn’t very clear.

It took me some digging around and experimenting, but this blog post has a comment by Wil Metcalf that made it all much easier for me.

Succinctly: check out pf_ring revision 4079, then build the kernel modules, then the userland/lib stuff.  You may need to add /usr/local/lib to /etc/  I had troubles with the latest version of pf_ring on my RHEL 5.5 installation.  YMMV by this point, of course.

You may also find this post to be useful, although it still talks about patching kernel sources.

Tangentially but also useful if you’re relatively new to RHEL and kernel sources, you might find this post also to be helpful – I did, but there’s probably nothing new there for experienced RedHat admins.

Once you have pf_ring going, you’ll want to rebuild libpcap to link against pf_ring.  I used vanilla source for this, and it was no problem with a straight ./configure && make.  And now suricata:

./configure –enable-pfring –with-libpfring-libraries=/usr/local/lib –with-libpfring-includes=/usr/local/include

And that was pretty much it for me.

A snark on modern computing

From an IRC rant of mine.  I took out a few comments, but this is otherwise unredacted.  Sorry if you don’t like strong language, skip to the next post.  I don’t claim the thoughts to be particularly original, but I don’t believe I’ve expressed them here, myself, before.

< kraigu> I don’t find it interesting that we’re reinventing mainframes; I find it depressing and shittacular that we’re not just reinventing them, we’re reinventing them _poorly_
< subdriven> How would you do it differently?
< kraigu> I’d see what a 390 would cost me nowadays
< kraigu> it’s amazing to me that 30 years after the PC revolution, we’re going to be using dual and quad core workstations with no less than 2 or 4GB of RAM to run apps in the ‘cloud’
< kraigu> or even if you’re ipad-enabled, you’re still using about 500 times the amount of computing power my parents had to basically run applications in exactly the same way they did on a keypunch machine.
< kraigu> that’s it
< kraigu> I’m writing a fucking JCL interpreter app for the iphone
< kraigu> it’ll submit jobs to EC2 for you

Except I don’t want to be bothered to give Apple money to develop for a platform I don’t have, so you, Kind Reader, have my permission to steal my wondrous idea.

What the hell, it can’t be any worse than any other job dispatcher out there.

Doing pcap stuff with Ruby on a Mac

This is probably old news to anybody who’s used to Ruby on Macs, but I’m not.  I like using MacPorts when I can, so that’s where my Ruby runs from.

I went looking for pcap modules and found a bunch, but the most promising seemed to be packetfu.  It came with a caveat: “PacketFu is reported to work on OS X, assuming you can get pcaprub installed correctly.”

So the first step was to get pcaprub going.  You can get it at rubyforge, the trick is it has a README, a single C source file, and a small ruby script. It turns out the secret is to do ‘ruby extconf.rb’, which will create a Makefile for you, and you can then ‘sudo make install’.

The author of packetfu recommends sticking with sources, available here. Check them out like this: ‘svn checkout packetfu-read-only’ – I like doing this in ~/src, but your tastes may differ.  Use the pcaprub_linux directory, and again, ‘ruby extconf.rb’ followed by a make / make install.  The test script bombs out – by default it wants to use the fw0 device.  Nevertheless, I pressed on and did as suggested: ‘cd .. && sudo ruby setup.rb’ which finished with no failures.

Note that following these steps will pollute your MacPorts ruby install with files about which it knows nothing – I generally like to avoid this, but it seems like scripting languages insist on having their own packaging systems that make it not quite impossible to work with other such systems.

Then I wrote a little test script that should just count packets:


require 'packetfu'
filename = ARGV[0] || exit
count = 0
incap = PacketFu::Read.f2a(:file => filename)

incap.each do |pkt|
 p = PacketFu::Packet.parse(pkt)
 count += 1

puts "#{count} packets"

I would not recommend doing as I did and turning it loose on a 711MB pcap trace – top showed the process using 1.9GB of memory before I managed to get a responsive terminal to kill it.  It fared slightly better on a 12MB trace (a subset of the larger ones) and correctly counted 85411 packets, but still hit 265MB:

real    4m0.359s
user    3m16.012s
sys    0m1.891s

I’m a fairly-incompetent Ruby programmer, but the above seems fairly straightforward – I’m not sure I’d want to turn this parser loose on anything of any real size.  While 711MB is a pretty big trace to be parsing, 12 is pretty small.  To be fair, I had other processes running at the time, including a Windows 7 VM that was patching (unbeknownst to me) but it’s a 4GB dual core machine.  I’d been hoping to more easily pull various bits of data out of the larger file, but it looks like I’m stuck with tcpdump and tshark for now.

ETA: I had been going to post again about xtractr, but it’s not a 100% Mac/Ruby solution. It provides an interface so that I could use Mac Ruby installs to talk to an xtractr instance, but so far as I can tell, there’s no 100% Mac solution. So I’m running it on an Ubuntu box, but I won’t bother detailing how I got it going – it was pretty straightforward, although it required some work I’d already done to make gems sane on an 8.04 system.

Snow Leopard vs Macfusion

I’m a bit late to the game with this, I know, but I actually used Macfusion today for the first time since upgrading to 10.6 and was nonplussed to find that it wasn’t even *trying* to connect.
This post explains how to fix things, with the exception of stipulating that you need to kill the agent as well. It will look something like this in a process listing (ps -xw):
/Applications/ -psn_0_6
I just kill -9’d that sucker, although more gentle ways of killing it might have worked. Either way, it was insufficient for me to merely exit Macfusion.