diff --git a/lib/cli.js b/lib/cli.js index bc19184..ad91268 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,18 +1,11 @@ (function() { - var REAVETARD_MENU, REAVETARD_TITLE, REAVETARD_TITLE_S, arrwrite, cdwrite, charm, commander, cwrite, exit; + var REAVETARD_MENU, REAVETARD_TITLE, REAVETARD_TITLE_S, arrwrite, cdwrite, charm, commander, cwrite; var __slice = Array.prototype.slice; commander = require('commander'); charm = require('charm')(process.stdout); - exit = function() { - charm.display('reset'); - return process.exit(); - }; - - charm.on('^C', exit); - arrwrite = function(arr, cd) { var a, _i, _len, _results; if (cd == null) cd = false; @@ -26,8 +19,11 @@ _results.push(cwrite.apply(null, a)); } } else { - if (cd) cdwrite.apply(null, [a]); - _results.push(cwrite.apply(null, [a])); + if (cd) { + _results.push(cdwrite.apply(null, [a])); + } else { + _results.push(cwrite.apply(null, [a])); + } } } return _results; @@ -48,14 +44,14 @@ }; cdwrite = function() { - if (arguments.length >= 2) { - charm.display('reset'); - charm.display(arguments[0]); - return cwrite.apply(null, arguments.slice(1)); - } + var args, disp; + disp = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + charm.display('reset'); + charm.display(disp); + return cwrite.apply(null, args); }; - REAVETARD_TITLE = [['reset', 'blue', ' eibbors.com/p/reavetard/\n'], ['dim', 'magenta', ' -------------------------------------------------------------\n'], ['bright', 57, ' - ▀█▀▀▀▄ ▄▀▀▀▄ ▀▀▀▀▄ █ █ ▄▀▀▀▄ ▄█▄▄ ▀▀▀▀▄ ▀█▀▀▀▄ ▀█ -\n'], ['bright', 56, ' - █ ▀ █▀▀▀▀ █▀▀▀█ ▀▄ ▄▀ █▀▀▀▀ █ ▄ █▀▀▀█ █ ▀ ▄▀▀▀█ -\n'], ['bright', 55, ' - ▀▀ ▀▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀▀ ▀▀▀▀▀ -\n'], ['reset', 'blue', ' - ~ Reaver Tools for AP Rotation & Data Management ~ -\n'], ['dim', 'magenta', ' -------------------------------------------------------------\n\n']]; + REAVETARD_TITLE = [['reset', 'blue', ' eibbors.com/p/reavetard/\n'], ['dim', 'magenta', ' -------------------------------------------------------------\n'], ['bright', 57, ' - ▀█▀▀▀▄ ▄▀▀▀▄ ▀▀▀▀▄ █ █ ▄▀▀▀▄ ▄█▄▄ ▀▀▀▀▄ ▀█▀▀▀▄ ▀█ -\n'], ['bright', 56, ' - █ ▀ █▀▀▀▀ █▀▀▀█ ▀▄ ▄▀ █▀▀▀▀ █ ▄ █▀▀▀█ █ ▀ ▄▀▀▀█ -\n'], ['bright', 55, ' - ▀▀ ▀▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀▀ ▀▀▀▀▀ -\n'], ['reset', 'blue', ' - ~ Reaver Tools for AP Rotation & Data Management ~ -\n'], ['dim', 'magenta', ' -------------------------------------------------------------\n'], ['reset', '\n']]; REAVETARD_TITLE_S = [['bright', 57, ' __ _ _ _ _ _ ___ _ __ _ \n'], ['bright', 56, ' |_| |_| _| | | |_| | _| | | _| '], ['reset', 'blue', 'CoffeeScript goodies for Reaver-WPS'], ['bright', 55, ' | \ |__ |_\ V |__ | |_\ | |_|_ '], ['reset', 'blue', 'Courtesy of Robbie Saunders (eibbors.com)\n'], ['magenta', '_________________________________________________________________________________']]; @@ -64,56 +60,70 @@ exports.title = function(full) { if (full == null) full = true; if (full) { - arrwrite(REAVETARD_TITLE, false); + arrwrite(REAVETARD_TITLE, true); } else { - arrwrite(REAVETARD_TITLE_S, false); + arrwrite(REAVETARD_TITLE_S, true); } return this; }; exports.menu = function() { - arrwrite(REAVETARD_MENU); + arrwrite(REAVETARD_MENU, true); return this; }; exports.washHit = function(station, status) { - var progress, _ref; - if (station.locked) charm.display('dim'); + var c, colors, _ref; + colors = { + C: 72, + W: 'blue', + N: 5 + }; + c = colors[status]; + if (station.locked) c = 'red'; + this.label(c, 'st', status); + this.label(c, 'rssi', station.rssi); + this.label(c, 'bssid', station.bssid); + this.label(c, 'ch', station.channel); + this.label(c, 'essid', station.essid); if (status === 'C') { - cwrite(57, "[C] rssi:" + station.rssi + " bssid:" + station.bssid + " ch:" + ch + " essid:'" + station.essid + "'\n"); - cwrite(57, " |- pin:" + ((_ref = station.session) != null ? _ref.pin : void 0) + " key:'" + station.key + "'"); + this.label(c, 'pin', (_ref = station.session) != null ? _ref.pin : void 0); + this.label(c, 'key', station.key); + this.label(c, 'checked', Number(station.session.ki1) + Number(station.session.ki2)); } else if (status === 'W') { - progress = Number(station.attempts / 110).toFixed(2) + '%'; + this.label(c, 'progress', "" + (Number(station.attempts / 110).toFixed(2)) + "%"); + this.label(c, 'phase', station.session.phase); + this.label(c, 'checks', Number(station.session.ki1) + Number(station.session.ki2)); if (station.attempts > 10000 || station.session.phase === 1) { - progress += " pin:" + station.session.pin + "____"; + this.label(c, 'pin', "" + station.session.pin); } - cwrite('magenta', "[W] rssi:" + station.rssi + " bssid:" + station.bssid + " ch:" + ch + " essid:'" + station.essid + "'\n"); - cwrite('magenta', " |- eliminated:" + station.attempts + "/11000 ~" + progress + " phase:" + station.phase); - } else if (status === 'N') { - cwrite('blue', "[C] rssi:" + station.rssi + " bssid:" + station.bssid + " ch:" + ch + " essid:'" + station.essid + "'"); } - if (station.locked) { - cdwrite('bright', 'red', ' locked\n'); - } else { - cwrite('green', ' unlocked\n'); + if (station.device != null) { + this.label(c, 'device', station.device.name); + this.label(c, 'manuf.', station.device.manufacturer); + this.label(c, 'model', "" + station.device.model + "/" + station.device.number); } - cdwrite('reset', '\n'); + if (station.locked) this.label(c, '!', 'LOCKED'); + charm.write('\n'); return this; }; - exports.label = function(ltext, rtext, enabled) { - if (enabled == null) enabled = true; - charm.display('bright'); - charm.write(ltext); - if (enabled) { - charm.display('reset'); - } else { - charm.display('dim'); - } - charm.write(rtext); + exports.label = function(fg, ltext, rtext) { + charm.display('reset').foreground(fg).write("" + ltext + "/"); + charm.display('bright').foreground(fg).write("" + rtext + " ").display('reset'); return this; }; + exports.labels = function(color, keys, obj) { + var key, _i, _len, _results; + _results = []; + for (_i = 0, _len = keys.length; _i < _len; _i++) { + key = keys[_i]; + _results.push(this.label(color, key, obj[key])); + } + return _results; + }; + exports.cwrite = function() { var args; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; diff --git a/lib/db.js b/lib/db.js index 03f0ff8..847329b 100644 --- a/lib/db.js +++ b/lib/db.js @@ -34,6 +34,10 @@ return this.db.all("SELECT * FROM history WHERE bssid = '" + bssid + "'", cb); }; + ReaverData.prototype.checkSurvey = function(bssid, cb) { + return this.db.all("SELECT * FROM survey WHERE bssid = '" + bssid + "'", cb); + }; + ReaverData.prototype.loadSession = function(bssid, filename) { var ki1, ki2, phase, pin, pset, session; if ((bssid != null) && !(filename != null)) { diff --git a/lib/reavetard.js b/lib/reavetard.js index fd0a517..97b5a14 100644 --- a/lib/reavetard.js +++ b/lib/reavetard.js @@ -28,28 +28,51 @@ scan: scan, ignoreFCS: true }); + process.on('exit', function() { + return w.stop(); + }); + cli._c.on('^C', function() { + w.stop(); + cli._c.display('reset'); + return process.exit(); + }); w.on('ap', function(station) { - return rdb.checkHistory(station.bssid, function(err, rows) { - var k, v, _ref, _ref2; - if (err) console.error(err); - if (rows.length > 0) { - _ref = rows[0]; - for (k in _ref) { - v = _ref[k]; - if ((_ref2 = station[k]) == null) station[k] = v; + return rdb.checkSurvey(station.bssid, function(err, rows) { + var device, k, v; + if (!err && rows.length > 0) { + device = { + name: rows[0].device_name, + manufacturer: rows[0].manufacturer, + model: rows[0].model_name, + number: rows[0].model_number + }; + for (k in device) { + v = device[k]; + if (v !== '') station.device = device; } - station.session = rdb.loadSession(station.bssid); - if (station.attempts >= 11000 || station.session.phase === 2) { - stations.complete.push(station); - return logStation(station, 'C'); + } + return rdb.checkHistory(station.bssid, function(err, rows) { + var k, v, _ref, _ref2; + if (err) console.error(errd); + if (rows.length > 0) { + _ref = rows[0]; + for (k in _ref) { + v = _ref[k]; + if ((_ref2 = station[k]) == null) station[k] = v; + } + station.session = rdb.loadSession(station.bssid); + if (station.attempts >= 11000 || station.session.phase === 2) { + stations.complete.push(station); + return cli.washHit(station, 'C'); + } else { + stations.inProgress.push(station); + return cli.washHit(station, 'W'); + } } else { - stations.inProgress.push(station); - return logStation(station, 'W'); + stations.noHistory.push(station); + return cli.washHit(station, 'N'); } - } else { - stations.noHistory.push(station); - return logStation(station, 'N'); - } + }); }); }); w.on('exit', function() { diff --git a/lib/wifi.js b/lib/wifi.js index 44c8d0e..c9cd4e1 100644 --- a/lib/wifi.js +++ b/lib/wifi.js @@ -63,7 +63,7 @@ }); } else { monok = /\s+\(monitor mode enabled on (\w+)\)/.exec(line); - if (monok) results.newMon = monok[1]; + if (monok) results.enabledOn = monok[1]; } } } @@ -79,37 +79,22 @@ }, getPhysicalInterfaces: function(cb) { return this.getInterfaces(function(ifaces) { - var iface, phys, pi, _i, _len, _ref, _ref2; + var iface, phys, _i, _len, _name, _ref; phys = {}; for (_i = 0, _len = ifaces.length; _i < _len; _i++) { iface = ifaces[_i]; - if (((_ref = iface.driver) != null ? _ref.length : void 0) != null) { - pi = iface.driver[1].slice(1, -1); - if ((_ref2 = phys[pi]) == null) phys[pi] = []; - phys[pi].push(iface); - } + if ((_ref = phys[_name = iface.phyid]) == null) phys[_name] = []; + phys[iface.phyid].push(iface); } return cb(phys); }); }, start: function(iface, cb) { - return this.run(['start', iface], function(res, sout) { - if (res.newMon) { - return cb(res.newMon); - } else { - throw "ERROR: Monitor mode not enabled? See output:\n'''\n" + sout + "\n'''"; - } - }); + return this.run(['start', iface], cb); }, stop: function(iface, cb) { return this.run(['stop', iface], cb); } }; - airmon.start('wlan1', console.log); - - setTimeout(function() { - return airmon.stop("mon0", console.log, 4000); - }); - }).call(this); diff --git a/package.json b/package.json index d84e862..e87a5e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reavetard", - "version": "0.0.1", + "version": "0.0.2", "description": "CoffeeScript modules that provide AP rotation support and a host of data management and general usability enhancements for Reaver-WPS Cracker and its partner in crime, Wash-WPS Scanner", "main": "index.js", "dependencies": {