Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- using System.Net;
- using System.Security.Cryptography;
- using System.IO;
- using System.Timers;
- namespace FxpBot
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- //Setting topic timer
- topictimer.Tick += new EventHandler(timer1_Tick);
- topictimer.Interval = 7000;
- topictimer.Enabled = false;
- //Setting message timer
- messagetimer.Tick += Messagetimer_Tick;
- messagetimer.Interval = 25000;
- messagetimer.Enabled = false;
- }
- private void Messagetimer_Tick(object sender, EventArgs e)
- {
- messagetimerfunction();
- }
- //--- ---
- //MESSAGE TIMER
- public void messagetimerfunction()//Message function code
- {
- //No error so far
- //Declaring local variables
- string currentuser;
- string currentpassword;
- string currentverify;
- //Start user loop
- for (int i = 0; i < listrowsnum; i++)
- {//STARTING EACH USER LOOP
- //Setting user and pass variables
- currentuser = listrows[i, 0];
- currentpassword = listrows[i, 1];
- currentverify = listrows[i, 2];
- string[] currentuserdetails;
- CookieCollection currentindexcookies;
- CookieCollection currentcookies;
- string messagetimerforumid = "21";
- currentindexcookies = GoToFXP();
- currentcookies = GetLoginCookies(currentindexcookies, currentuser, currentpassword, 0);
- if (currentcookies == null)//If couldn't log in
- {
- //Skip user and remove from list
- listrows[i, 2] = "0";//Mark user as a wrong user
- messagelog.Text += currentuser + " could not log in successfully, going to the next user.\n";
- continue;//Only then skip
- }
- else//If could log in only then dare to commit the TOKENID function
- {
- currentuserdetails = GetTokenAndID(currentcookies, messagetimerforumid);
- }
- if (currentverify == "0")//If user has been marked as unsuccesful
- {
- continue;//Skip to next user
- }
- else if (currentuserdetails.Length == 1)//Means couldn't get token and id, user is in ban or just doesn't work
- {
- //Skip user and remove from list
- listrows[i, 2] = "0";//Mark user as a wrong user
- messagelog.Text += currentuser + " is probably banned or something went wrong, going to the next user.\n";
- continue;//Only then skip
- }
- else//If hasn't got into any trouble so far continue to attempt to spam
- {
- TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
- int secondsSinceEpoch = (int)t.TotalSeconds;
- int currentmessagestatus = PostMessage(currentcookies, currentuserdetails[0], currentuserdetails[1], messagevictim.Text, messagetitle.Text, messagecontent.Text + secondsSinceEpoch);
- if (currentmessagestatus == 2)//If succeeded
- {
- messagesnumberint++;//Update topics number
- messagesnumber.Text = topicsnumberint.ToString();//Update and print the topics number textbox
- messagelog.Text += currentuser + " has sent a message successfully.\n";
- }
- }
- }//ENDING EACH USER LOOP
- messagelog.Text += "-----------------------\n";//Print signs and a new line to indicate this run of the timer has ended
- }
- //END MESSAGE TIMER
- //--- ---
- private void timer1_Tick(object sender, EventArgs e)
- {
- topictimerfunction();
- }
- System.Windows.Forms.Timer topictimer = new System.Windows.Forms.Timer();
- System.Windows.Forms.Timer messagetimer = new System.Windows.Forms.Timer();
- //--- ---
- //TOPIC TIMER
- public void topictimerfunction()
- {
- //No error so far
- //Declaring local variables
- string currentuser;
- string currentpassword;
- string currentverify;
- //Start user loop
- for (int i = 0; i < listrowsnum; i++)
- {//STARTING EACH USER LOOP
- //Setting user and pass variables
- currentuser = listrows[i, 0];
- currentpassword = listrows[i, 1];
- currentverify = listrows[i, 2];
- string[] currentuserdetails;
- CookieCollection currentindexcookies;
- CookieCollection currentcookies;
- currentindexcookies = GoToFXP();
- currentcookies = GetLoginCookies(currentindexcookies, currentuser, currentpassword, 1);
- if (currentcookies == null)//If couldn't log in
- {
- //Skip user and remove from list
- listrows[i, 2] = "0";//Mark user as a wrong user
- topiclog.Text += currentuser + " could not log in successfully, going to the next user.\n";
- continue;//Only then skip
- }
- else//If could log in only then dare to commit the TOKENID function
- {
- currentuserdetails = GetTokenAndID(currentcookies, forumid.Text);
- }
- if (currentverify == "0")//If user has been marked as unsuccesful
- {
- continue;//Skip to next user
- }
- else if (currentuserdetails.Length == 1)//Means couldn't get token and id, user is in ban or just doesn't work
- {
- //Skip user and remove from list
- listrows[i, 2] = "0";//Mark user as a wrong user
- topiclog.Text += currentuser + " is probably banned or something went wrong, going to the next user.\n";
- continue;//Only then skip
- }
- else//If hasn't got into any trouble so far continue to attempt to spam
- {
- TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
- int secondsSinceEpoch = (int)t.TotalSeconds;
- int currenttopicstatus = PostTopic(currentcookies, currentuserdetails[0], currentuserdetails[1], forumid.Text, topictitlebox.Text, topiccontentbox.Text + secondsSinceEpoch);
- if (currenttopicstatus == 5)//If succeeded
- {
- topicsnumberint++;//Update topics number
- topicsnumber.Text = topicsnumberint.ToString();//Update and print the topics number textbox
- topiclog.Text += currentuser + " has opened a topic successfully.\n";
- }
- else if (currenttopicstatus == 3)
- {
- topiclog.Text += currentuser + " has to wait a few more seconds.\n";
- }
- else
- {
- topiclog.Text += currentuser + " could not open a topic for some reason.\n";
- }
- }
- }//ENDING EACH USER LOOP
- topiclog.Text += "-----------------------\n";//Print signs and a new line to indicate this run of the timer has ended
- }
- //END TOPIC TIMER
- //--- ---
- //Pre aranging variables
- string[,] listrows = new string[100, 3];//username, password, is user verified
- int listrowsnum = 0;
- int topicsnumberint = 0;
- int messagesnumberint = 0;
- int istopicrunning = 0;
- bool doeshavetowait15 = false;
- int lastwait15minutes;
- int ismessagerunning = 0;
- public static bool IsOdd(int value)
- {
- return value % 2 != 0;
- }
- public bool IsTextUserValid()
- {
- listrowsnum = 0;
- string currentusertext = usertext.Text;
- MatchCollection matches;
- Regex pattern = new Regex(@"([a-zA-Z0-9_א-ת ]{3,})");
- matches = pattern.Matches(currentusertext);
- if (IsOdd(matches.Count) == true || matches.Count == 0)//If matches are not even it means users number isn't equal to passwords number, invalid
- {
- return false;
- }
- int p = 0;
- for (int i = 0; i < matches.Count; i++)
- {
- if (IsOdd(i) == false)//If the current match is username
- {
- listrows[p, 0] = matches[i].Value;//Set username
- listrows[p, 2] = "1";//Set user verify mode to 1 = true
- }
- //If the current match is password
- else
- {
- listrows[p, 1] = matches[i].Value;
- p++;//Add 1 to p, adding only every user, NOT every match
- listrowsnum++;//Adding 1 to rowsnum
- }
- }
- return true;
- }
- public string GetMD5(string input)
- {
- // step 1, calculate MD5 hash from input
- MD5 md5 = System.Security.Cryptography.MD5.Create();
- byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
- byte[] hash = md5.ComputeHash(inputBytes);
- // step 2, convert byte array to hex string
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < hash.Length; i++)
- {
- sb.Append(hash[i].ToString("X2"));
- }
- return sb.ToString();
- }
- public bool IsNumeric(string number)
- {
- int n;
- bool IsNumericBool = int.TryParse(number, out n);
- return IsNumericBool;
- }
- public CookieCollection GoToFXP()
- {
- //Creating the request
- HttpWebRequest indexrequest = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/");
- //Setting headers
- indexrequest.Host = "www.fxp.co.il";
- indexrequest.KeepAlive = true;
- indexrequest.Method = "GET";
- indexrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
- indexrequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
- indexrequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- indexrequest.AutomaticDecompression = DecompressionMethods.GZip;
- indexrequest.Timeout = 2000;
- indexrequest.CookieContainer = new CookieContainer();
- //Setting the content length
- string index_get_data = "";
- var indexdata = Encoding.UTF8.GetBytes(index_get_data);
- //Setting content length header
- indexrequest.ContentLength = indexdata.Length;
- try
- {
- var indexresponse = (HttpWebResponse)indexrequest.GetResponse();
- string indexsresponsestring = new StreamReader(indexresponse.GetResponseStream()).ReadToEnd();
- return indexresponse.Cookies;
- }
- catch (WebException e)
- {
- return StringCookiesToCollection(GetIndexPreCookies());
- }
- }
- public string GetIndexPreCookies()
- {
- return "visid_incap_12480=5W1466LVTC+kkk91qKgPzpo8BlgAAAAAQUIPAAAAAAAgtF/gOHddXrl6Zj7d/G+U; expires=Wed, 18 Oct 2017 08:49:58 GMT; path=/; Domain=.fxp.co.il; nlbi_12480=FzpGQfydv2iC1QiJz82m+gAAAACPxABoP6uvNp0pRuNBzg2v; path=/; Domain=.fxp.co.il; incap_ses_264_12480=WzI+VTIzETqNxW6cz+upA5o8BlgAAAAAJ5iKTFgCBVhCQljl4VRRUQ==; path=/; Domain=.fxp.co.il";
- }
- public bool DoesContain(string text, string pattern)
- {
- Regex regexpattern = new Regex(pattern);
- if (regexpattern.IsMatch(text))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public CookieCollection StringCookiesToCollection(string cookies)
- {
- //New cookie collection
- CookieCollection currentcookiecollection = new CookieCollection();
- //Preparing premade cookies
- string precookie = cookies;
- //Split by ';' and add
- string[] splittedprecookie = precookie.Split(' ');
- //Add each cookie
- for (int i = 0; i < splittedprecookie.Length; i++)
- {
- string[] cookienameandvalue = splittedprecookie[i].Split(new char[] { '=' }, 2);
- string[] cookievaluesplitted = cookienameandvalue[1].Split(';');//ERROR HERE
- string cookievalue = cookievaluesplitted[0];
- currentcookiecollection.Add(new Cookie(cookienameandvalue[0], cookievalue));
- }
- return currentcookiecollection;
- }
- public String CookiesCollectionToString(CookieCollection cookies)
- {
- CookieCollection currentcookiecollection = cookies;
- string returnstring = "";
- string subbix = "; ";
- for (int i = 0; i < currentcookiecollection.Count; i++)
- {
- returnstring += currentcookiecollection[i].Name + "=" + currentcookiecollection[i].Value;
- if (i != currentcookiecollection.Count - 1)//If isn't the last cookie
- {
- returnstring += subbix;
- }
- }
- return returnstring;
- }
- public CookieCollection GetPreCookies()
- {
- //New cookie collection
- CookieCollection currentcookiecollection = new CookieCollection();
- //Preparing premade cookies
- string precookie = "nlbi_12480=9aLtOa+ZdD9l/Ntjz82m+gAAAAA2y1kCrOr0eM6ak1UjUdLg; _dy_ses_load_seq=56172%3A1476699223915; _dy_csc_ses=t; _dy_c_exps=; _ga=GA1.3.1206978354.1476699225; _gat=1; visid_incap_12480=IEvkSQwWRVSBvmGOBiTxXlakBFgAAAAAQUIPAAAAAABPLCtvscoWjj+mHiOv0B4k; incap_ses_418_12480=tW0sQHm+VFvUVDYxJgnNBVakBFgAAAAA9M1u887c4olbrj7D/06LCA==; visid_incap_152115=9GubNMrsSXGFup6CDsnMw1ekBFgAAAAAQUIPAAAAAABggPiDgk8j0th24B0vh00w; incap_ses_418_152115=q8BGaHHi9yWJVTYxJgnNBVekBFgAAAAARpbTZRl594HRZziK43zkBA==; _dyid=2112188372742349912; _dyfs=true; _dycst=dk.w.c.ws.frv1.frs.; _dy_geo=IT.EU.IT_17.IT_17_Marco; _dy_df_geo=Italy..Marco; _dy_toffset=-2; _dyus_8767177=0%7C0%7C0%7C0%7C0%7C0.0.1476699226167.1476699226167.0.0%7C290%7C43%7C9%7C116%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0";
- //Split by ';' and add
- string[] splittedprecookie = precookie.Split(' ');
- //Add each cookie
- for (int i = 0; i < splittedprecookie.Length; i++)
- {
- string[] cookienameandvalue = splittedprecookie[i].Split(new char[] { '=' }, 2);
- string[] cookievaluesplitted = cookienameandvalue[1].Split(';');
- string cookievalue = cookievaluesplitted[0];
- currentcookiecollection.Add(new Cookie(cookienameandvalue[0], cookievalue));
- }
- return currentcookiecollection;
- }
- public CookieCollection GetLoginCookies(CookieCollection cookies, string LoginUser, string LoginPassword, int isittopic)
- {
- //Preparing variables
- LoginPassword = GetMD5(LoginPassword);
- //Setting post content
- string login_data = "vb_login_username=" + LoginUser + "&vb_login_password_hint=%D7%A1%D7%99%D7%A1%D7%9E%D7%94&vb_login_password=&s=&securitytoken=guest&do=login&cookieuser=1&vb_login_md5password=ac30be895d5f219e7ab29f3678237b7c&vb_login_md5password_utf=ac30be895d5f219e7ab29f3678237b7c";
- //Creating the request
- HttpWebRequest loginrequest = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/login.php?do=login");
- //Setting headers
- loginrequest.Host = "www.fxp.co.il";
- loginrequest.KeepAlive = true;
- loginrequest.Method = "POST";
- loginrequest.CookieContainer = new CookieContainer();
- loginrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
- loginrequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
- loginrequest.Referer = "https://www.fxp.co.il/login.php?do=login";
- loginrequest.ContentType = "application/x-www-form-urlencoded";
- loginrequest.Credentials = CredentialCache.DefaultCredentials;
- loginrequest.ServicePoint.Expect100Continue = false;
- loginrequest.Headers.Add("Upgrade-Insecure-Requests", "1");
- loginrequest.Headers.Add("Cache-Control", "max-age=0");
- loginrequest.Headers.Add("Origin", "https://www.fxp.co.il");
- loginrequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- loginrequest.AutomaticDecompression = DecompressionMethods.GZip;
- //Add new cookie container
- loginrequest.CookieContainer = new CookieContainer();
- loginrequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), GetPreCookies());
- byte[] loginbytearray = Encoding.ASCII.GetBytes(login_data);
- loginrequest.ContentLength = loginbytearray.Length;
- Stream newStream = loginrequest.GetRequestStream(); //open connection
- newStream.Write(loginbytearray, 0, loginbytearray.Length); // Send the data.
- newStream.Close();
- HttpWebResponse loginresponse = (HttpWebResponse)loginrequest.GetResponse();
- string htmlloginresponse;
- using (StreamReader sr = new StreamReader(loginresponse.GetResponseStream()))
- {
- htmlloginresponse = sr.ReadToEnd();
- }
- if (htmlloginresponse.Contains("אנא המתן 15 דקות לפני הנסיון הבא") == true || DoesContain(htmlloginresponse, "אנא המתן 15 דקות לפני הנסיון הבא") == true)
- {
- //Prepare time variables
- TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
- int secondsSinceEpoch = (int)t.TotalSeconds;
- //If 15 minutes block is on set variable to true
- lastwait15minutes = secondsSinceEpoch;
- doeshavetowait15 = true;
- if (isittopic == 1)//If the function calling GetCookies is for topic posting, act as for topic timer
- {
- //Stop the timer and exit with a message
- //Stop topic timer
- istopicrunning = 0;
- topictimer.Stop();
- topictimer.Enabled = false;
- topicsnumberint = 0;
- topicsnumber.Text = "0";
- topicsbutton.Text = "Spam topics";
- topiclog.Text += "A 15 minutes waiting error occured, the attack stopped, wait for 15 more minutes.\n----------\n";
- }
- else//Else act as for message timer
- {
- //Stop the timer and exit with a message
- //Stop message timer
- ismessagerunning = 0;
- messagetimer.Stop();
- messagetimer.Enabled = false;
- messagesnumberint = 0;
- messagesnumber.Text = "0";
- messagebutton.Text = "Spam messages";
- messagelog.Text += "A 15 minutes waiting error occured, the attack stopped, wait for 15 more minutes.\n----------\n";
- }
- return null;
- }
- if (htmlloginresponse.Contains("שם משתמש או סיסמה שגויים") == true)//Wrong pasword and username
- {
- return null;
- }
- return loginresponse.Cookies;
- }
- public string Between(string value, string a, string b)
- {
- int posA = value.IndexOf(a);
- int posB = value.LastIndexOf(b);
- if (posA == -1)
- {
- return "";
- }
- if (posB == -1)
- {
- return "";
- }
- int adjustedPosA = posA + a.Length;
- if (adjustedPosA >= posB)
- {
- return "";
- }
- return value.Substring(adjustedPosA, posB - adjustedPosA);
- }
- public CookieCollection SplitCookie(CookieCollection cookies)
- {
- CookieCollection newcookie = new CookieCollection();
- string[] getcookies = CookiesCollectionToString(cookies).Split(' ');
- string[] twocookieparts;
- for (int i = 0; i < 8; i++)
- {
- twocookieparts = getcookies[i].Split(';');
- twocookieparts = twocookieparts[0].Split(new char[] { '=' }, 2);
- newcookie.Add(new Cookie(twocookieparts[0], twocookieparts[1]));
- }
- return newcookie;
- }
- public string[] GetTokenAndID(CookieCollection cookies, string forumidint)
- {
- //Creating the login request
- HttpWebRequest detailsrequest = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/newthread.php?do=newthread&f=" + forumidint);
- //Setting the attributes of the login request
- string details_post_data = "";
- var detailsdata = Encoding.UTF8.GetBytes(details_post_data);
- detailsrequest.Host = "www.fxp.co.il";
- detailsrequest.KeepAlive = true;
- detailsrequest.Method = "GET";
- detailsrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36";
- detailsrequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
- detailsrequest.Referer = "https://www.fxp.co.il/newthread.php?do=newthread&f=" + forumidint;
- detailsrequest.ContentType = "application/x-www-form-urlencoded";
- detailsrequest.ContentLength = detailsdata.Length;
- detailsrequest.Headers.Add("Upgrade-Insecure-Requests", "1");
- detailsrequest.Headers.Add("Cache-Control", "max-age=0");
- detailsrequest.Headers.Add("Origin", "https://www.fxp.co.il");
- detailsrequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- detailsrequest.CookieContainer = new CookieContainer();
- detailsrequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), GetPreCookies());
- detailsrequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), SplitCookie(cookies));
- //Prepare return array variable
- string[] detailsarray = new string[2];
- //Html details response
- var detailsresponse = (HttpWebResponse)detailsrequest.GetResponse();
- string detailsresponsestring = new StreamReader(detailsresponse.GetResponseStream()).ReadToEnd();
- //Find security token by GetBetweenString
- detailsarray[0] = Between(detailsresponsestring, "securitytoken\" value=\"", ">");
- string[] splitdetails = detailsarray[0].Split('"');
- detailsarray[0] = splitdetails[0];
- //Setting user id, currently no need in actual id
- detailsarray[1] = "1";
- //Checks if user is in ban
- if (detailsresponsestring.Contains("הושעת מהאתר מהסיבה הבאה:"))
- {
- string[] isinban = new string[1];
- isinban[0] = "ERRORBAN";
- return isinban;//If is in ban returns array of only one variable
- }
- return detailsarray;
- }
- public int PostTopic(CookieCollection cookies, string currentsecuritytoken, string currentuserid, string forumidint, string topictitle, string topiccontent)
- {
- //Creating the login request
- HttpWebRequest topicrequest = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/newthread.php?do=postthread&f=" + forumidint);
- //Setting the attributes of the login request
- string topic_post_data = "prefixid=dis&subject=" + topictitle + "&message_backup=" + topiccontent + "&message=" + topiccontent + "&wysiwyg=1&s=&securitytoken=" + currentsecuritytoken + "&f=" + forumidint + "&do=postthread&posthash=&poststarttime=&loggedinuser=" + currentuserid.ToString() + "&sbutton=%D7%A6%D7%95%D7%A8+%D7%90%D7%A9%D7%9B%D7%95%D7%9C+%D7%97%D7%93%D7%A9&signature=1&parseurl=1";
- var topicdata = Encoding.UTF8.GetBytes(topic_post_data);
- topicrequest.Host = "www.fxp.co.il";
- topicrequest.KeepAlive = true;
- topicrequest.Method = "POST";
- topicrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36";
- topicrequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
- topicrequest.Referer = "https://www.fxp.co.il/newthread.php?do=newthread&f=" + forumidint;
- topicrequest.ContentType = "application/x-www-form-urlencoded";
- topicrequest.ContentLength = topicdata.Length;
- topicrequest.Headers.Add("Upgrade-Insecure-Requests", "1");
- topicrequest.Headers.Add("Cache-Control", "max-age=0");
- topicrequest.Headers.Add("Origin", "https://www.fxp.co.il");
- topicrequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- topicrequest.CookieContainer = new CookieContainer();
- topicrequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), GetPreCookies());
- topicrequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), SplitCookie(cookies));
- topicrequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- topicrequest.AutomaticDecompression = DecompressionMethods.GZip;
- using (Stream stream = topicrequest.GetRequestStream())
- {
- stream.Write(topicdata, 0, topicdata.Length);
- }
- //Html topic response
- var topicresponse = (HttpWebResponse)topicrequest.GetResponse();
- string topicresponsestring = new StreamReader(topicresponse.GetResponseStream()).ReadToEnd();
- //Got banned = 0, other error = 1, succeded = 2, 3 = has to wait more seconds, 5 = succeeded
- if(topicresponsestring.Contains("<div class=\"postbody\">") == true)
- {
- return 5;
- }
- //Check if has to wait seconds
- if (topicresponsestring.Contains("המערכת דורשת זמן המתנה בין פרסום הודעות/אשכולות") == true)//Check if seconds waiting error occured
- {
- return 3;
- }
- //Check if is in ban
- //Checks if "הושעת מהאתר מהסיבה הבאה:" is printed, if so it means the user is banned
- Regex topicbannedpattern = new Regex("הושעת מהאתר מהסיבה הבאה:");
- MatchCollection topicbannedmatches = topicbannedpattern.Matches(topicresponsestring);
- if (topicbannedmatches.Count > 0)//If the ban message does appear
- {
- return 0;//The user is in ban, return 0
- }
- return 2;//Otherwise return 2 as success
- }
- public int PostMessage(CookieCollection cookies, string currentsecuritytoken, string currentuserid, string messagevictim, string messagetitle, string messagecontent)
- {
- //Creating the login request
- HttpWebRequest messagerequest = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/private.php?do=insertpm&pmid=");
- //Setting the attributes of the login request
- string message_post_data = "recipients=" + messagevictim + "&title=" + messagetitle + "&message_backup=" + messagecontent + "&message=" + messagecontent + "&wysiwyg=1&s=&securitytoken=" + currentsecuritytoken + "&do=insertpm&pmid=&forward=&sbutton=%D7%A9%D7%9C%D7%97+%D7%94%D7%95%D7%93%D7%A2%D7%94&savecopy=1&signature=1&parseurl=1&s=&securitytoken=" + currentsecuritytoken + "&do=insertpm&pmid=&forward=";
- var messagedata = Encoding.UTF8.GetBytes(message_post_data);
- messagerequest.Host = "www.fxp.co.il";
- messagerequest.KeepAlive = true;
- messagerequest.Method = "POST";
- messagerequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36";
- messagerequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
- messagerequest.Referer = "https://www.fxp.co.il/private.php?do=newpm&u=" + currentuserid;
- messagerequest.ContentType = "application/x-www-form-urlencoded";
- messagerequest.ContentLength = messagedata.Length;
- messagerequest.Headers.Add("Upgrade-Insecure-Requests", "1");
- messagerequest.Headers.Add("Cache-Control", "max-age=0");
- messagerequest.Headers.Add("Origin", "https://www.fxp.co.il");
- messagerequest.Headers.Add("Accept-Language", "he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4");
- messagerequest.CookieContainer = new CookieContainer();
- messagerequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), GetPreCookies());
- messagerequest.CookieContainer.Add(new Uri("https://www.fxp.co.il"), SplitCookie(cookies));
- using (Stream stream = messagerequest.GetRequestStream())
- {
- stream.Write(messagedata, 0, messagedata.Length);
- }
- //Html message response
- var messageresponse = (HttpWebResponse)messagerequest.GetResponse();
- string messageresponsestring = new StreamReader(messageresponse.GetResponseStream()).ReadToEnd();
- //Got banned = 0, other error = 1, succeded = 2, 3 = has to wait more seconds
- //Check if has to wait seconds
- if (messageresponsestring.Contains("שניות בין שליחת הודעות פרטיות") == true)//Check if seconds waiting error occured
- {
- string waitnumber = Between(messageresponsestring, "לפחות ", " שניות");
- //System.Threading.Thread.Sleep(3000);
- }
- //Check if is in ban
- //Checks if "הושעת מהאתר מהסיבה הבאה:" is printed, if so it means the user is banned
- Regex messagebannedpattern = new Regex("הושעת מהאתר מהסיבה הבאה:");
- MatchCollection messagebannedmatches = messagebannedpattern.Matches(messageresponsestring);
- if (messagebannedmatches.Count > 0)//If the ban message does appear
- {
- return 0;//The user is in ban, return 0
- }
- return 2;//Otherwise return 2 as success
- }
- public bool IsValidVictim(string victim)
- {
- Regex victimpattern = new Regex("[a-zA-Z0-9_א-ת ]{3,}");
- if (victimpattern.IsMatch(victim) == true)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void button2_Click(object sender, EventArgs e)//Messagebutton event
- {
- //Check if is topicloop is running
- if (ismessagerunning == 0)
- {
- //Prepare time variables to check 15 minutes block error
- TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
- int secondsSinceEpoch = (int)t.TotalSeconds;
- int secondsleft = 900 - (secondsSinceEpoch - lastwait15minutes);
- if (secondsSinceEpoch >= (lastwait15minutes + 900))//If can set doeshavetowait15 to false
- {
- doeshavetowait15 = false;//If 15 minutes passed reset it to false
- }
- if (doeshavetowait15 == true)//If user has to wait because of 15 minutes login error
- {
- MessageBox.Show("Since you have tried to log in too many times or an error occured, you have to wait 15 minutes.You have left " + secondsleft);
- }
- else if (IsTextUserValid() == false)//Check if user text is invalid
- {
- MessageBox.Show("The user text inserted isn't valid.");
- }
- else if (messagecontent.Text.Length < 2 || messagetitle.Text.Length < 1)//Check if message title and content are too short
- {
- MessageBox.Show("The message title must have at least 1 character, and the message content must have at least 2 characters.");
- }
- else if (IsValidVictim(messagevictim.Text) == false)//Check if message victim is invalid
- {
- MessageBox.Show("The message recipient inserted isn't valid.");
- }
- else//If everything is ok only then begin the loop
- {
- messagetimerfunction();//Call the function immidietly otherwise it'll wait 30 seconds
- ismessagerunning = 1;//Set to is activated
- messagetimer.Enabled = true;
- messagetimer.Start();//Start message timer and activate it
- messagebutton.Text = "Stop messages";
- }
- }
- else//If it's already running
- {
- //Stop message timer
- ismessagerunning = 0;
- messagetimer.Stop();
- messagetimer.Enabled = false;
- messagesnumberint = 0;
- messagesnumber.Text = "0";
- messagebutton.Text = "Spam messages";
- }
- }
- private void topicsbutton_Click(object sender, EventArgs e)
- {
- //Check if is topicloop is running
- if (istopicrunning == 0)
- {
- //Prepare time variables to check 15 minutes block error
- TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
- int secondsSinceEpoch = (int)t.TotalSeconds;
- int secondsleft = 900 - (secondsSinceEpoch - lastwait15minutes);
- if (secondsSinceEpoch >= (lastwait15minutes + 900))//If can set doeshavetowait15 to false
- {
- doeshavetowait15 = false;//If 15 minutes passed reset it to false
- }
- if (doeshavetowait15 == true)//If user has to wait because of 15 minutes login error
- {
- MessageBox.Show("Since you have tried to log in too many times or an error occured, you have to wait 15 minutes.You have left " + secondsleft);
- }
- else if (IsTextUserValid() == false)//Check if user text is invalid
- {
- MessageBox.Show("The user text inserted isn't valid.");
- }
- else if (topiccontentbox.Text.Length < 2 || topictitlebox.Text.Length < 1)//Check if topic and content are too short
- {
- MessageBox.Show("The topic title must have at least 1 character, and the topic content must have at least 2 characters.");
- }
- else if (IsNumeric(forumid.Text) == false)//Check if forum id is invalid
- {
- MessageBox.Show("The forum id inserted isn't valid.");
- }
- else//If everything is ok only then begin the loop
- {
- topictimerfunction();//Call the function immidietly otherwise it'll wait 7 seconds
- istopicrunning = 1;//Set to is activated
- topictimer.Enabled = true;
- topictimer.Start();//Start topic timer and activate it
- topicsbutton.Text = "Stop topics";
- }
- }
- else//If it's already running
- {
- //Stop topic timer
- istopicrunning = 0;
- topictimer.Stop();
- topictimer.Enabled = false;
- topicsnumberint = 0;
- topicsnumber.Text = "0";
- topicsbutton.Text = "Spam topics";
- }
- }
- private void button2_Click_1(object sender, EventArgs e)
- {
- messagelog.Text = "";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- topiclog.Text = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement