Login Register






[vb.net]Login Form for Hackcommunity.com filter_list
Author
Message
[vb.net]Login Form for Hackcommunity.com #1
First insert these codes :
Code:
Imports System.Net Imports System.Text Imports System.IO.Compression Public Class Form1 Public MustInherit Class Forum Private _logindata 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 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub 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 Public Class myBB Inherits Forum Public Sub New(ByVal url As String, ByVal username As String, ByVal password As String) MyBase.New(url, "Http://hackcommunity.com" & "/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

Then u will need 2 textboxes and one button (Textbox for User&Pass)(Button for login)
Textbox1 = User
Textbox2 = Pass
Button1 = Login

Double click the button and insert this code :
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim wrkr As New HTTPWorker() Dim myBBForum As New myBB("http://www.hackcommunity.com", TextBox1.Text, TextBox2.Text) If wrkr.login(myBBForum) Then MsgBox("Logged in successfully!") Me.Hide() Else MsgBox("Invalid account, Register if u don't have an account on HC!") End If End Sub

Credits goes to WebHouse @ HF.net for the source Tongue


-Lenalee
[Image: 5DQAS.gif]

May the force be with you...

Reply

RE: [vb.net]Login Form for Hackcommunity.com #2
Very nice. Good work Webhouse and Lenalee. Smile
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [vb.net]Login Form for Hackcommunity.com #3
ya it is true.
can i Bump threads?

BUMP~
BUMP~
BUMP~
[Image: 5DQAS.gif]

May the force be with you...

Reply

RE: [vb.net]Login Form for Hackcommunity.com #4
um... i think that count's as spam XD Confusedpam:
Pierce the life fibers with your drill.

Reply

RE: [vb.net]Login Form for Hackcommunity.com #5
nice code love it love it love it :|
(This post was last modified: 02-03-2011, 06:47 AM by Skullmeat.)
Pierce the life fibers with your drill.

Reply

RE: [vb.net]Login Form for Hackcommunity.com #6
(02-03-2011, 03:26 AM)The 7th Sage Wrote: [Image: avatar_1.jpg?dateline=1296329548]
(01-31-2011, 04:35 AM)Lenalee Wrote: Credits goes to WebHouse @ HF.net for the source Tongue


-Lenalee

[Image: avatar_1.jpg?dateline=1296329548]

err...what meaning? lol i don't get it.
[Image: 5DQAS.gif]

May the force be with you...

Reply

RE: [vb.net]Login Form for Hackcommunity.com #7
forget what sage said he was with me.

PS:congratz on your dragon Smile
Pierce the life fibers with your drill.

Reply

RE: [vb.net]Login Form for Hackcommunity.com #8
(02-03-2011, 02:48 PM)1234hotmaster Wrote: forget what sage said he was with me.

PS:congratz on your dragon Smile

dragcave is down at the moment Sad
[Image: 5DQAS.gif]

May the force be with you...

Reply