Simulate login action in VBulletin using C #

I am trying to write a program (C #) that can log in and create a new topic in the VBulletin forums. I tried 2 ways:

1) Use HttpWebRequest . Login is complete. However, a new thread is not created. This is the post code:

public static void CreateNewThread(string url,string fId, string title, string message, string tag) { url += "newthread.php?do=postthread"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); //string result = ""; string values = "subject=" + title + "&message=" + message + "&tag=" + tag + "&do=postthread" + "&f=" + fId + "&s=" + "" ; req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = values.Length; ServicePointManager.Expect100Continue = false; // prevents 417 error using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8)) { writer.Write(values); } HttpWebResponse c = (HttpWebResponse)req.GetResponse(); } 

When executing the code above, no protection was created!

2) Use the WebBrowser control:

  webBrowser1.Document.GetElementById("navbar_username").InnerText = "admin"; webBrowser1.Document.GetElementById("navbar_password").InnerText = "123"; 

But I can’t imagine, because it does not have a name / id, and the login button is the same! Please tell me how to submit a form without the name / id of the form and the name / id of the button?

Thanks!

Respectfully,

+3
source share
1 answer

Try simulating email data instead of filling out a form:

 string postData = "username=Kurresmack&password=pw&action=login&url=/"; webBrowser1.Navigate("www.sweclockers.com/forum/member.php", "", System.Text.Encoding.UTF8.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n"); 
0
source

Source: https://habr.com/ru/post/1304476/


All Articles