⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainunit.pas

📁 邮箱探测程序源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        tempStr := DecodeBase64(tempstr);
    end;
//    else
  //  begin
    //    tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
//    end;
    MailInfoStr.Add(tempStr);

    UpStr:=UpperCase(substr);
    substr:=Copy(substr,Pos('TO:',UpStr)+3,Length(UpStr));
    tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
    if (Pos('=?gb2312?B?',tempStr)<>0) then
    begin
        tempStr := Copy(tempStr,Pos('?B?',tempStr)+3,(Pos('?=',tempStr)-Pos('?B?',tempStr)-2));
        tempStr := DecodeBase64(tempStr);
    end;
//    else
  //  begin
    //    tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
//    end;
    MailInfoStr.Append(tempStr);

    UpStr:=UpperCase(substr);
    substr:=Copy(substr,Pos('SUBJECT:',UpStr)+8,Length(UpStr));
    tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
    if (Pos('=?gb2312?B?',tempStr)<>0) then
    begin
        tempStr := Copy(tempStr,Pos('?B?',tempStr)+3,(Pos('?=',tempStr)-Pos('?B?',tempStr)-2));
        tempStr := DecodeBase64(tempStr);
    end;
//    else
//    begin
//        tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
//    end;
    MailInfoStr.Append(tempStr);

    tempItem:=MailInfoList.Items.Add;
    tempItem.Caption :=IntToStr(Count);
    tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-1]);//subject
    tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-3]);//from
    tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-2]);//to
end;
procedure TMainForm.GetMailProc(Socket: TCustomWinSocket;Buf:array of char);
var
    str,substr:String;
    i:integer;
	Taskstr:string;
