accounts.js 1.8 KB

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