wifi.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 = 'wifi'
  5. module.exports.description = 'List associated wifi networks and their usage information'
  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.getWifiList()
  14. .then((items) => {
  15. if (program.dump) {
  16. console.log(JSON.stringify(items, null, 4))
  17. return
  18. }
  19. items = items['List of known networks'].map(el => [
  20. el.lastJoined + '' || '',
  21. el.lastAutoJoined + '' || '',
  22. el.SSID_STR + '',
  23. el.BSSID + '',
  24. el.SecurityMode || '',
  25. el.HIDDEN_NETWORK + '',
  26. el.enabled + ''
  27. ]).sort((a, b) => new Date(a[0]).getTime() - new Date(b[0]).getTime())
  28. items = [['Last Joined', 'Last AutoJoined', 'SSID', 'BSSID', 'Security', 'Hidden', 'Enabled'], ['-', '-', '-', '-', '-', '-'], ...items]
  29. items = normalizeCols(items).map(el => el.join(' | ').replace(/\n/g, '')).join('\n')
  30. if (!program.color) { items = stripAnsi(items) }
  31. console.log(items)
  32. })
  33. .catch((e) => {
  34. console.log('[!] Encountered an Error:', e)
  35. })
  36. }