Created
November 11, 2021 05:58
-
-
Save akhil-reni/36d53e1b663bca69b24f6649a851db6e to your computer and use it in GitHub Desktop.
Domain enumeration for Azure
This file contains hidden or 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 urllib.request import urlopen, Request | |
import xml.etree.ElementTree as ET | |
domain = input("Enter your target: \n") | |
body = """<?xml version="1.0" encoding="utf-8"?> | |
<soap:Envelope xmlns:exm="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ext="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | |
<soap:Header> | |
<a:Action soap:mustUnderstand="1">http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetFederationInformation</a:Action> | |
<a:To soap:mustUnderstand="1">https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc</a:To> | |
<a:ReplyTo> | |
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> | |
</a:ReplyTo> | |
</soap:Header> | |
<soap:Body> | |
<GetFederationInformationRequestMessage xmlns="http://schemas.microsoft.com/exchange/2010/Autodiscover"> | |
<Request> | |
<Domain>{}</Domain> | |
</Request> | |
</GetFederationInformationRequestMessage> | |
</soap:Body> | |
</soap:Envelope>""".format(domain) | |
headers = { | |
"Content-type": "text/xml; charset=utf-8", | |
"SOAPAction": "http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetFederationInformation", | |
"User-agent": "AutodiscoverClient", | |
} | |
httprequest = Request( | |
"https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc", headers=headers, data=body.encode()) | |
with urlopen(httprequest) as response: | |
response = response.read().decode() | |
tree = ET.ElementTree(ET.fromstring(response)) | |
for elem in tree.iter(): | |
if elem.tag == "{http://schemas.microsoft.com/exchange/2010/Autodiscover}Domain": | |
print(elem.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment