• Log in or sign up for an account here: https://www.sythe.org/login

How to log into a vBulletin forum

Supah Fly

Active Member

Banned
Joined
Aug 22, 2007
Sythe Gold
0
Messages
202
Location
your face
First of all, not sythe, second, my function.

Code:
        private void HKPV(string URL, string PDATA, string GDATA, string REFERRER)
        {
            try
            {
                if (GDATA != "" && PDATA == "")
                {
                    URL = URL + GDATA;
                }
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
                if (PDATA != "" && GDATA == "")
                {
                    req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    byte[] buffer = Encoding.ASCII.GetBytes(PDATA);
                    req.ContentLength = buffer.Length;
                    Stream PostData = req.GetRequestStream();
                    PostData.Write(buffer, 0, buffer.Length);
                    PostData.Close();
                }
                // req.Proxy = PROXY;
                if (REFERRER != "")
                {
                    req.Referer = REFERRER;
                }
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                // MessageBox.Show(resp.StatusCode + " : " + req.Referer);
                Stream dataStream = resp.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                html = responseFromServer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex.Message));
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Disable some controls
            button1.Enabled = false;
            textBox1.Enabled = false;
            textBox2.Enabled = false;
            checkBox1.Enabled = false;
            // Disabled all controls fine

            // Login initiate
            try
            { // Try to log in, just in case an error happens we have a solution to it
                // Attempt to login with the given details
                // Encrypt the login passwords.
                String hashpass = HashString(textBox2.Text);
                String hashputf = Encoding.UTF8.GetString(
                    Encoding.Convert(
                    Encoding.UTF8, Encoding.UTF8,
                    Encoding.UTF8.GetBytes(hashpass)));
                // End encryption
                HKPV("http://www.someforum.net/login.php?do=login", "?vb_login_username=" + textBox1.Text + "&vb_login_password=" + textBox2.Text + "&securitytoken=guest&do=login&vb_login_md5password=" + hashpass + "&vb_login_md5password_utf=" + hashputf, "", "http://www.someforum.net/index.php");
                textBox3.Text = html;
                // End attempt, success if you have made it this far
            } // End of trying to log in, or an error arose
            catch (Exception ex)
            { // Error reporting
                // If an error occurs we don't want the program to quit, we will just assume that the site is now offline
            } // End error reporting
            finally
            { // After we do all that, do the stuff at the end
                button1.Enabled = true;
                textBox1.Enabled = true;
                textBox2.Enabled = true;
                checkBox1.Enabled = true;
            } // Finished cleanup
            // Login close
        }

so... im guessing i need a new security token each time, i want to do that in the same function, but i really honestly dont know how to parse something out in c# i need to parse

Code:
SESSIONURL = "?s=34095383945340&";

out of the javascript near the top of the page of a vBulletin forum.
 
You don't need to mess with the javascript at all... I have written a vb login function in both php and python just fine with using only a single post request... works just fine.
 
cp,you double posted ;0


Also:
i think cp cleared it up ;p
Good job, you're wasting space here in the programming forums.

so... im guessing i need a new security token each time, i want to do that in the same function, but i really honestly dont know how to parse something out in c# i need to parse
Can you be more specific as to why you think you need to parse the session ID and where it comes from? As far as I can tell cp is right and it should be way simpler...
 
what am i doing wrong then?

thats the only thing i can think of that would mess up the login. it says invalid password when i enter a valid one.
 
Code:
vb_login_username=[B]USERNAME[/B]&cookieuser=1&vb_login_password=[B]PASSWORD[/B]&s=&do=login&vb_login_md5password=[B]PASSWORDINMD5[/B]&vb_login_md5password_utf=[B]PASSWORDINMD5[/B]
That is what I used in my functions and it works.
 
Runescape Gamblingrunescape gambling
Back
Top