calls.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const stripAnsi = require('strip-ansi')
  2. const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
  3. const normalizeCols = require('../util/normalize.js')
  4. module.exports.name = 'calls'
  5. module.exports.description = 'List all call records contained in the backup.'
  6. module.exports.func = function (program, base) {
  7. if (!program.backup) {
  8. console.log('use -b or --backup <id> to specify backup.')
  9. process.exit(1)
  10. }
  11. // Grab the backup
  12. var backup = iPhoneBackup.fromID(program.backup, base)
  13. backup.getCallsList()
  14. .then((items) => {
  15. if (program.dump) {
  16. console.log(JSON.stringify(items, null, 4))
  17. return
  18. }
  19. items = items.map(el => [
  20. el.Z_PK + '',
  21. el.XFORMATTEDDATESTRING,
  22. el.ZANSWERED + '',
  23. el.ZORIGINATED + '',
  24. el.ZCALLTYPE + '',
  25. el.ZDURATION + '',
  26. el.ZLOCATION + '',
  27. el.ZISO_COUNTRY_CODE + '',
  28. el.ZSERVICE_PROVIDER + '',
  29. (el.ZADDRESS || '').toString()
  30. ])
  31. items = [['ID', 'Date', 'Answered', 'Originated', 'Type', 'Duration', 'Location', 'Country', 'Service', 'Address'], ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-'], ...items]
  32. items = normalizeCols(items).map(el => el.join(' | ').replace(/\n/g, '')).join('\n')
  33. if (!program.color) { items = stripAnsi(items) }
  34. console.log(items)
  35. })
  36. .catch((e) => {
  37. console.log('[!] Encountered an Error:', e)
  38. })
  39. }