Understanding the Process of Android Data Recovery
Recently I’ve tried some Android data recovery software to restore the files from my phone, but many restrictions encountered. So after figured out the internal process of this kind of program I find there’re more choices than I thought, like you can make use of those traditional data recovery software with more powerful algorithm on PC.
About device type
The method given in this article is tested with Xiaomi Mi 3, with native android 4.4 ROM provided by a Xiaomi internal tech employee.
Understand what software has done from the outside-in
Android is just a Unix-like system, so the software is just copying data under one specific mount point in a Unix-like system to PC and analyzing it with related algorithm then picking out the missing files.1
21. Copy data of specific mount point in a Unix-like system to PC
2. Analyze data and restore files.
Now it’s the problem how to achieve these two points. The difficulties are mainly focused on point 1, due to the involvement of two hardware, you should first establish physical communication channel using USB cable, and make sure your smartphone’s USB Debugging Mode is enabled. Of course you can have your two hardware in the same LAN by Wi-Fi but the data transimission speed of network is significant slower than of cable.
Then the software part, PC side needs Netcat
to download data from smartphone’s specific mount point. If you want to monitor the progress, prepare the Pipe Viewer
. For PC side, as opposed to Unix-like system, Window system should also prepare a Linux command-line environment (like Cygwin or MSYS2); For smartphone side Netcat is also needed to open a port for PC side’s Netcat. Besides, in order to confirm the mount point of /data
, mount
command should be invoked in advance to get the path of mount point, blindly follow the instructions of some online tutorials will fail to complete the mission.
Next, it’s not easy to execute the operation mentioned above on smartphone. The first one is privilege, android system should be rooted in advance; The second one is Linux tools, Busybox
should be installed to acquire Netcat; The third one is operating approach, you can install ADB
tools on PC and send commands after logged in Android shell, or directly use terminal app on smartphone.
So the reason why some online tutorials list that many requirements should be clear at a glance.
Steps
Tools preparation
- Root your smartphone.
- Install Busybox.
- Prepare command-line environment on PC.
- Download ADB tools (now Google has release ADB tools as standalone, no need to download full Android Studio).
- Put
adb.exe
,AdbWinApi.dll
andAdbWinUsbApi.dll
underPATH
. - Download
nc.exe
andpv.exe
.
Command line operation
Step 11
2$ adb kill-server
$ adb devices
This reset the ADB service, preventing interference from other existing ADB processes.
Step 21
2
3
4
5$ adb shell
(Android shell entered...)
$ mount
$ su
$ busybox nc -l -s 127.0.0.1 -p <your port number> -e dd if=<data mount path>
Be aware that you should consciously invoke mount
to figure out the path of /data
mount point, and use it in the next command.
Apart from that, you should take special care of whether you need to specify IP when using Netcat, because specifying IP MAY cause your port opened as tcp6. So in this case please open another command line window, enter Android shell and execute the command below to check port usage. If you find your port is opened as tcp6, add parameter -s 127.0.0.1
to force tcp instead of tcp6.1
$ netstat lnt
Step 3
Open another window and execute1
2adb forward tcp:<your port number> tcp:<your port number>
nc 127.0.0.1 <your port number> | pv -i 0.5 > datablock.raw
First you need to establish a port mapping from PC to Android using ADB’s forwarding function, then use Netcat to execute the data download, the target file name is datablock.raw
.
Analyze data and restore
Thanks to the extracted raw data from smartphone, now you can choose some more professional data recovery software on PC, such as R-Studio and Easy Recovery.