-
Notifications
You must be signed in to change notification settings - Fork 13
/
brute.js
52 lines (47 loc) · 1.52 KB
/
brute.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
var request = require('request')
, fs = require('fs')
, async = require('async')
, available = fs.createWriteStream('./available')
, fileNames = process.argv.splice(2)
, processed = 0
, log
, reservedWords = ['post', 'session', 'join', 'apps', 'auth', 'list', 'root', 'phone']
/* queue of requests with a pool of 10 async */
, q = async.queue(function(task, callback) {
request.head('http://www.twitter.com/' + task.name, function (err, res) {
if(res && res.statusCode == 404) {
available.write(task.name + '\n')
}
callback(err)
})
}, 10)
/* catch sigusr1 for an update */
process.on('SIGUSR1', function(){
console.log(processed +' handles have been processed')
})
/* read all dictionaries */
fileNames.forEach(function(fileName) {
fs.readFile('./' + fileName, 'utf8', function(err, data) {
if(err) { return console.log(err) }
/* split file by lines */
data.split('\n').forEach(function(line) {
if(line < 4) {
console.log('ignoring '+line+' because 3 or less handles are all taken')
return
}
if(reservedWords.indexOf(line) > 0) {
console.log('ignoring '+line+' because it\'t a reserved by twitter')
return
}
/* push each word */
q.push({name: line}, function(err) {
if(err) {
log = log || fs.createWriteStream('./error-log')
log.write('\n\nsomething weird happened with '+line+'\n')
log.write(err)
}
processed++
})
})
})
})