-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
executable file
·111 lines (106 loc) · 3.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env node
'use strict'
const debug = require('debug')('kickthemout:flow')
const _ = require('lodash')
const async = require('async')
const chalk = require('chalk')
const checkForUpdate = require('./lib/utility').checkForUpdate
const isRoot = require('./lib/utility').isRoot
const printLogoAndCredits = require('./lib/utility').printLogoAndCredits
const Attack = require('./lib/Attack')
const Network = require('./lib/Network')
const Inquiries = require('./lib/Inquiries')
const Spinner = require('cli-spinner').Spinner
debug('Debug enabled.')
const network = new Network()
const ask = new Inquiries()
async.waterfall([
function (callback) {
debug('Printing logo and credits')
printLogoAndCredits(function (err, ascii) {
if (err) throw err
console.log(ascii)
callback(null)
})
},
function (callback) {
// root permission required
if (!isRoot()) {
callback(new Error('root permission required'))
} else {
console.log(chalk.green(' \u2713 Running as', chalk.bold('root')))
callback(null)
}
},
function (callback) {
debug('Checks for available update..')
checkForUpdate(callback)
},
function (callback) {
// starting questions
ask.whatToDo(callback)
},
function (callback) {
// get Interfaces
network.getInterfaces(callback)
},
function (ifaces, callback) {
// select Interface
ask.selectInterface(ifaces, function (err, iface) {
if (err) return callback(err)
network.selectInterface(iface)
callback(null)
})
},
function (callback) {
// host discovery
var iface = network.iface
var myIP = iface.ip_address
var spinner = new Spinner(' Scanning LAN.. %s')
spinner.setSpinnerString('|/-\\')
spinner.start()
network.scan(myIP, function (hosts) {
debug('hosts found:', hosts)
if (!hosts.length) return callback(new Error('No hosts found!'))
spinner.stop()
// adding iface mac (if found)
var gw = _.find(hosts, {'ip': iface.gateway_ip})
network.iface.gateway_mac_address = gw ? gw.mac : 'Not found'
// removing ourself and the iface ip from targetHosts.
_.remove(network.hosts, function (host) { return host.ip === myIP || host.ip === iface.gateway_ip })
// getting target hosts' vendors (new prop. vendor)
network.resolveVendors()
callback(null)
})
},
/*
function(callback){
require('arpjs').table(function(err, table){
// now refreshed by Ping sweep
if (err) debug(err)
debug('Local ARP Table:', table)
callback(null)
})
},
*/
function (callback) {
console.log(chalk.blue(chalk.green('\n \u2713'), 'Gateway', chalk.yellow(network.iface.gateway_ip), 'has', chalk.green(network.hosts.length), 'hosts up\n'))
// attack options
ask.attackOption(network.hosts, callback)
},
function (targets) {
// starting attack
var attack = new Attack()
attack.setInterface(network.iface)
.setTarget(targets)
.start()
console.log(chalk.green(' \u2713'), chalk.blue('Attack running...'))
ask.nextStep(attack, 'pause')
}
],
// final result callback
function (err, results) {
// Never reached
console.log(chalk.red('Error: ' + err.message || err))
debug('Async final results:', results)
})