Parsi Coders

نسخه‌ی کامل: ،سورس کد فرستادن ایمیل از طریق وینساک (اسمبلی)
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
xMailSend.asm

کد :
کد:
;////////////////////////////////////////////////////////////////////
;/////////////////  xSendMail by Greedy Fly /////////////////////////
;////////////////////////////////////////////////////////////////////
szText  MACRO Name, Text:VARARG
        LOCAL lbl
        jmp lbl
        Name db Text,0
lbl:
endm

xSendMail PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
Base64Encode PROTO :DWORD, :DWORD, :DWORD

.code
xSendMail PROC Smtp: DWORD, Login: DWORD, Password: DWORD, From: DWORD, To: DWORD, Head: DWORD, Text: DWORD
   LOCAL wsadata: WSADATA
   LOCAL FSocket: DWORD
   LOCAL sin: sockaddr_in
   LOCAL RecvBuf[512]: BYTE
   LOCAL b64user[64]: BYTE
   LOCAL b64pass[64]: BYTE
   LOCAL Buff[127]: BYTE

invoke WSAStartup, 202h, addr wsadata
Connect:
invoke socket, AF_INET, SOCK_STREAM, 0
   mov FSocket, eax
invoke htons, 25
   mov sin.sin_port, ax
   mov sin.sin_family, AF_INET
invoke gethostbyname, Smtp
   mov eax,[eax+12]
   mov eax,[eax]
   mov eax,[eax]
   mov sin.sin_addr, eax
invoke connect, FSocket, addr sin, sizeof sockaddr_in
   test eax, eax
   jne Reconnect
  
invoke recv, FSocket, addr RecvBuf, 512, 0
szText Helo, "EHLO server",0Dh, 0Ah
invoke send, FSocket, addr Helo, sizeof Helo, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

szText Auth, "AUTH LOGIN",0Dh, 0Ah
invoke send, FSocket, addr Auth, sizeof Auth, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

szText crlf, 13,10,0
invoke lstrlen, Login
invoke Base64Encode, Login, addr b64user, eax
invoke lstrcat, addr b64user, addr crlf
invoke send, FSocket, addr b64user, sizeof b64user, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

invoke lstrlen, Password
invoke Base64Encode, Password, addr b64pass, eax
invoke lstrcat, addr b64pass, addr crlf
invoke send, FSocket, addr b64pass, sizeof b64pass, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

invoke lstrcpy, addr Buff, From
invoke lstrcat, addr Buff, addr crlf
invoke lstrlen, addr Buff
invoke send, FSocket, addr Buff, eax, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

invoke lstrcpy, addr Buff, To
invoke lstrcat, addr Buff, addr crlf
invoke lstrlen, addr Buff
invoke send, FSocket, addr Buff, eax, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

szText Data, "DATA",0Dh, 0Ah
invoke send, FSocket, addr Data, 6, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

szText Ending, 13,10,".",13,10,0
invoke lstrcat, Head, Text
invoke lstrcat, Head, addr Ending

invoke lstrlen, Head
invoke send, FSocket, Head, eax, 0
invoke recv, FSocket, addr RecvBuf, 512, 0

szText Quit, "QUIT",0Dh, 0Ah
invoke send, FSocket, addr Quit, 6, 0
invoke recv, FSocket, addr RecvBuf, 512, 0
invoke closesocket, FSocket
invoke WSACleanup
   ret
Reconnect:
invoke closesocket, FSocket
invoke Sleep, 4000
   jmp Connect
   ret
xSendMail endp

Base64Encode PROC uses esi edi ebx lpSrc, lpDst, Len: DWORD
   mov esi, lpSrc
   mov edi, lpDst
   mov ecx, Len

   xor eax, eax
   xor ebx, ebx
@gen:
   lodsb
   shl eax, 8
   loop @@2
   shl eax, 8
   jmp @@4
@@2:
   lodsb
   shl eax, 8
   loop @@3
   jmp @@4
@@3:
   lodsb
   dec ecx
@@4:
   push ecx
   push 4
   pop ecx
   push ecx
@@:
   rol edx, 8
   mov dl, al
   and dl, 00111111B
   shr eax, 6
   loop @B

   pop ecx
@edx_conv:
   cmp dl, 62
   jae dl_62_63
   cmp dl, 51
   ja digit_0_9
   add dl, 'A'
   cmp dl, 'Z'
   jbe @F
   add dl, 'a'-'Z'-1
@@:
   jmp rotate_edx
digit_0_9:
   add dl, 30h-52
   jmp rotate_edx
dl_62_63:
   sub dl, 62
   shl dl, 2
   add dl, 43
rotate_edx:
   rol edx, 8
   loop @edx_conv
   xchg eax, edx
   stosd
   xchg eax, edx

   pop ecx
   inc ebx
   inc ebx
@next:
   test ecx, ecx
   jnz @gen
   sub al,al
   stosb
   ret
Base64Encode endp

مثال :

کد:
.486
.model flat, stdcall
option casemap:none


include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\ws2_32.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\advapi32.inc
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\ws2_32.lib
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\advapi32.lib


.data
smtpserver db "smtp.mail.ru",0
User db "login",0
Pass db "password",0
MailFrom db "MAIL FROM:<frommail@mail.ru>",0
MailTo db "RCPT TO:<tomail@mail.ru>",0
Header db  "From: frommail@mail.ru ",0Dh, 0Ah,
           "To: tomail@mail.ru",0Dh, 0Ah,
           "Subject: Test",0Dh, 0Ah, 0
UserName db "UserName - ",0
          
.data?
Result db 127 dup(?)
xSize dd ?

.code
include xSendMail.asm

ep:
   mov xSize, sizeof Result
invoke GetUserName, addr Result, addr xSize
invoke lstrcat, addr UserName, addr Result


invoke xSendMail, addr smtpserver, addr User, addr Pass, addr MailFrom, addr MailTo, addr Header, addr UserName
   push 0
   call ExitProcess
end ep