Overview
Scan4all provides a programmatic API that allows you to integrate its scanning capabilities into your own Go applications. The API is located inlib/api/main.go and provides a simple interface for triggering scans.
Quick Start
Import the Package
Basic Scan
Scan with Custom Options
API Reference
StartScan Function
The main entry point for programmatic scanning:oOpts: Optional map of configuration options that override default settings
Configuration Options
The following options can be passed toStartScan:
Target Options
| Option | Type | Description | Example |
|---|---|---|---|
Host | string | Single target host | "192.168.1.1" |
HostsFile | string | File containing target list | "targets.txt" |
List | string | Comma-separated target list | "192.168.1.1,example.com" |
Ports | string | Ports to scan | "80,443,8080-8090" |
Scan Options
| Option | Type | Description | Default |
|---|---|---|---|
Output | string | Output file path | "" |
JSON | bool | Output in JSON format | false |
Verbose | bool | Verbose output | false |
Debug | bool | Debug mode | false |
Silent | bool | Silent mode | false |
EnableProgressBar | bool | Show progress bar | false |
NoColor | bool | Disable colored output | false |
Advanced Options
| Option | Type | Description |
|---|---|---|
priorityNmap | bool | Use nmap for scanning |
noScan | bool | Skip port scan, use existing results |
enableNuclei | bool | Enable Nuclei scanning |
UrlPrecise | bool | Precise URL scanning |
Advanced Usage
Scanning Multiple Targets
Port-Specific Scanning
Using Nmap Results
Working with Results
Result Storage
Scan results are stored in multiple formats:- File Output - Specified via
Outputoption - Elasticsearch - If configured in
config/config.json - In-memory - Accessible via global variables
Accessing Results in Code
Integration Patterns
Web Service Integration
CI/CD Pipeline Integration
Batch Scanning
Environment Variables
Many options can be controlled via environment variables:Error Handling
Performance Considerations
Thread Pool Management
Thread Pool Management
The default thread pool size is 5000. Adjust based on your system resources:
Memory Management
Memory Management
For large-scale scans, consider:
- Processing targets in batches
- Using
Silentmode to reduce memory usage - Enabling Elasticsearch for result storage
- Clearing result files periodically
Network Optimization
Network Optimization
Configuration Files
Loading Custom Config
Scan4all loads configuration fromconfig/config.json. You can customize:
Integration Examples
Complete Example
Async Scanning
Next Steps
Custom Modules
Create custom scan modules
Contributing
Contribute to the scan4all project