Help me understand this tool for dumping ldb files?

Some of you may remember that my Winterstrike Let’s Play ended somewhat ignominiously, as I thought I had downloaded my transcript for the last session and it turned out that I hadn’t. But the browser’s localStorage is stored, well, locally, so theoretically there is a way to access it by dumping the contents of some .ldb files. Because I use Opera, this requires a tool that supports Chromium’s idb_cmp1 comparator, and the only tool I can find that definitely does is this one: GitHub - cions/leveldb-cli: A command-line interface for LevelDB · GitHub

However, its documentation is, not to put too fine a point on it, garbage. Presumably people who are very comfortable with the command line can just figure it out and if anything’s unclear they can skim the code, but I’m not comfortable with the command line, I’m not a real programmer, and this isn’t even the one language I kindasorta know, so I’m out of my depth. I can’t get it to work and I’m not sure if it’s missing dependencies or my command syntax is wrong or what. Can someone explain to me like I’m five the series of steps I need to take to get my .ldb dump? I can’t guarantee a last Winterstrike update if you do, since I took so long that the data might not have been retained, but there’s a distant possibility, at least…

2 Likes

Ugh, that is a mess. OK. Hrm. I just installed Opera and played something-or-other to get some localStorage data and tested a bit.

The short version of the steps seems to be:

  • that leveldb command works on the database in the current directory, so you need to open a command prompt in the right place.
  • Then leveldb keys will show what things are stored
  • leveldb get "key_name" will get the data for that key, adding > output.txt to the end of the command will put it in a file.
  • You may need leveldb -i in both commands if you get a “Manifest corrupted” error talking about BytewiseComparator vs. idb_cmp1

In full intimidating detail (on Windows; I am but I forget if you are?)

  • The data is stored in AppData\Roaming\Opera Software\Opera Stable\Default\Local Storage\leveldb
  • The AppData folder is usually hidden: I think the easiest way to get to it is open the Windows menu, type Run to find the Run command, then type %appdata% into that and hit enter. That opens AppData\Roaming on my machine, from there you can navigate to the leveldb folder.
  • Since the leveldb command is a single .exe (I grabbed https://github.com/cions/leveldb-cli/releases/download/v1.5.2/leveldb-windows-amd64-1.5.2.zip) probably the easiest thing is just to put leveldb.exe in the Local Storage\leveldb directory so it’s right there and easy to run without having to enter the full path of where it is.
  • Then you need to get a command-line window in that directory: if you have git bash you may be able to right-click the folder window and Open Git bash here. Otherwise you can copy the path from the file viewer: where it has the path at the top below the ribbon, right-click it and Copy Address. Windows, Command Prompt, enter, type cd and then for some reason just right-clicking will paste the address. Enter.
  • That should put you in the right directory. For me leveldb keys works here (but if you get a “Manifest corrupted” error that says something about “BytewiseComparer” vs. “idb_cmp1” you’ll need leveldb -i for all the commands; not sure if that’s consistent).
  • Then you need to find the right key. Hmm. This list is probably stupid long because it’s everything you have in local storage, so try leveldb keys > keys.txt to dump the key listing to a file so you can search it with a text editor?
  • Yeah, in the windows Command Prompt, again, copy-pasting is weird: if I drag with the mouse to select the key and right-click, it copies (and clears the highlight). You can also drag-select and right-click in the window title bar, Edit > Copy. So maybe you want to dump it to a file even if it’s not ridiculously long, just for easier copying.
  • leveldb get " and paste the key with right-click, close the " and hit enter. For some reason my Windows command prompt starts in overwrite mode, so if you need to edit the command you probably want to hit Insert to flip it to the usual insert mode; ugh.
  • If the data for the key looks like the right thing, you can up-arrow to get the command back from the history and add > transcript.txt to the end to pipe the output to a text file.
  • And then you’ll want to move that file to somewhere easier to find.

Hope that helps; let me know if I’ve missed something I should have explained, or if something is different for you?

4 Likes

Shoot. If you do have git bash, it’ll be easier to get to the directory, but you’ll need to use ./leveldb (./leveldb.exe? it should tab-complete) to tell it “the leveldb binary that’s in this directory” because unix is more careful about not executing random binaries that happen to be lying around.

2 Likes

Ah, sorry, I was tired and a bit frustrated when I wrote this up and missed several key details! Yes, I am on Windows, and I do have git bash.

I also feel a bit bad for making you go through everything from the very beginning instead of trying to give a better idea of what stage I was failing at (which was the entering of commands—I got the ./leveldb thing because just typing leveldb in the folder where the exe is produces a useful error message, but the commands I tried to use after that were failing and the error messages were basically like “hmm, something’s wrong with your command and it might be any one of three or four things, good luck with that”). But my understanding of this stuff is so patchy that I was worried there might be necessary steps that I missed. So thank you so much for taking the time to write all this up!

Ah. No worries, it was an entertaining adventure in “ugh, programmers.” :slight_smile:

Well, this may not help then: the only error I managed to get was the one about the indexing/comparator thing. Or I guess the one where you need to be actually in the leveldb directory – most of these kinds of commands take a directory or filename on the command line but this one needs -d directory if you want to point to somewhere other than the current directory, I think?

But if you still have a particular error message, I can maybe poke at it more.

Thanks! I can at least try it with -i and see where that gets me, and if that doesn’t work I can post the exact error message I’m getting.

I was too busy to look into this yesterday, but tried today and was indeed able to recover my second bonus update! I’m going to a convention this weekend so no idea when I’ll actually be posting it, but I look forward to closing the thread out properly sometime soonish. Thanks for the help, @JoshGrams!

3 Likes

My brain making silly connections today …the dark side of error messages is when they’re like cryptic crossword clues in that you need to know the jargon to have much hope of deciphering them… do we need beginner’s guides to deciphering programmers’ utterances in the same way we have articles about how to get started with cryptics?

Edit: no, wait, it’d be funnier written the other way around: A Programmer’s Guide to Calibrating the Difficulty of Your Error Puzzles Messages

3 Likes

My favorite one is when PHP says “Error: Expected T_PAAMAYIM_NEKUDOTAYIM”. You have to know Hebrew to recognize that this means “double-double-dot token”—that is, :: (two colons, the scope resolution operator).

This error message, of course, means that you forgot a $ before a variable name.

Why does this happen?

Courtesy of Manngo on StackOverflow:

…the short answer is that PHP is (mis-)interpreting a constant as a class name. Some operations, such as empty, won’t evaluate expressions which include constants. Therefore they will try to interpret a constant as a class name and expect it to have a :: to indicate a static property. And, of course, if you forget the $ on a variable, it is mis-interpreted as a constant.

2 Likes