
Multi-threaded scanner for detecting exposed Swagger/OpenAPI endpoints across web domains and subdomains, with automatic XSS detection, PoC generation, and false-positive filtering for API security assessments.
Presented at BlackHat Arsenal 2024 (Link)
/swagger-ui/index.html endpointsAPIDetector v3 requires Python 3.x and the following packages:
flask # Web framework
requests # HTTP client
playwright # Browser automation for screenshots
nest_asyncio # Async IO support
All dependencies are listed in requirements.txt and can be installed automatically during setup.
After installing the required packages, you need to install the Playwright browsers:
python -m playwright install
This is required for the screenshot functionality to work properly.
git clone https://github.com/brinhosa/apidetector.git
cd apidetector
# On macOS/Linux:
python3 -m venv venv
source venv/bin/activate
# On Windows:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
playwright install
python app.py
python app.py --port 8080 --host 0.0.0.0
Open your browser and navigate to the URL shown in the terminal.
Using the web interface:
The screenshots are saved in the screenshots directory for future reference.
APIDetector v3 offers two ways to interact with the tool: a modern web interface (new in v3) and a traditional command-line interface (original).
python app.py [options]
Available options:
| Option | Description | Default |
|---|---|---|
-p, --port | Port number | 5000 |
--host | Host address | 127.0.0.1 |
-d, --debug | Enable debug mode | False |
Examples:
# Run on default settings (localhost:5000)
python app.py
# Run on custom port
python app.py -p 8080
# Allow external access
python app.py --host 0.0.0.0
# Run in debug mode
python app.py -d
Access the web interface:
View Results:
Run APIDetector using the command line. Here are some usage examples:
Common usage, scan with 30 threads a list of subdomains using a Chrome user-agent and save the results in a file:
python apidetector.py -i list_of_company_subdomains.txt -o results_file.txt -t 30 -ua "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
To scan a single domain:
python apidetector.py -d example.com
To scan multiple domains from a file:
python apidetector.py -i input_file.txt
To specify an output file:
python apidetector.py -i input_file.txt -o output_file.txt
To use a specific number of threads:
python apidetector.py -i input_file.txt -t 20
To scan with both HTTP and HTTPS protocols:
python apidetector.py -m -d example.com
To run the script in quiet mode (suppress verbose output):
python apidetector.py -q -d example.com
To run the script with a custom user-agent:
python apidetector.py -d example.com -ua "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
If you are using APIDetector v2, replace the commands by apidetectorv2.py.
-d, --domain: Single domain to test.-i, --input: Input file containing subdomains to test.-o, --output: Output file to write valid URLs to.-t, --threads: Number of threads to use for scanning (default is 10).-m, --mixed-mode: Test both HTTP and HTTPS protocols.-q, --quiet: Disable verbose output (default mode is verbose).-ua, --user-agent: Custom User-Agent string for requests.Exposing Swagger or OpenAPI documentation endpoints can present various risks, primarily related to information disclosure. Here's an ordered list based on potential risk levels, with similar endpoints grouped together APIDetector scans: