[Vb.Net] Imvu Login Code 10 posts

OP Sun Jul 08, 2012 6:45 am
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
This is the code that will allow you to login to imvu with your program and store the data in a cookie. This is useful if you want to use the Imvu api in your programs or access ap/vip data.

Code
Dim postData As String = "POSTDATA=sauce=&avatarname=" & avibx.Text & "&" & "password=" & passbx.Text & "&password_strength=strong&sendto="
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)

Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://secure.imvu.com/login/login/"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "http://www.imvu.com/login/"
postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1"
postReq.ContentLength = byteData.Length

Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse

postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

''This is for debugging / checking for a successful login
Dim thepage As String = postreqreader.ReadToEnd

Debugbx.Text = thepage

    If Debugbx.Text.Contains("<title>My IMVU</title>") Then
        MsgBox("Success")
    End If
''End Dubug / Check Code   


All you need to do after putting the above code in your program somewhere is declare the global logincookie variable at the top of your class like so:
Code
Dim logincookie As CookieContainer


Then set your codes cookie container to the logincookie and your code will have whatever data you store from logging in (Ap/vip access for example).
Thu Jul 02, 2015 4:33 am
User avatar
  • Gender: Female
  • Posts: 53
  • Joined: Jan, 2012
  • Karma: 0
Only if i understood coding..im sure this would be nice.

Thank you.
Fri Apr 08, 2016 2:43 pm
User avatar
TIM Enthusiast
Legendary Family Member
  • Gender: Female
  • Posts: 702
  • Joined: Sep, 2015
  • Advertisements: 1
  • Karma: 0
Thank you so much DM: You are the best! :bunny:
Fri Sep 02, 2016 2:02 pm
User avatar
  • Posts: 5
  • Joined: Sep, 2016
  • Karma: 0
im just learning how to programming using MS visual so ty may this help me in future
Sun Feb 05, 2017 3:10 am
User avatar
Social Engineer
Lower Family Member
  • Posts: 152
  • Joined: Jan, 2017
  • Karma: 21
thank you for this it can come in handy for some projects
Tue Oct 03, 2017 7:23 am
User avatar
  • Posts: 6
  • Joined: Aug, 2017
  • Karma: 10
Hello
@D.M
. Well, i've updated your code and make it more better. hope you will like it. Thanks.

Code
Imports System
Imports System.IO
Imports System.Net
Imports System.Web
Imports System.Collections.Specialized
Module Module1
    Private Const UserAgent As String = "Mozilla/5.0 (Windows NT 6.1; rv:53.0) Gecko/20100101 Firefox/53.0"
    Private Const LoginURL As String = "https://secure.imvu.com/login/login/"
    Private Const Referer As String = "https://secure.imvu.com/login/"
    Dim Username As String = "<YOUR USERNAME>"
    Dim Password As String = "<YOUR PASSWORD>"
    Sub Main()

        ServicePointManager.Expect100Continue = False

        Dim PostData As NameValueCollection = HttpUtility.ParseQueryString(String.Empty)
        PostData.Add("avatarname", Username)
        PostData.Add("password", Password)
        PostData.Add("sendto", Nothing)

        Dim Request1 As HttpWebRequest = CType(HttpWebRequest.Create(LoginURL), HttpWebRequest)
        Request1.Method = WebRequestMethods.Http.Post
        Request1.UserAgent = UserAgent
        Request1.ContentType = "application/x-www-form-urlencoded"
        Request1.Headers.Add("Upgrade-Insecure-Requests", "1")
        Request1.CookieContainer = New CookieContainer
        Request1.Referer = Referer
        Request1.AllowAutoRedirect = False
        Request1.KeepAlive = True

        Using ReqestStreamWriter As New StreamWriter(Request1.GetRequestStream)
            ReqestStreamWriter.Write(PostData)
        End Using

        Dim Response1 As HttpWebResponse = CType(Request1.GetResponse, HttpWebResponse)

        If Not (Response1.StatusCode = HttpStatusCode.Moved) Then
            Console.WriteLine("LOGIN FAILURE!")
            Exit Sub
        End If

        Dim HomePageLink = Response1.Headers.Item(HttpResponseHeader.Location)

        Dim Cookies As CookieCollection = Response1.Cookies

        If Cookies Is Nothing OrElse Cookies.Item("_imvu_avnm") Is Nothing Then
            Console.WriteLine("LOGIN FAILURE!")
        Else
            Console.WriteLine("LOGIN SUCCESS!")
        End If

    End Sub
End Module
OP Tue Oct 03, 2017 1:14 pm
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
I don't use VB anymore but thank you, this will come in handy for others and I do see some interesting bits I might convert to c#.

I'm curious where you got that cookie value from, I have never seen it before. Have you confirmed that it works 100% of the time? I have issues with cookies on some accounts, they don't always return the same values even for a successful login.
Tue Oct 03, 2017 1:52 pm
User avatar
  • Posts: 6
  • Joined: Aug, 2017
  • Karma: 10
D.M wrote:
I don't use VB anymore but thank you, this will come in handy for others and I do see some interesting bits I might convert to c#.I'm curious where you got that cookie value from, I have never seen it before. Have you confirmed that it works 100% of the time? I have issues with cookies on some accounts, they don't always return the same values even for a successful login.


Ofcourse it works 100% of the time for me, i made it myself today, make sure you just disable the auto-redirect. It won't be redirected to homepage automatically if AllowAutoRedirect is false.

key of "_imvu_avnm" exists in Cookies if login successful and it doesn't exist if failed.
OP Tue Oct 03, 2017 3:29 pm
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
ZedMan wrote:
key of "_imvu_avnm" exists in Cookies if login successful and it doesn't exist if failed.


Interesting, the debugging program I wrote (you can download it HERE) that displays all the cookies a login request returns never showed a cookie with that name.

I'll disable the redirect and see if that makes a difference.


EDIT:

Disabling the redirect worked on 3 account so far, I was able to get the cookie you mentioned but only on 2 of IMVU's login portals: https://secure.imvu.com/login/login/ and http://imvu.com/login/

https://secure.imvu.com/welcome/login/ still fails to return anything I can reliably use to determine a successful login.
Tue Oct 03, 2017 8:18 pm
User avatar
  • Posts: 6
  • Joined: Aug, 2017
  • Karma: 10
D.M wrote:
https://secure.imvu.com/welcome/login/ still fails to return anything I can reliably use to determine a successful login.


Here is my code, which work with IMVU Next Version

Code

Imports System
Imports System.IO
Imports System.Net
Imports System.Web
Imports System.Collections.Specialized
Imports System.Web.Script.Serialization
Imports System.Collections.Generic
Imports System.Text

    Private MySerializer As New JavaScriptSerializer
    Private Username As String = "<YOUR USERNAME>"
    Private Password As String = "<YOUR PASSWORD>"

    Structure LoginForNext
        Public username As String
        Public password As String
    End Structure

    Private Sub IMVU_Next()

        Const API_IMVU As String = "https://api.imvu.com/login"
        Const Referer_Next As String = "https://secure.imvu.com/welcome/login/"
        Const UserAgent As String = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"

        Dim Login As New LoginForNext
        Login.username = Username
        Login.password = Password

        Dim LoginJSON As String = MySerializer.Serialize(Login)

        Dim Request1 As HttpWebRequest = CType(HttpWebRequest.Create(API_IMVU), HttpWebRequest)
        Request1.Method = WebRequestMethods.Http.Post
        Request1.UserAgent = UserAgent
        Request1.Accept = "application/json; charset=utf-8"
        Request1.ContentType = "application/json; charset=utf-8"
        Request1.Referer = Referer_Next
        Request1.Headers.Add("Origin", "https://secure.imvu.com")
        Request1.Headers.Add("X-imvu-application", "welcome/1")
        Request1.KeepAlive = True

        Using ReqestStreamWriter As New StreamWriter(Request1.GetRequestStream)
            ReqestStreamWriter.Write(LoginJSON)
        End Using

        Try

            Dim Response1 As HttpWebResponse = CType(Request1.GetResponse, HttpWebResponse)

            If Not (Response1.StatusCode = HttpStatusCode.Created) Then
                Console.WriteLine("LOGIN FAILURE!")
                Exit Sub
            End If

            Dim DataReader As String

            Using Reader As New StreamReader(Response1.GetResponseStream)
                DataReader = Reader.ReadToEnd
            End Using

            Dim ResponseJSON As Dictionary(Of String, Object) = MySerializer.Deserialize(Of Dictionary(Of String, Object))(DataReader)

            If ResponseJSON.ContainsKey("status") AndAlso ResponseJSON.Item("status").ToString = "success" Then
                Console.WriteLine("LOGIN SUCCESS!")
            Else
                Console.WriteLine("LOGIN FAILURE!")
            End If

        Catch wex As WebException

            If CType(wex.Response, HttpWebResponse).StatusCode = HttpStatusCode.BadRequest Then
                Console.WriteLine("LOGIN FAILURE!")
            Else
                Console.WriteLine("UNKNOWN!")
            End If

        End Try

    End Sub


and we don't need Cookie and AutoRedirect. Thanks.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT