(土木狗所写,本文为第一篇,望各位大牛勿喷,刚入行不久,望各位同僚勿拍砖)
先上源码!本源码是在网上的一个程序改编而写的,我测试了些时间,没成功,即在该基础上进行进一步改写。如有部分代码侵权,本人会即刻删帖。还是首先向原作者致敬(不记得在哪儿下载的了,望谅解)。
补充注意点:因为本代码是在qq邮箱服务器上测试的,一下以qq邮箱为例说明
szUsername 为账号(qq号码)的base64编码
szPassword 为密码的base64编码
INCLUDELIB MSVCRTD.LIB 是为了使用printf函数
_TEXT SEGMENT和_TEXT END语法,是从vc2010编译出的asm文件学习的,初次编写完后,怎么运行都不能正常结束
代码最后为END,也是从vc2010编译出的asm文件学习的
本代码最终测试成功。希望能共勉
编写过程中有一个问题没解决,同僚们如有办法,求各位告知
问题描述如下:
我想在每次向qq服务器发送后,调用函数接收返回编码,于是用该函数如下:
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,200,0
push offset szRcvBuffer
push offset sz100s
call printf
因为调用次数比较多(如下代码可以看到,屡次调用该段),想单独写成一个函数。
我才入手汇编一两个礼拜,试了几遍,没试出来。
(土木狗向各位同僚致谢!)
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include wsock32.inc
includelib wsock32.lib
.data
hSocket dd ?
wsadata WSADATA <>
sin sockaddr_in <>
szSend db "smtp.qq.com",0
szRcvBuffer db 100 dup(0)
szHelo db "EHLO abcdefg-PC",13,10,0
szAuth db "AUTH LOGIN",13,10,0
szUsername db "NjU0OTU2NTYx",13,10,0
szPassword db "************",13,10,0
szRCPT db "RCPT TO:<wangdingqian@126.com>",13,10,0
szMailFrom db "MAIL FROM: <654956561@qq.com>",13,10,0
szData db "DATA",13,10,0
szFrom db "654956561@qq.com",13,10,0
szSubject db "SUBJECT:%s",13,10,0
szReplyTo db "Reply-TO:%s",13,10,0
szNull db 13,10,0
szHead db "From:<654956561@qq.com>",13,10,"To:<wangdingqian@126.com>",13,10,"Subject:Hello",13,10,13,10,0
;szHead最后必须两次/r/n即,13,10,13,10,0
szContent db "just fuck it ,and no hesitate",13,10,".",13,10,0
szQuit db "QUIT",13,10,0
szServer db "smtp.qq.com",0
.code
_TEXT SEGMENT
start:
invoke WSAStartup, 101h, addr wsadata
invoke socket, AF_INET, SOCK_STREAM, 0
mov hSocket, eax
invoke RtlZeroMemory,addr sin,sizeof sin
mov sin.sin_family, AF_INET
invoke htons, 25;主机字节顺序转化为网络字节顺序
mov sin.sin_port, ax
invoke gethostbyname, addr szSend
.if eax
mov eax, [eax + hostent.h_list]
mov eax, [eax]
mov eax, [eax]
mov sin.sin_addr, eax
.endif
;; 建立连接
invoke connect, hSocket, addr sin, sizeof sin
;; 发送“ehlo local”
invoke lstrlen,addr szHelo
invoke send, hSocket, addr szHelo, eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 发送“auth login”
invoke lstrlen,addr szAuth
invoke send, hSocket, addr szAuth, eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;发送用户名
invoke lstrlen,addr szUsername
invoke send, hSocket, addr szUsername, eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 发送密码
invoke lstrlen,addr szPassword
invoke send, hSocket, addr szPassword, eax, 0
;; 发送“mail from”
invoke lstrlen,addr szMailFrom
invoke send, hSocket, addr szMailFrom,eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 发送“rcpt”
invoke lstrlen,addr szRCPT
invoke send, hSocket, addr szRCPT,eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; DATA 准备开始发送邮件内容
invoke lstrlen,addr szData
invoke send, hSocket, addr szData, eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
; 邮件内容为szHead
invoke lstrlen,addr szHead
invoke send, hSocket, addr szHead,eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 发送邮件正文
invoke lstrlen,addr szContent
invoke send, hSocket, addr szContent,eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 发送“quit”
invoke lstrlen,addr szQuit
invoke send, hSocket, addr szQuit, eax, 0
invoke RtlZeroMemory,addr szRcvBuffer,sizeof szRcvBuffer
invoke recv,hSocket,addr szRcvBuffer,100,0
;; 断开连接
invoke closesocket, hSocket
invoke WSACleanup
ret 0
_TEXT ENDS
end start
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
上传的附件: