Advertisement
Guest User

Youtube Login[Vb.net]

a guest
Apr 29th, 2012
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.11 KB | None | 0 0
  1. Option Strict On
  2. Imports System.Net, System.IO, System.Text.RegularExpressions
  3. Module Module1
  4.  
  5.  
  6.     Class Youtube
  7.         Private Containa As CookieContainer = New CookieContainer
  8.         Private Function Req(ByVal Site As String, ByVal Met As String, Optional ByVal P As String = "") As String
  9.             Dim Response As String = String.Empty
  10.             Try
  11.                 Dim R As HttpWebRequest = CType(HttpWebRequest.Create(Site), HttpWebRequest)
  12.                 R.Method = Met
  13.                 R.CookieContainer = Containa
  14.                 R.AllowAutoRedirect = True
  15.                 R.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0"
  16.                 R.ContentType = "application/x-www-form-urlencoded"
  17.                 R.ServicePoint.Expect100Continue = False
  18.                 If Met = "POST" Then
  19.                     R.ContentLength = P.Length
  20.                     Dim Wr As New StreamWriter(R.GetRequestStream(), System.Text.Encoding.Default)
  21.                     Wr.Write(P)
  22.                     Wr.Close()
  23.                 End If
  24.  
  25.                 Dim Re As New StreamReader(R.GetResponse.GetResponseStream())
  26.                 Response = Re.ReadToEnd
  27.                 Re.Close()
  28.             Catch
  29.             End Try
  30.             Return Response
  31.         End Function
  32.  
  33.         Public Function Login(ByVal Nick As String, ByVal Pass As String) As Boolean
  34.             Dim S As String = Req("https://accounts.google.com/ServiceLoginAuth", "GET")
  35.             Dim Galx As String = Regex.Match(S, "GALX""\s+value=""([^""]+)").Groups(1).Value
  36.             Dim Dsh As String = Regex.Match(S, "dsh"" value=""([^""]+)").Groups(1).Value
  37.             Dim Location As String = Regex.Match(S, "&hl=([^""]+)").Groups(1).Value
  38.             Dim Ltmpl As String = Regex.Match(S, "ltmpl=([^&]+)").Groups(1).Value
  39.             Dim Log As String = "continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26feature%3Dheader%26nomobiletemp%3D1%26hl%3D" & Location & "%26next%3D%252F%253Fgl%253DDE%2526hl%253Dde&service=youtube&uilel=3&dsh=" & Dsh & "&ltmpl=" & Ltmpl & "&hl=de_DE&GALX=" & Galx & "&pstMsg=1&dnConn=&checkConnection=youtube%3A778%3A1&checkedDomains=youtube&timeStmp=&secTok=&Email=" & Nick & "&Passwd=" & Pass & "&signIn=Anmelden&PersistentCookie=yes&rmShown=1"
  40.             Dim Loggin As String = Req("https://accounts.google.com/ServiceLoginAuth", "POST", Log)
  41.             Return Loggin.Contains("Loading, please wait") AndAlso Not Loggin.Contains("Nutzername oder das Passwort ist falsch")
  42.         End Function
  43.     End Class
  44.  
  45.  
  46.     Sub Main()
  47.         Console.WriteLine("Please type in your youtube nickname: " & Environment.NewLine)
  48.         Dim Nick As String = Console.ReadLine
  49.         Console.WriteLine("Please type in your pass: " & Environment.NewLine)
  50.         Dim Pw As String = Console.ReadLine
  51.         Console.Clear()
  52.         Console.WriteLine(">> Trying to log in ...")
  53.         Dim B As New Youtube
  54.         If B.Login(Nick, Pw) Then Console.WriteLine(">>> Login successfully!") Else Console.WriteLine(">>> Login failed!")
  55.         Console.ReadLine()
  56.     End Sub
  57.  
  58.  
  59. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement