Firmware-mod-kit Extract ilegal image after build.

Started by fazzianeric, January 20, 2025, 07:27:40 AM

Previous topic - Next topic

fazzianeric

Greetings, i've been spending time on this a while now, i'm trying to create something like an stock firmware for an router for my ISP use. And for this I used many tools to extract and recompile de .bin file, I succeded on extracting, altering the files I needed but when i recompile inevitably the checksumd5 alters and the router doesn't accept the firmware, everything I did till here was with regular tools like Binwalk, unsquashfs and mksquashfs and I decided to give it a try with the mod-kit, but then I saw it is more linke a script that uses the very same tools i've been using so far, the main issue here is that when the image is the checksum canges and I know it is very hard to avoid this, but the router checks this information and I don't know the parameter that it uses to reconize an legal firmware from an "ilegal". So I guess the question is, is there a way to do this without changing the checksum of it?


damey

You're tackling an impressive challenge! Modifying and repackaging router firmware, especially for ISP use, requires deep technical knowledge of file structures, checksum validation, and security mechanisms. You've already done a great job extracting, modifying, and repackaging the firmware using tools like Binwalk, unsquashfs, and mksquashfs, which is no small feat.

BradleySpencer

I'm running into the exact same problem. I can extract and modify the firmware just fine, but once it's rebuilt the checksum changes and the router refuses to accept it. I've tried the usual tools (binwalk, unsquashfs/mksquashfs, mod-kit) with the same result. Haven't figured out how the device validates a "legit" image either, so I'm stuck at the same stage.

Dustin21

#3
Quote from: fazzianeric on January 20, 2025, 07:27:40 AMGreetings, i've been spending time on this a while now, i'm trying to create something like an stock firmware for an router for my ISP use. And for this I used many tools to extract and recompile de .bin file, I succeded on extracting, altering the files I needed but when i recompile inevitably the checksumd5 alters and the router doesn't accept the firmware, everything I did till here was with regular tools like Binwalk, unsquashfs and mksquashfs and I decided to give it a try with the mod-kit, but then I saw it is more linke a script that uses the very same tools i've been using so far, the main issue here is that when the image is the checksum canges and I know it is very hard to avoid this, but the router checks this information and I don't know the parameter that it uses to reconize an legal firmware from an "ilegal". So I guess the question is, is there a way to do this without changing the checksum of it?
 
It is impossible to modify a file's content and keep the same MD5 checksum.
You are fixing the wrong problem. The router isn't rejecting the file because the checksum changed; it is rejecting it because the Header at the start of the file still claims the old checksum is the correct one.
You do not need to fake the hash. You need to recalculate the new hash and write it into the firmware header so they match.

amongusfree

#4
When you repack the firmware, this checksum must be recalculated and written back into the header.