Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. public void SubmitData()
  2.         {
  3.             try
  4.             {
  5.                 string user = textBox1.Text;
  6.                 string pass = textBox2.Text;
  7.  
  8.                 ASCIIEncoding encoding = new ASCIIEncoding();
  9.                 string postData = "data%5BUser%5D%5Buserid%5D=" + user + "&data%5BUser%5D%5Bpassword%5D=" + pass + "&submit=Sign+in";
  10.                 byte[] data = encoding.GetBytes(postData);
  11.  
  12.                 WebRequest request = WebRequest.Create("https://vpn.hidemyass.com/vpncontrol/signin");
  13.                 request.Method = "POST";
  14.                 request.ContentType = "application/x-www-form-urlencoded";
  15.                 request.ContentLength = data.Length;
  16.  
  17.                 Stream stream = request.GetRequestStream();
  18.                 stream.Write(data, 0, data.Length);
  19.                 stream.Close();
  20.                
  21.                 WebResponse response = request.GetResponse();
  22.                 stream = response.GetResponseStream();
  23.  
  24.                 StreamReader sr = new StreamReader(stream);
  25.  
  26.                 string final_reponse = sr.ReadToEnd();
  27.                
  28.                 Regex r = new Regex(@"Invalid login or password!");
  29.                 Match m = r.Match(final_reponse);
  30.                                
  31.                 MessageBox.Show(m.Value);
  32.                
  33.  
  34.                 sr.Close();
  35.                 stream.Close();
  36.             }
  37.             catch (Exception ex)
  38.             {
  39.                 MessageBox.Show("Error: " + ex.Message);
  40.             }
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement