-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbackground.html
executable file
·280 lines (215 loc) · 9.48 KB
/
background.html
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!--
The Exploit Database Extension for Google Chrome
Author: 10n1z3d <10n1z3d[at]w[dot]cn>
License: GPLv3
-->
<html>
<head>
<script type="text/javascript">
var exploits = []; // contains newest exploits
var unsorted = []; // contains all exploits
function init() {
if (!localStorage.updateInterval) {
localStorage.updateInterval = 5;
}
if (!localStorage.types) {
localStorage.types = "remote:true;webapps:true;shellcode:true;local:true;dos:true;papers:true";
}
chrome.browserAction.setBadgeBackgroundColor({color:[255, 102, 0, 255]});
setTimeout(makeRequest, 3000);
}
function makeRequest() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
parseExploits(xmlhttp.responseXML);
}
};
xmlhttp.open("GET", "http://www.exploit-db.com/rss.php", true);
xmlhttp.send(null);
setTimeout(makeRequest, 1000 * 60 * localStorage.updateInterval);
}
function parseExploits(data) {
var items = data.getElementsByTagName("item");
for (var i = 0; i < items.length; i++) {
var item = items[i];
var dateNode = item.getElementsByTagName("pubDate")[0];
var date = formatDate(dateNode.firstChild.data);
var titleNode = item.getElementsByTagName("title")[0];
var title = formatTitle(titleNode.firstChild.data);
var type = titleNode.firstChild.data.split("[")[1].split("]")[0];
var linkNode = item.getElementsByTagName("link")[0];
var link = trimSpaces(linkNode.firstChild.data);
var authorNode = item.getElementsByTagName("author")[0];
var author = authorNode.firstChild.data;
var exploit = { date: date,
title: title,
featured: false,
type: type,
author: author,
link: link };
unsorted[i] = exploit;
}
processExploits();
}
function processExploits() {
exploits = getExploitsFromToday();
if (exploits.length < 5) {
for (x in unsorted) {
var curr = unsorted[x];
if (checkType(curr["type"])
&& !exploitExists(curr["link"])) {
exploits.push(curr);
}
if (exploits.length == 5)
break;
}
} else {
for (x in unsorted) {
var curr = unsorted[x];
if (checkDate(curr["date"])
&& checkType(curr["type"])
&& !exploitExists(curr["link"])) {
curr["featured"] = true;
exploits[x] = curr;
}
if (exploits.length == 5)
break;
}
}
updateBadge();
}
function getExploitsFromToday() {
var temp = [];
for (x in unsorted) {
var curr = unsorted[x];
if (checkDate(curr["date"])
&& checkType(curr["type"])) {
curr["featured"] = true;
if (exploitExists(curr["link"])
&& !isFeatured(curr["link"])) {
curr["featured"] = false;
}
temp.push(curr);
}
}
return temp;
}
function getTodaysCount() {
var count = 0;
for (x in exploits) {
var curr = exploits[x];
if (checkDate(curr["date"])) {
count++
}
}
return count;
}
function getFeaturedCount()
{
var featured = 0;
for (x in exploits) {
if (exploits[x]["featured"] == true) {
featured++;
}
}
return featured;
}
function checkDate(date) {
var today = new Date();
var date = new Date(date);
return (today.getFullYear() == date.getFullYear()
&& today.getMonth() == date.getMonth()
&& today.getDate() == date.getDate());
}
function checkType(type) {
var types = localStorage.types.split(";");
for (var i = 0; i < types.length; i++) {
var temp = types[i].split(":");
if (temp[0] == type && temp[1] == "true") {
return true;
}
}
return false;
}
function exploitExists(link) {
for (x in exploits) {
if (exploits[x]["link"] == link) {
return true;
}
}
return false;
}
function isFeatured(link) {
for (x in exploits) {
if (exploits[x]["link"] == link) {
if (exploits[x]["featured"] == true) {
return true;
}
}
}
return false;
}
function deleteExploit() {
for (var i = exploits.length - 1; i >= 0; i--) {
if (exploits[i]["featured"] == false) {
exploits.splice(i, 1);
break;
}
}
}
function doCleaning() {
var count = exploits.length;
var todays = getTodaysCount();
if (count > 5) {
if (todays >= 5) {
while (count > todays) {
deleteExploit();
count = exploits.length;
}
} else {
if (todays < 5) {
while(count > 5) {
deleteExploit();
count = exploits.length;
}
}
}
}
}
function formatDate(string) {
var date = new Date(string);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
return year + "-" + month + "-" + day;
}
function trimSpaces(string) {
return string.replace(/\s/g, "");
}
function formatTitle(string) {
return string.replace(/\[\w+\]\s\-\s/, "").replace(/[\n\r\f]/g, "");
}
function updateBadge() {
doCleaning();
var featured = getFeaturedCount();
if (featured > 0) {
chrome.browserAction.setBadgeText({text: featured + ""});
chrome.browserAction.setTitle({title: featured + " new exploit" + ((featured > 1) ? "s": "")});
} else {
chrome.browserAction.setBadgeText({text: ""});
chrome.browserAction.setTitle({title: "No new exploits"});
}
console.log("badge updated");
}
</script>
</head>
<body onload="init();">
</body>
</html>