Guest User

Messy

a guest
Jun 28th, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. Function Request(url As String, data As String)
  2. Dim vystup As String = Nothing
  3. Try
  4.  
  5. 'Our postvars
  6. Dim buffer As Byte() = System.Text.Encoding.ASCII.GetBytes(data)
  7. 'Initialisation, we use localhost, change if appliable
  8. Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
  9. 'Our method is post, otherwise the buffer (postvars) would be useless
  10. WebReq.Method = "POST"
  11. 'We use form contentType, for the postvars.
  12. WebReq.ContentType = "application/x-www-form-urlencoded"
  13. 'The length of the buffer (postvars) is used as contentlength.
  14. WebReq.ContentLength = buffer.Length
  15. 'We open a stream for writing the postvars
  16. Dim PostData As Stream = WebReq.GetRequestStream()
  17. 'Now we write, and afterwards, we close. Closing is always important!
  18. PostData.Write(buffer, 0, buffer.Length)
  19. PostData.Close()
  20. 'Get the response handle, we have no true response yet!
  21. Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetResponse(), HttpWebResponse)
  22. 'Now, we read the response (the string), and output it.
  23. Dim Answer As Stream = WebResp.GetResponseStream()
  24. Dim _Answer As New StreamReader(Answer)
  25. 'Congratulations, you just requested your first POST page, you
  26. 'can now start logging into most login forms, with your application
  27. 'Or other examples.
  28. vystup = _Answer.ReadToEnd()
  29. Return vystup.Trim() + vbLf
  30. Catch ex As Exception
  31. End Try
  32. End Function
  33.  
  34. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  35. IO.File.WriteAllText("hh.html", Request("http://force-generator.de/register.php", "username=gaylegsbian&password=mgama&confirmpassword=mgama&email=Farl81951%40jourrapide.com"))
  36. Process.Start("hh.html")
  37. End Sub
Add Comment
Please, Sign In to add comment