Advertisement
a7m3dalbalawi

snapchat api login

Jun 25th, 2017
2,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.21 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net
  3. Imports System.Net.Security
  4. Imports System.Net.Sockets
  5. Imports System.Text
  6. Imports System.Text.RegularExpressions
  7. Public Class Form1
  8.  
  9. '         _               _          _             _              _            _            _   _         _             _      
  10. '        /\_\            /\ \       /\ \     _    /\ \           /\ \         /\ \         /\_\/\_\ _    / /\         /\ \    
  11. '       / / /  _         \ \ \     /  \ \   /\_\ /  \ \         /  \ \____   /  \ \       / / / / //\_\ / /  \       /  \ \    
  12. '      / / /  /\_\       /\ \_\   / /\ \ \_/ / // /\ \_\       / /\ \_____\ / /\ \ \     /\ \/ \ \/ / // / /\ \__   / /\ \ \  
  13. '     / / /__/ / /      / /\/_/  / / /\ \___/ // / /\/_/      / / /\/___  // / /\ \ \   /  \____\__/ // / /\ \___\ / / /\ \ \  
  14. '    / /\_____/ /      / / /    / / /  \/____// / / ______   / / /   / / // / /  \ \_\ / /\/________/ \ \ \ \/___// / /  \ \_\
  15. '   / /\_______/      / / /    / / /    / / // / / /\_____\ / / /   / / // / /   / / // / /\/_// / /   \ \ \     / / /    \/_/
  16. '  / / /\ \ \        / / /    / / /    / / // / /  \/____ // / /   / / // / /   / / // / /    / / /_    \ \ \   / / /          
  17. ' / / /  \ \ \   ___/ / /__  / / /    / / // / /_____/ / / \ \ \__/ / // / /___/ / // / /    / / //_/\__/ / /  / / /________  
  18. '/ / /    \ \ \ /\__\/_/___\/ / /    / / // / /______\/ /   \ \___\/ // / /____\/ / \/_/    / / / \ \/___/ /  / / /_________\  
  19. '\/_/      \_\_\\/_________/\/_/     \/_/ \/___________/     \/_____/ \/_________/          \/_/   \_____\/   \/____________/  
  20. '                                                                                                                              '
  21. '
  22. '
  23. '  
  24. '  Kingdom ( الممَلكة ) .
  25. '  instagram : KingDomSc .
  26. '  whatsapp  : 00966501615727 .
  27.  
  28.     Function getCasperData(username As String, password As String) As String
  29.         Try
  30.             Dim request As HttpWebRequest = HttpWebRequest.Create("http://kingdomsc.us/snap/api.php")
  31.             request.CookieContainer = New CookieContainer
  32.             request.Method = "POST"
  33.             request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0"
  34.             request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  35.             request.Headers.Add("Accept-Language: en-US,en;q=0.5")
  36.             request.ContentType = "application/x-www-form-urlencoded"
  37.             Dim PostData As String = "usname=" & username & "&pwd=" & password & "&data=1"
  38.             Dim bytearray As Byte() = Encoding.Default.GetBytes(PostData)
  39.             request.ContentLength = bytearray.Length
  40.             Dim dataStream As Stream = request.GetRequestStream()
  41.             dataStream.Write(bytearray, 0, bytearray.Length)
  42.             dataStream.Close()
  43.             Dim response As HttpWebResponse = request.GetResponse()
  44.             dataStream = response.GetResponseStream()
  45.             Dim reader As New StreamReader(dataStream)
  46.             Dim responseFromServer As String = reader.ReadToEnd()
  47.             reader.Close()
  48.             dataStream.Close()
  49.             response.Close()
  50.             Return "{" & Regex.Match(responseFromServer & vbNewLine, vbNewLine & "{(.*?)}" & vbNewLine).Groups.Item(1).Value & "}"
  51.         Catch ex As WebException
  52.             Return "Error is:" & vbNewLine & New StreamReader(ex.Response.GetResponseStream).ReadToEnd
  53.         End Try
  54.     End Function
  55.     Function SnapChat_Login(CasperResponse As String, username As String, password As String) As String
  56. tt:
  57.         Dim timestamp As String = Regex.Match(CasperResponse, """timestamp"":(.*?),").Groups.Item(1).Value
  58.         Dim req_token As String = Regex.Match(CasperResponse, """req_token"":""(.*?)"",").Groups.Item(1).Value
  59.         Dim d As String = "confirm_reactivation=false&from_deeplink=false&height=1136&nt=1&password=" & password & "&pre_auth_token=&remember_device=true&req_token=" & Regex.Match(CasperResponse, """req_token"":""(.*?)""").Groups.Item(1).Value & "&screen_height_in=3.5&screen_height_px=568&screen_width_in=1.9&screen_width_px=320&timestamp=" & Regex.Match(CasperResponse, """timestamp"":(.*?),").Groups.Item(1).Value & "&username=" & Regex.Match(CasperResponse, """username"":""(.*?)""").Groups.Item(1).Value & "&width=640"
  60.         Dim data As String = "POST /loq/login HTTP/1.1
  61. Accept: */*
  62. Accept-Language: en;q=1
  63. Accept-Locale: en_US
  64. User-Agent: Snapchat/10.6.2.0 (iPhone6,2; iOS 9.3.2; gzip)
  65. X-Snapchat-Client-Token: " & Regex.Match(CasperResponse, """X-Snapchat-Client-Token"":""(.*?)""").Groups.Item(1).Value & "
  66. X-Snapchat-Client-Auth-Token: " & Regex.Match(CasperResponse, """X-Snapchat-Client-Auth-Token"":""(.*?)""").Groups.Item(1).Value & "
  67. X-Snapchat-UUID: " & Regex.Match(CasperResponse, """X-Snapchat-UUID"":""(.*?)""").Groups.Item(1).Value & "
  68. Content-Type: application/x-www-form-urlencoded
  69. Content-Length: " & d.Length & "
  70. Host: app.snapchat.com
  71. Connection: Keep-Alive
  72.  
  73. " & d
  74.         Dim client As New TcpClient()
  75.         client.Connect("app.snapchat.com", 443)
  76.         Dim by As Byte() = Encoding.Default.GetBytes(data, 0, data.Length)
  77.         Dim Stream As SslStream = New SslStream(client.GetStream, False, Function()
  78.                                                                              Return True : End Function, Nothing)
  79.         Stream.AuthenticateAsClient("app.snapchat.com")
  80.         Stream.Write(by, 0, by.Length)
  81.         Stream.Flush()
  82.         by = New Byte(1024) {}
  83.         Dim Response As New StringBuilder()
  84.         Do
  85.             Dim dd As New StringBuilder()
  86.             dd.Append(Encoding.ASCII.GetString(by, 0, Stream.Read(by, 0, by.Length)))
  87.             Try
  88.                 Response.Append(Regex.Unescape(dd.ToString))
  89.             Catch ex As Exception
  90.                 Response.Append(dd.ToString)
  91.             End Try
  92.             If dd.ToString.Contains("}" & vbNewLine) Then
  93.                 Exit Do
  94.             End If
  95.         Loop
  96.         Return Response.ToString
  97.     End Function
  98.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
  99.         Dim Casper_response As String = getCasperData("snap_username", "snap_password")
  100.         MsgBox(SnapChat_Login(Casper_response, "snap_username", "snap_password"))
  101.     End Sub
  102. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement