阅读:1691回复:10
如何用汇编写邮件发送程序
小弟入门不久,最近在写一个东东,需要一个邮件发送程序,看了别人写的一些代码,自己‘抄’了一边,准备自己给自己发送一份邮件,调试时send成功返回,可并未受到邮件,大家看看是哪里写错了,先谢了。
.386 .model flat,stdcall option casemap:none include windows.inc include kernel32.inc includelib kernel32.lib include user32.inc includelib user32.lib include wsock32.inc includelib wsock32.lib .const szLocation db \'mail.sina.com.cn\', 0 Format db \'Begin connect: %s\', 0 Receiver db \'Jzz2004@sina.com\', 0 MsgSuccess db \'Success\', 0 _HostName db \'Jzz2004\', 0 .data? buffer1 db 20h dup (?) buffer2 db 20h dup (?) buffer3 db 100h dup (?) buffer4 db 100h dup (?) buffer db 100h dup (?) hostname db 100h dup (?) .code start: push offset buffer push 101h call WSAStartup or eax, eax jnz _Exit invoke socket, AF_INET, SOCK_STREAM, 0 inc eax or eax, eax jz _WSACleanUp dec eax mov ebx, eax mov word ptr [buffer], AF_INET invoke htons, 25 mov word ptr [buffer + 2], ax push offset szLocation call gethostbyname or eax, eax jz _CloseSocket mov esi, [eax + 0ch] _EnumIPAddress: cmp dword ptr [esi], 0 jz _CloseSocket lodsd mov eax, [eax] mov dword ptr [buffer + 4], eax invoke connect, ebx, offset buffer, sizeof sockaddr_in or eax, eax jnz _EnumIPAddress push eax push esp push offset hostname call GetComputerName pop eax call PushMailHeader db \'HELO mail.sian.com.cn\', 0dh, 0ah db \'MAIL FROM: Jzz2004@sina.com\', 0dh, 0ah db \'RCPT TO: %s\', 0dh, 0ah db \'DATA\', 0dh, 0ah db \'FROM:%s@sina.com\', 0dh, 0ah db \'TO: %s\', 0dh, 0ah db \'SUBJECT: %s is comming!\', 0dh, 0ah, 0 PushMailHeader: pop eax push offset _HostName push offset Receiver push offset _HostName push offset Receiver push eax push offset buffer4 call wsprintf push 0 push eax push offset buffer4 push ebx call send cmp eax, SOCKET_ERROR jz _CloseSocket invoke Sleep, 1000 call PushMailEnd db 0dh, 0ah, \'.\', 0dh, 0ah PushMailEnd: pop eax invoke send, ebx, eax, 5, 0 cmp eax, SOCKET_ERROR jz _CloseSocket invoke Sleep, 1000 call PushMailQuit db \'QUIT\', 0dh, 0ah, 0 PushMailQuit: pop eax invoke send, ebx, eax, 6, 0 cmp eax, SOCKET_ERROR jz _CloseSocket invoke Sleep, 1000 _CloseSocket: push ebx call closesocket _WSACleanUp: call WSACleanup _Exit: invoke ExitProcess, 0 end start |
|
沙发#
发布于:2005-03-22 07:58
你先要\"AUTH LOGIN \",有些SMTP server要Login,username and password先用base64编码
给你一段C.
|
|
板凳#
发布于:2005-03-22 08:59
看看pop协议吧
|
|
|
地板#
发布于:2005-03-22 15:16
实现smtp协议就可以了.不过服务器端认证方式有好几种.
|
|
|
地下室#
发布于:2005-03-23 15:18
找了一点资料,发现有些代码里涉及到了Base64, 具体内容好象是将Ansi转换成另一种形式。
Base64是什么呢?这和发邮件有什么关系啊? 晚辈实在看不明白,还望高手指点,谢谢。 |
|
5楼#
发布于:2005-03-23 23:43
base64 是用64个字母表示的编码。其编码表为:(0-63) A-Z,a-z,0-9,+,/ 。另等号作填充字符。每三个原码编码后变为四个字。不足则用=填。其规则为三个原码的24bits 化为四个6bits,再查表。
如:BOY---> 0x42 0x4F 0x59 ---->0100 0010 0100 1111 0101 1001 ---->010000 100100 111101 011001 ---->0x10 0x24 0x3D 0x19 ---->QK9Z |
|
6楼#
发布于:2005-03-25 00:04
用汇编语言写ESMTP邮件发送程序
http://www.luocong.com/articles/show_article.asp?Article_ID=21 |
|
7楼#
发布于:2005-03-25 22:47
谢谢楼上几位提供的资料,但还是有问题:
.data socketaddress sockaddr_in <?> szHelo db \'HELO mail.sina.com.cn\',13, 10, 0 szAuth db \'AUTH LOGIN\', 13, 10, 0 1) connect, hSocket, offset socketaddress, sizeof sockaddr_in recv的内容是:220 sina.com ESMTP 2) lstrlen, offset szHelo send,hSocket, offset szHelo, eax, 0 recv的内容是:250 sina.com 3) lstrlen, offset szAuth send, hSocket, offset szAuth, eax, 0 recv的内容是:553,....... -unrecognized authentiction type 4) 然后BufferToBase64后发送用户名和密码recv的内容都是 unimplemented 为什么发送‘AUTH LOGIN’失败, 是不是这个命令格式有问题? |
|
8楼#
发布于:2005-03-26 12:37
试试把
szAuth db \'AUTH LOGIN\', 13, 10, 0 改成 szAuth db \'AUTH LOGIN \', 13, 10, 0 很久没用汇编语言写东西了 !! |
|
9楼#
发布于:2005-03-26 20:32
还是不行,是不是某些服务器有特殊的命令?
|
|
10楼#
发布于:2005-04-05 13:21
又找了一些网站,在进行auth login时,我将Base64之后的username和password发送过去,回显总是535 auth failure;如果故意用错误的username和password,回显结果便是535 auth error,然后便遗失对主机的连接。
对比两种不同的错误信息(虽然错误代码一样的),我想auth login时是不是还要对Base64之后的username和password进行一些其他的处理呢? |
|