[Unauthenticated][Information Gathering] Enumerate public resources in Azure using Cloud_Enum

Description

Cloud_Enum is a multi-cloud OSINT tool, in this case we are going to use it to enumerate Microsoft Azure

Requirements

  • Company Name or domain

How to Use

1. Download the tool

  • git clone https://github.com/initstring/cloud_enum.git

2. Install the necessary modules

  • pip3 install -r requirements.txt

3. Display the menu

  • python3 cloud_enum.py -h

4. Select the regions you want the search to apply

  • vi enum_tools/azure_regions.py

Exploitation

1. Run the tool only for Azure

  • python3 cloud_enum.py -k <company name> --disable-aws --disable-gcp

2. Set threads

  • cloud_enum -k keyword -t 10

References

https://github.com/initstring/cloud_enum

[Unauthenticated][Information Gathering] Enumerate Azure OWA and EWS using MailSniper

Description

MailSniper is a penetration testing tool for searching through email in a Microsoft Exchange environment for specific terms (passwords, insider intel, network architecture information, etc.). It can be used as a non-administrative user to search their own email or by an Exchange administrator to search the mailboxes of every user in a domain.

MailSniper also includes additional modules for password spraying, enumerating users and domains, gathering the Global Address List (GAL) from OWA and EWS and checking mailbox permissions for every Exchange user at an organization.

For more information about the primary MailSniper functionality check out blog post.

For more information about additional MailSniper modules check out:

Download the MailSniper Field Manual to quickly reference various MailSniper functions.

How to Use

Two main functions in MailSniper.

These two functions are Invoke-GlobalMailSearch and Invoke-SelfSearch.

  • Invoke-GlobalMailSearch is a module that will connect to a Microsoft Exchange server and grant the "ApplicationImpersonation" role to a specified user. Having the "ApplicationImpersonation" role allows that user to search through all other domain user's mailboxes.
  • After this role has been granted, the Invoke-GlobalMailSearch function creates a list of all mailboxes in the Exchange database. It then connects to Exchange Web Services (EWS) using the impersonation role to gather a number of emails from each mailbox and ultimately searches through them for specific terms. By default, the script searches for "*password*","*creds*","*credentials*"

Invoke-GlobalMailSearch Options

  • ImpersonationAccount - This user will be granted the ApplicationImpersonation role on the Exchange server.
  • ExchHostname - The hostname of the Exchange server to connect to (If $AutoDiscoverEmail is specified the server will be autodiscovered).
  • AutoDiscoverEmail - A valid email address that will be used to autodiscover where the Exchange server is located.
  • MailsPerUser - The total number of emails returned from each mailbox.
  • Terms - Specific search terms used to search through each email subject and body. By default, the script searches for "*password*","*creds*","*credentials*".
  • OutputCsv - Outputs the results of the search to a CSV file.
  • ExchangeVersion - Specify the version of Exchange server to connect to. By default the script tries Exchange2010.
  • AdminUserName - The username of an Exchange administator (i.e. member of the "Exchange Organization Administrators" or "Organization Management" group) including the domain (i.e. domain\adminusername).
  • AdminPassword - The password to the Exchange administator (i.e. member of the "Exchange Organization Administrators" or "Organization Management" group) account specified with AdminUserName.
  • EmailList - A text file listing email addresses to search (one per line).
  • Folder - A specific folder within each mailbox to search. By default, the script only searches the "Inbox" folder. By specifying 'all', all folders and subfolders will be searched.
  • Regex - Use a regular expressions when performing searches. This will override the -Terms flag.
  • CheckAttachments - Attempts to search through the contents of email attachements in addition to the default body and subject. These attachments can be downloaded by specifying the -DownloadDir option. Searches for the following extensions: .bat, .htm, .msg, .pdf, .txt, .ps1, .doc and .xls.
  • DownloadDir - Download files to a specific location.

Invoke-SelfSearch Options

  • ExchHostname - The hostname of the Exchange server to connect to (If $Mailbox is specified the server will be autodiscovered).
  • Mailbox - Email address of the current user the PowerShell process is running as.
  • MailsPerUser - Number of emails to return.
  • Terms - Specific search terms used to search through each email subject and body. By default, the script searches for "*password*","*creds*","*credentials*".
  • OutputCsv - Outputs the results of the search to a CSV file.
  • ExchangeVersion - Specify the version of Exchange server to connect to (default Exchange2010).
  • Remote - A new credential box will pop up for accessing a remote EWS service from the internet.
  • Folder - A specific folder within each mailbox to search. By default, the script only searches the "Inbox" folder. By specifying 'all', all folders and subfolders will be searched.
  • Regex - Use a regular expressions when performing searches. This will override the -Terms flag.
  • CheckAttachments - Attempts to search through the contents of email attachements in addition to the default body and subject. These attachments can be downloaded by specifying the -DownloadDir option. Searches for the following extensions: .bat, .htm, .msg, .pdf, .txt, .ps1, .doc and .xls.
  • DownloadDir - Download files to a specific location.
  • OtherUserMailbox - Use this flag when attempting to read emails from a different user's mailbox
  • UsePrt - Uses the current user's PRT to authenticate.
  • AccessToken - Use provided oauth access token to authenticate.

