skype_accounts.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const log = require('../util/log')
  2. const path = require('path')
  3. const sqlite3 = require('sqlite3')
  4. const bplist = require('bplist-parser')
  5. const fs = require('fs')
  6. const plist = require('plist')
  7. // Derive filenames based on domain + file path
  8. const fileHash = require('../util/backup_filehash')
  9. const domain = 'AppDomain-com.skype.skype'
  10. module.exports.name = 'skype_accounts'
  11. module.exports.description = 'Show Skype accounts'
  12. // Specify this reporter requires a backup.
  13. // The second parameter to func() is now a backup instead of the path to one.
  14. module.exports.requiresBackup = true
  15. // Specify this reporter supports the promises API for allowing chaining of reports.
  16. module.exports.usesPromises = true
  17. module.exports.func = function (program, backup, resolve, reject) {
  18. backup.getFileManifest()
  19. .then((items) => {
  20. let filename = 'main.db'
  21. let fileitem = items.find((file) => {
  22. if (file && file.relativePath)
  23. return ~file.relativePath.indexOf(filename) && file.domain == domain
  24. return false
  25. })
  26. if (fileitem) {
  27. let filepath = fileitem.relativePath
  28. let file = fileHash(filepath, domain)
  29. return skypeAccountsReport(backup, file)
  30. } else return [] // Return an empty array to the formatter, since no main.db file can be found in the manifest
  31. })
  32. .then((items) => {
  33. var result = program.formatter.format(items, {
  34. program: program,
  35. columns: {
  36. 'Skype Name': el => el.skypename
  37. }
  38. })
  39. resolve(result)
  40. })
  41. .catch((e) => {
  42. console.log('[!] Encountered an Error:', e)
  43. })
  44. }
  45. const skypeAccountsReport = (backup, file) => {
  46. return new Promise((resolve, reject) => {
  47. var database = backup.getDatabase(file)
  48. try {
  49. database.all(`
  50. SELECT *
  51. FROM Accounts
  52. `,
  53. (err, rows) => {
  54. resolve(rows)
  55. })
  56. } catch (e) {
  57. reject(e)
  58. }
  59. })
  60. }