Well I'd try to just change all 5 occurrences of 192.168.7.x with some other subnet and see if it works. Or are you asking how to edit the binary config.bin file? I work on OSX so all the utilities I need are already there, so I just wrote a simple, quick little script (it should work on any Linux system as well as OSX) to make it easier (most of the code is just to provide the command line options
):
dlinkconf.sh:
code:#!/bin/bash
declare PROG=${0##*/}
declare BIN_FILE=""
declare XML_FILE=""
declare HDR_FILE=""
declare ZIP_FILE=""
declare MAGIC_NUM=""
declare -i PACK=0
declare -i UNPACK=0
declare OP=""
function usage()
{
cat << EOF
NAME:
${PROG} -- Pack/unpack a DLink router config.xml file to/from a config.bin file.
SYNOPSIS:
${PROG} -{m|h|x} <BinFilePath>
${PROG} -p <XmlFilePath> -M <Magicnumber> -H <HeaderFilePath> -b <BinFilePath>
DESCRIPTION:
Extracts either the magic number, header or embedded xml config file to stdout.
Compresses a xml file and packs it into a bin file using the supplied magic number
and header.
OPTIONS:
Extract:
-m <BinFilePath>
Extract magic number from bin file.
Example: '-m config.bin'
Will output the 32-bit magic number in hexadecimal.
-h <BinFilePath>
Extract header from bin file.
Example: '-h config.bin > header.txt'
Will output the header, converting nulls to newlines.
-x <BinFilePath>
Extract xml from bin file.
Example: '-x config.bin > config.xml'
Will decompress and output the embedded gzip archive.
Pack:
-p <XmlFilePath>
Gzip and pack the xml file using the supplied magic number and header.
-M <MagicNumber>
The magic number to use for the bin file.
-H <HeaderFilePath>
Path to the header file to insert into the bin file
-b <BinFilePath>
Path to the bin file to create.
Example: '-p config.xml -M 5ea3a417 -H header.txt -b config.bin'
Will create config.gz and pack it into config.bin.
EOF
}
function get_magic()
{
xxd -l 4 -p ${BIN_FILE}
}
function get_hdr()
{
local -i hdr_len=$((0x$(xxd -s 4 -l 4 -p ${BIN_FILE})))
dd ibs=1 skip=28 count=${hdr_len} if=${BIN_FILE} 2>/dev/null | tr '\0' '\n'
}
function get_xml()
{
local -i hdr_len=$((0x$(xxd -s 4 -l 4 -p ${BIN_FILE})))
local -i z_off=28+${hdr_len}
dd ibs=1 skip=${z_off} if=${BIN_FILE} 2>/dev/null | zcat
}
function pack_xml()
{
ZIP_FILE="${XML_FILE}.gz"
local -i hdr_len=$(ls -nld "${HDR_FILE}" | awk '{print $5}')
local hdr_lenx=$(printf "%08x" ${hdr_len})
echo "Hdr size: $hdr_len (0x$hdr_lenx)"
echo "Creating $ZIP_FILE..."
cat ${XML_FILE} | gzip -c > ${ZIP_FILE}
local -i zip_len=$(ls -nld "${ZIP_FILE}" | awk '{print $5}')
local zip_lenx=$(printf "%08x" ${zip_len})
echo "Zip size: $zip_len (0x$zip_lenx)"
local crc=$(md5 -q ${ZIP_FILE}) # crc=$(openssl dgst ${ZIP_FILE} | awk {'print $2'})
echo "Zip MD5: $crc"
echo "Creating $BIN_FILE..."
echo "0: $MAGIC_NUM" | xxd -r > ${BIN_FILE}
echo "4: $hdr_lenx" | xxd -r - ${BIN_FILE}
echo "8: $zip_lenx" | xxd -r - ${BIN_FILE}
echo "C: $crc" | xxd -r - ${BIN_FILE}
cat ${HDR_FILE} | tr '\n' '\0' | dd ibs=4 2>/dev/null >> ${BIN_FILE} #conv=sync
cat ${ZIP_FILE} >> ${BIN_FILE}
}
# Main
while getopts :m:h:x:p:M:H:b: option; do
case ${option} in
m)
UNPACK=1
OP=${option}
BIN_FILE="$OPTARG"
;;
h)
UNPACK=1
OP=${option}
BIN_FILE="$OPTARG"
;;
x)
UNPACK=1
OP=${option}
BIN_FILE="$OPTARG"
;;
p)
PACK=1
XML_FILE="$OPTARG"
;;
M) MAGIC_NUM="$OPTARG" ;;
H) HDR_FILE="$OPTARG" ;;
b) BIN_FILE="$OPTARG" ;;
esac
done
if [ $UNPACK == 1 ]; then
if [ -z "$BIN_FILE" ]; then
echo "Error: You must specify the bin file."
usage
exit 1
fi
case ${OP} in
m) get_magic ;;
h) get_hdr ;;
x) get_xml ;;
esac
exit 0
elif [ $PACK == 1 ]; then
if [ -z "$XML_FILE" ]; then
echo "Error: You must specify the xml file."
usage
exit 1
fi
if [ -z "$MAGIC_NUM" ]; then
echo "Error: You must specify the magic number."
usage
exit 1
fi
if [ -z "$HDR_FILE" ]; then
echo "Error: You must specify the header file."
usage
exit 1
fi
if [ -z "$BIN_FILE" ]; then
echo "Error: You must specify the bin file."
usage
exit 1
fi
pack_xml
exit 0
fi
usage
exit 1
/end code