Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Communications (http://www.xtremevbtalk.com/communications/)
-   -   vb6 INET Cookies (http://www.xtremevbtalk.com/communications/326434-vb6-inet-cookies.html)

ravi_elite 09-17-2013 01:25 PM

vb6 INET Cookies
 
Hello all,

I hope someone can help me with this problem
I have created (3) Inet Connections

first connection does a GET to login.live.com
grabs a cookie
then the second Inet Connection Posts that cookie and logs into login.live.com via SSL and grabs a token

then the third Inet Connection goes to a different website and Posts the token
to grab additional cookies i need for something else


it all works


the problem is the next time that i do it again... it has allready logged me into login.live.com and just sends me the token to go straight to the other website... I dont want to do that...

i believe that the cookies are being saved.. i have cleared Temporary internet files and ...well...NOTHING

I have tried sending a cookie header that rewrites over the previous cookies ..nothing...


anyway here is the entire code

I have removed my real email and password
Code:

Sub ConnectUpdater()
Dim strURL As String      ' URL string
Dim intFile As Integer  ' FreeFile variable
intFile = FreeFile()
fConnection.Inet2.Protocol = icHTTP
strURL = "http://login.live.com"
Dim GetString As String
GetString = " "
fConnection.Inet2.URL = "http://login.live.com"
fConnection.Inet2.Execute strURL + "/wlogin.srf?appid=000000004C04B301&alg=wsignin1.0", "GET", GetString, "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "Host:login.live.com" & vbCrLf & "User-Agent: root" & vbCrLf & "Cookie: MUID=DFD2582018CB460B91F4707517868FF8" & vbCrLf
While fConnection.Inet2.StillExecuting
  DoEvents
Wend
returnstr = fConnection.Inet2.GetChunk(2048, icString)
Dim Cookie1 As String
Cookie1 = fConnection.Inet2.GetHeader()
Cookie1 = Split(Cookie1, vbCrLf)(10)
Cookie1 = Split(Cookie1, "=")(1)
Cookie1 = Split(Cookie1, ";")(0)
 Dim len2value As Integer
 Dim len2end As Integer
 Dim Cookie2 As String
 Dim stoken As String
Do While Len(returnstr) <> 0
  If InStr(1, returnstr, "PPFT") > 0 Then
  len2value = InStr(1, returnstr, "PPFT")
  Cookie2 = (Mid(returnstr, len2value))
  Cookie2 = Split(Cookie2, "=")(2)
  Cookie2 = Split(Cookie2, Chr(34))(1)
  ElseIf InStr(1, returnstr, "stoken") > 0 Then
  len2value = InStr(1, returnstr, "stoken")
  stoken = (Mid(returnstr, len2value))
  stoken = Split(stoken, "=")(2)
  stoken = Split(stoken, Chr(34))(1)
  End If
  'RichTextBox2.SelStart = Len(RichTextBox2.Text)
  'RichTextBox2.SelText = RichTextBox2.SelText & returnstr
  'RichTextBox2.SelStart = Len(RichTextBox2.Text)
    returnstr = fConnection.Inet2.GetChunk(2048, icString)
Loop
If Cookie2 = "" Then
  If stoken <> "" Then
 stoken = Replace(Replace(stoken, Chr(37) & "2", Chr(37) & "252"), Chr(37) & "3D", Chr(37) & "253D")
 ConnectToIRC7s stoken
 End If
 ElseIf Cookie2 <> "" Then
 ConnectToSSL1 Cookie1, Cookie2
  End If
End Sub
Sub ConnectToSSL1(Cookie1 As String, Cookie2 As String)
 'MsgBox Cookie1
 'MsgBox Cookie2
Dim strURL As String      ' URL string
Dim intFile As Integer  ' FreeFile variable
fConnection.Inet1.AccessType = icUseDefault
fConnection.Inet1.Protocol = icHTTPS
intFile = FreeFile()
strURL = "https://login.live.com"
strURL = strURL & "/ppsecure/post.srf?appid=000000004C04B301&alg=wsignin1.0&bk=" & UnixTime
Dim PostData As String
Dim sData As String
Dim sLen As Integer
sData = "login=ez%40live.com&passwd=boot&SI=Sign+in&PPFT=" & Cookie2
sLen = Len(sData)
'PostData = "/ppsecure/post.srf?appid=000000004C04B301&alg=wsignin1.0&bk=" & UnixTime & " HTTP/1.1" & _
'vbCrLf & "HOST: login.live.com" & vbCrLf & "Content-Length: " & sLen & vbCrLf & "User-Agent: Root" & vbCrLf & "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "Cookie: MSPOK=" & Cookie1 & vbCrLf & vbCrLf & sData
PostData = sData
'MsgBox sData
fConnection.Inet1.Execute strURL, "POST", PostData, "Host: login.live.com" & vbCrLf & "User-Agent: Root" & vbCrLf & "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "Cookie: MSPOK=" & Cookie1
While fConnection.Inet1.StillExecuting
  DoEvents
Wend
'MsgBox Inet1.GetHeader()
 Dim len2value As Integer
 Dim len2end As Integer
 Dim stoken As String
 
returnstr = fConnection.Inet1.GetChunk(2048, icString)
'Dim oldStr As String
Do While Len(returnstr) <> 0
  MsgBox returnstr
  'Text1.Text = ReturnStr
  'RichTextBox1.SelStart = Len(RichTextBox1.Text)
  'RichTextBox1.SelText = RichTextBox1.SelText & returnstr
  'RichTextBox1.SelStart = Len(RichTextBox1.Text)
  'oldStr = RichTextBox1.SelText
  'RichTextBox1.Text = oldStr & returnStr
    returnstr = fConnection.Inet1.GetChunk(2048, icString)
Loop
  If stoken <> "" Then
 stoken = Replace(Replace(stoken, Chr(37) & "2", Chr(37) & "252"), Chr(37) & "3D", Chr(37) & "253D")
 ConnectToIRC7s stoken
 End If
End Sub

Sub ConnectToIRC7s(stoken As String)
 'MsgBox Cookie1
 'MsgBox Cookie2
Dim strURL As String      ' URL string
Dim intFile As Integer  ' FreeFile variable
fConnection.Inet3.AccessType = icUseDefault
fConnection.Inet3.Protocol = icHTTP
intFile = FreeFile()
strURL = "http://irc7.com"
strURL = strURL & "/webauth-handler.aspx"
Dim PostData As String
Dim sData As String
Dim sLen As Integer
sData = "stoken=" & stoken & "&action=login"
sLen = Len(sData)
'PostData = "/ppsecure/post.srf?appid=000000004C04B301&alg=wsignin1.0&bk=" & UnixTime & " HTTP/1.1" & _
'vbCrLf & "HOST: login.live.com" & vbCrLf & "Content-Length: " & sLen & vbCrLf & "User-Agent: Root" & vbCrLf & "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "Cookie: MSPOK=" & Cookie1 & vbCrLf & vbCrLf & sData
PostData = sData
'MsgBox sData
fConnection.Inet3.Execute strURL, "POST", PostData, "Host: irc7.com" & vbCrLf & "Content-Length: " & sLen & vbCrLf & "User-Agent: Root" & vbCrLf & "Connection: Keep-Alive" & vbCrLf & "Content-Type: application/x-www-form-urlencoded" & vbCrLf & vbCrLf
While fConnection.Inet3.StillExecuting
  DoEvents
Wend
'MsgBox Inet1.GetHeader()
returnstr = fConnection.Inet3.GetChunk(2048, icString)
'Dim oldStr As String
Dim len2value As Integer
 Dim len2end As Integer
 Dim Gkp As String
 Dim Profile As String
 Dim Ticket As String
 Dim MSNRegCookie As String
Do While Len(returnstr) <> 0
If InStr(1, returnstr, "MSRegCookie") > 0 Then
  len2value = InStr(1, returnstr, "MSRegCookie")
  MSNRegCookie = (Mid(returnstr, len2value))
  MSNRegCookie = Split(MSNRegCookie, "=")(1)
  MSNRegCookie = Split(MSNRegCookie, "<br />")(0)
  MsgBox "MSNRegCookie: " & MSNRegCookie
  'MsgBox Cookie2
  End If
  If InStr(1, returnstr, "GateKeeperPassport") > 0 Then
  'MsgBox "here!"
  len2value = InStr(1, returnstr, "GateKeeperPassport")
  Gkp = (Mid(returnstr, len2value))
  Gkp = Split(Gkp, "=")(1)
  Gkp = Split(Gkp, "<br />")(0)
  MsgBox "GateKeeperPassport: " & Gkp & "@GateKeeperPassport"
  'MsgBox stoken
  End If
  If InStr(1, returnstr, "MSPAuth") > 0 Then
  'MsgBox "here!"
  len2value = InStr(1, returnstr, "MSPAuth")
  Ticket = (Mid(returnstr, len2value))
  Ticket = Split(Ticket, "=")(1)
  Ticket = Split(Ticket, "<br />")(0)
  MsgBox "Ticket: " & Ticket
  'MsgBox stoken
  End If
    If InStr(1, returnstr, "MSPProf") > 0 Then
  'MsgBox "here!"
  len2value = InStr(1, returnstr, "MSPProf")
  Profile = (Mid(returnstr, len2value))
  Profile = Split(Profile, "=")(1)
  Profile = Split(Profile, "<br />")(0)
  MsgBox "Profile: " & Profile
  'MsgBox stoken
  End If
 'MsgBox returnstr
  'Text1.Text = ReturnStr
  'RichTextBox3.SelStart = Len(RichTextBox3.Text)
  'RichTextBox3.SelText = RichTextBox3.SelText & returnstr
  'RichTextBox3.SelStart = Len(RichTextBox3.Text)
  'oldStr = RichTextBox1.SelText
  'RichTextBox1.Text = oldStr & returnStr
    returnstr = fConnection.Inet3.GetChunk(2048, icString)
Loop
End Sub
Function UnixTime() As Variant
'The first parameter determines how the
' difference will be measured in i.e. "S" for seconds
UnixTime = DateDiff("S", "1/1/1970", Now())
End Function


ravi_elite 09-17-2013 05:06 PM

nobody can help me with this?

not enough info?

ravi_elite 09-17-2013 06:30 PM

sorry guys i fixed it..all i had to do was go to the logout page
on login.live.com first..

thanks anyway


All times are GMT -6. The time now is 01:34 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.