http://fritschy.de
cat /dev/kmem

Fixes for bad smalling code...

...actually it still smells bad, but I fixed the broken [int]sudoku awk thing. Have fun.

Graphing of iptables firewalls

Recently I found this [ext]page on how an iptables firewall could be visualized using the [ext]graphviz package. I did this thing on my own too, it is kind of different in it's details, and I found it pretty interesting to anylize simpler firewalls (just seeing the structure is pretty insightful).
 img[gfx/ipt2dot.png]
Here is some more information on this thing:
  • chains w/o policy, i.e. user-defined ones will have a return policy
  • line width is the amount of data gone through that rule/policy, it is scale logarithmically, since there are some rules which have pretty much no traffic, but others get the bulk of data. Also, the scale is fixed to a maximum width, which can be specified on the command line
  • dashed lines are ones which were not yet hit by any traffic
  • built-in targets are 'end states' and displayed as ellipses
  • non referenced chains will not be plotted
As noted above some behavior is configurable through some command line switches. See the "-h" switch and the README file inside the package.
usage
sudo python ipt2dot.py -c | tee filter.dot dot -Tpng -ofilter.png filter.dot
Though this works fine, i suggest to save dot output to svg and use e.g. [ext]inkscape to export a beautiful png ;).

schniff fixes and a dumb sudoku solver

After reading some of my code, in particular schniff.c. I found some potential bugs and misbehavior (according to the programs help). Those are fixed now.
Additionally, rough dns decoding, exact-string and extended-regex matching are implemented. As before, all filters are ANDed together ;). See [int]schniff.c for code.
About sudoku; well, some weeks ago, notably before the last exams ;) I played with depth-first searching and wrote solvers for sudoku and the [ext]n-queens Problem. There's not really much to say about it. See [int]t-sudoku.cpp for an insane templated implementation, and [int]sudoku.awk for the backtracking sudoku solver in the AWK scripting language.

dumb XML parser

I found it interesting how could an XML parser be coded using c++ and stl. It took me some hours of work and later refinements took even more hours, that's evolution ;).
The parser itself, as mentioned, is dumb. Dumb in this context means, regarding anti-features:
  • does not know about charsets
  • does not know anything about XML Processing Instructions
  • does not handle any doctype
  • is kind of slow... I think
  • not portable and
  • not standard
  • UGLY UGLY code
and features:
  • handles strings or files through iostreams/sstreams
  • parses whole document and builds document tree
  • simplistic, the structure is as simple as it is dumb ;)
  • output a tree-like thing or...
  • output an xml document
Throughout all the XML documents I have around here I did not found one that my parser(lein) failed... (those documents are written by my self or generated through self written xslt ;o))
I think that's much info... for some 480 lines of code... I did not made a tarball, it is basically one files containing a simple introductory comment (which tells you how to compile - using a modestly recent gnu compiler).
usage
./xmlparse [files...]
I tested it on a solaris express box i have around and linux width g++ 4.0 or 4.1 (solaris has a gcc 3.4)

newer, better schniff

I experienced those hangings when using schniff - hey, I firstly even didn't knew why it was hanging (the first 1/100th second I guess)... but then, it came to my mind that it is just waiting for some packets to arrive!!! What discovery - well it didn't took long to fix this with select(2) - one of my favourite system calls.
And just before I forget about it another time - I did a simplistic (read: not completed!) dns decoder... it does read flags and decodes the name someone's asking - but that's merely all.
nevertheless, I hope somebody enjoys my small [int]tool.

venom, an arp poisoning tool - and backup.sh

Venom is a smallish arp poisoning tool that came out of one of the network programming assignments. I found it quite usable, so I decided to publish it here.
Currently I am attending a network programming course. The assignment for next month is a small arp poisoning tool base upon [ext]libnet 1.1. It's kind of early for the code to be finished, fun I had fun doing it, and learned to appreciate libnet ;).
My tool is a bit more than the assignment requested, so here is an overview of what it does:
  • N hosts poisoning
  • automatically enable ipv4 ip-forwarding (currently only on linux through the sysctl interface)
  • a really slick spinner that uses [ext] Ken Perlin's improved noise
  • user definable arp-send delay
  • user definable spoof-hwaddress
  • for convenience output a tcpdump match for all relevant packets
The current version is [int]v0.08.
I also added my backup script that does quite a good job on securing the most important data of my server machine to another computer (which in turn will write them to dvd from time to time - ok, I am managing this manually... ;)). See it [int]here.

rm.c - a small integer op register machine

