3

Extracting Data from an Old iOS App Broken by iOS 14.5

 2 years ago
source link: https://tidbits.com/2021/05/20/extracting-data-from-an-old-ios-app-broken-by-ios-14-5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Adam Engst

20 May 2021 8 comments

Extracting Data from an Old iOS App Broken by iOS 14.5

So this is embarrassing. Back in 2013, I was looking for an app I could use for diary-like journal entries, and I settled on Momento. I used it for a while, and at some point, it prompted me to upgrade to a new paid version. I didn’t want any of the new features, so I dismissed the upgrade notice. The app didn’t nag me to upgrade again that I remember, so I kept using it with no problems, apparently for years. Until, that is, Apple released iOS 14.5, which somehow prevented Momento—now called Momento Classic—from launching. Uh oh.

(This problem isn’t limited to Momento. Several other apps have displayed similar alerts since upgrading to iOS 14.5. I don’t know what changed with iOS 14.5 to break apps that worked in previous versions of iOS 14.)

I wasn’t opposed to paying for the current version of Momento in principle, though the app’s current approach is a freemium model that would have required a $16.49-per-year subscription to get the features I used in Momento Classic. However, the question of whether the subscription was worthwhile wasn’t really at issue. When I downloaded the current version of Momento and tried to import data from Momento Classic, I got the same error dialog as when I tried to launch Momento Classic under iOS 14.5. Presumably, the new version needs to communicate directly with the old version to import data.

Email to Momento’s developers generated a Zendesk auto-reply but no ideas for how to transfer the data. I wasn’t particularly bothered by losing the data, but all things being equal, I’d prefer to keep it. So after waiting three weeks, I decided to see what I could do on my own. (Momento support finally replied to my initial message, suggesting only that if I had a separate backup of the Momento Classic data, which I don’t, I could potentially work with that on an iPhone running an older version of iOS.)

Restore to an Older iPhone

My first thought was to see if I could restore the Momento data from a backup of my iPhone 11 Pro to an old iPhone 6s I had lying around that was still running iOS 12 and could thus run Momento Classic. I erased the old iPhone and set it up again, first trying to restore from an iCloud backup and then from a local backup made in the Finder. In both cases, the iPhone insisted on upgrading itself to iOS 14.5.1. I blocked it both times since I assumed the upgrade would render Momento Classic inoperable again, but then my only choice was to erase and start over.

I was able to restore a 2014 backup made when I had an iPhone 5, and that even had some of the Momento data I was looking for, but of course, nothing since 2014. So I could theoretically get Momento Classic working again, but not with the current data.

For giggles, I tried restoring an iPhone 11 Pro backup from iOS 14.5.1 onto an old iPhone 6 running iOS 12.4. That failed too, unsurprisingly, but the fact that it didn’t work is worth keeping in mind. An old iPhone that can’t run the current version of iOS isn’t worth much as a backup device since you would be limited to the data on it as of the last time you had used it, however many years before.

Extract Data from the iPhone Backup

Working with the backups got me thinking that perhaps I could extract the data from a recent backup of my iPhone 11 Pro. I normally back up only to iCloud, but I had made a local (unencrypted) backup on my Mac while trying to see if I could restore that without upgrading to iOS 14.5.1. That backup would be up-to-date, at least, and getting the data out turned out to be surprisingly easy.

I downloaded the demo version of iExplorer, launched it, opened its Backup Explorer view, and did a search on “momento.” That revealed Documents and Library folders, and a few seconds later, I had discovered /Library/Application Support/Momento Data/Database.momentodb, with a recent modification date. I dragged the file to the Desktop and had my data back. Eureka! (I later tested iPhone Backup Extractor, and it too was perfectly capable of extracting that file, and I assume iMazing and AnyTrans would be as well.)

The next question was what format Momento used for its database. I dropped the file on BBEdit, which is happy to display nearly anything, and got my answer instantly: SQLite 3. I also scrolled down in the file and confirmed that it did indeed hold my text. So at the very least, I could write some grep searches to clean up the file to get my text back.

But could I do better? I’m no database expert, but I’ve had to fiddle with MySQL databases for the old TidBITS Publishing System and our current WordPress content management system, so I knew there were good Mac apps for working with databases. I opened Setapp and searched on “sqlite” to see what it had. A cornucopia of riches!

I picked Base at random, launched it, opened my database, and after a few minutes of poking around, found my data. A quick trip to File > Export, and I had my data back in a delimited text file. (I later confirmed that at least SQLPro for SQLite provided the same capabilities for opening and exporting the Momento database file.)

So at long last, I had my data back, if not in its pretty Momento interface.

Could I Inject Data into a Backup?

The fact that I was so easily able to extract data from a local unencrypted iPhone backup got me thinking. Since I now had my data outside of Momento Classic, perhaps there was a way to get it back in, either to Momento Classic or the new version of Momento. For this to work, I’d need to modify data in an unencrypted backup on my Mac and then restore that backup to an iPhone.

To make a long story short, I struck out, despite my extreme cleverness in finding the necessary inscrutably named file in the local iPhone backup and replacing it with an identically named version of the extracted SQLite database. For one test, I modified the database slightly; for another, I replaced the 2014 version with the 2021 version. With the modified version of a database injected into the new version of Momento, it launched fresh, with no entries at all. Replacing the 2014 database with the 2021 version seemingly corrupted the backup because the restore included only a single third-party app, not the large collection that should have been there.

I guess I’m not surprised that injecting data into a backup and restoring doesn’t work because it feels like it could be a security vulnerability.

A Happy Reversal of Fortune

Remember how I had assiduously prevented the iPhone 6s from upgrading from iOS 12 to iOS 14.5.1? I did that because Momento Classic stopped working in iOS 14.5. However, I had also pulled an iPhone 7 running iOS 14.0 out of the closet while figuring out what I had available for testing. It didn’t contain the latest version of Momento Classic’s data, but the app still launched. As part of the testing to see if I could inject data into a backup, I brought the iPhone 7 into play, figuring that I could restore a modified iPhone 11 Pro backup to it. As before, I was stymied by the need to upgrade to iOS 14.5.1, but this time I let it upgrade itself. The injection test failed, but you can imagine my surprise when Momento Classic launched, even if it had no data in it. Wait, what?

Apparently, whatever prevented Momento Classic from launching in iOS 14.5 was also related to running on an iPhone 11 Pro. Trying it on an iPhone 7 changed the underlying elements such that it could launch.

I erased the iPhone 7 again—I can’t tell you how many times I’ve done this—and restored it from last night’s iCloud backup from my iPhone 11 Pro. Once it was operational, I checked Momento Classic again, and again it worked, letting me create a separate backup and export the data as a text file as well. Next, I opened the new version of Momento and imported the data from the old version. And finally, I made a backup from the new version on the iPhone 7 and was able to restore it into the version I have on the iPhone 11 Pro.

All’s well that ends well, but you know how I say that upgrading isn’t really optional, even if you can put it off temporarily? (If not, go read “Why You Should Upgrade (On Your Own Terms),” 4 September 2015.) This experience is yet another reason why you can’t fall too far behind with upgrades. I made one decision not to upgrade long ago and then failed to think about it again. It’s possible that Momento warned me subsequently, though I have no memory of that happening; regardless, I knew I was using an ancient app and have no one to blame but myself for what happened.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK