Help with Firmware .bin file

Doubts, help and support about QuickBMS and other game research tools
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Help with Firmware .bin file

Post by ye_sansa »

Hi guys, I would like to modify my car's firmware.
I just want to modify the GPS voice instructions for my car, changing a .txt file where I think there are all the commands from where the TTS read all the voice directions.
OK. Inside the firmware files, there are a lot of .bin files, renaming them to .tar.gz I can see what is inside of most of them and I have found in one of them a .txt file what seem to be all the voice directions. So far so good.

That doesn't seem to me the right way to unpack a .bin file and later on I don't know how to repack it again. I have a research on the internet and I have found your great tool to unpack and repack files.

Now my problem is to find a proper script to use with quickbms. I have check with HxD editor and the first lines are like this
1F 8B 08 00 00 00 00 00 04 00 EC BD
Which after a little research again it seems to be a gzip file, which makes sense that changing the extension to .tar.gz I am able to see the content
I have tried to use this script from your web http://aluigi.altervista.org/bms/_gzip.bms but it doesn't do anything. It only copies my .bin file to the output folder.
Any idea how could I unpack and repack this .bin file?

If you guys need any more info, please just ask!!!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Help with Firmware .bin file

Post by aluigi »

That pattern is for sure a gzip header with 2 bytes of deflate compressed data.
It's strange that the gzip decompressor in quickbms gives an error, upload the file and I will check what's wrong.
Maybe it's a fake header, don't know.
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Re: Help with Firmware .bin file

Post by ye_sansa »

It doesn't give me an error exactly, quickbms simply copy the input file into the output folder. but the program doesn't decompress the .bin file

Please have a look at the file attached.

As I said if I rename the .bin file to .tar.gz I can open an see the content of the file, but It doesn't seem to me the proper way to unpack the file, and later on I wouldn't know how to repack the file again.
If I could do it with your program if think it would be perfect
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Help with Firmware .bin file

Post by aluigi »

Honestly here the script perfectly decompresses the bin, and yes the bin is a tgz indeed and you can clearly extract all its files without any problem.
So you don't need a script, extract the tgz and re-tgz it again when you have finished your editing by using tar.
They are also known file formats like shared libraries, pvr and so on.

Am I missing something or what? :)

*edit* ah if you are on Windows tar is available on cygwin but I guess many archiving software like 7-zip support the creation of tar, for gzipping it you can use gzip or a script like "comtype gzip_compress ; get SIZE asize ; clog output.bin 0 SIZE SIZE"
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Re: Help with Firmware .bin file

Post by ye_sansa »

I don't know why it worked for you but not for me with quickbms. I will try again.
Which script did you use?

I can try to do it on Ubuntu on VMWare or with the installation disc
Wichi one would the full command to repack using tar? I don't know too much about Linux. But at the end of the process I will have a .tar file. Can I just rename it to .bin?

Thanks so much for your patience!!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Help with Firmware .bin file

Post by aluigi »

The same _gzip.bms you used, the resulting file is over 10Mb while the original is less than 4Mb.

Anyway do the following.
Rename sd_dir.bin as sd_dir.bin.tgz
Open sd_dir.bin.tgz with 7-zip (I suggest 7-zip simply because it's open source and quite diffused, maybe you already have it, any other tool is ok) or use this script.
Extract the whole content in a new folder, they are about 432 files.
Check and edit the files you desire.
Now reuse 7-zip to create a tar archive, probably you can do it just by selecting the whole content of the folder (5 folders in your case) and selecting "7-zip->Add to archive", then select "tar" as archive format.
Then use the following script on the generated tar file:

Code: Select all

comtype gzip_compress
get SIZE asize
clog sd_dir.bin 0 SIZE SIZE
That's all.
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Re: Help with Firmware .bin file

Post by ye_sansa »

Thank you SO SO much mate.
But you are gonna kill me

I understand everything, rename the file, extract the content, edit it and recompress again... I have no problem with that
and I guess that the final script that you have written is to equal the sizes of both files because one of them is about 4mb and the edited one is about 10mb.

But how can I use that script? I have to create a bms file and use it with quickbms.
This would be the command? > quickbms c:\yourscrpt.bms c:\fileafterediting.bin c:\final\sd_dir.bin

I am going to check the script that you have just sent me, try to edit it with the final script and save it and try to use it with quickbms

Thank you SO SO much and pardon me for my stubbornness
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Re: Help with Firmware .bin file

Post by ye_sansa »

I have done it but the final file is not exactly the same size as the original one. but It might work

I don't want to take advantage of you mate, but you could help me with another related thing...
NOw I have to check and change the crc to make a .bin valid for the firmwae, in order to avoid errors at the flashing time.
next to the .bin file there is another file with the same name but with the extension .bin.inf which contains the following data
CRC32: -1944217546
SIZE: 10638006
SIZE_1: 10923008
SIZE_2: 11333632
SIZE_4: 12124160
SIZE_8: 13762560
SIZE_16: 17121280
SIZE_32: 23986176

crc32 value I will have to edit it with the new crc value. But, what are all of these size values? and how can I figure out the new values ?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Help with Firmware .bin file

Post by aluigi »

Regarding the script, even if you already solved it, it's just a text file so create a new text file, copy&paste those 3 lines and that's all. You don't even need to rename the txt file as bms.
Then you can launch quickbms with double-click or using it from the command-line as you did.
The alternative is using gzip, I tought that a quickbms script would have been easier, sorry :)

I'm not sure about what are those "SIZE" fields refer to because they don't match the size of sd_dir.bin or those of the files in it or the uncompressed sd_dir.bin or anything else.

Instead CRC32 matches and it's just the classic crc (0x77073096 polynomial) of sd_dir.bin, you can calculate it with hashcalc or any other checksum calculator existent.
Then convert the hex crc32 into decimal
ye_sansa
Posts: 6
Joined: Sun Feb 04, 2018 12:04 pm

Re: Help with Firmware .bin file

Post by ye_sansa »

Thank you SO much Aluigi. I do appreciate it.

I already did all the script thing, I even renamed it as .bms to use it (now I know that I can even use that script with a .txt file)

The only thing is that the file sizes don't match. Don't know why I thought that at the end the files sizes would match. but it is OK it is not a big deal

Thank you again!!!
-VASKO-
Posts: 4
Joined: Thu Dec 20, 2018 4:50 pm

Re: Help with Firmware .bin file

Post by -VASKO- »

Friends, please help me decipher the firmware for the ancient gadget Alcatel Pixi. The attached scatter was downloaded through the official Mobile Upgrade S utility, but after that the upgrade process was not launched. Usually, the scatter has a text format and contains a description of the firmware structure, but in this case it seems to be packed or encrypted by some unknown algorithm. If there are people here who have enough experience in such matters, I would be very grateful for any information and assistance. Thanks a lot!
Last edited by -VASKO- on Sat Jan 12, 2019 9:10 am, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Help with Firmware .bin file

Post by aluigi »

@-VASKO-
I guess you have to open a new topic in the Game Archive section.
Anyway there is lack of reverse engineers who can do the work.