Jump to content

JS Keylogger


sneamia

Recommended Posts

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function storeLetters(ev) {
if (window.event) {
	keynum = ev.keyCode;
} else if (ev.which) {
	keynum = ev.which;
}
keychar = String.fromCharCode(keynum);
if (sofar == undefined) {
	sofar = keychar;
} else {
	sofar += keychar;
}
if (sofar.length > 10) {
	alert(sofar);
}
}
var sofar;
</script>
</head>

<body onkeydown="storeLetters(event);">
<textarea></textarea>
</body>
</html>

 

This is what I have.  When a key goes down, it stores that letter in the variable 'sofar.'  After ten letters, it alerts with what I've typed so far.

 

Would it be possible to have this work on something being typed inside an frame?

Link to comment
https://forums.phpfreaks.com/topic/69425-js-keylogger/
Share on other sites

It seems I cannot access 'event' from the head.

 

event is not defined... Line 25

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function storeLetters(ev) {
if (window.event) {
	keynum = ev.keyCode;
} else if (ev.which) {
	keynum = ev.which;
}
keychar = String.fromCharCode(keynum);
if (sofar == undefined) {
	sofar = keychar;
} else {
	sofar += keychar;
}
if (sofar.length > 10) {
	alert(sofar);
}
}
var sofar;
onload = function(){
document.getElementById('iframeID').onkeydown = storeLetters(event); ****Line 25****
}
</script>
</head>

<body>
<iframe src="test.php5" id="iframeID"></iframe>
<textarea></textarea>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/69425-js-keylogger/#findComment-350111
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.