Skip to content

Instantly share code, notes, and snippets.

@marshall
Last active November 6, 2020 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshall/eabc018013bb36935b5beeb5aa47cfb1 to your computer and use it in GitHub Desktop.
Save marshall/eabc018013bb36935b5beeb5aa47cfb1 to your computer and use it in GitHub Desktop.
Dump a Brave extension's LevelDB json data from command line

Setup

clone and build leveldb-cli

go get github.com/liderman/leveldb-cli
cd ~/go/src/github.com/liderman/leveldb-cli

go install

Usage

dump the JSON data from Brave Nightly's Crypto Wallets extension (default)

./dump-extension-data.sh

dump data from Crypto Wallets in a custom profile

PROFILE=/path/to/profile ./dump-extension-data.sh

dump data from an arbitrary extension in a custom profile

EXTENSION=abcdefghijklmnop PROFILE=/path/to/profile ./dump-extension-data.sh
#!/bin/bash
set -e
LEVELDB_CLI=$HOME/go/bin/leveldb-cli
EXTENSION=${EXTENSION:-odbfpeeihdkbihmopkbjmoonfanlbfcl} # default is Crypto Wallets
PROFILE=${PROFILE:-"$HOME/Library/Application Support/BraveSoftware/Brave-Browser-Nightly"} # default nightly profile
FORMATTER=
if which jq 1>/dev/null 2>/dev/null; then
FORMATTER="jq ."
elif which python3 1>/dev/null 2>/dev/null; then
FORMATTER=python3 -mjson.tool
fi
echo "Loading extension '$EXTENSION' in profile dir '$PROFILE'"
cd "$PROFILE/Default/Local Extension Settings"
data=$((echo -e "open $EXTENSION\nget data\nexit") | ~/go/bin/leveldb-cli | tail -n +7)
if [[ -z "$FORMATTER" ]]; then
echo "$data"
else
echo "$data" | eval "$FORMATTER"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment