skype_calls.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_calls'
  11. module.exports.description = 'Show Skype calls'
  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. 'Begin Timestamp': el => (new Date((el.begin_timestamp) * 1000).toDateString()) + ' ' + (new Date((el.begin_timestamp) * 1000).toTimeString()),
  37. 'Host Identity': el => el.host_identity,
  38. 'Duration': el => el.duration ? el.duration : 'N/A',
  39. 'Is Incoming': el => el.is_incoming === 1 ? 'Yes' : 'No',
  40. 'Caller': el => el.caller_mri_identity
  41. }
  42. })
  43. resolve(result)
  44. })
  45. .catch((e) => {
  46. console.log('[!] Encountered an Error:', e)
  47. })
  48. }
  49. const skypeAccountsReport = (backup, file) => {
  50. return new Promise((resolve, reject) => {
  51. var database = backup.getDatabase(file)
  52. try {
  53. database.all(`
  54. SELECT *
  55. FROM Calls
  56. `,
  57. (err, rows) => {
  58. resolve(rows)
  59. })
  60. } catch (e) {
  61. reject(e)
  62. }
  63. })
  64. }