1

Hello i'm trying to unpack file Download.img from alcatel mw40 (based on qualcomm 9x07) firmware but it seems i can't do it with 7zip or mount the img file . someone already extracted the file which will give partition images like this :

appsboot_fastboot.mbn
appsboot.mbn
b.vhd
config.xml
custom_info.xml
efs.mbn
ENPRG9x07.mbn
jrdresource.ubi
mdm9607-boot.img
mdm9607-sysfs.ubi
NON-HLOS.ubi
NPRG9x07.mbn
partition.mbn
rpm.mbn
sbl1.mbn
tz.mbn

under linux the format of the file is :

file Download.img 
Download.img: dBase III DBT, version number 0, next free block index 65545, 1st item "D\343\006"

anyone can show how to unpack this file to get the list of mentioned files above thanks for help , i'm trying to learn how. file link Download.img

  • Can You help please? I have same problem I use command C:\Python27\python.exe code.py Download.img but I get error: IOError: [Errno 2] No such file or directory: "('Download.img.out/', u'NPRG9x07.mbn')wb" any one can suggest what I'm doing wrong? NPRG9x07.mbn it's one of the files but somehow is not extracting anything. Thanks in advance – Martin Dec 17 '19 at 18:45
3

The file format consists of a file table starting at 0xC8 with each entry being:

  • char filename[48]
  • uint32_t position
  • uint32_t size

Where position indicates the position in the archive and size the archived file's size.

Run code.py Download.img to extract the files and place them into Download.img.out/:

from __future__ import print_function
import os
import sys
import struct

if len(sys.argv) <= 1:
    print('usage: {} file'.format(sys.argv[0]))
    exit(1)

path = '{}.out/'.format(sys.argv[1])

if not os.path.exists(path):
    os.makedirs(path)

with open(sys.argv[1], 'rb') as f:
    i = 0
    while True:
        f.seek(0xC8 + i*0x50)
        name = f.read(0x48).decode('ascii').split('\x00')[0]
        if (len(name) == 0): break
        if struct.calcsize('II') == 0x08:
            v = struct.unpack('II', f.read(0x08))
        elif struct.calcsize('LL') == 0x08:
            v = struct.unpack('LL', f.read(0x08))
        else:
            print("Unsupported platform")
            exit(1)
        f.seek(v[0])
        out = open('{}{}'.format((path, name), 'wb'))
        out.write(f.read(v[1]))
        out.close()
        i += 1
    f.close()
| improve this answer | |
  • Hi Thanks for your answer , i'm getting this error : python code.py Download.img Traceback (most recent call last): File "code.py", line 20, in <module> v = struct.unpack('LL', f.read(0x08)) struct.error: unpack requires a string argument of length 16 – coolirc Jul 27 '19 at 10:13
  • also if i add a print(f) right after name = ... and after v = struct.unpack i get same value : the output of print(f) is same twice <open file 'Download.img', mode 'rb' at 0x7fda9c519780> <open file 'Download.img', mode 'rb' at 0x7fda9c519780> – coolirc Jul 27 '19 at 15:46
  • Thanks actually i tried the script on a windows machine with python version 2.7 and this script actually worked as expected , i don't know why it did not work on linux ubuntu machine , maybe the python version is not compatible i'll look for it later . thanks – coolirc Jul 27 '19 at 19:24
  • Doesn't work because of parenthesis in the out=open. Here is the good one : out = open('{}{}'.format(path, name), 'wb') – RoyalPanda Feb 3 at 22:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.