How to extract ramdisk.img - android

use ubuntu
I type file ramdisk.img and the Terminal display ramdisk.img: data,
I use cpio and get nothing extracted!
How can I extract such ramdisk.img?

It's highly possible that ramdisk.img actually is a compressed file ramdisk.cpio.gz. To extract it use this commands:
cd /Path/To/Folder/With/ramdisk.cpio.gz/File
mkdir temp_directory && cd temp_directory
gunzip -c ../ramdisk.img | cpio -idm
Check this blog post for more info: http://blog.djodjo.org/?p=536

you can mount images:
mkdir ~/img_mnt
mount -t udf filename.img ~/img_mnt -o loop

Just use p7-zip which is 7z just for POSIX.
7z e ramdisk.e RamdiskExtracted
I'm not sure about repacking and keeping metadata though.
I guess you could mount it as rw??

Related

How to unzip, unpack and convert android rootfs to ext4

Android rootfs is compressed and split into:
super.raw.00.gz, super.raw.01.gz, super.raw.03.gz, super.raw.04.gz
How to unzip, combine, unpack them to ext4 files that can be mounted ?
Steps are:
Unzip each of the multi-zip files:
gzip -d super.raw.00.gz
gzip -d super.raw.01.gz
gzip -d super.raw.02.gz
gzip -d super.raw.03.gz
Concatenate them to a single file:
cat super.raw.00 super.raw.01 super.raw.02 super.raw.03 > super.raw
Unpack the super image using lpunpack tool. Download link.
./lpunpack super.raw
Mount the image- For eg: system_a
mkdir mount_system
sudo mount -t ext4 -o loop system_a.img mount_system

How to handle .tar.md5 files

I was wondering about how to create / extract / verify .tar.md5 files. These files are used when flashing images to android devices, see here for example.
As far as I can tell the checksum is appended to the file like this:
cp file.tar file.tar.md5
md5sum file.tar >> file.tar.md5
Firstly I would like to know how to extract the file. Can I simply use tar -xf on the file.tar.md5?
How can I verify the integrity of the file? I would like to remove the last bytes (containing the checksum) from the file to obtain the original file back. I guess you would have to use a regexp to match the checksum file.tar? Is something like this implemented somewhere already?
First of all tar -xf should work since tar continues while it matches its' packing algorithm. If the file stops matching so would tar.
Also most archive managers such as 7-zip or winrar will open it if you remove the ".md5".
They might print error regarding mismatch with the end of the file, ignore it.
As for verifying the file:
print out the stored md5sum: tail -z -n 1 [File name here].tar.md5
calculate the md5sum of the tar part of the file: head -z -n -1 [File name here].tar.md5 | md5sum
What works for me with Ubuntu 19.10 is:
download single-file 4 GiB zip from sammobile com
unzip to several *.tar.md5
run the below command-line
.
for F in *.tar.md5; do echo -n "$F " &&
EXP=($(tail --lines=1 "$F")) &&
ACT=($(head --lines=-1 "$F" | md5sum)) &&
if [ ${EXP[0]} = ${ACT[0]} ]; then echo -n "md5ok " &&
tar --extract --file "$F" && echo "done"
else echo "FAIL"; fi; done &&
unlz4 --multiple --verbose *.lz4
AP_G965U1UEU3ARL1_CL14745140_QB21029084_REV01_user_low_ship_MULTI_CERT_meta.tar.md5 md5ok done
BL_G965U1UEU3ARL1_CL14745140_QB21029084_REV01_user_low_ship_MULTI_CERT.tar.md5 md5ok done
CP_G965U1UEU3ARL1_CP11407818_CL14745140_QB21029084_REV01_user_low_ship_MULTI_CERT.tar.md5 md5ok done
CSC_OMC_OYM_G965U1OYM3ARL1_CL14745140_QB21029084_REV01_user_low_ship_MULTI_CERT.tar.md5 md5ok done
HOME_CSC_OMC_OYM_G965U1OYM3ARL1_CL14745140_QB21029084_REV01_user_low_ship_MULTI_CERT.tar.md5 md5ok done
…
But we should all try to get away from bash

Rsync and ssh on android: No such file or directory

I'm trying to write an android app that backs up data from selected directory of an android device to a remote host using rsync and ssh. When I run the rsync command from adb shell as follows, it works:
rsync -rvz -e "/system/xbin/ssh -y -p 22" "/mnt/sdcard/" "rajeesh#10.0.2.2:backup/"
But my java code using Runtime.exec fails with an error that says:
Error: rsync: failed to exec /system/xbin/ssh -y -p 22: No such file or directory (2)
The code I used is as follows:
String[] commands = {
"rsync", "-rvz", "-e", "\"/system/xbin/ssh -y -p 22\"",
"\"/mnt/sdcard/\"", "\"rajeesh#10.0.2.2:backup/\""
};
Process process = Runtime.getRuntime().exec(commands);
Both rsync and ssh have been placed at /system/xbin and chmoded to 755. Tried replacing "rsync" with "/system/xbin/rsync" also but the issue remains. What would be the issue here?
Found out the issue myself.
When run directly from the shell, quotes have specific meaning and they are required here as follows:
rsync -rvz -e "ssh -y -p 22" "/path/to/src/" "/path/to/dest"
My java snippet above was trying to run the command with the quotes escaped, like "\"arg\"". But quotes not required when used outside shell. The correct usage is:
String[] commands = {
"/system/xbin/rsync", "-rvz", "-e", "/system/xbin/ssh -y -p 22",
"/mnt/sdcard", "rajeesh#10.0.2.2:backup/"
};
I'm not sure but maybe problem is that the destination path (rajeesh#10.0.2.2:backup/) is not absolute?
Also if you what to sync your files in the same device, maybe you should try to not use ssh? And do something like that:
rsync -rvz /mnt/sdcard/some_directory /backup