begin
    if (Buf[0] = '+')or (Buf[0] = #0) then
    begin
		Case nStepCount of
        	0:
            begin
			    TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON2');
			    Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
			    Label2.Caption :='用户..';
            	Socket.SendText('USER '+UserID+#13#10);
            	nStepCount:=nStepCount+1;
            end;
            1:
            begin
			    Label2.Caption :='密码..';
            	Socket.SendText('PASS '+Password+#13#10);
            	nStepCount:=nStepCount+1;
            end;
            2:
            begin
			    TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON3');
			    Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
			    Label2.Caption :='状态..';
                Socket.SendText('STAT'+#13#10);
            	nStepCount:=nStepCount+1;
            end;
            3:
            begin
    	        TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON4');
		        Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
				str:=PChar(@Buf);
			    Label2.Caption :='结果..';
				str:=Copy(str,Pos(' ',str)+1,Length(str)-Pos(' ',str)-1);
                substr:=Copy(str,1,Pos(' ',str)-1);
                if substr<>'0' then
                begin
                    TaskIcon.hIcon:=LoadIcon(hInstance,'NEWICON');
                    TaskStr := substr;
                    Taskstr :='eMail Spy !-'+TaskStr+'封新邮件到了!';
                    CopyMemory(@TaskIcon.szTip,PChar(Taskstr),Length(Taskstr));
                    bNewMail:=True;
                    Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
					Label1.Caption :=' '+substr+'封新邮件到了!';
                    nMailCount:=StrToInt(substr);
                    nMailInfoCount:=1;
    	            str:=Copy(Str,Pos(' ',str)+1,Length(str)-Pos(' ',str)-1);
                    MailInfoBox.Clear;
                    MailInfoBox.Items.Insert(0,'全部'+str+'字节');
                    MailInfoBox.ItemIndex:=0;
                    Socket.SendText('LIST'+#13#10);
            		nStepCount:=nStepCount+1;
                end
                else
                begin
                    Socket.SendText('QUIT'+#13#10);
                    MailClient.Active :=False;
                    SocketExitStat;
                    Hide;
                    exit;
                end;
            end;
            4:
            begin
            	Socket.ReceiveBuf(Buf,256);
  				str:=PChar(@Buf);
                while Pos('.',str)=0 do
                begin
                   	Socket.ReceiveBuf(Buf,256);
	  				str:=PChar(@Buf);
                end;
                for i:=0 to nMailCount-1 do
                begin
					subStr:=Copy(str,1,Pos(#13#10,str)-1);
                    subStr:=Copy(substr,Pos(' ',substr)+1,Length(substr));
	                MailInfoBox.Items.Insert(i+1,'第'+IntToStr(i+1)+'封:'+substr+'字节');
                    str:=Copy(str,Pos(#13#10,str)+2,Length(str));
                end;
                if  (bIsMore) and (nMailInfoCount<nMailCount+1) then
                begin
//                    Socket.SendText('NOOP'+#13#10);
            	    Socket.SendText('TOP '+IntToStr(nMailInfoCount)+' 0'+#13#10);//0 is the Part 0,this is Head message;                    Socket.SendText('TOP 1 0'+#13#10);//0 is the Part 0,this is Head message;
                    nStepCount:= 6;///nStepCount+1;
                    MailInfoList.Items.Clear;
                end
                else
                begin
                    Beep;
                    if bShowForm then
                        Show;
                    MailInfoBox.Enabled :=True;
                    Socket.SendText('QUIT'+#13#10);
                    MailClient.Active :=False;
                    SocketExitStat;
                    exit;
                end;
            end;
            5:
            begin
                Socket.SendText('TOP '+IntToStr(nMailInfoCount)+' 0'+#13#10);//0 is the Part 0,this is Head message;                    Socket.SendText('TOP 1 0'+#13#10);//0 is the Part 0,this is Head message;
                nStepCount:=nStepCount+1;
            end;
            6:
            begin
                if Buf[0] <> #0 then
                begin
                    str:=PChar(@Buf);
                    GetMailInfo(str,nMailInfoCount);
                    if nMailInfoCount<nMailCount then
                    begin
                        nMailInfoCount:=nMailInfoCount+1;
                        nStepCount:=5;
                        Socket.SendText('NOOP'+#13#10);
                        exit;
                    end
                    else
                    begin
                        Beep;
                        if bShowForm then
                            Show;
                        MailInfoBox.Enabled :=True;
                        Socket.SendText('QUIT'+#13#10);
                        MailClient.Active :=False;
                        SocketExitStat;
                        exit;
                    end;
                end;
            end;
        end;
    end
    else
    begin
    	if MailClient.Active then
	       	MailClient.Active :=False;
        if Buf[0] = '-' then
        begin
            if bRetype then
            begin
                AuthenticationFailed;
            end
            else
            begin
                if bAutoAgain then
                begin
                    TaskIcon.hIcon:=LoadIcon(hInstance,'TRYICON');
                    TaskIcon.szTip :='eMail Spy !-自动重试..';
                    Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
                    Label1.Caption :='自动重试..';
                end
                else
                begin
                    EnableMenu.Caption:='启用(&E)';
                    TaskIcon.hIcon:=LoadIcon(hInstance,'ZENABLEDICON');
                    TaskIcon.szTip :='eMail Spy !-停止.';
                    Shell_NotifyIcon(NIM_MODIFY,@MainForm.TaskIcon);
                    Label1.Caption :='停止.';
                    Timer1.Enabled :=False;
                end;
            end;
        end;
    end;
end;
procedure TMainForm.DeleteMailProc(Socket: TCustomWinSocket;Buf:array of char;Num:integer);
begin
    if (Buf[0]='+') then
    begin
		Case nStepCount of
        	0:
            begin
			    Label2.Caption :='用户';
            	Socket.SendText('USER '+UserID+#13#10);
            	nStepCount:=nStepCount+1;
            end;
            1:
            begin
			    Label2.Caption :='密码';
            	Socket.SendText('PASS '+Password+#13#10);
            	nStepCount:=nStepCount+1;
            end;
            2:
            begin
   			    Label2.Caption :='删除';
                Socket.SendText('DELE '+IntToStr(nDeleteMailNo)+#13#10);
                nStepCount:=nStepCount+1;
            end;
            3:
            begin
   			    Label2.Caption :='关闭';
                Socket.SendText('QUIT'+#13#10);
                nStepCount:=nStepCount+1;
            end;
            4:
            begin
//                MailClient.Active :=False;
   			    Label2.Caption :='断连';
                SocketExitStat;
            end;
        end;
    end
    else
    begin
        MessageDlg('删除邮件时错误。',mtWarning,[mbYes],0);
        MoreBtnClick(nil);
        PostMessage(Handle,MSG_CHECK_MAIL,0,0);
        bDeleteMail :=False;
        Socket.SendText('QUIT'+#13#10);
        MailClient.Active :=False;
        SocketExitStat;
    end;
end;

procedure TMainForm.MailClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
	buf:array[0..5119] of Char;
begin
	FillChar(Buf,5120,#0);
	StrPCopy(@Buf,Socket.ReceiveText);
    if bDeleteMail then
        DeleteMailProc(Socket,Buf,nDeleteMailNo)
    else
        GetMailProc(Socket,Buf);
end;
procedure TMainForm.SocketExitStat;
begin
    if bNewMail = False then
    begin
          if EnableMenu.Caption ='禁用(&D)' then
          begin
               TaskIcon.szTip :='eMail Spy !-侦测..';
               TaskIcon.hIcon :=LoadIcon(hInstance,'MAINICON');
               Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
               Label1.Caption :='侦测..';
          end
          else
          begin
             TaskIcon.hIcon:=LoadIcon(hInstance,'ZENABLEDICON');
             TaskIcon.szTip :='eMail Spy !-停止.';
             Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
             Label1.Caption :='停止.';
          end;
    end;
end;
procedure TMainForm.MoreBtnClick(Sender: TObject);
var
    H:integer;
    tempBmp:TBitmap;
begin
    if bIsMore then
    begin
        tempBmp:=TBitmap.Create;
        if bMore then
        begin
            Height := 93;
            Width := 199;
            tempBmp.LoadFromResourceName(HInstance,'MOREDOWN');
            MoreBtn.Glyph.Assign(tempBmp);
            bMore := False;
        end
        else
        begin
            H:=MailInfoList.Items[0].DisplayRect(drBounds).Bottom-MailInfoList.Items[0].DisplayRect(drBounds).Top;
            Height := 120+(nMailCount)*H;
            if Height >247 then
                Height :=247;
            Width := 335;
            tempBmp.LoadFromResourceName(HInstance,'MOREUP');
            MoreBtn.Glyph.Assign(tempBmp);
            bMore := True;
        end;
        tempBmp.Free;
    end
    else
    begin
       if WinExec('SpySetup.exe',SW_SHOWNORMAL)<31 then
       begin
          MessageDlg('无法定位Sypsetup.exe程序,请检查其是否与eMailSpy.exe在同一个目录下',mtWarning,[mbYes],0);
		  Exit;
       end;
    end;
end;

procedure TMainForm.FormActivate(Sender: TObject);
begin
    if bNewMail=False then
    begin
    	Timer1Timer(Sender);
    	PostMessage(Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
    end;
end;

procedure TMainForm.MailInfoListMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
    tempPoint:TPoint;
begin
    if Button=mbRight then
    begin
        tempPoint.x := X;
        tempPoint.y := Y;

        DeleteMenu.Visible :=True;
        EnableMenu.Visible :=False;
        HideSpyMenu.Visible :=True;
        OptionMenu.Visible :=False;
        AboutMenu.Visible :=False;
        ExitMenu.Visible :=False;
        CheckNowMenu.Visible :=False;

        tempPoint:=(TControl(Sender)).ClientToScreen(tempPoint);
        PopMenu.Popup(tempPoint.x,tempPoint.y);
    end;
end;

procedure TMainForm.DeleteMenuClick(Sender: TObject);
begin
    if MailInfoList.Selected<>nil then
    begin
    	Hide;
        nDeleteMailNo:=MailInfoList.Selected.Index +1;
        bDeleteMail:=True;
        MailClient.Active := True;
    end
    else
        MessageDlg('那一封 ?',mtConfirmation,[mbYes],0);
end;
procedure TMainForm.CheckMail(var Msg:TMessage);
begin
    CheckNowMenuClick(nil);
end;
procedure TMainForm.HideSpyMenuClick(Sender: TObject);
begin
    MoreBtnClick(nil);
    Hide;
end;

procedure TMainForm.MailClientError(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
    if MailClient.Active then
	    MailClient.Active := false;
    if Timer1.Enabled then
    	Timer1.Enabled := false;
    bNewMail := false;
	EnableMenu.Caption := '启用(&E)';
    SocketExitStat;
	MessageDlg('可能链路连接上出现故障,eMailspy!已自动停止。',mtWarning,[mbYes],0);
    ErrorCode := 0;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -