Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT] How to login to Mybb with your applications [VB.NET]

This code will add Hackforums login to your programs :P
Hope you like it!

This was not written by me. It was written by Webhouse :)
Just sharing 🙂

First add class: HTTPWorker.vb
Quote:'Written by Webhouse, please add credits if you use this.
Imports System.Net
Imports System.Text
Imports System.IO.Compression

Public Class HTTPWorker
Public Shared cookies As CookieContainer
Private data As Byte()

Public Function login(ByVal forumInstance As Forum) As Boolean
Dim request As HttpWebRequest
Dim response As HttpWebResponse
Dim stream As IO.Stream

cookies = New CookieContainer
Try
request = WebRequest.Create(forumInstance.loginUrl)
setConnectionParameters(request)

data = Encoding.ASCII.GetBytes(forumInstance.logindata)
request.ContentLength = data.Length
stream = request.GetRequestStream()
stream.Write(data, 0, data.Length)
stream.Flush()
stream.Close()

response = request.GetResponse()

If forumInstance.isLoggedIn(cookies) Then
Return True
End If
Catch ex As Exception
'do something with the exception
End Try
Return False
End Function

Public Sub setConnectionParameters(ByRef request As HttpWebRequest)
With request
.Method = "POST"
.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.ContentType = "application/x-www-form-urlencoded"
.Proxy = Nothing
.CookieContainer = cookies
.KeepAlive = True
.ServicePoint.Expect100Continue = False
.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5; FBI-version/0.07"
'.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate") if you want to speed up the steam reading (most boards support this)
End With
End Sub

'this function not implemented, it is added to show how to link the cookies from the login
Public Sub navTo()
'Dim request As HttpWebRequest
'request.CookieContainer = cookies
'etcetc: you could set idletime, speed if you simultaniously want to fire requests, headers, method (get/post), etc
End Sub

'Note: to read the result in login()
'--If you want to read the result (using compression techniques to speed it up--
'Dim responseStream As IO.Stream = response.GetResponseStream()

'If (response.ContentEncoding.ToLower().Contains("gzip")) Then
' responseStream = New GZipStream(responseStream, CompressionMode.Decompress)
'ElseIf (response.ContentEncoding.ToLower().Contains("deflate")) Then
' responseStream = New DeflateStream(responseStream, CompressionMode.Decompress)
'End If

'Dim streamReader As IO.StreamReader = New IO.StreamReader(responseStream, Encoding.Default)
'Dim result As String = streamReader.ReadToEnd().Trim()
'streamReader.Close()
'--
End Class


Add new class: Forum.vb
Quote:'Written by Webhouse, please add credits if you use this.
Public MustInherit Class Forum
Privatelogindata As String
Private _loginUrl As String
Private _url As String
Private _username As String
Private _defaultCookieName As String
Private _defaultCookieSearch As String

Public Sub New(ByVal url As String, ByVal loginUrl As String, ByVal username As String, ByVal cookieName As String,

ByVal cookieSearch As String, Optional ByVal data As String = "")
Me._url = url
Me.loginUrl = loginUrl
Me.logindata = data
Me.username = username
Me._defaultCookieName = cookieName
Me._defaultCookieSearch = cookieSearch
End Sub

Public MustOverride Function isLoggedIn(ByVal cookies As System.Net.CookieContainer) As Boolean

Public Property logindata() As String
Get
Return Me._logindata
End Get
Set(ByVal value As String)
Me._logindata = value
End Set
End Property

Public Property url() As String
Get
Return Me._url
End Get
Set(ByVal value As String)
Me._url = value
End Set
End Property
Public Property loginUrl() As String
Get
Return Me._loginUrl
End Get
Set(ByVal value As String)
Me._loginUrl = value
End Set
End Property

Public Property username() As String
Get
Return Me._username
End Get
Set(ByVal value As String)
Me._username = value
End Set
End Property
Public Property defaultCookieName() As String
Get
Return Me._defaultCookieName
End Get
Set(ByVal value As String)
Me._defaultCookieName = value
End Set
End Property
Public Property defaultCookieSearch() As String
Get
Return Me._defaultCookieSearch
End Get
Set(ByVal value As String)
Me._defaultCookieSearch = value
End Set
End Property
End Class


And last one class: MyBB.vb
Quote:'Written by Webhouse, please add credits if you use this.
Imports System.Net

Public Class myBB
Inherits Forum

Public Sub New(ByVal url As String, ByVal username As String, ByVal password As String)
MyBase.New(url, url & "/member.php?action=login", username, "mybbuser", "", "username=" + username & "&password=" + password & "&submit=Login&action=do_login&url=")
End Sub

Public Overrides Function isLoggedIn(ByVal cookies As System.Net.CookieContainer) As Boolean
If Not IsNothing(cookies.GetCookies(New Uri(url)).Item(defaultCookieName)) Then
Return True
End If
Return False
End Function
End Class


Now we need:
  • 2 Textboxes

  • 1 Button



Click the button "Login" and add this code:
Quote:Dim wrkr As New HTTPWorker()
Dim myBBForum As New myBB("https://hackforums.net/", TextBox1.Text, TextBox2.Text)
If wrkr.login(myBBForum) Then
MsgBox("Logged in successfully!")
Me.Hide()
Main.Show()
Else
MsgBox("Invalid account, please try again! Register if you don't have an account.")
End If


Hope you liked it :)
Again, This was not written by me. It was written by Webhouse :)
This isn't allowed I think as you're logging in from a third party application.

Someone made a PM spammer before
(Jul 21, 2012 04:10 AM)Authorization Wrote:  This isn't allowed I think as you're logging in from a third party application.

Someone made a PM spammer before

Im sorry if I did anything wrong, if needed I will delete the post...
(Jul 21, 2012 04:15 AM)Chuck Freakin Norris Wrote:  Im sorry if I did anything wrong, if needed I will delete the post...

Change the title to "How to login to Mybb with your applications"

Not HF

Done, simple.
(Jul 21, 2012 04:20 AM)Oppresor Wrote:  Change the title to "How to login to Mybb with your applications"

Not HF

Done, simple.

done, thanks a lot :)
Sorry in the first place, Im kinda new around here.
Id add some pictures to the thread, maybe some color too. Looks dull, and unnatractive. BUT nice tutorial! 👍
(Jul 21, 2012 06:22 AM)0BliVi0N Wrote:  Id add some pictures to the thread, maybe some color too. Looks dull, and unnatractive. BUT nice tutorial! 👍

Not really creative by me but note taken, I tried to add some colors :P
Wish I was able to create those "spoilers" thingies :P
Hello there

Thanks for the tutorial i really appreciate this !

sauron
I don't care if you gave credits this is downright leeching. Webhouse's thread is still on here and all people have to do is search for it.
Does anyone know if this is still working on VB? I can't seem to get it to work :(


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by StaticCGJul 3, 2025 02:00 AM 19 1,187 Jul 3, 2025 02:00 AM
Last Post: john ronaldsad
[.NET] by ClusterzIncMar 11, 2019 09:48 AM 10 1,249 Mar 11, 2019 09:48 AM
Last Post: ClusterzInc
[.NET] by ClusterzIncSep 11, 2018 11:30 AM 1 426 Sep 11, 2018 11:30 AM
Last Post: PolarisGang