Skip to content

Instantly share code, notes, and snippets.

@mkrishtopa
Forked from bjarki/Gmail password reset
Last active January 5, 2018 22:13
Show Gist options
  • Save mkrishtopa/67184ba6f45fb0379c25 to your computer and use it in GitHub Desktop.
Save mkrishtopa/67184ba6f45fb0379c25 to your computer and use it in GitHub Desktop.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' If your phone was lost or stolen and you want to use Android Device Manager
' from Google you should not change your password. If you do change it
' Android Device Manager will not be able to find your phone. If you change
' your password and you later want to reset it to the one that existed when you
' lost the phone Google does not allow you to use a previously used password.
' You can overcome this limitation by resetting your password 100 times.
' This script resets the password 100 times so that you can then set it to the
' password used at the time that the phone was lost/stolen. Then you can use
' Android Device Manager to find your phone if the Google account hasn't been
' erased or reset to a new username.
' NB: WinXP is ok for this task, but you should install AutoIT library.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Versions
'
' Version: 1.6
' source: inzi.com
'
' Change Log
'
' v1.6 10/15/2014 - Michael Krishtopa, @krishtopa
' - Fixed {TAB}s, Google changed pages structure a bit
' - Browser autostart - removed. Start it by hands, open new tab, then start script
' - Changed Google Chrome to Mozilla Firefox (may be reverted in you need - just replace in code Mozilla Firefox -> Chrome)
' - Commented out almost all popups, this saves time
'
' v1.5 10/23/2013
' - Added iSlowConnectionFactor, an easy way to tweak speed of script
' - Updated default path to Chrome
' - Added 2nd tab to account for lost password link at line 109
'
' v1.0
' Original
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Declare Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oShell
Dim oAutoIt
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Initialise Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set oShell = WScript.CreateObject("WScript.Shell")
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
WScript.Echo "This script will reset your google password 100 times so you can use an old password."
WScript.Echo "Open Firefox, LOG IN with your CURRENT password into google account, then press LOG OUT. So Google will remember your used username. Then OPEN NEW TAB and press OK below."
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You should only edit value after this
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Your Google username (email address)
sUN = "[email protected]"
' Replace with the Current password to your google account
curPW = "??????????????"
' Replace with the final password you want assigned to the account. The one you want to set the account's password *back to*.
oldPW = "???????????????"
' Is it going to fast? You can slow it down by adjusting this value.
' If you set it to 2, it will run twice as slow
' So if it is entering data into the wrong fields, try increasing this.
' It might help.
iSlowConnectionFactor = 1
' If your password has a quote in it ("), then use "" in its place.
' For example, let's say your password was
' MyPass"word!-55
'
' The proper VBScript way to put that into a variable would look like this
' curPW = "MyPass""word!-55"
'
' See Microsoft's website for more detail
' Where is the Chrome executable? Replace this with its location.
' Point app to Chrome Manually
' An easy way to find this is to right click the Chrome shortcut and copy the value in Target.
' Click Start, type Chrome, right click Google Chrome, click Properties, copy *everything* in Target, and put it here.
' This example path is for 64 bit windows
' ChromeEXE = "C:\Documents and Settings\Admin\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
' This example path is for 32 bit windows
' "C:\Program Files\Google\Chrome\Application\chrome.exe"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You should not have to edit anything after this
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Start of Script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Some of this code uses the AutoIT com object. See their documentation for more details.
'oShell.Run ChromeEXE, 1, False
' Wait for the Mozilla Firefox window to become active
oAutoIt.WinWaitActive "New Tab - Mozilla Firefox", ""
oAutoIt.Sleep 3000
WScript.Echo "Entering Loop"
' Enter the loop, change the password 99 more times
tCurPw = curPW
For x = 1 To 20
' WScript.Echo "Step " & x
WScript.Echo "Current PW: " & tCurPw
tNewPW = curPW & x
' WScript.Echo "Setting the password to: " & tNewPW
GLogin sUN, tCurPw
GEditPW
oAutoIt.Send tCurPw & "{TAB}{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send tNewPW & "{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send tNewPW & "{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send "{ENTER}"
oAutoIt.Sleep 3000 * iSlowConnectionFactor
tCurPw = tNewPW
GLogout
Next
WScript.Echo "Final Change"
GLogin sUN, tCurPw
GEditPW
oAutoIt.Send tCurPw & "{TAB}{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send oldPW & "{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send oldPW & "{TAB}"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send "{ENTER}"
oAutoIt.Send "https://www.google.com/accounts/Logout{ENTER}"
oAutoIt.Sleep 2000 * iSlowConnectionFactor
WScript.Echo "Password reset"
WScript.Quit
Function GLogin(un, pw) ' Opens the Google Login page, enters the supplied Username (un) and Password (pw), and presses Enter.
' WScript.Echo "Logging in: " & un & ", " & pw
oAutoIt.Send "!d"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send "https://accounts.google.com/Login{ENTER}"
oAutoIt.Sleep 2000 * iSlowConnectionFactor
' oAutoIt.Send un & "{TAB}"
' oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send pw & "{ENTER}"
oAutoIt.Sleep 3000 * iSlowConnectionFactor
End Function
Function GEditPW() ' Opens the Google Change Password web page
oAutoIt.Send "!d"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send "https://accounts.google.com/b/0/EditPasswd{ENTER}"
oAutoIt.Sleep 2000 * iSlowConnectionFactor
End Function
Function GLogout() ' Logs out from google. This is necessary for the password change to take effect. Trust me, I tried to do it without logging out. No luck.
' WScript.Echo "Logging out"
oAutoIt.Send "!d"
oAutoIt.Sleep 250 * iSlowConnectionFactor
oAutoIt.Send "https://www.google.com/accounts/Logout{ENTER}"
oAutoIt.Sleep 3000 * iSlowConnectionFactor
End Function
@g1g9g9g9
Copy link

g1g9g9g9 commented Jan 5, 2018

how it's work?
how to run it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment