forked from FladeX/homakov.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhustlers.rb
More file actions
154 lines (126 loc) · 3.16 KB
/
hustlers.rb
File metadata and controls
154 lines (126 loc) · 3.16 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
var http = require('http');
var fs = require('fs');
var hustlers = [];
var bounties = [];
done = function(){
if(--requested == 0){
hustlers.sort(function(a,b){
return b.bounties.length-a.bounties.length
});
for(var i=0,l=hustlers.length;i<l;i++){
details = [];
for(var key in hustlers[i].details){
details += key+" ("+hustlers[i].details[key]+")"
}
result += ("<tr><td>"+i+"</td><td>" + hustlers[i].handles[0] + "</td><td>" + details.join(', ') + "</td></tr>")
}
result = '<table>' + result + '</table>';
fs.writeFile("hustlers.html", result, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
}
}
get = function(url, cb){
http.get(url, function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
cb(body);
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
})
}
upgrade_hustler = function(h,id){
h.bounties.push(id);
if(h.details[bounties[id].name]){
h.details[bounties[id].name] += 1
}else{
h.details[bounties[id].name] = 1
}
}
lookup_hustler = function(name){
for(var i=0,l=hustlers.length;i<l;i++){
if(hustlers[i].handles.indexOf(name) != -1){
return hustlers[i];
}
}
num = hustlers.push({
handles: [name],
reward: 0,
bounties: [],
details: {}
});
return hustlers[num-1];
}
bounties.push({
name: "Ebay",
url: 'http://pages.ebay.com/securitycenter/ResearchersAcknowledgement.html',
cb: function(r, id){
var res;
var reg = /<li>(.*?)<\/li>/g;
var html = /</;
while ((res = reg.exec(r)) !== null){
if(!html.test(res[1])){
h = lookup_hustler(res[1]);
upgrade_hustler(h,id);
}
}
}
})
bounties.push({
name: "Chromium",
url: 'http://www.chromium.org/Home/chromium-security/hall-of-fame',
cb: function(r, id){
var res;
var reg = /<li>(.*?)<\/li>/g;
while ((res = reg.exec(r)) !== null){
item = res[1].split(/\sfor/)[0];
item = item.split(/\sto\s/).reverse();
h = lookup_hustler(item[0]);
upgrade_hustler(h,id);
if(item.length == 2)
h.reward += parseInt(item[1].substr(1))
}
}
})
bounties.push({
name: "Google",
url: 'http://www.google.com/about/appsecurity/hall-of-fame/reward/',
cb: function(r, id){
var res;
var reg = /td>\s*<td class="name">\s*(.*?)\s*</g
var html = /</;
while ((res = reg.exec(r)) !== null){
console.log(res[1])
h = lookup_hustler(res[1]);
upgrade_hustler(h,id);
}
}
})
var requested = bounties.length;
var result = '';
for(id=0,l=bounties.length;id<l;id++){
var callback = (function(cb,id) {
return function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
cb(body,id);
console.log(requested)
done();
});
}
})(bounties[id].cb,id)
http.get(bounties[id].url, callback).on('error', function(e) {
console.log("Got error: " + e.message);
})
}