57 lines · 1.8 KB · Python
RawDownload
#!/usr/bin/python# ------------------------------------------------------------# name      FancyBear# type      exploit# cve       —# year      unknown# os        Windows# authors   unknown# source    RamadhanAmizudin/malware# archived  RamadhanAmizudin, krisyotam (2026)# notes     —# ------------------------------------------------------------ import argparseimport httplib2 from apiclient.discovery import buildfrom oauth2client.client import flow_from_clientsecretsfrom oauth2client.file import Storagefrom oauth2client.tools import run_flow, argparser # Parse the command-line arguments (e.g. --noauth_local_webserver)parser = argparse.ArgumentParser(parents=[argparser])flags = parser.parse_args() # Path to the client_secret.json file downloaded from the Developer ConsoleCLIENT_SECRET_FILE = '_secret.json' # Check https://developers.google.com/gmail/api/auth/scopes# for all available scopesOAUTH_SCOPE = 'https://www.googleapis.com/auth/gmail.readonly' # Location of the credentials storage fileSTORAGE = Storage('gmail.storage') # Start the OAuth flow to retrieve credentialsflow = flow_from_clientsecrets(CLIENT_SECRET_FILE, scope=OAUTH_SCOPE)http = httplib2.Http() # Try to retrieve credentials from storage or run the flow to generate themcredentials = STORAGE.get()if credentials is None or credentials.invalid:  credentials = run_flow(flow, STORAGE, flags, http=http) # Authorize the httplib2.Http object with our credentialshttp = credentials.authorize(http) # Build the Gmail service from discoverygmail_service = build('gmail', 'v1', http=http) # Retrieve a page of threadsthreads = gmail_service.users().threads().list(userId='me').execute() # Print ID for each threadif threads['threads']:  for thread in threads['threads']:    print 'Thread ID: %s' % (thread['id'])