calls.js 2.1 KB

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