Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.98 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Text
  3. Imports System.IO
  4. Imports System.Text.RegularExpressions
  5. Imports System.Threading
  6.  
  7. Public Class QuoraLogin
  8.  
  9. Public Function Login(email As String, pass As String, proxyinfo As String) As CookieContainer
  10.  
  11. Dim logincookie As New CookieContainer
  12.  
  13.  
  14. Dim ids = GetUniqueIDs("https://www.quora.com/", proxyinfo, logincookie)
  15.  
  16.  
  17. Dim postData As String = "json=%7B%22args%22%3A%5B%5D%2C%22kwargs%22%3A%7B%22email%22%3A%22" & email & "%22%2C%22password%22%3A%22" & pass & "%22%2C%22passwordless%22%3A1%7D%7D&formkey=" & ids.FormId & "&postkey=" & ids.PostKey & "&window_id=" & ids.windowId & "&referring_controller=index&referring_action=index&_lm_transaction_id=0.168214091389562&_lm_window_id=dep3004-268454598272995956&__vcon_json=%5B%22Vn03YsuKFZvHV9%22%5D&__vcon_method=do_login&__e2e_action_id=ecwlr32628&js_init=%7B%7D"
  18. Dim result = MobilePost(postData, logincookie, proxyinfo)
  19.  
  20. Return logincookie
  21.  
  22. End Function
  23.  
  24. Public Function MobilePost(postData As String, logincookie As CookieContainer, proxyinfo As String) As String
  25. Try
  26. Dim myProxy As WebProxy
  27. Dim proxynumber As String = ""
  28. Dim proxyport As Integer
  29. Dim ProxyUser As String = ""
  30. Dim ProxyPass As String = ""
  31. If Not proxyinfo = "" Then
  32.  
  33. If proxyinfo.Split(":").Length > 2 Then
  34. Dim proxycode As String() = proxyinfo.Split(":")
  35. proxynumber = proxycode(0)
  36. proxyport = proxycode(1)
  37. ProxyUser = proxycode(2)
  38. ProxyPass = proxycode(3)
  39. Else
  40. Dim proxycode As String() = proxyinfo.Split(":")
  41. proxynumber = proxycode(0)
  42. proxyport = proxycode(1)
  43. End If
  44.  
  45. myProxy = New WebProxy(proxynumber & ":" & proxyport, True)
  46. End If
  47. Dim encoding As New UTF8Encoding
  48. Dim byteData As Byte() = encoding.GetBytes(postData)
  49.  
  50. Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://www.quora.com/webnode2/server_call_POST"), HttpWebRequest)
  51. postReq.KeepAlive = False
  52. If Not proxyinfo = "" Then
  53. postReq.Proxy = myProxy
  54.  
  55. If proxyinfo.Split(":").Length > 2 Then
  56. myProxy.Credentials = New NetworkCredential(ProxyUser, ProxyPass)
  57. End If
  58. End If
  59. postReq.Method = "POST"
  60. postReq.CookieContainer = logincookie
  61. postReq.ContentType = "application/x-www-form-urlencoded"
  62. postReq.Referer = "https://www.quora.com/"
  63. postReq.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/10B350 Safari/8536.25"
  64. postReq.ContentLength = byteData.Length
  65. Dim postreqstream As Stream = postReq.GetRequestStream()
  66. postreqstream.Write(byteData, 0, byteData.Length)
  67. postreqstream.Close()
  68. Dim postresponse As HttpWebResponse
  69. postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
  70. logincookie.Add(postresponse.Cookies)
  71. logincookie = logincookie
  72. Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
  73. Dim thepage As String = postreqreader.ReadToEnd
  74. postresponse.Close()
  75.  
  76. Return thepage
  77. Catch
  78. Return "error"
  79. End Try
  80.  
  81. End Function
  82.  
  83. Public Function GetUniqueIDs(url As String, proxyinfo As String, logincookie As CookieContainer) As UniqueIDs
  84. Try
  85. Dim myProxy As WebProxy
  86. Dim proxynumber As String = ""
  87. Dim proxyport As Integer
  88. Dim ProxyUser As String = ""
  89. Dim ProxyPass As String = ""
  90. If Not proxyinfo = "" Then
  91.  
  92. If proxyinfo.Split(":").Length > 2 Then
  93. Dim proxycode As String() = proxyinfo.Split(":")
  94. proxynumber = proxycode(0)
  95. proxyport = proxycode(1)
  96. ProxyUser = proxycode(2)
  97. ProxyPass = proxycode(3)
  98. Else
  99. Dim proxycode As String() = proxyinfo.Split(":")
  100. proxynumber = proxycode(0)
  101. proxyport = proxycode(1)
  102. End If
  103.  
  104. myProxy = New WebProxy(proxynumber & ":" & proxyport, True)
  105. End If
  106.  
  107. Dim uri As New Uri(url)
  108. Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
  109. request.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/10B350 Safari/8536.25"
  110. If Not proxyinfo = "" Then
  111. request.Proxy = myProxy
  112.  
  113. If proxyinfo.Split(":").Length > 2 Then
  114. myProxy.Credentials = New NetworkCredential(ProxyUser, ProxyPass)
  115. End If
  116. End If
  117. request.Method = WebRequestMethods.Http.Get
  118. request.CookieContainer = logincookie
  119. Dim response As HttpWebResponse = request.GetResponse()
  120. logincookie.Add(response.Cookies)
  121. Dim reader As New IO.StreamReader(response.GetResponseStream())
  122. Dim tmp As String = reader.ReadToEnd()
  123.  
  124. Dim uniqueids As New UniqueIDs
  125. uniqueids.response = tmp
  126. uniqueids.FormId = GetformKey(tmp)
  127. uniqueids.MobileWindowID = GetWindowId(tmp)
  128. uniqueids.PostKey = GetPostKey(tmp)
  129. response.Close()
  130.  
  131. Return uniqueids
  132. Catch ex As Exception
  133. Dim uniqueids As New UniqueIDs
  134. uniqueids.response = "error"
  135. Return uniqueids
  136. End Try
  137. End Function
  138.  
  139. Public Function GetWindowId(ByVal page) As String
  140.  
  141. Dim myRegex As New Regex("fake_window_(.*?)""")
  142. Dim t As String = page
  143. Return myRegex.Match(t).Groups(1).ToString
  144.  
  145. End Function
  146.  
  147. Public Function GetformKey(ByVal page) As String
  148. Dim myRegex As New Regex("formkey"": ""(.*)"", ""isLoggedIn")
  149. Dim t As String = page
  150. Return myRegex.Match(t).Groups(1).ToString
  151. End Function
  152.  
  153. Public Function GetPostKey(ByVal page) As String
  154.  
  155. Dim myRegex As New Regex("postkey"": ""(.*)"", ""save_feed_story_debug")
  156. Dim t As String = page
  157. Return myRegex.Match(t).Groups(1).ToString
  158.  
  159. End Function
  160.  
  161. Public Structure UniqueIDs
  162. Public FormId As String
  163. Public windowId As String
  164. Public MobileWindowID As String
  165. Public PostKey As String
  166. Public ProfileId As String
  167. Public voterid As String
  168. Public optimisticcount As String
  169. Public response As String
  170.  
  171. End Structure
  172.  
  173. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement