Pārlūkot izejas kodu

Update from 'master'

Rich Infante 7 gadi atpakaļ
vecāks
revīzija
de9ad6cf60
4 mainītis faili ar 78 papildinājumiem un 28 dzēšanām
  1. 7 0
      Readme.md
  2. 12 14
      package-lock.json
  3. 5 4
      tools/index.js
  4. 54 10
      tools/reports/manifest.js

+ 7 - 0
Readme.md

@@ -87,6 +87,13 @@ ibackuptool -b $UDID --report voicemail-files --export ./ExportedVoicemails
 
 # List wifi networks 
 ibackuptool -b $UDID --report wifi
+
+# Extract all files into a new directory called "BACKUP"
+ibackuptool -b $UDID --report manifest --extract BACKUP --filter all
+
+# Extract all Camera Roll data into a new directory called "BACKUP".
+# See the wiki for additonal info about filtering.
+ibackuptool -b $UDID --report manifest --extract BACKUP --filter CameraRollDomain
 ```
 
 ### Messages Access

+ 12 - 14
package-lock.json

@@ -259,10 +259,9 @@
       }
     },
     "debug": {
-      "version": "2.6.9",
-      "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
-      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
-      "dev": true,
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
+      "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
       "requires": {
         "ms": "2.0.0"
       }
@@ -610,16 +609,6 @@
         "lodash.set": "4.3.2",
         "lodash.uniq": "4.5.0",
         "path-is-absolute": "1.0.1"
-      },
-      "dependencies": {
-        "debug": {
-          "version": "3.1.0",
-          "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
-          "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
-          "requires": {
-            "ms": "2.0.0"
-          }
-        }
       }
     },
     "jsonfile": {
@@ -3507,6 +3496,15 @@
         "unicode-length": "1.0.3"
       },
       "dependencies": {
+        "debug": {
+          "version": "2.6.9",
+          "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+          "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+          "dev": true,
+          "requires": {
+            "ms": "2.0.0"
+          }
+        },
         "tap-parser": {
           "version": "5.4.0",
           "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-5.4.0.tgz",

+ 5 - 4
tools/index.js

@@ -31,15 +31,16 @@ var formatters = {
 }
 
 program
-    .version('2.0.5')
+    .version('3.0.0')
     .option('-l, --list', 'List Backups')
     .option(`-b, --backup <backup>`, 'Backup ID')
-    .option('-r, --report <report_type>', 'Select a report type. see below for a full list.')
     .option(`-d, --dir <directory>`, `Backup Directory (default: ${base})`)
-    .option(`-v, --verbose`, 'Verbose debugging output')
-    .option(`-x, --no-color`, 'Disable colorized output')
+    .option('-r, --report <report_type>', 'Select a report type. see below for a full list.')
     .option('-f, --formatter <type>', 'Specify output format. default: table')
     .option(`-e, --extract <dir>`, 'Extract data for commands. supported by: voicemail-files')
+    .option(`-f, --filter <filter>`, 'Filter output for individual reports. See the README for usage.')
+    .option(`-v, --verbose`, 'Verbose debugging output')
+    .option(`-x, --no-color`, 'Disable colorized output')
 
 program.on('--help', function () {
   console.log('')

+ 54 - 10
tools/reports/manifest.js

@@ -1,7 +1,9 @@
 const stripAnsi = require('strip-ansi')
 const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
 const normalizeCols = require('../util/normalize.js')
-
+const fs = require('fs-extra')
+const chalk = require('chalk')
+const path = require('path')
 module.exports.name = 'manifest'
 module.exports.description = 'List all the files contained in the backup (iOS 10+)'
 
@@ -15,22 +17,64 @@ module.exports.func = function (program, base) {
     var backup = iPhoneBackup.fromID(program.backup, base)
     backup.getFileManifest()
     .then((items) => {
-        if (program.dump) {
-            console.log(JSON.stringify(items, null, 4))
-            return
+      if (program.dump) {
+        console.log(JSON.stringify(items, null, 4))
+        return
+      }
+
+      // Extract items for analysis on-disk.
+      if (program.extract) {
+        for (var item of items) {
+          // Filter by the domain.
+          // Simple "Contains" Search
+          if (program.filter === 'all' || (program.filter && item.domain.indexOf(program.filter) > -1)) {
+            // Do nothing, we'll process later.
+          } else {
+            // Skip to the next iteration of the loop.
+            console.log(chalk.yellow('skipped'), item.relativePath)
+            continue
+          }
+
+          try {
+            var sourceFile = backup.getFileName(item.fileID)
+            var stat = fs.lstatSync(sourceFile)
+
+            // Only process files that exist.
+            if (stat.isFile() && fs.existsSync(sourceFile)) {
+              console.log(chalk.green('export'), item.relativePath)
+
+                // Calculate the output dir.
+              var outDir = path.join(program.extract, item.domain, item.relativePath)
+
+                // Create the directory and copy
+              fs.ensureDirSync(path.dirname(outDir))
+              fs.copySync(sourceFile, outDir)
+
+                // Save output info to the data item.
+              item.output_dir = outDir
+            } else if (stat.isDirectory()) {
+              // Do nothing..
+            } else {
+              console.log(chalk.blue('not found'), item.relativePath)
+            }
+          } catch (e) {
+            console.log(chalk.red('fail'), item.relativePath, e.toString())
+          }
         }
-        
+      } else {
+        // Otherwise, output the table of items.
         items = items.map(el => [
-            el.fileID + '',
-            el.domain + ': ' + el.relativePath
+          el.fileID + '',
+          el.domain + ': ' + el.relativePath
         ])
-        
+
         items = [['ID', 'Domain/Path'], ['-'], ...items]
         items = normalizeCols(items, 1).map(el => el.join(' | ').replace(/\n/g, '')).join('\n')
-        
+
         if (!program.color) { items = stripAnsi(items) }
-        
+
         console.log(items)
+      }
     })
     .catch((e) => {
         console.log('[!] Encountered an Error:', e)