How to create OBB files USING jobb tool Android

My app has grown to be over 50mb, so I now need to use an expansion file. On searching I came to know that there are different files that can be used as expansion files such as zip, pdf etc. I am trying to put my data in .obb files but I don't know how to create these files and put the data in these files.
Updated
First:
I found out that jobb tool is used to create obb files. But I am confused how this $ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11 command is run.
I tried to run this ($ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11 on cmd but my cmd saying jobb is not recognise as internal or external command.
Second:
Which type of files can I put in these obb files? I am thinking layouts, drawable files?
my cmd saying jobb is not recognise as internal or external command
Add /tools to your path or instead of jobb use path/to/sdk/tools/jobb.bat
which type of files are put in these obb files
Big ones. Like drawables, sounds etc. Then, for example, you can use this code to put drawable file into ImageView:
imageView.setImageBitmap(
BitmapFactory.decodeFile(
sm.getMountedObbPath("/path/to/obb/file") +
"path/to/file/in/obb.png")
or, play sound:
mp.setDataSource(AcItem.this,
Uri.fromFile(new File(
sm.getMountedObbPath("/path/to/obb/file") +
"path/to/file/in/obb.png"));
mp.prepare();
mp.start();
As I promised, GitHub link to my obb manager class: https://github.com/uncleLem/AndroidUtils/blob/master/src/io/github/unclelem/androidutils/utils/ObbExpansionsManager.java
I hope it would help.
Just write Like this in command prompt and press enter
C:\>C:\Development\Android\adt-bundle-windows-x86-20140321\sdk\tools\jobb -d C:\
Myworkspace\ImageTargets\assets\ -o Imagetargets.obb -k globe -pn com.ib.globeap
p.activity -pv 200 -v

convert odex file to dex file

I would like to covert odex file to dex file. I already pulled framework folder from system. I tried the following command,
java -jar baksmali-2.1.2.jar -d system/framework -x temp.odex
but error was produced - error message is like below.
Error occurred while loading boot class path files. Aborting. org.jf.util.ExceptionWithContext: Cannot locate boot class path file /system/framework/core.jar
at org.jf.dexlib2.analysis.ClassPath.loadClassPathEntry(ClassPath.java:277)
at org.jf.dexlib2.analysis.ClassPath.fromClassPath(ClassPath.java:182)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:67)
at org.jf.baksmali.main.run(main.java:113)
at org.jf.baksmali.main.main(main.java:322)
I could not find "core.jar" in my android system framework folder.
As of 2017-06-09 baksmali has changed. It works like this.
java -jar baksmali-2.2.0.jar d SamsungInCallUI.odex -o SamsungInCallUI
Then assemble the dex file.
java -jar smali-2.2.0.jar ass SamsungInCallUI -o SamsungInCallUI.dex
Try this instead:
java -jar baksmali-2.1.2.jar -c boot.oat -d system/framework/arm/boot.oat -x temp.odex
The specific path to your boot.oat might be different.
Also note that baksmali doesn't yet support deodexing the N preview images.
This worked for me adb pull /system/framework/arm/boot.oat /tmp/framework/boot.oat Placing the apk and the odex file baksmali.jar -x -c boot.oat -d /tmp/framework APKname.odex -o APKname
I'm not sure that I've understood correctly your question (kindly correct me if I'm wrong), but if you are trying to convert an odex to dex, I've already replied to a similar question here: https://reverseengineering.stackexchange.com/questions/12393/reverse-engineering-android-vendor-system-apps/12406#12406
Anyway, to my knowledge you have two chooice:
Follow this guide: http://www.naldotech.com/how-to-deodex-applications-on-android-5-0-lollipop/
Or use oat2dex as pointed out by the user who commented my answer on RE stackexchange.
Good luck
This is an extension of #kakopappa's answer.
Get the latest version of baksmali and smali jar from here and put them in a folder and add this method to your .bash_profile file if you are a mac/linux user.
Get baksmali and smali jar in your computer and assign it to these variables from terminal.
BAKSMALI_JAR_PATH = ""
SMALI_JAR_PATH=""
Note : After editing the value should look something like
BAKSMALI_JAR_PATH = "/Users/rabbit/tools/baksmali-2.2.7.jar"
SMALI_JAR_PATH = "/Users/rabbit/tools/smali-2.2.7.jar"
Copy paste this script in your terminal and restart your terminal. This is a shortcut function which would get added to .bash_profile and you would get it handy.
echo "BAKSMALI_JAR_PATH="$BAKSMALI_JAR_PATH >> ~/.bash_profile
echo "SMALI_JAR_PATH="$SMALI_JAR_PATH >> ~/.bash_profile
echo >>
function odextodex() {
odex_file_name=$1
deassembled_file=${odex_file_name%.odex}
java -jar $BAKSMALI_JAR_PATH d $1 -o $deassembled_file
java -jar $SMALI_JAR_PATH ass $deassembled_file -o $deassembled_file.dex
rm -rf $deassembled_file
}
After doing this type odextodex filename.odex - you should see filename.jar file in your current directory.

Categories

Resources