Invoke-GlobalO365MailSearch Options

  • UsePrtImperonsationAccount - Uses the current user's PRT to authenticate ImperonsationAccount.
  • AccessTokenImpersonationAccount - Use provided oauth access token to authenticate ImperonsationAccount.
  • UsePrtAdminAccount - Uses the current user's PRT to authenticate AdminAccount.
  • AccessTokenAdminAccount - Use provided oauth access token to authenticate ImperonsationAccount.

Additional MailSniper Modules

Get-GlobalAddressList

it will attempt to connect to an Outlook Web Access (OWA) portal and utilize the "FindPeople" method (only available in Exchange2013 and up) of gathering email addresses from the GAL. If this does not succeed the script will attempt to connect to EWS and attempt to gather the GAL.

  • Get-GlobalAddressList -ExchHostname mail.domain.com -UserName domain\username -Password Spring2021 -OutFile gal.txt

Get-MailboxFolders

it will connect to a Microsoft Exchange server using EWS and gather a list of folders from the current user's mailbox.

  • Get-MailboxFolders -Mailbox current-user@domain.com

Invoke-PasswordSprayOWA

It will attempt to connect to an OWA portal and perform a password spraying attack using a userlist and a single password.

  • Invoke-PasswordSprayOWA -ExchHostname mail.domain.com -UserList .\userlist.txt -Password Spring2021 -Threads 15 -OutFile owa-sprayed-creds.txt

Invoke-PasswordSprayEWS

It will attempt to connect to an EWS portal and perform a password spraying attack using a userlist and a single password.

  • Invoke-PasswordSprayEWS -ExchHostname mail.domain.com -UserList .\userlist.txt -Password Spring2021 -Threads 15 -OutFile sprayed-ews-creds.txt

Invoke-PasswordSprayGmail

This module will first attempt to connect to a Gmail Authentication portal and perform a password spraying attack using a userlist and a single password.

  • Invoke-PasswordSprayGmail -UserList .\userlist.txt -Password Fall2016 -Threads 15 -OutFile gmail-sprayed-creds.txt

Invoke-DomainHarvestOWA

It will attempt to connect to an OWA portal and determine a valid domain name for logging into the portal from the WWW-Authenticate header returned in a web response from the server or based off of small timing differences in login attempts.

  • Invoke-DomainHarvestOWA -ExchHostname mail.domain.com

Invoke-UsernameHarvestOWA

It will attempt to connect to an OWA portal and harvest valid usernames based off of small timing differences in login attempts.

  • Invoke-UsernameHarvestOWA -ExchHostname mail.domain.com -UserList .\userlist.txt -Threads 1 -OutFile owa-valid-users.txt

Invoke-UsernameHarvestGmail

This is a module that will attempt to enumerate Google Apps user accounts and potentially identify user accounts that opt-out of implemented 2FA solutions.

  • Invoke-UsernameHarvestGmail -Account
  • Invoke-UsernameHarvestGmail -UserFile .\emails.txt
  • Invoke-UsernameHarvestGmail -UserFile .\emails.txt -ProxyHosts 10.0.0.5:8080,10.0.0.6:8080,10.0.0.10:443
  • Invoke-UsernameHarvestGmail -UserFile .\emails.txt -Detailed
  • Get-Content emails.txt | % { Invoke-UsernameHarvestGmail $_ }

Invoke-OpenInboxFinder

It will attempt to determine if the current user has access to the Inbox of each email address in a list of addresses.

  • Invoke-OpenInboxFinder -EmailList email-list.txt

Get-ADUsernameFromEWS

It will attempt to determine the Active Directory username for a single email address or a list of addresses. Use the Get-GlobalAddressList module to harvest a full list of email addresses to use with Get-ADUsernameFromEWS.

  • Get-ADUsernameFromEWS -EmailList email-list.txt

Send-EWSEmail

It will attempt to connect to EWS and send an email.

  • Send-EWSEmail --ExchHostname substrate.office.com -Recipient $targetEmail -Subject "Foo" -EmailBody "Bar" -AccessToken $Accesstoken

References

https://github.com/dafthack/MailSniper

[Unauthenticated][Information Gathering] Enumerate Azure Office users

Description

This is a simple Python script used to validate email accounts that belong to Office 365 tenants. This script takes either a single email address or a list of email addresses as input, sends a request to Office 365 without a password, and looksfor the the "IfExistsResult" parameter to be set to 0 for a valid account. Invalid accounts will return a 1.

Requirements

  • List of users
  • Domain

How to Use

1. Download the tool into your computer

  • git clone https://github.com/LMGsec/o365creeper.git

2. Display the help menu

  • python2.7 o365creeper.py -h

-e EMAIL, --email EMAIL

  • Single email address to validate.

-f FILE, --file FILE

  • List of email addresses to validate, one per line.

-o OUTPUT, --output OUTPUT

  • Output valid email addresses to the specified file.

Exploitation

1. testing a sing user

  • python2.7 o365creeper.py -e ceo@adpentesteracademy.onmicrosoft.com

VALID

INVALID

2. Enumerate using a file containing different emails

  • python2.7 o365creeper.py -f emails.txt

References

https://github.com/LMGsec/o365creeper