wydadforever
9 years ago
I am currently developing an application in c# using easendmail, all is working fine , i work with the socks. this is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EASendMail;
using System.IO;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Collections.Concurrent;
using System.Net.Sockets;
using System.Net;


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EASendMail;
using System.IO;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Collections.Concurrent;
using System.Net.Sockets;
using System.Net;


namespace ApplicationHJ
{
public class Sender
{
public string Socksl;
public string Letter;



public Sender(string socks, string letter)
{
Socksl = socks;
Letter = letter;
}


public List loadSocks()
{
var result = new List();
string fileSocks = Path.GetFullPath(Path.Combine(Application.StartupPath, this.Socksl));
var input = File.ReadAllText(fileSocks);
var r = new Regex(@"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})");
foreach (Match match in r.Matches(input))
{
string ip = match.Groups[1].Value;
int port = Convert.ToInt32(match.Groups[2].Value);

ServerSocks bi = new ServerSocks();
bi.IpAddress = IPAddress.Parse(ip);
bi.Port = port;
result.Add(bi);
}
return result;
}
public void Exploit()
{
List arRcpt = new List();
Console.ReadLine();
string fileName;
OpenFileDialog fd = new OpenFileDialog();
fd.ShowDialog();
fileName = fd.FileName;
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
var logFile = File.ReadAllLines(fileName);
file.Close();
arRcpt = new List(logFile);
int nRcpt = arRcpt.Count;
SmtpMail[] arMail = new SmtpMail[nRcpt];
SmtpClient[] arSmtp = new SmtpClient[nRcpt];
SmtpClientAsyncResult[] arResult = new SmtpClientAsyncResult[nRcpt];
List list = loadSocks();
var oServer = new SmtpServer("");
for (int i = 0; i < nRcpt; i++)
{
arMail[i] = new SmtpMail("try it");
arSmtp[i] = new SmtpClient();
}
for (int i = 0; i < nRcpt; i++)
{
oServer.SocksProxyServer = list[i % list.Count].IpAddress.ToString();
oServer.SocksProxyPort = list[i % list.Count].Port;
oServer.ProxyProtocol = SocksProxyProtocol.Socks5;
oServer.SocksProxyUser = "login";
oServer.SocksProxyPassword = "password";
SmtpMail oMail = arMail[i];
oMail.SMIMERFCCompatibility = true;
oMail.From = new MailAddress("", "");
oMail.Subject = "Bonjour tous le monde";
oServer.HeloDomain = "";
oMail.ReplyTo = "";
oMail.Style = MailStyle.EASendMailStyle;
oMail.Priority = MailPriority.High;
oMail.EncryptionAlgorithm = EncryptionAlgorithmType.ENCRYPTION_ALGORITHM_RC2;
//the message will be send to this email
oMail.To = new AddressCollection(arRcpt[i]);
oMail.HeaderEncoding = HeaderEncodingType.EncodingBase64;
oMail.TextBody = "";
oMail.AutoTextBody = false;
try
{
string fileHtml = Path.GetFullPath(Path.Combine(Application.StartupPath, "Exploit1/lettercmb.html"));
//fileHtml = fileHtml.Replace("{random}", NumberOf7.ToString());
oMail.ImportHtmlBody(fileHtml, ImportHtmlBodyOptions.NoOptions);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
SmtpClient oSmtp = arSmtp[i];
arResult[i] = oSmtp.BeginSendMail(oServer, oMail, (AsyncCallback)null, (object)null);
Console.WriteLine(String.Format("Start to send email to {0} ...",
arRcpt[i] + i));

}
int nSent = 0;
while (nSent < nRcpt)
{
for (int i = 0; i < nRcpt; i++)
{
// this email has been sent
if (arResult[i] == null)
continue;

// wait for specified email ...
if (!arResult[i].AsyncWaitHandle.WaitOne(10, false))
{
continue;
}

try
{
// this email is finished, using EndSendMail to get result

arSmtp[i].EndSendMail(arResult[i]);
System.Threading.Thread.Sleep(1000 * 1);
Console.WriteLine(String.Format("Send email to {0} successfully", arRcpt[i]));

}
catch (Exception ep)
{
Console.WriteLine(
String.Format("Failed to send email to {0} with error {1}: ",
arRcpt[i] + i, ep.Message));
Console.ReadLine();
}
// Set this email result to null, then it won't be processed again
arResult[i] = null;
nSent++;
}
}
}

}
}


he send email then she take 3 second than he send another email.

i want if i have 4 socks for exemple he send 4 email in the same time , each email with a differentsocks, then he pause one second and send another 4 emails.

what i should do please ?
ivan
  • ivan
  • 100% (Exalted)
  • Administration
9 years ago
Hi, you should not use oResult.AsyncWaitHandle.WaitOne after just sent one email, you should send all emails at first, then use AsyncWaitHandle.

Please have a look at this example:

https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=13 

You can also refer to mass.csharp sample project in EASendMail installation path.
wydadforever
9 years ago

Hi, you should not use oResult.AsyncWaitHandle.WaitOne after just sent one email, you should send all emails at first, then use AsyncWaitHandle.

Please have a look at this example:

https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=13 

You can also refer to mass.csharp sample project in EASendMail installation path.

Originally Posted by: ivan 




Hi evan thanks for your help , i update the code as you can see in my post, but the problem he send all email in one time , what i want that he send 3 email than he make pause one secone than he send 3 other email in the list what i should do
?
ivan
  • ivan
  • 100% (Exalted)
  • Administration
9 years ago

Then you can call Sleep(1000) after BeginSendMail ...

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.