[8/3/2019]Updated Android IMG Tools[Upto Android 9.0]

Search This thread

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,288
7,687
28
Sydney
here is the boot.img from the Amazon Fire HD 10, 2017, firmware version update-kindle-40.6.0.5_user_605485120.bin. Thank you so much. Let me know if you need anything else. Just extract the .img from the zip.

i can confirm this works with that boot.img, split the boot.img with unpackbootimg then unpack the ramdisk with gzip and cpio
 

Nightmare_MYS

Member
Oct 29, 2018
20
0
the binaries are in the %tmp%\BIN folder

i extract all of bin when i unpacking system.img,i find that it has a make_ext4fs and ext4analyse.exe,i use this word'echo ext4analyse.exe folder>**.txt',and then the txt a little like file_contexts,and i use CMD to use make_ext4fs,use file_contexts built by Classy Kitchen,it working,i think that just need find out ext4analyse how to build a context file,maybe it is a project in github,i see Classy Kitchen thanks for a project in github which called EXT4,cubinator's project
 

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,288
7,687
28
Sydney
i extract all of bin when i unpacking system.img,i find that it has a make_ext4fs and ext4analyse.exe,i use this word'echo ext4analyse.exe folder>**.txt',and then the txt a little like file_contexts,and i use CMD to use make_ext4fs,use file_contexts built by Classy Kitchen,it working,i think that just need find out ext4analyse how to build a context file,maybe it is a project in github,i see Classy Kitchen thanks for a project in github which called EXT4,cubinator's project

im not sure, its abit un-needed though, the contexts are in etc/selinux/*file_contexts, so the point of that is almost useless
 

Nightmare_MYS

Member
Oct 29, 2018
20
0
im not sure, its abit un-needed though, the contexts are in etc/selinux/*file_contexts, so the point of that is almost useless

Classy Kitchen build context above 300kb,in etc just 28kb,i nerver use context in etc,and ext4_analyser.exe can save fs_config,make_ext4fs need that,and it have another file is busybox,maybe he use busybox grep to extract fs_config and context
 

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,288
7,687
28
Sydney
Classy Kitchen build context above 300kb,in etc just 28kb,i nerver use context in etc,and ext4_analyser.exe can save fs_config,make_ext4fs need that,and it have another file is busybox,maybe he use busybox grep to extract fs_config and context

i noticed this, pretty sure imgextractor can do the same thing, however if you do find the source code for his ext4 analyser binary do link me to it
 

Nightmare_MYS

Member
Oct 29, 2018
20
0
i noticed this, pretty sure imgextractor can do the same thing, however if you do find the source code for his ext4 analyser binary do link me to it

u need know that imgextractor can not extract after 8.0,it means so much big file was brake down,u can test it,and fs_config is incomplete,so after 8.0 i first use imgextractor extract system.img and use 7zip extract the big file,i extract all of Classy Kithen binary,https://d rive.go ogle.com/open?id=1oiwVUl d4r7u6rqsdzRvP2O7oHMBLWLBD
 

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,288
7,687
28
Sydney
u need know that imgextractor can not extract after 8.0,it means so much big file was brake down,u can test it,and fs_config is incomplete,so after 8.0 i first use imgextractor extract system.img and use 7zip extract the big file,i extract all of Classy Kithen binary,https://d rive.go ogle.com/open?id=1oiwVUl d4r7u6rqsdzRvP2O7oHMBLWLBD

Im currently using on android 9.0(AMLogic based firmware) and it seems to work fine, however i can look into the e2fsdroid on reverse engineering, also that link you sent doesnt work
 

appdroiddevelop

New member
Jul 14, 2018
4
0
u need know that imgextractor can not extract after 8.0,it means so much big file was brake down,u can test it,and fs_config is incomplete,so after 8.0 i first use imgextractor extract system.img and use 7zip extract the big file,i extract all of Classy Kithen binary,h ttps://d rive.go ogle.com/open?id=1oiwVUl d4r7u6rqsdzRvP2O7oHMBLWLBD
Hello! I ran into the problem that imgextractor fails when trying to extract the SYSTEM.img file (android 9): "Exception EOutOfMemory in module imgextractor.exe at".
I used the tools from your archive. Can you tell me what I'm doing wrong?
 

JamFlux

Senior Member
May 14, 2014
266
1,097
Villavicencio
i noticed this, pretty sure imgextractor can do the same thing, however if you do find the source code for his ext4 analyser binary do link me to it

Hi friend.
i found the .py code:
https://github.com/cubinator/ext4/issues/8#issuecomment-438177556

#!/usr/bin/env python3

import ext4
import argparse
import os
import sys

parser = argparse.ArgumentParser(description='Read <modes, symlinks, contexts and capabilities> from an ext4 image')
parser.add_argument('ext4_image', help='Path to ext4 image to process')
args = parser.parse_args()
exists = os.path.isfile(args.ext4_image)
if not exists:
print("Error: input file " f"[{args.ext4_image}]" " was not found")
sys.exit(1)

file = open(args.ext4_image, "rb")
volume = ext4.Volume(file)

def scan_dir (root_inode, root_path = ""):
for entry_name, entry_inode_idx, entry_type in root_inode.open_dir():
if entry_name == "." or entry_name == "..":
continue
entry_inode = root_inode.volume.get_inode(entry_inode_idx, entry_type)
entry_inode_path = root_path + "/" + entry_name
if entry_inode.is_dir:
scan_dir(entry_inode, entry_inode_path)
if entry_inode_path[-1] == '/':
continue
xattrs_perms = list(entry_inode.xattrs())
found_cap = False
found_con = False
if "security.capability" in f"{xattrs_perms}": found_cap = True
if "security.selinux" in f"{xattrs_perms}": found_con = True
contexts = ""
capability = ""
if found_cap:
if found_con:
if "security.five" in f"{xattrs_perms}":
capability = f"{xattrs_perms[2:3]}"
else:
capability = f"{xattrs_perms[1:2]}"
else:
capability = f"{xattrs_perms[0:1]}"
capability = capability.split(" ")[1][:-3][+2:].encode('utf-8').decode('unicode-escape').encode('ISO-8859-1')
capability = str(hex(int.from_bytes(capability[4:8] + capability[14:18], "little")))
capability = "capabilities="f"{capability}"
capability = " "f"{capability}"
if found_con:
contexts = f"{xattrs_perms[0:1]}"
contexts = f"{contexts.split( )[1].split('x00')[0][:-1][+2:]}"
contexts = " "f"{contexts}"
print(f"{entry_inode.mode_str:s}" " " f"{entry_inode_path}"f"{contexts}"f"{capability}")

scan_dir(volume.root)
file.close()
 

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,288
7,687
28
Sydney
Hi friend.
i found the .py code:
https://github.com/cubinator/ext4/issues/8#issuecomment-438177556

#!/usr/bin/env python3

import ext4
import argparse
import os
import sys

parser = argparse.ArgumentParser(description='Read <modes, symlinks, contexts and capabilities> from an ext4 image')
parser.add_argument('ext4_image', help='Path to ext4 image to process')
args = parser.parse_args()
exists = os.path.isfile(args.ext4_image)
if not exists:
print("Error: input file " f"[{args.ext4_image}]" " was not found")
sys.exit(1)

file = open(args.ext4_image, "rb")
volume = ext4.Volume(file)

def scan_dir (root_inode, root_path = ""):
for entry_name, entry_inode_idx, entry_type in root_inode.open_dir():
if entry_name == "." or entry_name == "..":
continue
entry_inode = root_inode.volume.get_inode(entry_inode_idx, entry_type)
entry_inode_path = root_path + "/" + entry_name
if entry_inode.is_dir:
scan_dir(entry_inode, entry_inode_path)
if entry_inode_path[-1] == '/':
continue
xattrs_perms = list(entry_inode.xattrs())
found_cap = False
found_con = False
if "security.capability" in f"{xattrs_perms}": found_cap = True
if "security.selinux" in f"{xattrs_perms}": found_con = True
contexts = ""
capability = ""
if found_cap:
if found_con:
if "security.five" in f"{xattrs_perms}":
capability = f"{xattrs_perms[2:3]}"
else:
capability = f"{xattrs_perms[1:2]}"
else:
capability = f"{xattrs_perms[0:1]}"
capability = capability.split(" ")[1][:-3][+2:].encode('utf-8').decode('unicode-escape').encode('ISO-8859-1')
capability = str(hex(int.from_bytes(capability[4:8] + capability[14:18], "little")))
capability = "capabilities="f"{capability}"
capability = " "f"{capability}"
if found_con:
contexts = f"{xattrs_perms[0:1]}"
contexts = f"{contexts.split( )[1].split('x00')[0][:-1][+2:]}"
contexts = " "f"{contexts}"
print(f"{entry_inode.mode_str:s}" " " f"{entry_inode_path}"f"{contexts}"f"{capability}")

scan_dir(volume.root)
file.close()

i found this but couldnt get a proper compilation of the code in the form of an executable, ill dig deeper soon, thanks for linking :)
 

Top Liked Posts