I want to make a bot that logs into someones email, open a certain email, then clicks the link inside the email to confirm their accounts.
Here is the code someone helped me out with. Can you see if its right?
Here is the code someone helped me out with. Can you see if its right?
Code:
private string HTTP_POST(string host, string path, string postdata, bool SetCookies)
{
try
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://" + host + path);
req.Method = "POST";
req.Host = host;
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6) Gecko/20100101 Firefox/4.0b6";
req.Accept = "*/*";
req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] loginDataBytes = encoding.GetBytes(postdata);
req.ContentLength = loginDataBytes.Length;
Stream stream = req.GetRequestStream();
stream.Write(loginDataBytes, 0, loginDataBytes.Length);
stream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
return sr.ReadToEnd();
}
catch (Exception err)
{
return "ERR" + err.Message;
}
}
public void Login()
{
string html = HTTP_POST("www.***.com", "/cmy/***/login/",
"username=" + Account.Name + "&password=" + Account.Password + "&next=", true);
}
public string[] GetAllMatches(string _html)
{
System.Collections.Generic.List<String> matches = Regex("<a href=\"/cmy/match/([0-9]*)/\">Details</a>", _html);
return matches.ToArray();
}
private List<string> Regex(string p,string _html)
{
throw new NotImplementedException();
}
private string GetSomething(string _html)
{
Regex r_token = new Regex("\\[_csrf_token]\" value=\"([0-9A-Za-z]*)\"", RegexOptions.None);
Match m = r_token.Match(_html);
if (m.Success)
{
return r_token.Match(_html).Groups[1].Value;
}
else
{
System.Windows.Forms.MessageBox.Show("Token Error");
return null;
}
}
}