I was just learning some theory and there was a nice example of a simple register machine in the book that could do some mathematical operations on integers. I coded a small tool that does axactly that and it is quite nice running. [int]rm.c There is a sample program and a README in the source itself - just see and have fun :)

schniff.c - a smallish test network s(ch)niffer AND redo_menu.sh

I wrote this tool some weeks ago when I had trouble with my ADSL. I thought that it would be nice to see what happens on the line with a self-brew-tool. Well, that's the result of it... 1 or 2 days of coding - I don't remember ;). The tool itself is really dead simple, and straightforward coded - no magic not at all tested, but if anybody wants to see a bad example on how stuff merely works :). [int]schniff.c
The other thing - redo_menu.sh - is may way of managing my website menu. The thing consists of a script that inserts the menu from a menu-template to all html pages. It's - as usual - not good code, but I never had trouble with it. [int]redo_menu.sh

getQuote.pl

I added a small script I just wrote... it fetches irc-quotes... but look yourself: [int]getQuote.pl

c++ sources

tcprobe c sockets to c++ class wrapper and demo program doing a tcp-connect scan to a host given on the command line[int]tcprobe.cpp
microtimer class to do simple timing operations, uses gettimeofday(2) for time retrieval[int]microtimer.h[int]microtimer.cpp
strtok.cpp a c++ STLized version of strtok(3): [int]strtok.cpp.
xmlparse2.cpp My dumb xml parser: [int]link.
t-sudoku.cpp Templated depth-first-search sudoku solver --- takes an insane amount of time and memory to compile to just plain ugly cmp+jmp asm.... ;) [int]t-sudoku.cpp
matrizen Class representing 4x4 matrices and methods to perform misc calculations on them. Uses microtimer to do some basic benchmarking

c sources

rsa.c sample implementation of the RSA ecryption in c using libgmp[int]rsa.c
wipeit.c tool to securely erase files from disk - does only support wiping of regular files.[int]wipeit.c
find.c exercise in implementing a part of the unix find[int]find.c
tcprobe.c simple but fast, multiprocess tcp-connect scanner[int]tcprobe.c
schniff.c A simplistic stupid packet sniffer (knows tcp/ip/udp/arp/pppoe[int]schniff.c
rm.c A simple integer math register machine[int]rm.c
venom-0.08.tar.gz a simple arp poisoning tool: [int] tarball
tr.c a simple reimplementation of tr(1), just know of character ranges :D: [int]tr.c

python sources

rsa.py sample implementation of the RSA encryption in python[int]rsa.py
strange.py Draw strange attractors using OpenGL. Do not expect too much, it's just grey on blue ;)[int]strange.py
ipt2dot Translate an iptables firewall to the dot graphing language.

perl sources

scale_images.pl usage: scale_images.pl -s factor [-n nameAddition] files... scales all given images by factor s and if no option -n is given renames them to e.g. file.jpg -> file_scaled.jpg note, this isn't tested very much :o) [int]scale_images.pl
getQuote.pl Small script that fetches a quote from http://bash.pilgerer.org, pareses it and prints the quote number and the quote itself... :)[int]getQuote.pl
inetaddr.pl From a given ipv4-address in the format address/netbits, e.g. 192.168/24 calculates all possible parameters, i.e. address, network, netmask, hostbits, netbits highip and lowip[int]inetaddr.pl
weird.pl
weird thing, same as the weird.sh
$x=($ARGV[1]or 1);print"$x\n";map{@d=split//,$x;($x, $u,$w)=("",0,$d[0]);map{$w==$_ or$x.="$u$w",$u=0;++$ u;$w=$_}@d;$x.="$u$w";print"$x\n"}1..($ARGV[0]or 9);
create_batch.pl Creates an sftp-batch file of all changed files in the directory tree ./. I coded this thingy to upload only changed files to my webspace - hey, this is a great advantage when having only an isdn/modem dial-in line.[int]create_batch.pl

shell sources

weird.sh weird.sh based on a fortune printing out some lines... :)[int]weird.sh
redo_menu.sh Menu managing for my simple website[int]redo_menu.sh
backup.sh The backup script I am using at the moment, [int]backup.sh

asm sources

rsa.asm small RSA implementation. Note: this is only the idea of the RSA algorithm - nothing more. That is, an rsa with only really small numbers - practically unusable ;)[int]rsa.asm
mcat.asm mmapped mini cat in assembler. It maps the whole file to memory, which might be a problem for really large files ;). [int]mcat.asm

awk sources

sudoku.awk Depth-first search to find all solutions to a given sudoku puzzle in AWK. [int]sudoku.awk. Update: This code was updated on [int]2008-03-25.