FORUMS
Remove All Ads from XDA

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

5,154 posts
Thanks Meter: 7,562
 
By Ricky Divjakovski, Recognized Developer / Recognized Contributor on 20th January 2019, 03:23 PM
Post Reply Email Thread
28th February 2019, 07:23 PM |#21  
Ricky Divjakovski's Avatar
OP Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 7,562
 
Donate to Me
More
Quote:
Originally Posted by DragonFire1024

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
 
 
4th March 2019, 12:51 AM |#22  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Ricky Divjakovski

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
4th March 2019, 04:21 AM |#23  
Ricky Divjakovski's Avatar
OP Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 7,562
 
Donate to Me
More
Quote:
Originally Posted by Nightmare_MYS

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
4th March 2019, 04:59 AM |#24  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Ricky Divjakovski

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
4th March 2019, 10:29 AM |#25  
Ricky Divjakovski's Avatar
OP Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 7,562
 
Donate to Me
More
Quote:
Originally Posted by Nightmare_MYS

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
5th March 2019, 10:36 AM |#26  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Ricky Divjakovski

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
5th March 2019, 01:48 PM |#27  
Ricky Divjakovski's Avatar
OP Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 7,562
 
Donate to Me
More
Quote:
Originally Posted by Nightmare_MYS

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
12th March 2019, 12:00 PM |#28  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Ricky Divjakovski

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

https://drive.google.com/open?id=1oi...vP2O7oHMBLWLBD
23rd April 2019, 08:14 AM |#29  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Nightmare_MYS

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?
28th April 2019, 06:00 PM |#30  
Senior Member
Villavicencio
Thanks Meter: 969
 
More
Quote:
Originally Posted by Ricky Divjakovski

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/is...ment-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()
1st May 2019, 12:38 PM |#31  
Ricky Divjakovski's Avatar
OP Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 7,562
 
Donate to Me
More
Quote:
Originally Posted by JamFlux

Hi friend.
i found the .py code:
https://github.com/cubinator/ext4/is...ment-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
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes