Skip to content

Instantly share code, notes, and snippets.

@gaetan-sbt
Created August 29, 2024 14:17
Show Gist options
  • Save gaetan-sbt/fc8e483097c4296a72b3525fbf9d300c to your computer and use it in GitHub Desktop.
Save gaetan-sbt/fc8e483097c4296a72b3525fbf9d300c to your computer and use it in GitHub Desktop.
Dump Signal identity keys on Signal for desktop.
// Code is adapted from https://vmois.dev/query-signal-desktop-messages-sqlite/
const os = require('os');
const fs = require('fs');
const path = require('path');
const SQL = require('@signalapp/better-sqlite3');
function getFolderPath() {
return path.join(os.homedir(), '.config/Signal');
}
function getDBPath() {
return path.join(getFolderPath(), 'sql/db.sqlite');
}
function getDBKey() {
const config = path.join(getFolderPath(), 'config.json');
return JSON.parse(fs.readFileSync(config).toString())['key'];
}
const db = SQL(getDBPath(), { readonly: false });
db.pragma(`key = "x'${getDBKey()}'"`);
var stm = db.prepare(`SELECT * FROM items WHERE id='identityKeyMap'`);
const identityKeys = JSON.parse(stm.get().json);
console.log(identityKeys);
// Prints:
// {
// id: 'identityKeyMap',
// value: {
// '0f662776-d1a5-4735-ad71-83b1af6fbe20': {
// privKey: 'REDACTED',
// pubKey: 'BR5ez9EMLoGvQvZpnvUXsjPJjZJdK6oVWcbFCk2/KVsr'
// },
// 'PNI:c6f0c9a6-c3f3-4d4f-aa21-3c29af12d013': {
// privKey: 'REDACTED',
// pubKey: 'Be/4XRZUGtOZOi9bI9pcCyCOtYpTI8jmFyUoC0DvCaJ9'
// }
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment