Created
August 24, 2017 20:36
-
-
Save anonymous/0c34af68bf2f59fd7d75ecc6c0fa692d to your computer and use it in GitHub Desktop.
Retrieve google drive OAuth token from the Windows Registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from winreg import ConnectRegistry, OpenKey, EnumValue, HKEY_CURRENT_USER | |
TARGET_KEY = r'SOFTWARE\Google\Drive' | |
def main(): | |
with ConnectRegistry(None, HKEY_CURRENT_USER) as wr: | |
GdriveKey = OpenKey(wr, TARGET_KEY) | |
i = 0 | |
while True: | |
try: | |
k, v, _ = EnumValue(GdriveKey, i) | |
if 'OAuth' in k: | |
print("Found OAuth token:\n\tOAuth Private Key ID={}\n\tOAuth Key={}".format(k.split("_")[1], v)) | |
except: | |
break | |
else: | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment