nelenkov / android-backup-extractor Goto Github PK
View Code? Open in Web Editor NEWAndroid backup extractor
License: Other
Android backup extractor
License: Other
README.md says "Utility to extract and repack Android backups created with adb logcat (ICS). Largely based on BackupManagerService.java from AOSP."
I think logcat => backup.
David
I get this when trying to decrypt a Android 6.0 backup from Nexus 5x
This backup is encrypted, please provide the password
Password:
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:203)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:118)
... 1 more
I tried this on a backup from a Hudl Tablet (4.4.2). The tar file produced is empty:
codecowboy@codecowboy-P5E3-Premium:~/Android/Sdk/platform-tools/android-backup-extractor$ java -jar abe.jar unpack ../backup.ab ../backup.tar "123"
Calculated MK checksum (use UTF-8: false): 4FC9F7082543089D608F6E5E6C53DC7E7FEDD41208AE863A63EF28AA5202CFB1
Checksum does not match.
Calculated MK checksum (use UTF-8: false): DD612A26A43A37294ABA86689564C5CD53740ABD42A523179B13A3A3A0D1AE40
1024 bytes written to ../backup.tar
I just made 2 ab files from Android 5.0.1 on a Nexus 9. One with -system -all -apk -shared and one with -nosystem -all -apk -shared. When using the extractor I get the following:
$ java -jar ~/src/android-backup-extractor/build/libs/abe-all.jar unpack n9_apk_shared_nosystem_all_20150815.ab <pwd>
This backup is encrypted, please provide the password
Password:
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:203)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:118)
... 1 more
I had a desktop backup password set (which is what I gave on the command line) and I had an encryption password set to the same, given interactively.
I suspect that either the 5.0 format is different than expected, or installing the bouncy castle bcprov-jdk15on-152.jar wasn't quite right...
I used ./gradlew after putting the jar in lib, and it seems to have made the right abe-all.jar... yet I get the above.
This is a great utility you've created that is working well for me on Mac OS X. However, when rebuilding the archive, you advised in the readme file to use "tar tf backup.tar | grep -F "com.package.name" >package.list" to store off the original order of the files to be used subsequently with "tar cf restore.tar -T package.list" when creating the new tar file to pack,
There is a big problem with this suggestion: tar includes subdirectory names as well as files in the package.list file! When you go to recreate the tar using that list file, all the files in the subdirectories get added multiple times! (once for the directory listings, and again for the file listings). Talk about bloat! Not to mention the exact file ordering is not preserved for the subdirectories because they are added for the subdirectory listing first. There isn't an easy way to fix this, the subdirectories need to be filtered out of the package.list somehow and tar doesn't provide such an option, for now I'm using a bash shell script to repair the list.
This is what I get when I try to unpack my big, unencrypted backup.
While changing totalRead to long from int solves the overflow, InflaterInputStream (last version of jre7) seems to crash on so big file, after reading about 3.946.000.000 bytes (output tar is about the same lenght at that moment).
The biggest single file into the archive is less the 700 MB.
[...]
-348804600 bytes read
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: java.util.zip.ZipException: invalid stored block lengths
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:179)
at org.nick.abe.Main.main(Main.java:35)
... 5 more
Caused by: java.util.zip.ZipException: invalid stored block lengths
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:160)
... 6 more
Hi,
I got an exception from this line because the versionStr
is ""
. What could this mean?
Thank you!
Tried this on a Nexus 6 running 5.1. Received an exception regarding illegal key size. Will try to make some time this week to look at the code and format further, but figured I'd report it up.
$ head b.ab
ANDROID BACKUP
3
1
AES-256
...
java -jar build/libs/abe-all.jar unpack ../b.ab ../b.tar 12345
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:203)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1029)
at javax.crypto.Cipher.implInit(Cipher.java:795)
at javax.crypto.Cipher.chooseProvider(Cipher.java:854)
at javax.crypto.Cipher.init(Cipher.java:1374)
at javax.crypto.Cipher.init(Cipher.java:1308)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:118)
... 1 more
I created a non-encrypted backup with $ adb backup -apk -shared -all -system
on LG V20 (Android 7.0)
but it fails to convert it to tar
$ abe unpack backup.ab backup.tar
0% 1% 2% 3% 4% 5% 6% 7% 8% 9% 10% 11% 12% 13% 14% 15% 16% 17% 18% 19% 20% 21% 22% 23% 24% 25% 26% 27% Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: invalid block type
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:233)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.util.zip.ZipException: invalid block type
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:205)
... 1 more
I tried to extract calendar data from a full backup and restore it to my device.
It's a Google/LG Nexus 4 running CyanogenMod 12.1, Android 5.1.1.
It successfully decrypts it, but then apparently fails to extract it.
# ls -lah calendar_data.tar
-rw-r--r-- 1 root staff 1.5M Nov 30 20:27 calendar_data.tar
# tar -tf calendar_data.tar
apps/
apps/com.android.calendar/
apps/com.android.providers.calendar/
apps/org.sufficientlysecure.localcalendar/
apps/org.sufficientlysecure.localcalendar/_manifest
apps/org.sufficientlysecure.localcalendar/a/
apps/org.sufficientlysecure.localcalendar/a/org.sufficientlysecure.localcalendar-2.apk
apps/com.android.providers.calendar/_manifest
apps/com.android.providers.calendar/db/
apps/com.android.providers.calendar/sp/
apps/com.android.providers.calendar/sp/CalendarUpgradeReceiver.xml
apps/com.android.providers.calendar/db/calendar.db
apps/com.android.providers.calendar/db/calendar.db-journal
apps/com.android.calendar/_manifest
apps/com.android.calendar/r/
apps/com.android.calendar/sp/
apps/com.android.calendar/sp/_has_set_default_values.xml
apps/com.android.calendar/sp/calendar_alerts.xml
apps/com.android.calendar/sp/com.android.calendar_preferences.xml
apps/com.android.calendar/sp/com.android.calendar_preferences_no_backup.xml
apps/com.android.calendar/r/app_webview/
apps/com.android.calendar/r/app_webview/Web Data
apps/com.android.calendar/r/app_webview/Web Data-journal
# java -jar abe-all.jar pack calendar_data.{tar,ab} $password
1624064 bytes written to calendar_data.ab.
# head -4 calendar_data.ab
ANDROID BACKUP
1
1
AES-256
# adb restore calendar_data.ab
Now unlock your device and confirm the restore operation.
#
Logcat:
D/AndroidRuntime(10630): Calling main entry com.android.commands.bu.Backup
D/bu (10630): Beginning: restore
I/BackupManagerService( 2085): Beginning full restore...
D/BackupManagerService( 2085): Starting restore confirmation UI, token=954785733
W/ContextImpl( 2085): Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:1266 com.android.server.backup.BackupManagerService.startConfirmationUi:8602 com.android.server.backup.BackupManagerService.fullRestore:8569 com.android.server.backup.Trampoline.fullRestore:268 android.app.backup.IBackupManager$Stub.onTransact:243
W/ContextImpl( 2085): Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:1278 android.app.ContextImpl.startActivity:1267 com.android.server.backup.BackupManagerService.startConfirmationUi:8602 com.android.server.backup.BackupManagerService.fullRestore:8569 com.android.server.backup.Trampoline.fullRestore:268
I/ActivityManager( 2085): START u0 {act=fullrest flg=0x10000000 cmp=com.android.backupconfirm/.BackupRestoreConfirmation (has extras)} from uid 1000 on display 0
I/am_home_stack_moved( 2085): [0,0,1,1,startingNewTask]
I/am_create_task( 2085): [0,222]
I/am_create_activity( 2085): [0,181563705,222,com.android.backupconfirm/.BackupRestoreConfirmation,fullrest,NULL,NULL,276824064]
V/WindowManager( 2085): addAppToken: AppWindowToken{345ad0df token=Token{52fc37e ActivityRecord{ad27139 u0 com.android.backupconfirm/.BackupRestoreConfirmation t222}}} to stack=1 task=222 at 0
I/am_pause_activity( 2085): [0,1009361814,com.cyanogenmod.trebuchet/com.android.launcher3.Launcher]
I/am_on_paused_called( 2709): [0,com.android.launcher3.Launcher]
I/am_home_stack_moved( 2085): [0,0,1,1,startedActivity setFocusedActivity]
I/am_focused_activity( 2085): [0,com.android.backupconfirm/.BackupRestoreConfirmation]
I/am_restart_activity( 2085): [0,181563705,222,com.android.backupconfirm/.BackupRestoreConfirmation]
D/BackupManagerService( 2085): Waiting for full restore completion...
V/WindowManager( 2085): Adding window Window{3956c456 u0 Starting com.android.backupconfirm} at 3 of 9 (after Window{19daba9b u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher})
I/am_on_resume_called( 9262): [0,com.android.backupconfirm.BackupRestoreConfirmation]
V/WindowManager( 2085): Adding window Window{34fa59c4 u0 com.android.backupconfirm/com.android.backupconfirm.BackupRestoreConfirmation} at 3 of 10 (before Window{3956c456 u0 Starting com.android.backupconfirm})
I/am_activity_launch_time( 2085): [0,181563705,com.android.backupconfirm/.BackupRestoreConfirmation,138,138]
I/ActivityManager( 2085): Displayed com.android.backupconfirm/.BackupRestoreConfirmation: +138ms
I/Timeline( 9262): Timeline: Activity_idle id: android.os.BinderProxy@255d705f time:2077992
I/sf_frame_dur( 183): [com.cyanogenmod.trebuchet/com.android.launcher3.Launcher,15,0,0,0,0,0,1]
I/Timeline( 2085): Timeline: Activity_windows_visible id: ActivityRecord{ad27139 u0 com.android.backupconfirm/.BackupRestoreConfirmation t222} time:2078678
I/LatinIME( 2498): Starting input. Cursor position = 0,0
I/notification_cancel( 2085): [10007,2308,com.android.systemui,100,low_battery,-1,0,64,8,NULL]
I/LatinIME( 2498): Starting input. Cursor position = 0,0
I/notification_cancel( 2085): [10007,2308,com.android.systemui,100,low_battery,-1,0,64,8,NULL]
D/BackupManagerService( 2085): acknowledgeFullBackupOrRestore : token=954785733 allow=true
D/BackupManagerService( 2085): Sending conf message with verb 10
E/AudioTrack( 2085): AudioTrack::set : Exit
I/BackupManagerService( 2085): --- Performing full-dataset restore ---
I/BackupManagerService( 2085): Initiating bind of OBB service on com.android.server.backup.BackupManagerService$FullBackupObbConnection@78b348
W/ContextImpl( 2085): Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1798 com.android.server.backup.BackupManagerService$FullBackupObbConnection.establish:3041 com.android.server.backup.BackupManagerService$PerformAdbRestoreTask.run:5699 java.lang.Thread.run:818 <bottom of call stack>
I/BackupManagerService( 2085): OBB service connection com.android.internal.backup.IObbBackupService$Stub$Proxy@2309bbf4 connected on com.android.server.backup.BackupManagerService$FullBackupObbConnection@78b348
I/notification_cancel( 2085): [10007,2308,com.android.systemui,100,low_battery,-1,0,64,8,NULL]
I/dvm_lock_sample( 2085): [system_server,0,ReferenceQueueDaemon,8,ReferenceQueue.java,135,-,90,1]
E/BackupManagerService( 2085): Parse error in header: Illegal semantic path in
I/hexdump ( 2085): 0000 61 70 70 73 2f 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0060 00 00 00 00 30 30 30 37 35 35 20 00 30 30 30 30
I/hexdump ( 2085): 0070 30 30 20 00 30 30 30 30 30 30 20 00 30 30 30 30
I/hexdump ( 2085): 0080 30 30 30 30 30 30 30 20 31 32 36 32 37 30 32 37
I/hexdump ( 2085): 0090 31 37 30 20 30 31 32 31 32 34 00 20 35 00 00 00
I/hexdump ( 2085): 00a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 00b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 00c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 00d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 00e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 00f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0100 00 75 73 74 61 72 00 30 30 72 6f 6f 74 00 00 00
I/hexdump ( 2085): 0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0120 00 00 00 00 00 00 00 00 00 77 68 65 65 6c 00 00
I/hexdump ( 2085): 0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0140 00 00 00 00 00 00 00 00 00 30 30 30 30 30 30 20
I/hexdump ( 2085): 0150 00 30 30 30 30 30 30 20 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I/hexdump ( 2085): 01f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/BackupManagerService( 2085): io exception on restore socket read
W/BackupManagerService( 2085): java.io.IOException: Illegal semantic path in
W/BackupManagerService( 2085): at com.android.server.backup.BackupManagerService$PerformAdbRestoreTask.readTarHeaders(BackupManagerService.java:6777)
W/BackupManagerService( 2085): at com.android.server.backup.BackupManagerService$PerformAdbRestoreTask.restoreOneFile(BackupManagerService.java:5917)
W/BackupManagerService( 2085): at com.android.server.backup.BackupManagerService$PerformAdbRestoreTask.run(BackupManagerService.java:5766)
W/BackupManagerService( 2085): at java.lang.Thread.run(Thread.java:818)
I/BackupManagerService( 2085): Full restore processing complete.
D/bu (10630): Finished.
D/AndroidRuntime(10630): Shutting down VM
D/BackupManagerService( 2085): Full restore pass complete.
I/am_finish_activity( 2085): [0,181563705,222,com.android.backupconfirm/.BackupRestoreConfirmation,app-request]
I/am_home_stack_moved( 2085): [0,1,0,0,finishActivity adjustFocus]
I/wm_task_moved( 2085): [208,1,1]
I/am_home_stack_moved( 2085): [0,1,0,0,finishActivity adjustTopFocus setFocusedActivity]
I/am_focused_activity( 2085): [0,com.cyanogenmod.trebuchet/com.android.launcher3.Launcher]
W/art ( 2085): Long monitor contention event with owner method=android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplications(android.os.IBinder, int, int, int, boolean) from WindowManagerService.java:6272 waiters=0 for 1.466s
I/dvm_lock_sample( 2085): [system_server,1,android.display,1466,WindowAnimator.java,130,WindowManagerService.java,6272,100]
I/am_pause_activity( 2085): [0,181563705,com.android.backupconfirm/.BackupRestoreConfirmation]
I/am_on_paused_called( 9262): [0,com.android.backupconfirm.BackupRestoreConfirmation]
I/am_resume_activity( 2085): [0,1009361814,208,com.cyanogenmod.trebuchet/com.android.launcher3.Launcher]
I/am_on_resume_called( 2709): [0,com.android.launcher3.Launcher]
I/dvm_lock_sample( 2085): [system_server,1,Binder_1,15,WindowManagerService.java,3082,WindowAnimator.java,130,3]
I/dvm_lock_sample( 2085): [system_server,1,Binder_2,24,WindowManagerService.java,7514,-,3082,4]
I/Timeline( 2709): Timeline: Activity_idle id: android.os.BinderProxy@b1a8a3f time:2099687
W/IInputConnectionWrapper( 9262): showStatusIcon on inactive InputConnection
I/am_destroy_activity( 2085): [0,181563705,222,com.android.backupconfirm/.BackupRestoreConfirmation,finish-imm]
I/Timeline( 2085): Timeline: Activity_windows_visible id: ActivityRecord{3c29a396 u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher t208} time:2099901
I/sf_frame_dur( 183): [InputMethod,0,2,2,10,4,0,1]
I/wm_task_removed( 2085): [222,removeAppToken: last token]
I/wm_task_removed( 2085): [222,removeTask]
I/sf_frame_dur( 183): [com.android.backupconfirm/com.android.backupconfirm.BackupRestoreConfirmation,113,2,3,11,14,10,0]
The hexdump from above represents:
apps/000755 000000 000000 00000000000 12627027170 012124 5ustar00rootwheel000000 000000
Those are the first 512 bytes of the calendar_data.tar
file. root…wheel
that's the user/group owning the files in the tar archive (on my machine). I also tried using a non-root user first, but that didn't work either.
Am I missing something? Do I need to specially craft the tar archive?
I took this repository to Gitlab and configured their CI system to produce binaries (the build/libs/abe-all.jar
file produced by Gradle).
https://gitlab.com/somini/android-backup-extractor
The CI configuration is here, should be pretty simple: https://gitlab.com/somini/android-backup-extractor/blob/master/.gitlab-ci.yml
The binaries are available here: https://gitlab.com/somini/android-backup-extractor/-/jobs/artifacts/master/browse/build/libs?job=deploy
That link will always point to the latest correct build on the master
branch.
The issue is that if you use unpack xxx.ab -
then System.out
is being used (https://github.com/nelenkov/android-backup-extractor/blob/master/src/org/nick/abe/AndroidBackup.java#L310) but the progress is using System.out
as well (https://github.com/nelenkov/android-backup-extractor/blob/master/src/org/nick/abe/AndroidBackup.java#L215) which seems like a mistake since line 209 and 219 use System.err
instead.
As a result using abe xxx.ab - | tar tv
is not working for example
Hi, I tried to see the .ab file from a coolpad android 7.0 version, in vain. The ab file shows version 5.Please resolve the issue at your best.
Full backup often only work on the phone which made the backup, many vendor apps cause crashes if restored on another device/emulator.
Would it be possible to add an 'split' option, which would take an full AB file and create for each app a smaller AB just for the apps themselves?
Hi,
first let me say thanks for such a great tool! I have discovered that inside long paths filenames get cut after conversion to tar. Is there a way to avoid this?
Thank you and best regards,
Christoph
On Debian 8:
running as root, I installed Java7 and ant from the repositories, then ran:
root@d8:/usr/src/android-backup-extractor# ant -f build.xml abe
Results:
Buildfile: /usr/src/android-backup-extractor/build.xml
BUILD FAILED
Target "abe" does not exist in the project "null".
Total time: 0 seconds
build.xml looks fine. Any suggestions here?
I'm getting this while trying to extract. PLEASE HELP
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
?l?=?±ô?y: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid Magic xÄè?
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:502)
at org.nick.abe.Main.main(Main.java:128)
... 5 more
?l?=?±ô?y: java.lang.IllegalArgumentException: Invalid Magic xÄè?
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:332)
... 6 more
$ gradle
Download https://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/1.0.3/shadow-1.0.3.pom
Download https://jcenter.bintray.com/jdom/jdom/1.1/jdom-1.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm/4.1/asm-4.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/4.1/asm-parent-4.1.pom
Download https://jcenter.bintray.com/org/ow2/ow2/1.3/ow2-1.3.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-commons/4.1/asm-commons-4.1.pom
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/25/commons-parent-25.pom
Download https://jcenter.bintray.com/org/apache/apache/9/apache-9.pom
Download https://jcenter.bintray.com/org/jdom/jdom/1.1/jdom-1.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/4.1/asm-tree-4.1.pom
Download https://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/1.0.3/shadow-1.0.3.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm/4.1/asm-4.1.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-commons/4.1/asm-commons-4.1.jar
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.jar
Download https://jcenter.bintray.com/org/jdom/jdom/1.1/jdom-1.1.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/4.1/asm-tree-4.1.jar
FAILURE: Build failed with an exception.
Where:
Build file 'C:\temp\android-backup-extractor-master\build.gradle' line: 9
What went wrong:
A problem occurred evaluating root project 'android-backup-extractor-master'.
Failed to apply plugin [class 'com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin']
No signature of method: org.gradle.internal.classloader.FilteringClassLoader.allowPackage() is applicable for argument types: (java.lang.String) values: [org.apache.tools.zip]
BUILD FAILED
Total time: 9.083 secs
Hello Nikolay and other contributors.
I just wanted to say thank you. I had many issues with Sony backup tools and sd card and your software just save few of my data.
Thanks a lot !
Extracting an encrypted backup I've just made fails giving me this error:
'''
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:196)
at org.nick.abe.Main.main(Main.java:35)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1034)
at javax.crypto.Cipher.implInit(Cipher.java:800)
at javax.crypto.Cipher.chooseProvider(Cipher.java:859)
at javax.crypto.Cipher.init(Cipher.java:1370)
at javax.crypto.Cipher.init(Cipher.java:1301)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:111)
... 1 more
'''
Is this problem related to my backup?
Thanks
Created backups from ICS. I am able to unpack and pack properly when no encryption is set on the backups. I get the following error when trying to unpack and encrypted backup:
$ ./abe.sh unpack test.ab test.tar password
Magic: ANDROID BACKUP
Version: 1
Compressed: 1
Algorithm: AES-256
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyE
xception: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:180)
at org.nick.abe.Main.main(Main.java:35)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:106)
... 1 more
And when I try to pack a .tar file with encryption, I get this:
$ ./abe.sh pack test3.tar test4.ab password
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyE
xception: Illegal key size or default parameters
at org.nick.abe.AndroidBackup.packTar(AndroidBackup.java:233)
at org.nick.abe.Main.main(Main.java:37)
Caused by: java.security.InvalidKeyException: Illegal key size or default parame
ters
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1011)
at javax.crypto.Cipher.implInit(Cipher.java:786)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1213)
at javax.crypto.Cipher.init(Cipher.java:1153)
at org.nick.abe.AndroidBackup.emitAesBackupHeader(AndroidBackup.java:267
)
at org.nick.abe.AndroidBackup.packTar(AndroidBackup.java:203)
... 1 more
Any ideas? Apparently ICS won't restore unless a password is set.
I'm using Git Bash on Windows XP Pro to run the script.
Thanks for the help.
Hi there,
you should add a maven build file to have the dependencies (bouncycastle) resolved automatically.
I'm trying to extract a backup and repeatedly getting this failure:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:420)
at org.nick.abe.Main.main(Main.java:128)
... 5 more
Caused by: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:121)
at javax.crypto.CipherInputStream.read(CipherInputStream.java:239)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:397)
... 6 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)
at javax.crypto.Cipher.doFinal(Cipher.java:2048)
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:118)
... 11 more
I made this backup from a phone running a 7.1 preview.. So could this be the issue? Or is there something going on here I can address?
For reference, I've installed the Java Crypto files, and put the bcprov*.jar in /lib.
Any ideas? Thanks!
Hello.
I have an issue with abe.jar, when I try to extract an encrypted backup with the correct password. (the password is working with adb restore )
GOOD PASSWORD ERROR MESSAGE
Strong AES encryption enabled
Magic: ANDROID BACKUP
Version: 1
Compressed: 1
Algorithm: AES-256
….
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Invalid password or master key checksum.
BAD PASSWORD ERROR MESSAGE
Strong AES encryption enabled
Magic: ANDROID BACKUP
Version: 1
Compressed: 1
Algorithm: AES-256
….
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
Thank you for your help
Hi!
You already covered the subject in the following issue:
#7
Unfortunately the last available abe.jar build (on sourceforge) usable on windows is dated back to late may of 2013 (http://sourceforge.net/projects/adbextractor/)
I'm currently having issues getting data out of a backup file i made a few days earlier from a android 4.1.2 device. unfortunately i used password encryption so i keep hitting the mentioned error ( given final block not properly padded)
I've read through the posts, unfortunately i am not able to compile the source files into a working jar file, since the available sources should work around the problem (according to the earlier linked issue post)
My question:
Is it possible to update the .jre file on sourceforge or to make such a file available here? (I'm sorry if my writing contains a few errors, but english isn't my mother-tongue, so there may be some errors)
the full output by the cmd shell is as follows:
(password is correct, but replaced by the phrase password, original password consists of 8 lower case letters followed by 4 numbers without space or underscore
c:\Users\Joe\Desktop\abe>java -jar "abe.jar" unpack "backup.ab" "backup.tar" password
Magic: ANDROID BACKUP
Version: 1
Compressed: 1
Algorithm: AES-256
Exception in thread "main" java.lang.RuntimeException: javax.crypto.BadPaddingEx
ception: Given final block not properly padded
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:180)
at org.nick.abe.Main.main(Main.java:35)
Caused by: javax.crypto.BadPaddingException: Given final block not properly padd
ed
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:2087)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:109)
... 1 more
I have run the following commands to backup my Android N device (7.1.1, N4F26T) and to check the files in the backup using ABE (a checkmark ✔ after any command indicates exit code 0):
[ /media/data/backups/files ] ✔
$ adb backup '-all -apk -shared -nosystem'
[ /media/data/backups/files ] ✔
$ head -n4 backup.ab
ANDROID BACKUP
4
1
AES-256
[ /media/data/backups/files ] ✔
$ java -jar ../android-backup-extractor/build/libs/abe-all.jar unpack backup.ab backup.tar
This backup is encrypted, please provide the password
Password:
Calculated MK checksum (use UTF-8: true): [hash]
2381763584 bytes written to backup.tar.
[ /media/data/backups/files ] ✔
$
So far, so good. Now, the following command should give me a list of all files in the backup (.tar) file, but unfortunately, after a long list files, it gives me an error:
$ tar -tf backup.tar
apps/cc.dict.dictcc/_manifest
apps/cc.dict.dictcc/a/base.apk
[...]
shared/0/WhatsApp/Media/WhatsApp Video/VID-20161224-WA0001.mp4
shared/0/WhatsApp/Media/WhatsApp Video/VID-20161209-WA0001.mp4
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Am I doing anything the wrong way? Or is this a bug in ABE when unpacking the .ab file?
Device: Nexus 4
Build: KOT49H (Android 4.4.2)
Performed backup using (encrypted with password):
adb backup -apk -shared -all -f backup.ab
Performed unpack (successfully):
java -jar abe.jar unpack backup.ab backup.tar
Extracted the tar-file and removed one directory (which the restore stuck on during adb restore of the original backup.ab file).
Created a new tar file (with the failing directory removed).
Performed pack:
java -jar abe.jar pack-kk new-backup.tar new-backup.ab
Tried restore back to device, like:
adb restore new-backup.ab
I get prompted for password on the device, but the restore cancels immediately.
I tried packing both with and without setting an encryption password, neither works.
Hello,
I'm trying to unpack an Android 4.4.2 encrypted archive generated on a 2012 Nexus 7, and it's failing with the following message:
Magic: ANDROID BACKUP
Version: 1
Compressed: 1
Algorithm: AES-256
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:192)
at org.nick.abe.Main.main(Main.java:35)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:108)
... 1 more
The security password was 5-digit PIN-based, perhaps this is an issue?
Thank you for looking into it!
Best regards,
Valentin Plugaru
IvParameterSpec ivSpec = new IvParameterSpec(IV);
c.init(Cipher.DECRYPT_MODE, new SecretKeySpec(userKey.getEncoded(), "AES"), ivSpec);
byte[] mkCipher = hexToByteArray(masterKeyBlobHex);
byte[] mkBlob = c.doFinal(mkCipher);
While debugging I noticed that the app crashes right after executing the line 127 which calls c.init(...
This is the values evaluated during runtime before the app crashes:
ivSpec has a 16 byte array with the following values.
[-107, -89, -89, 112, -74, 39, 37, 88, 80, 55, -78, 8, -13, 19, 31, 121]
userKey.getEncoded() is returning a 32 byte array
[81, 36, 65, 10, -38, 57, 97, 27, 81, -6, -1, 21, 67, -97, 76, -114, 119, -38, 61, 111, -40, -63, -6, -116, -10, 117, 84, 59, -93, 102, 34, 48]
when I call new SecretKeySpec(userKey.getEncoded(), "AES") i get an object with a key with this 32 byte's array: [81, 36, 65, 10, -38, 57, 97, 27, 81, -6, -1, 21, 67, -97, 76, -114, 119, -38, 61, 111, -40, -63, -6, -116, -10, 117, 84, 59, -93, 102, 34, 48]
The the app crashes: java.security.InvalidKeyException: Illegal key size
My phone died, but I had a backup made with adb backup -shared
, so I wasn't worried about it.
I got a new phone, but I don't want to do a full restore because it's a different model.
I'm using abe to extract the backup into a tar file, tar-bin-split to split it into multiple tar files, and then abe to pack the individual files back into restorable backups.
However, the backup is quite large, and the abe step fails when handling the shared contents.
This error shows up after the counter hits 100%:
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: incorrect data check
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:233)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.util.zip.ZipException: incorrect data check
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:205)
The resulting tar file is about the same size as the original backup, but when I try to extract its contents, I get the following output:
...
shared/0/com.appyet.feedplus/cache/ImageFit/a60e4d802cb8068c824a5e762c99521a
shared/0/com.appyet.feedplus/cache/ImageFit/aa3c5f5651f41b2cd41eb42e4ea0d61b
shared/0/com.appyet.feedplus/cache/ImageFit/b77565301ef59124b8dee4c46a9eb68d
shared/0/com.appyet.feedplus/cache/ImageFit/eebf292d25be4ecb707af54530a3d855
tar: Damaged tar archive
tar: Retrying...
tar: Damaged tar archive
tar: Retrying...
tar: Damaged tar archive
tar: Retrying...
...
The tar file is damaged somewhere in the middle of the shared files.
I read somewhere that there is a bug in adb backup where only part of the backup is encrypted or only part of the file is deflated or something like that, but I don't remember where I found that information. Can anyone help me fix my extracted tar file?
Exception during unpack with PW from 5GB backup create with oreo 8.0.0, adb 1.0.40 via adb backup -apk -shared -all adb restore fails, too Thanks for your work!
0% 1% 2% 3% 4% 5% 6% 7% 8% 9% 10% 11% 12% 13% 14% 15% 16% 17% 18% 19% 20% 21% 22% 23% 24% 25% 26% 27% 28% 29% 30% 31% 32% 33% 34% 35% 36% 37% 38% 39% 40% 41% 42% 43% 44% 45% 46% Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: invalid stored block lengths
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:233)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.util.zip.ZipException: invalid stored block lengths
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:165)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:205)
... 1 more
(I guess its better to start new thread here referring to Android 4.4.2 encrypted backup problem (Illegal key size) #12 )
Hi!
Downloaded android-backup-extractor-20140630-bin.zip and installed the two jar files requested from UnlimitedJCEPolicyJDK8.zip.
I.e. replaced
US_export_policy.jar and local_policy.jar in C:\Program Files\Java\jdk1.8.0_25\jre\lib\security.
But still I am getting illegal key size
Br Peter
I tried to build with ant on OSX 10.10.3 and got the following error:
ant
Buildfile: /Volumes/Data/Users/lukemackenzie/Downloads/android-backup-extractor-master/build.xml
build:
[javac] Compiling 2 source files to /Volumes/Data/Users/lukemackenzie/Downloads/android-backup-extractor-master/build
[javac] javac: invalid source release: 1.7
[javac] Usage: javac <options> <source files>
[javac] use -help for a list of possible options
BUILD FAILED
My build file:
<project default="all">
<!-- author: Jan Peter Stotz -->
<property name="jar.filename" value="abe.jar" />
<property name="main.class" value="org.nick.abe.Main" />
<property name="bcprov.jar" value="lib/bcprov-ext-jdk15on-152.jar" />
<target name="all" depends="build,jar" />
<target name="build">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="build" includes="**/*" />
</delete>
<mkdir dir="build" />
<javac srcdir="src" destdir="build" classpath="${bcprov.jar}" debug="true" includeantruntime="false" encoding="UTF-8" source="1.7" />
</target>
<target name="jar" depends="build" description="Create a standalone-jar (no external dependency)">
<delete file="${jar.filename}" />
<jar destfile="${jar.filename}" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="${main.class}" />
</manifest>
<fileset dir="build" />
<!-- Include BouncyCastle JAR -->
<zipfileset src="${bcprov.jar}" includes="org/**" />
</jar>
</target>
</project>
<echo message="Using Java version ${ant.java.version}."/>
returns 1.6
When trying to unpack, I'm getting the following exception:
java -jar build/libs/abe-all.jar unpack backup.ab backup.tar Foobar
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:203)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:118)
... 1 more
I built this with the "./gradlew" command on OSX, using both 'bcprov-jdk15on-152.jar' and 'bcprov-ext-jdk15on-152.jar' located in the 'lib' directory.
Any thoughts?
Thanks in advance.
After unpacking an encrypted 1.4 mb backup.ab file into a tar file, I only get a backup.tar file that contains only /apps/androidbackuptokenagent/_manifest
Hi,
I am getting the "Given final block not properly padded" runtime error while trying to extract backup data from my encrypted S5. I am sure that the password is correct. Also, the same procedure works perfectly fine on my old S4 with the same Android 4.4.2 (with exactly the same password, which contains lower/upper case letters and numbers). It appears to me that this issue is S5 specific.
Do you have any ideas how to resolve it?
$ java -jar abe.jar unpack backup.ab backup.tar myPassword
Exception in thread "main" java.lang.RuntimeException: javax.crypto.BadPaddingException: Given final block not properly padded
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:195)
at org.nick.abe.Main.main(Main.java:35)
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:2087)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:113)
... 1 more
TWRP seems to add some rows.
$ java -debug -jar "/home/jonathan/Downloads/Android Backup Utilities/Android Backup Extractor/android-backup-extractor-20171005-bin/abe.jar" unpack backup.ab backup.tar
Invlaid Magic: TWRPtwstreamheader���¨G+TWRPtwfilename h?fs�/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheader���¨G+TWRPtwfilename h?fs�/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:502)
at org.nick.abe.Main.main(Main.java:128)
... 5 more
Caused by: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheader���¨G+TWRPtwfilename h?fs�/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:332)
... 6 more
Skipping them helped but I don't get all data from an extraction. Help would be really appreciated :-)
Check your file:
$ head backup.ab
Twrp has added some things in the beginning. Skipping those with:
$ dd if=backup.ab bs=512 skip=3 | head
Got me to a semiworking extraction.
$ dd if=backup.ab bs=512 skip=3 | tar -x
jonathan@sandra ~/tmp_backup_onyx $ java -debug -jar abe-all.jar unpack backup.ab backup.tar
Exception in thread "main" java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "/addon.d/004075500000000000000000000000001323115710500111445ustar rootroot/addon.d/50-cm.sh01007550000000000000000000000062111270740000012421xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0"
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:233)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.lang.NumberFormatException: For input string: "/addon.d/004075500000000000000000000000001323115710500111445ustar rootroot/addon.d/50-cm.sh01007550000000000000000000000062111270740000012421xustar rootroot50 RHT.security.selinux=u:object_r:system_file:s0"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:569)
at java.lang.Integer.parseInt(Integer.java:615)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:71)
... 1 more
i use the command "adb backup -share -all " to backup my phone, and then extract it to my local file system.
there is a directory named "DCIM" on my sdcard, and has to sub-directory named "100ANDRO" and "Camera", but when extracted to file system , these two directories change to two normal files with the same name that i can't read, is there something i have missed?
Extracting an encrypted backup yields a *.tar file that is exactly 1024 bytes long, all of which are 00. I have tried backing up a few apps, all of which to the same result.
These are the exact commands I have run:
./adb.exe backup -f ./com.fedex.ida.android.ab -noapk com.fedex.ida.android
java -jar ./abe-all.jar unpack "com.fedex.ida.android.ab" "com.fedex.ida.android.tar" 1111
And running java -version
yields:
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) Client VM (build 25.221-b11, mixed mode)
I have attached a sample app backed up from my old phone (LG G6) encrypted with the password '1111'
I think it's a bad move, they want to solely rely on the cloud, but all we know you can't control what is backed up and what not to the cloud, plus you don't get detailed information on each backup that is on the cloud and you can't restore a single file of an app, for example.
After extracting a backup.ab file(5.69GB) I get a backup.tar(6.01GB) but at the end I get the following error while running this in eclipse,
Calculated MK checksum (use UTF-8: true): AFBE26845CDE730DCC0B7D821656764FBF542DA4B819CA2B6368B8A0B4682C05
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:203)
at org.nick.abe.Main.main(Main.java:42)
Caused by: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:115)
at javax.crypto.CipherInputStream.read(CipherInputStream.java:233)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:182)
... 1 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:2014)
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112)
... 6 more
I have a backup from Android 6.0.1 (nexus 5x), which is encrypted, and no matter what I use as the password, I get the error message in the title:
Exception in thread "main" java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:219)
at org.nick.abe.Main.main(Main.java:40)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1029)
at javax.crypto.Cipher.implInit(Cipher.java:795)
at javax.crypto.Cipher.chooseProvider(Cipher.java:854)
at javax.crypto.Cipher.init(Cipher.java:1374)
at javax.crypto.Cipher.init(Cipher.java:1308)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:134)
... 1 more
Since pbkdf2 is being used, it SHOULD create the right key-length, so I'm (so far) stumped. Not sure what other information I can provide. I turned on DEBUG=true, and see:
Magic: ANDROID BACKUP
Version: 3
Compressed: 1
Algorithm: AES-256
This backup is encrypted, please provide the password
Password:
where I enter the password. Next thing I see is the above error.
Hi,
//backup samsung galaxy 3(Android 4.1.2) with password: 0000
$adb backup -f galaxy3_shared_nosystem.ab -apk -shared -nosystem -all
//list files in current directory
$ ls -lh
-rw-rw-r-- 1 buck buck 2.5M Jun 3 15:33 abe.jar
-rw-r----- 1 buck buck 2.0G Jun 3 17:36 galaxy3_shared_nosystem.ab
//unpack encrypted backup via abe.jar
$java -jar abe.jar unpack galaxy3_shared_nosystem.ab galaxy3_shared_nosystem_passwd.tar 0000
...
2427917900 bytes read
2427987000 bytes read
Exception in thread "main" java.lang.RuntimeException: java.io.EOFException: Unexpected end of ZLIB input stream
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:192)
at org.nick.abe.Main.main(Main.java:35)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:173)
Another case, if backup without shared data, unpack is successful
//backup samsung galaxy 3(Android 4.1.2) with password: 0000
$adb backup -f galaxy3_noshared_nosystem.ab -apk -noshared -nosystem -all
//unpack is successful
$java -jar abe.jar unpack galaxy3_noshared_nosystem.ab galaxy3_noshared_nosystem_passwd.tar 0000
To support MIUI BACKUP magic header simple,
I do my patch like below,
--- a/src/org/nick/abe/AndroidBackup.java
+++ b/src/org/nick/abe/AndroidBackup.java
@@ -63,6 +63,25 @@ public class AndroidBackup {
if (DEBUG) {
System.err.println("Magic: " + magic);
}
+
+ if (magic.equals("MIUI BACKUP")) {
+ System.err.println("-- 1: " + magic);
+ String line2 = readHeaderLine(rawInStream);
+ System.err.println("-- 2: " + line2);
+ String line3 = readHeaderLine(rawInStream);
+ System.err.println("-- 3: " + new String(line3.getBytes("iso8859-1"), "UTF-8"));
+ String line4 = readHeaderLine(rawInStream);
+ System.err.println("-- 4: " + line4);
+ String line5 = readHeaderLine(rawInStream);
+ System.err.println("-- 5: " + line5);
+
+ magic = readHeaderLine(rawInStream);
+ }
+ if (!magic.equals("ANDROID BACKUP")) {
+ System.err.println("Invlaid Magic: " + magic);
+ throw new IllegalArgumentException("Invalid Magic " + magic);
+ }
+
String versionStr = readHeaderLine(rawInStream); // 2
if (DEBUG) {
System.err.println("Version: " + versionStr);
wish you enjoy it.
Apparently the backup file format has changed.
With an Android 7.0 phone connected to USB on a linux pc:
~/backup$ adb backup -all
Now unlock your device and confirm the backup operation.
~/backup$ ls -s backup.ab
8448 backup.ab
~/backup$ perl ~/bin/backupdecrypt.pl --compress --debug AES-backup.ab out.tar
Error: Don't know how to process version '4'...
Extract method found elsewhere doesn't work either:
~/backup$ du -sh backup.ab
8.3M backup.ab
~/backup$ (printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -n +5 backup.ab) | tar xizf -
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
~/backup$ du -sh apps
14M apps
Unsure if everything is there...
Not a real issue, but I want to make sure I got this correctly.
Can I backup a phone, use this tool to change things that I wouldn't normally have permissions to do, and then write it back to the phone?
This is very useful in this case.
So I used the pre built jar available and entered the commands to unpack the backup but it gave me "was unexpected at this time" I've installed the latest java so I'm unsure what the issue can be.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.