Archive for the ‘C’ Category

LMCC and Router Configs

Wednesday, October 22nd, 2008

Source code attached, see end of article.

I had to pull the password for the internet connection out of a router at work recently and stumbled upon a problem that didn’t seem to have much of a solution, the router allows you to save a binary copy of the config, but it didn’t appear to be a known format.

kosh@aerith ~ $ file config.bin
config.bin: data

So after a little digging I found a Zlib header in the file and found a resource on the internet that had a windows only decoder (which failed for me :( ) so I proceeded to figure it out for myself.

kosh@aerith ~ $ hexdump -C config.bin | head -n 2
00000000 4c 4d 4d 43 00 03 00 00 c9 1a 00 00 8d 0e 8d cb |LMMC............|
00000010 e0 a2 00 00 78 9c ed 3d 6b 73 db 38 92 9f ef 7e |....x..=ks.8...~|

You can see the Zlib style magic at the 20-byte mark (0×14, “78 9c”). I tested my theory by grabbing zpipe.c from the zlib website and using dd to decode it.

kosh@aerith ~ $ dd if=config.bin of=test.bin.Z bs=20 skip=1
342+1 records in
342+1 records out
6857 bytes (6.9 kB) copied, 0.0165227 s, 415 kB/s
kosh@aerith ~ $ ./zpipe -d < test.bin.Z
<config version="3.7.0" fsstamp="20061221093151">
....
</config>

But considering I was 5 minutes from a simple working setup, I hacked zpipe.c down and made zlmcc.c from it. I've made zlmcc.c available for anyone else that wants to deflate these files quickly.

Usual guarantee applies, if it blows up the world, not my fault. I only tested it on my system and with my single config file, using the above steps you should be able to figure it out if they change the format by a little (offset, etc)

KoshWiki - zlmcc.c

Kosh’s Sidebar – Bandwidth

Tuesday, August 2nd, 2005

I have been looking at making a load balance between my two main download links (Rikku and Vandread) since i’m doing a Debian update at the moment, and Vandread is saturated.
But Rikku is sitting there with almost no utilization. Grrr.

I sm just putting my idea out there, but I am considering searching for and modifying or writing a modification to squid to allow it to sense load from my gateways using my “remote data daemon” (how my sidebar gets those figures at the moment, they are updated every second at the server and every 20 seconds in my sidebar at the moment)

Basically squid would have to query the gateway periodically to check load and then use the link with the least load, it could probably tie in with my usage monitors and then try to avoid pushing Vandread over it is data cap (since my routed range is handled on Vandread’s link).

I have got a machine I was working on for this specifically, it just used a catch to make a host route for in use connections to the current and change the default link when it sensed load was too high on one link.

Worked ok, but it is very … nasty, especially to UDP traffic, but it was only a proxy server, so it was not too bad.

Past Tense, because I trashed the box and moved back to my original proxy when I got sick of the lack of reliability (in the box, not the OS).

Anyway, here is an image of how my sidebar looks like at the moment. Image Here