Question Post HTTP Headers to log into forums

MadDokK

Member
Joined
Apr 25, 2009
Messages
5
Programming Experience
1-3
Hello.

I am currently working on a personal project with hopes of using VB.NET 2008 to connect to my personal forum for use of both authentications into the program and group changes. People in my forum are based on ranks, the ranks are organized via the groups in the forum so if one person gains a rank they need to be taken out of one group and placed into another. With multiple people this is a process and presents a security risk should someone get kicked out but accidently be left in a group giving them access.

For the time being, I need to be able to post the headers to the forum to login and parse the response. Any help is greatly appreciated. I have tried many times and I’m currently trying this using the chilkat dll as a reference which allows me to send headers and see the response, but the response is always the failure to login page. The headers are as follows:
Host: UPS Clan - "We Deliver"
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: United Players Syndicate • Index page
Cookie: style_cookie=null; phpbb3_mnlmm_u=1; phpbb3_mnlmm_k=; phpbb3_mnlmm_sid=30f17052cec9d6ef9dbe5b6338912003
Content-Type: application/x-www-form-urlencoded
Content-Length: 66
username=myUsername&password=myPassword&autologin=on&login=Login
The code I’ve tried using the chilkat refrence (documentation: VB.NET Components Documentation )
VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim req As New Chilkat.HttpRequest()
        Dim http As New Chilkat.Http()

        Dim success As Boolean

        '  Any string unlocks the component for the 1st 30-days.
        success = http.UnlockComponent("Anything for 30-day trial")
        If (success <> True) Then
            MsgBox(http.LastErrorText)
            Exit Sub
        End If


        '  Build an HTTP POST Request:
        req.UsePost()
        req.Path = "/forums/ucp.php?mode=login"
        req.AddHeader("Host", "www.upsclan.com")
        req.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 (.NET CLR 3.5.30729)")
        req.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
        req.AddHeader("Accept-Language", "en-us,en;q=0.5")
        req.AddHeader("Accept-Encoding", "gzip,deflate")
        req.AddHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
        req.AddHeader("Keep-Alive", "300")
        req.AddHeader("Connection", "keep-alive")
        req.AddHeader("Referer", "http://www.upsclan.com/forums/ucp.php?mode=login")
        req.AddHeader("Cookie", "style_cookie=null; phpbb3_mnlmm_u=1; phpbb3_mnlmm_k=; phpbb3_mnlmm_sid=")
        req.AddHeader("Content-Type", "application/x-www-form-urlencoded")
        req.AddHeader("Content-Length", "122" & vbCr & "username=myUsername&password=myPassword&autologin=on&redirect=index.php&login=Login")
        '  Send the HTTP POST and get the response.  Note: This is a blocking call.
        '  The method does not return until the full HTTP response is received.
        Dim domain As String
        Dim port As Long
        Dim ssl As Boolean
        domain = "www.upsclan.com"
        port = 80
        ssl = False
        Dim resp As Chilkat.HttpResponse

        resp = http.SynchronousRequest(domain, port, ssl, req)
        If (resp Is Nothing) Then
            TextBox1.Text = TextBox1.Text & http.LastErrorText & vbCrLf
        Else
            '  Display the HTML page returned.
            TextBox1.Text = TextBox1.Text & resp.BodyStr & vbCrLf
        End If

    End Sub

Thank you very much for your help.
 
Back
Top