Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.IO;
- using System.Diagnostics;
- namespace MagtiFun_Test
- {
- public partial class MagtiFun_frm : Form
- {
- public MagtiFun_frm()
- {
- InitializeComponent();
- }
- private void login_btn_Click(object sender, EventArgs e)
- {
- string post_data = "&act=1&user=" + usrname_txt.Text + "&password=" + pass_txt.Text;
- string uri = "http://www.magtifun.ge/index.php?page=11&lang=ge";
- //string csrf_token;
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
- HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
- req.KeepAlive = false;
- req.ProtocolVersion = HttpVersion.Version10;
- req.Method = "POST";
- //csrf_token = resp.Headers["set-cookie"] + post_data;
- //WebHeaderCollection header = resp.Headers;
- byte[] postByte = Encoding.ASCII.GetBytes(post_data);
- req.ContentType = "application/x-www-form-urlencoded";
- req.ContentLength = postByte.Length; //error here
- Stream reqStream = req.GetRequestStream();
- reqStream.Write(postByte, 0, postByte.Length);
- reqStream.Close();
- using (StreamReader file = new StreamReader(resp.GetResponseStream(),Encoding.UTF8))
- {
- //just to see the response code
- File.AppendAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test.txt", file.ReadToEnd());
- }
- //Process.Start("firefox.exe", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+"\\test.txt");
- MessageBox.Show(resp.StatusCode.ToString()); //shows "OK" even when not logged in
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement