LMCC and Router Configs
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)
