Advertisement
Guest User

Untitled

a guest
Aug 21st, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Net;
  11. using System.IO;
  12. using System.Security.Cryptography;
  13.  
  14. namespace Kenyaty
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.             timer1 = new Timer();
  22.             timer1.Tick += new EventHandler(timer1_Tick);
  23.             timer1.Interval = 1000; // in miliseconds
  24.         }
  25.         public System.Windows.Forms.Timer timer1;
  26.  
  27.         int messagemodeon = 0;
  28.         public int topicid = 0;
  29.         public string get_md5(string input)
  30.         {
  31.             // step 1, calculate MD5 hash from input
  32.  
  33.             MD5 md5 = System.Security.Cryptography.MD5.Create();
  34.  
  35.             byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
  36.  
  37.             byte[] hash = md5.ComputeHash(inputBytes);
  38.  
  39.             // step 2, convert byte array to hex string
  40.  
  41.             StringBuilder sb = new StringBuilder();
  42.  
  43.             for (int i = 0; i < hash.Length; i++)
  44.  
  45.             {
  46.  
  47.                 sb.Append(hash[i].ToString("X2"));
  48.  
  49.             }
  50.  
  51.             return sb.ToString().ToLower();
  52.         }
  53.  
  54.         public string Between(string value, string a, string b)
  55.         {
  56.             int posA = value.IndexOf(a);
  57.             int posB = value.LastIndexOf(b);
  58.             if (posA == -1)
  59.             {
  60.                 return "";
  61.             }
  62.             if (posB == -1)
  63.             {
  64.                 return "";
  65.             }
  66.             int adjustedPosA = posA + a.Length;
  67.             if (adjustedPosA >= posB)
  68.             {
  69.                 return "";
  70.             }
  71.             return value.Substring(adjustedPosA, posB - adjustedPosA);
  72.         }
  73.  
  74.  
  75.         private void button1_Click(object sender, EventArgs e)
  76.         {
  77.            
  78.             timer1.Enabled = true;
  79.             timer1.Start();
  80.            
  81.  
  82.  
  83.          
  84.         }
  85.  
  86.         private void timer1_Tick(object sender, EventArgs e)
  87.         {
  88.  
  89.             //set login user and pass variables
  90.             var vbusername = username.Text;
  91.             var vbpasswordmd5 = get_md5(password.Text);
  92.  
  93.             //login
  94.             var request = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/login.php?do=login");
  95.  
  96.             var postData = "securitytoken=guest&do=login&s=&cookieuser=1&vb_login_password=&vb_login_md5password=" + vbpasswordmd5 + "&vb_login_md5password_utf=" + vbpasswordmd5 + "&vb_login_password_hint=סיסמא&vb_login_username=" + username.Text;
  97.             var data = Encoding.ASCII.GetBytes(postData);
  98.  
  99.             request.Method = "POST";
  100.             request.ContentType = "application/x-www-form-urlencoded";
  101.             request.ContentLength = data.Length;
  102.             request.KeepAlive = true;
  103.             request.Host = "www.fxp.co.il";
  104.             request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
  105.             request.Referer = "https://www.fxp.co.il/";
  106.             request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
  107.             request.CookieContainer = new CookieContainer();
  108.             using (var stream = request.GetRequestStream())
  109.             {
  110.                 stream.Write(data, 0, data.Length);
  111.             }
  112.  
  113.             var response = (HttpWebResponse)request.GetResponse();
  114.  
  115.             var cookieJar1 = response.Cookies;
  116.  
  117.             var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
  118.             // Get security token
  119.  
  120.  
  121.  
  122.             var request2 = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/newthread.php?do=newthread&f=" + forumid.Text);
  123.  
  124.             request2.Method = "GET";
  125.             request2.ContentType = "application/x-www-form-urlencoded";
  126.  
  127.             request2.KeepAlive = true;
  128.             request2.Host = "www.fxp.co.il";
  129.             request2.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
  130.             request2.Referer = "Referer: https://www.fxp.co.il/forumdisplay.php?f=" + forumid.Text;
  131.             request2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
  132.             request2.CookieContainer = new CookieContainer();
  133.             request2.CookieContainer.Add(cookieJar1);
  134.  
  135.             var response2 = (HttpWebResponse)request2.GetResponse();
  136.  
  137.             var cookieJar2 = response2.Cookies;
  138.  
  139.             var responseString2 = new StreamReader(response2.GetResponseStream()).ReadToEnd();
  140.  
  141.             string[] securitytoken = Between(responseString2, @"securitytoken"" value=""", "\"").Split('"');
  142.             string[] loggeduser = Between(responseString2, @"loggedinuser"" value=""", "\"").Split('"');
  143.             string Asecuritytoken = securitytoken[0];
  144.             string Aloggeduser = loggeduser[0];
  145.  
  146.             // Open thread OR Send message
  147.  
  148.  
  149.             HttpWebRequest request3;
  150.             string postData3;
  151.  
  152.             if (messagemodeon == 0) {
  153.                 request3 = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/newthread.php?do=postthread&f=" + forumid.Text);
  154.             postData3 = "prefixid=dis&subject=" + title.Text + +topicid + "&message_backup=" + content.Text + topicid + "&message=" + content.Text + topicid + "&wysiwyg=1&s=&securitytoken=" + Asecuritytoken + "&f=" + forumid.Text + "&do=postthread&posthash=&poststarttime=&loggedinuser=" + Aloggeduser + "&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";
  155.         }
  156.         else{
  157.         request3 = (HttpWebRequest)WebRequest.Create("https://www.fxp.co.il/private.php?do=insertpm&pmid=" + forumid.Text);
  158.         postData3 = "recipients=" + forumid.Text + "&title=" + title.Text + "&message_backup=" + content.Text + "&message=" + content.Text + "&wysiwyg=1&s=&securitytoken=" + Asecuritytoken + "&do=insertpm&pmid=&forward=&sbutton=%D7%A9%D7%9C%D7%97+%D7%94%D7%95%D7%93%D7%A2%D7%94&savecopy=1&parseurl=1&s=&securitytoken=" + Asecuritytoken + "&do=insertpm&pmid=&forward=";
  159.  
  160.     }
  161.  
  162.  
  163.     var data3 = Encoding.UTF8.GetBytes(postData3);
  164.  
  165.             request3.Method = "POST";
  166.             request3.ContentType = "application/x-www-form-urlencoded";
  167.             request3.ContentLength = data3.Length;
  168.             request3.KeepAlive = true;
  169.             request3.Host = "www.fxp.co.il";
  170.             request3.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
  171.             request3.Referer = "https://www.fxp.co.il/newthread.php?do=newthread&f=" + forumid.Text;
  172.             request3.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
  173.             request3.CookieContainer = new CookieContainer();
  174.             request3.CookieContainer.Add(cookieJar1);
  175.             using (var stream = request3.GetRequestStream())
  176.             {
  177.                 stream.Write(data3, 0, data3.Length);
  178.             }
  179.  
  180.             var response3 = (HttpWebResponse)request3.GetResponse();
  181.  
  182.             var cookieJar3 = response3.Cookies;
  183.  
  184.             var responseString3 = new StreamReader(response3.GetResponseStream()).ReadToEnd();
  185.  
  186.             loginfirstcode.Text = responseString;
  187.  
  188.             topicid++;
  189.  
  190.         }
  191.  
  192.         private void button1_Click_1(object sender, EventArgs e)
  193.         {
  194.             timer1.Stop();
  195.             timer1.Enabled = false;
  196.         }
  197.  
  198.         private void messageMode_CheckedChanged(object sender, EventArgs e)
  199.         {
  200.             if(messagemodeon == 0)
  201.             {
  202.                 messagemodeon = 1;
  203.             }
  204.             else
  205.             {
  206.                 messagemodeon = 0;
  207.             }
  208.         }
  209.  
  210.         private void loopTime_Leave(object sender, EventArgs e)
  211.         {
  212.             int n;
  213.             bool isNumeric = int.TryParse(loopTime.Text, out n);
  214.             if (isNumeric == true) {
  215.                 timer1.Interval = Int32.Parse(loopTime.Text);
  216.         }
  217.             else
  218.             {
  219.                 MessageBox.Show("Changes have not been made.Please enter a valid number.");
  220.  
  221.             }
  222.         }
  223.     }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement