programming

vim as hex editor?

Yes..who would have thought?

Being a vim user, I hoped it would be able to edit hex files. I didn’t know for sure if it can do it or not so I decided to start digging into the manuals. This nice feature of vim has proven to be really important for me lately, now that I’m testing a protocol by modifying valid pcap files.
› Continue reading

Tags: , ,

Friday, May 7th, 2010 General No Comments

Combining inotify and python with pyinotify.

While working on a python project recently, I got to the point where I had to monitor a file for modifications. For example, I want to monitor an sqlite database (which is a normal file) to check if I’m the only one modifying it. Fortunately, pyinotify comes to the rescue! Unfortunately, the documentation on their website is a little outdated. Something important to be noted is that pyinotify is based on a Linux Kernel feature called inotify; this means that it’s only available under Linux.

Anyway, after several tries and failures I manage to come up with a decent implementation of a watcher class. The example I’m about to provide uses ThreadedNotifier, since my watcher is supposed to allow my GUI application to run in parallel. Also, please note that you can’t monitor the file itself, but instead you need to monitor the changes to files in a directory! This part was somehow omitted from the documentation; I wonder why.
› Continue reading

Tags: , , ,

Thursday, April 22nd, 2010 Projects No Comments

Writing Loadable Kernel Modules using netfilter hooks (in-depth HOWTO) – Part 1

Note: This article was inspired by the lack of updated documentation on how to write proper netfilter kernel modules. At the time I’m writing this article, the latest stable release was 2.6.32.8. I am also assuming you are familiar with how LKMs (Loadable Kernel Modules) work. If you are not, then you might want to check this article first: tldp.org/HOWTO/Module-HOWTO/

In this article (Part 1) I will present how to create a simple Linux kernel module that implements a netfilter hook for a generic transport protocol (not one of the usual ones).

In Part 2, I plan to connect the module to the iptables rules generated on the userspace side.
› Continue reading

Tags: , , , , , , ,

Monday, February 15th, 2010 General, Projects No Comments