-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter.js
70 lines (48 loc) · 1.91 KB
/
filter.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
var callback = function(details) {
//alert("Loading: " + details.url);
var mydata,mypost,requestURL;
requestURL=details.url;
if(details.method == "GET")
{
//alert(JSON.stringify(details));
//alert(requestURL);
/*
requestURL.replace(/\s/g, "");
if((requestURL.match(/%3Cscript%3E/gi))||(requestURL.match(/<script>/gi)) )
{
alert("XSS detected. Blocking");
return {cancel: true};
}
*/
var dec_URL=decodeURIComponent(requestURL);
var splitURL=dec_URL.split("?getp=");
param=splitURL[1];
param=param.replace(/\s/g, "");
param=param.replace(/\+/g, "");
if((param.match(/%3Cscript%3E/gi))|| (param.match(/<script>/gi) ) || (param.match(/<scripttype="text\/javascript"/gi)))
{
alert("XSS detected. Blocking");
return {cancel: true};
}
}
if(details.method == "POST")
{
//alert(JSON.stringify(details.requestBody.formData));
mydata=details.requestBody.formData;
mypost=JSON.stringify(mydata.postp);
mypost=mypost.replace(/\s/g, "");
mypost=mypost.replace(/\+/g, "");
mypost=mypost.replace(/\\/g, "");
//alert(mypost);
if((mypost.match(/<script>/gi)) || (mypost.match(/<scripttype="text\/javascript\">/gi)))
{
alert("XSS detected. Blocking");
return {cancel: true};
}
}
};
//{"formData":{"postp":["<script>;<script>"],"submit":
var filter={urls: ["<all_urls>"]};
var opt_extrainfo=["blocking", "requestBody"];
chrome.webRequest.onBeforeRequest.addListener(
callback,filter,opt_extrainfo );