How to log into a vBulletin forum

Discussion in 'Programming General' started by Supah Fly, Dec 2, 2008.

How to log into a vBulletin forum
  1. Unread #1 - Dec 2, 2008 at 4:24 AM
  2. Supah Fly
    Joined:
    Aug 22, 2007
    Posts:
    202
    Referrals:
    1
    Sythe Gold:
    0

    Supah Fly Active Member
    Banned

    How to log into a vBulletin forum

    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.
     
  3. Unread #2 - Dec 2, 2008 at 6:31 PM
  4. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    How to log into 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.
     
  5. Unread #3 - Dec 2, 2008 at 8:30 PM
  6. C r u n c h
    Joined:
    Nov 22, 2008
    Posts:
    233
    Referrals:
    0
    Sythe Gold:
    0

    C r u n c h Active Member
    Banned

    How to log into a vBulletin forum

    cp,you double posted ;0


    Also:
    i think cp cleared it up ;p
     
  7. Unread #4 - Dec 2, 2008 at 9:37 PM
  8. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    How to log into a vBulletin forum

    Good job, you're wasting space here in the programming forums.

    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...
     
  9. Unread #5 - Dec 3, 2008 at 11:35 PM
  10. Supah Fly
    Joined:
    Aug 22, 2007
    Posts:
    202
    Referrals:
    1
    Sythe Gold:
    0

    Supah Fly Active Member
    Banned

    How to log into a vBulletin forum

    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.
     
  11. Unread #6 - Dec 4, 2008 at 12:05 AM
  12. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    How to log into a vBulletin forum

    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.
     
  13. Unread #7 - Dec 6, 2008 at 11:10 AM
  14. Supah Fly
    Joined:
    Aug 22, 2007
    Posts:
    202
    Referrals:
    1
    Sythe Gold:
    0

    Supah Fly Active Member
    Banned

    How to log into a vBulletin forum

    Well Im trying this on 3.7.4 forums... Doesn't work.
     
< Hopefully a simple problem.... | Help Will Be Appreciated Here! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site