[Vb.Net] Imvu Login Code

DataMine
by DataMine · 10 posts
11 years ago in .Net (C#, VB, etc)
Posted 11 years ago · Author
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).
Posted 8 years ago
Only if i understood coding..im sure this would be nice.

Thank you.
Posted 7 years ago
im just learning how to programming using MS visual so ty may this help me in future
Posted 7 years ago
thank you for this it can come in handy for some projects
Posted 6 years ago
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
Posted 6 years ago · Author
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.
Posted 6 years ago
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.
Posted 6 years ago · Author
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.
Posted 6 years ago
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
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts