manifest.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 = 'manifest'
  5. module.exports.description = 'List all the files contained in the backup (iOS 10+)'
  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.getFileManifest()
  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.fileID + '',
  21. el.domain + ': ' + el.relativePath
  22. ])
  23. items = [['ID', 'Domain/Path'], ['-'], ...items]
  24. items = normalizeCols(items, 1).map(el => el.join(' | ').replace(/\n/g, '')).join('\n')
  25. if (!program.color) { items = stripAnsi(items) }
  26. console.log(items)
  27. })
  28. .catch((e) => {
  29. console.log('[!] Encountered an Error:', e)
  30. })
  31. }