'###########################################
'## DynDNS.org Auto-Login for Free Users
'##
'## Author: atomicrabbit (atombomb2k@hotmail.com)
'## Date: 2013.05.30
'###########################################
title = "DynDNS.org Auto-Login"
'Edit the following variables appropriately
'------- START EDITING HERE -------
'URLs
basePage = "https://account.dyn.com/"
loginPage = basePage & "entrance/"
loginSvcPage = loginPage & "?return=/services/"
logoutPage = loginPage & "?__logout=1"
svcPage = basePage & "services/"
'Login form variables
' These refer to various objects in the login form.
' Leave these variables alone unless you know what you're doing
loginFormRe = "^login(\d*)$" 'Allows to find randomly generated number
loginUserFieldId = "login#_username" 'The # will be replaced with the randomly generated number
loginPassFieldId = "login#_password" 'The # will be replaced with the randomly generated number
loginSubmitId = "login#_submit" 'The # will be replaced with the randomly generated number
loggedInId = "myServicesButton"
'Login Info
username = "USERNAME" 'Your username
password = "PASSWORD" 'Your passowrd
'IE Window Visibility
' True - IE window will be visible while processing the code
' False - IE window will be hidden and run the code in the background
windowVisible = True
'Browser Timeout
' Set max timeout for browser responsiveness (in seconds)
' Default: 7
timeout = 7
'------- STOP EDITING HERE ... DO NOT TOUCH ANYTHING BELOW -------
timeout = timeout * 20 'because the iterations are 50ms
tCount = 1
'Create IE object
Set objIE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
'Go to Login page
objIE.Navigate loginSvcPage
objIE.Visible = windowVisible
While objIE.Busy
WScript.Sleep 50
Wend
'Find randomly generated number in login form
Set objLoginForm = objIE.Document.Forms(0) 'the login form is usually the first form
Set re = new RegExp
re.Pattern = loginFormRe
re.IgnoreCase = true
Set reMatches = re.Execute(objLoginForm.id)
if reMatches(0) is nothing then
'Close IE
objIE.Quit
else
loginFormNum = reMatches(0).SubMatches(0)
'Check if not logged in
if not objLoginForm is nothing then
' Login if you're not already
objIE.Document.All.Item(Replace(loginUserFieldId,"#",loginFormNum)).Value = username
objIE.Document.All.Item(Replace(loginPassFieldId,"#",loginFormNum)).Value = password
objIE.Document.All.Item(Replace(loginSubmitId,"#",loginFormNum)).click
'Wait for page to load
While objIE.Busy OR tCount >= timeout
tCount = tCount + 1
WScript.Sleep 50
Wend
end if
if tCount >= timeout AND objIE.Document.All.Item(loggedInId) is nothing Then
MsgBox "Browser timeout. Try running the script again.", vbOkOnly, title
'Close IE
objIE.Quit
'exit script
Elseif objIE.LocationURL = svcPage AND not objIE.Document.All.Item(loggedInId) is nothing Then
'Logout
objIE.Navigate logoutPage
'Close IE
objIE.Quit
MsgBox "Logged into DynDNS account for '" & username & "' on " & Now & "!", vbOkOnly, title
Else
'Close IE
objIE.Quit
MsgBox "Error logging in with '" & username & "'", vbOkOnly, title
'exit script
End if
end if
'Clear variables
Set objIE = Nothing
Set title = Nothing
Set basePage = Nothing
Set loginPage = Nothing
Set loginSvcPage = Nothing
Set logoutPage = Nothing
Set svcPage = Nothing
Set loginFormRe = Nothing
Set loginUserFieldId = Nothing
Set loginPassFieldId = Nothing
Set loginSubmitId = Nothing
Set loginErrorId = Nothing
Set loggedInId = Nothing
Set username = Nothing
Set password = Nothing
Set windowVisible = Nothing
Set timeout = Nothing
Set tCount = Nothing
Set re = Nothing
Set reMatches = Nothing
Set objLoginForm = Nothing
Set loginFormNum = Nothing
Wscript.quit