Skip to content

Instantly share code, notes, and snippets.

@jalex19100
Created November 2, 2024 04:11
Show Gist options
  • Save jalex19100/1cd12c49a5bd4c219d58862c38d4bd1d to your computer and use it in GitHub Desktop.
Save jalex19100/1cd12c49a5bd4c219d58862c38d4bd1d to your computer and use it in GitHub Desktop.
Locates the latest sqldeveloper settings directory and decrypts all saved passwords to stdout, in case they weren't previously recorded
#!/bin/bash
##
# Auto wrapper to decrypt "super-secure" saved passwords for Oracle SQL Developer 19.x+
#
# Author: Lazy Jason.Alexander
# Date: 20230110
#
# Requires: sqldeveloperpassworddecryptor (install via pip) or see https://github.com/maaaaz/sqldeveloperpassworddecryptor
#
##
# Find and use the most recent settings dir:
LATEST_VER=`ls -d ~/.sqldeveloper/system*|tail -1`
DB_SYSTEM_ID=`grep db.system.id $LATEST_VER/o.sqldeveloper/product-preferences.xml|sed -e 's/.*v=\"//g' -e 's/\"\/\>//g'`
CONNECTIONS_JSON="$LATEST_VER/o.jdeveloper.db.connection/connections.json"
cat $CONNECTIONS_JSON |jq -c '.connections[] | { name: .name, username: .info.user, password: .info.password }'| sed -e 's/^.*\"name\":\"//g' -e 's/\",\"[a-zA-Z]\{8\}\"\:/,/g' -e 's/[\"\}]//g'| while read line
do
# echo $line
CONNECTION_NAME=`echo $line| cut -f1 -d,`
USERNAME=`echo $line|cut -f2 -d,`
PASSWORD=`echo $line| cut -f3 -d,`
echo "Connection: $CONNECTION_NAME, Username: $USERNAME"
sqldeveloperpassworddecryptor -p $PASSWORD -d $DB_SYSTEM_ID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment