Arachni aide-mémoire
Overview
Arachni is a feature-rich, modular, high-performance Ruby framework aimed at helping penetration testers and administrators evaluate the security of modern application webs. Developed with a focus on usability and modularity, Arachni provides comprehensive application web security assessment capabilities through its advanced crawling engine, extensive vulnérabilité detection modules, and flexible reporting system. The framework is designed to handle complex modern application webs including those with heavy JavaScript utilisation, AJAX functionality, and dynamic content generation.
The framework distinguishes itself through its intelligent crawling capabilities and comprehensive vulnérabilité detection. Arachni can effectively analyze single-page applications (SPAs), REST APIs, and traditional application webs with equal proficiency. Its modular architecture allows for easy customization and extension, making it suitable for both automated security testing and manual tests de pénétration workflows. The platform includes advanced features such as browser clustering for JavaScript-heavy applications, custom charge utile generation, and sophisticated false positive reduction mechanisms.
Arachni's strength lies in its ability to perform both black-box and gray-box security testing. The framework can operate in various modes, from quick security scans to comprehensive deep-dive assessments. It includes built-in support for authentification, session management, and complex multi-step attack scenarios. The platform's reporting capabilities generate detailed technical reports suitable for developers, executive summaries for management, and compliance documentation for regulatory requirements.
The framework is particularly valuable for organizations requiring regular security assessments of application webs. Its automation capabilities make it suitable for integration into CI/CD pipelines, while its comprehensive manual testing features support detailed tests de pénétration engagements. Arachni's active development community ensures regular updates to address emerging application web security threats and testing methodologies.
Installation
Docker Installation (Recommended)
# Pull official Arachni Docker image
docker pull arachni/arachni
# Run Arachni container with web interface
docker run -d -p 9292:9292 --name arachni-web arachni/arachni arachni_web
# Run Arachni container for commande-line utilisation
docker run -it --rm arachni/arachni arachni --help
# Run comprehensive scan with Docker
docker run -it --rm -v $(pwd)/reports:/reports arachni/arachni \
arachni http://exemple.com --report-save-path=/reports/scan_report.afr
# Access Arachni Web UI
# Navigate to http://localhôte:9292
# Run with custom configuration
docker run -d -p 9292:9292 \
-v $(pwd)/config:/config \
-v $(pwd)/reports:/reports \
--name arachni-web arachni/arachni \
arachni_web --config=/config/arachni.conf
Docker Compose Installation
# Create docker-compose.yml
cat << 'EOF' > docker-compose.yml
version: '3.8'
services:
arachni-web:
image: arachni/arachni
container_name: arachni-web
ports:
- "9292: 9292"
volumes:
- arachni_reports: /reports
- arachni_config: /config
- arachni_logs: /logs
commande: arachni_web --hôte=0.0.0.0 --port=9292
environment:
- ARACHNI_WEB_hôte=0.0.0.0
- ARACHNI_WEB_port=9292
restart: unless-stopped
networks:
- arachni_network
arachni-dispatcher:
image: arachni/arachni
container_name: arachni-dispatcher
ports:
- "7331: 7331"
volumes:
- arachni_reports: /reports
- arachni_config: /config
commande: arachni_rpcd --hôte=0.0.0.0 --port=7331
environment:
- ARACHNI_DISPATCHER_hôte=0.0.0.0
- ARACHNI_DISPATCHER_port=7331
restart: unless-stopped
networks:
- arachni_network
volumes:
arachni_reports:
arachni_config:
arachni_logs:
networks:
arachni_network:
driver: bridge
EOF
# Start Arachni services
docker-compose up -d
# View logs
docker-compose logs -f arachni-web
# Stop services
docker-compose down
# Stop and remove volumes
docker-compose down -v
Manual Installation on Ubuntu/Debian
# Update system
sudo apt update && sudo apt upgrade -y
# Install Ruby and dependencies
sudo apt install -y ruby ruby-dev build-essential libssl-dev \
libxml2-dev libxslt1-dev libcurl4-openssl-dev \
libsqlite3-dev zlib1g-dev
# Install RubyGems
sudo apt install -y rubygems
# Install Arachni
wget https://github.com/Arachni/arachni/releases/download/v1.6.1.3/arachni-1.6.1.3-0.6.1.1-linux-x86_64.tar.gz
tar -xzf arachni-1.6.1.3-0.6.1.1-linux-x86_64.tar.gz
sudo mv arachni-1.6.1.3-0.6.1.1 /opt/arachni
# Add Arachni to PATH
echo 'export PATH="/opt/arachni/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Verify Installation
arachni --version
# Install additional gems (optional)
cd /opt/arachni
sudo gem install bundler
sudo bundle install
# Start Arachni Web UI
arachni_web --hôte=0.0.0.0 --port=9292
# Start Arachni RPC dispatcher
arachni_rpcd --hôte=0.0.0.0 --port=7331
Installation on CentOS/RHEL
# Install EPEL repository
sudo yum install epel-release -y
# Install Ruby and development tools
sudo yum groupinstall "Development Tools" -y
sudo yum install ruby ruby-devel rubygems \
openssl-devel libxml2-devel libxslt-devel \
libcurl-devel sqlite-devel zlib-devel -y
# Download and install Arachni
cd /tmp
wget https://github.com/Arachni/arachni/releases/download/v1.6.1.3/arachni-1.6.1.3-0.6.1.1-linux-x86_64.tar.gz
tar -xzf arachni-1.6.1.3-0.6.1.1-linux-x86_64.tar.gz
sudo mv arachni-1.6.1.3-0.6.1.1 /opt/arachni
# Set permissions
sudo chown -R root:root /opt/arachni
sudo chmod +x /opt/arachni/bin/*
# Add to PATH
echo 'export PATH="/opt/arachni/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Create systemd service for Arachni Web
sudo tee /etc/systemd/system/arachni-web.service << 'EOF'
[Unit]
Description=Arachni Web Interface
After=network.cible
[service]
Type=simple
User=arachni
Group=arachni
WorkingDirectory=/opt/arachni
ExecStart=/opt/arachni/bin/arachni_web --hôte=0.0.0.0 --port=9292
Restart=always
[Install]
WantedBy=multi-user.cible
EOF
# Create arachni user
sudo useradd -r -s /bin/false arachni
sudo chown -R arachni:arachni /opt/arachni
# Start and enable service
sudo systemctl démon-reload
sudo systemctl start arachni-web
sudo systemctl enable arachni-web
Source Installation
# Install Ruby version manager (rbenv)
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# Install Ruby 2.7.0 (required for Arachni)
rbenv install 2.7.0
rbenv global 2.7.0
# Clone Arachni repository
git clone https://github.com/Arachni/arachni.git
cd arachni
# Install dependencies
gem install bundler
bundle install
# Build Arachni
rake build
# Install Arachni
rake install
# Verify Installation
arachni --version
Basic utilisation
commande Line Interface
# Basic application web scan
arachni http://exemple.com
# Scan with specific checks
arachni http://exemple.com --checks=xss,sqli,csrf
# Scan with custom scope
arachni http://exemple.com --scope-include-pattern="exemple\.com" \
--scope-exclude-pattern="logout|admin"
# Scan with authentification
arachni http://exemple.com --plugin=autologin:url=http://exemple.com/login,paramètres="nom d'utilisateur=admin&mot; de passe=secret"
# Scan with custom headers
arachni http://exemple.com --http-request-headers="autorisation: Bearer jeton123"
# Scan with proxy
arachni http://exemple.com --http-proxy=http://127.0.0.1:8080
# Scan with custom user agent
arachni http://exemple.com --http-user-agent="Custom Scanner 1.0"
# Scan with session cookies
arachni http://exemple.com --http-cookie-string="PHPSESSID=abc123; auth=jeton456"
# Scan with rate limiting
arachni http://exemple.com --http-request-delay=1000 --http-request-concurrency=5
# Scan with timeout settings
arachni http://exemple.com --http-request-timeout=30000 --http-response-max-size=1048576
Advanced Scanning options
# Comprehensive deep scan
arachni http://exemple.com \
--checks=* \
--plugins=* \
--scope-auto-redundant=5 \
--audit-links \
--audit-forms \
--audit-cookies \
--audit-headers \
--audit-jsons \
--audit-xmls
# Scan with browser clustering (for JavaScript-heavy apps)
arachni http://exemple.com \
--browser-cluster-pool-size=3 \
--browser-cluster-job-timeout=30 \
--browser-cluster-worker-time-to-live=100
# Scan with custom wordlists
arachni http://exemple.com \
--checks=path_traversal \
--plugin=path_extractor:wordlist=/path/to/custom_wordlist.txt
# Scan with form filling
arachni http://exemple.com \
--input-value-fill-mode=exhaustive \
--input-values-file=/path/to/input_values.txt
# Scan with custom charge utiles
arachni http://exemple.com \
--checks=xss \
--plugin=charge utile_generator:charge utiles=/path/to/xss_charge utiles.txt
# Scan with vulnérabilité verification
arachni http://exemple.com \
--checks=sqli \
--plugin=verification:verify_sqli=true
# Scan with custom crawling depth
arachni http://exemple.com \
--scope-depth-limit=5 \
--scope-page-limit=1000 \
--scope-directory-depth-limit=3
# Scan with exclusions
arachni http://exemple.com \
--scope-exclude-path-patterns="logout,admin,delete" \
--scope-exclude-content-patterns="text/css,image/*"
authentification and session Management
# Form-based authentification
arachni http://exemple.com \
--plugin=autologin:url=http://exemple.com/login,paramètres="nom d'utilisateur=admin&mot; de passe=secret",check="Welcome"
# HTTP Basic authentification
arachni http://exemple.com \
--http-authentification-nom d'utilisateur=admin \
--http-authentification-mot de passe=secret
# Custom authentification script
arachni http://exemple.com \
--plugin=script:script=/path/to/auth_script.rb
# session management with cookies
arachni http://exemple.com \
--http-cookie-jar=/path/to/cookies.txt \
--session-check-url=http://exemple.com/profile \
--session-check-pattern="Welcome"
# Multi-step authentification
arachni http://exemple.com \
--plugin=multi_step_auth:steps="step1.rb,step2.rb,step3.rb"
# OAuth authentification
arachni http://exemple.com \
--plugin=oauth:client_id=your_client_id,client_secret=your_secret,redirect_uri=http://localhôte/callback
vulnérabilité Detection
injection SQL Testing
# Basic injection SQL scan
arachni http://exemple.com --checks=sqli
# Advanced injection SQL with custom charge utiles
arachni http://exemple.com \
--checks=sqli \
--plugin=charge utile_generator:charge utiles=/path/to/sqli_charge utiles.txt \
--audit-paramètre-names \
--audit-paramètre-values
# Blind injection SQL testing
arachni http://exemple.com \
--checks=sqli_blind_rdiff,sqli_blind_timing \
--plugin=timing_attack:delay=5
# Database-specific injection SQL
arachni http://exemple.com \
--checks=sqli \
--plugin=database_detection:databases="mysql,postgresql,mssql,oracle"
# injection SQL with verification
arachni http://exemple.com \
--checks=sqli \
--plugin=verification:verify_sqli=true,extract_data=true
cross-site scripting (XSS) (XSS) Testing
# Basic XSS scan
arachni http://exemple.com --checks=xss
# Comprehensive XSS testing
arachni http://exemple.com \
--checks=xss,xss_dom,xss_event,xss_script_context,xss_tag \
--audit-links \
--audit-forms \
--audit-cookies \
--audit-headers
# Custom XSS charge utiles
arachni http://exemple.com \
--checks=xss \
--plugin=charge utile_generator:charge utiles=/path/to/xss_charge utiles.txt
# DOM-based XSS testing
arachni http://exemple.com \
--checks=xss_dom \
--browser-cluster-pool-size=2 \
--browser-cluster-job-timeout=30
# XSS with context analysis
arachni http://exemple.com \
--checks=xss \
--plugin=context_analysis:analyze_responses=true
Cross-Site Request Forgery (CSRF) Testing
# Basic CSRF scan
arachni http://exemple.com --checks=csrf
# CSRF with authentification
arachni http://exemple.com \
--checks=csrf \
--plugin=autologin:url=http://exemple.com/login,paramètres="nom d'utilisateur=admin&mot; de passe=secret"
# CSRF jeton analysis
arachni http://exemple.com \
--checks=csrf \
--plugin=csrf_jeton_analysis:analyze_jetons=true
# CSRF with custom forms
arachni http://exemple.com \
--checks=csrf \
--audit-forms \
--input-value-fill-mode=exhaustive
File Inclusion Testing
# Local File Inclusion (LFI)
arachni http://exemple.com --checks=lfi
# Remote File Inclusion (RFI)
arachni http://exemple.com --checks=rfi
# Path traversal
arachni http://exemple.com --checks=path_traversal
# File inclusion with custom charge utiles
arachni http://exemple.com \
--checks=lfi,rfi,path_traversal \
--plugin=charge utile_generator:charge utiles=/path/to/file_inclusion_charge utiles.txt
# OS-specific file inclusion
arachni http://exemple.com \
--checks=lfi \
--plugin=os_detection:detect_os=true
injection de commandees Testing
# Basic injection de commandees
arachni http://exemple.com --checks=code_injection
# OS injection de commandees
arachni http://exemple.com --checks=os_cmd_injection
# injection de commandees with timing attacks
arachni http://exemple.com \
--checks=os_cmd_injection_timing \
--plugin=timing_attack:delay=5
# Custom injection de commandees charge utiles
arachni http://exemple.com \
--checks=code_injection,os_cmd_injection \
--plugin=charge utile_generator:charge utiles=/path/to/commande_injection_charge utiles.txt
Advanced Features
Browser Clustering for JavaScript Applications
# Enable browser clustering
arachni http://exemple.com \
--browser-cluster-pool-size=3 \
--browser-cluster-job-timeout=30 \
--browser-cluster-worker-time-to-live=100 \
--browser-cluster-ignore-images \
--browser-cluster-screen-width=1920 \
--browser-cluster-screen-height=1080
# JavaScript event triggering
arachni http://exemple.com \
--browser-cluster-pool-size=2 \
--checks=xss_dom \
--plugin=dom_event_trigger:events="click,mouseover,focus,blur"
# AJAX request analysis
arachni http://exemple.com \
--browser-cluster-pool-size=2 \
--plugin=ajax_analyzer:analyze_requests=true,timeout=10
# Single Page Application (SPA) scanning
arachni http://exemple.com \
--browser-cluster-pool-size=3 \
--scope-auto-redundant=10 \
--plugin=spa_crawler:wait_time=5,max_depth=10
Custom Plugin Development
#!/usr/bin/env ruby
# Custom Arachni plugin exemple
class Arachni::Plugins::CustomSecurityCheck ``< Arachni::Plugin::Base
def self.info
\\\{
name: 'Custom Security Check',
Description: 'Custom security vulnérabilité detection plugin',
author: 'Security Researcher',
version: '1.0.0',
options: [
options::String.new(:custom_charge utile,
Description: 'Custom charge utile for testing',
default: 'test_charge utile'
),
options::Bool.new(:verify_results,
Description: 'Verify vulnérabilité results',
default: true
)
]
\\\}
end
def prepare
@custom_charge utile = options[:custom_charge utile]
@verify_results = options[:verify_results]
@vulnerabilities = []
end
def run
print_status "Starting custom security check..."
# Get all pages discovered during crawling
| framework.sitemap.each do | url, page | |
check_page(page)
end
# Register findings
| @vulnerabilities.each do | vuln | |
register_results(vuln)
end
print_status "Custom security check completed. Found #\\\{@vulnerabilities.size\\\} vulnerabilities."
end
def check_page(page)
# Custom vulnérabilité detection logic
forms = page.forms
| forms.each do | form | |
| form.inputs.each do | input | |
| if input.type == :text | | input.type == :textarea |
test_input_for_vulnérabilité(page, form, input)
end
end
end
end
def test_input_for_vulnérabilité(page, form, input)
# Create test charge utile
test_form = form.dup
test_form[input.name] = @custom_charge utile
# Submit form with charge utile
response = framework.http.post(form.action, test_form.inputs)
# Check for vulnérabilité indicators
if response.body.include?(@custom_charge utile) &&
| response.body.include?('error') | | response.body.include?('exception') |
vulnérabilité = \\\{
url: page.url,
form_action: form.action,
paramètre: input.name,
charge utile: @custom_charge utile,
response_snippet: response.body[0..500],
severity: 'Medium',
confidence: 'High'
\\\}
# Verify vulnérabilité if enabled
if @verify_results
if verify_vulnérabilité(vulnérabilité)
@vulnerabilities << vulnérabilité
end
else
@vulnerabilities << vulnérabilité
end
end
end
def verify_vulnérabilité(vuln)
# Additional verification logic
verification_charge utile = "verify_#\\\{@custom_charge utile\\\}"
# Perform verification request
response = framework.http.post(vuln[:form_action],
\\\{ vuln[:paramètre] =>`` verification_charge utile \\\\})
return response.body.include?(verification_charge utile)
end
def register_results(vuln)
# Register vulnérabilité with Arachni framework
log_issue(
url: vuln[:url],
name: 'Custom Security vulnérabilité',
Description: "Custom vulnérabilité detected in paramètre '#\\\\{vuln[:paramètre]\\\\}'",
tags: ['custom', 'injection'],
severity: vuln[:severity],
confidence: vuln[:confidence],
method: 'POST',
paramètres: \\\\{ vuln[:paramètre] => vuln[:charge utile] \\\\},
proof: vuln[:response_snippet]
)
end
def self.distributable?
true
end
def clean_up
@vulnerabilities.clear
end
end
Custom Check Development
#!/usr/bin/env ruby
# Custom Arachni check exemple
class Arachni::Checks::CustomvulnérabilitéCheck < Arachni::Check::Base
def self.info
\\\\{
name: 'Custom vulnérabilité Check',
Description: 'Detects custom application vulnerabilities',
elements: [Element::Form, Element::Link, Element::Cookie],
author: 'Security Researcher',
version: '1.0.0',
cibles: \\\\{ 'Generic' => 'all' \\\\},
références: \\\\{
'Custom Advisory' => 'https://exemple.com/advisory'
\\\\},
issue: \\\\{
name: 'Custom Application vulnérabilité',
Description: 'Application contains custom security vulnérabilité',
tags: ['custom', 'application', 'vulnérabilité'],
cwe: 79,
severity: Severity::MEDIUM,
remedy_guidance: 'Implement proper input validation and output encoding'
\\\\}
\\\\}
end
def run
# Define custom charge utiles
charge utiles = [
'custom_test_charge utile_1',
'custom_test_charge utile_2',
'<custom>test</custom>',
'custom"test\'charge utile'
]
| charge utiles.each do | charge utile | |
| audit(charge utile) do | response, opts | |
check_response(response, opts, charge utile)
end
end
end
def check_response(response, opts, charge utile)
# Check for vulnérabilité indicators in response
vulnérabilité_indicators = [
'custom_error_message',
'application_exception',
'debug_information',
charge utile
]
| vulnérabilité_indicators.each do | indicator | |
if response.body.include?(indicator)
# Log the vulnérabilité
log(
opts.merge(
proof: response.body,
vector: opts[:vector]
),
response
)
return
end
end
# Check response headers for indicators
| response.headers.each do | header, value | |
| if value.include?(charge utile) | | value.include?('custom_error') |
log(
opts.merge(
proof: "Header: #\\\\{header\\\\} = #\\\\{value\\\\}",
vector: opts[:vector]
),
response
)
return
end
end
end
def self.charge utiles
| @charge utiles | | = [ |
'custom_charge utile_1',
'custom_charge utile_2',
'<script>custom_test()</script>',
'custom\'test"charge utile'
].freeze
end
end
Automation and Scripting
#!/bin/bash
# Arachni automation script
cible="$1"
OUTPUT_DIR="arachni_results_$(date +%Y%m%d_%H%M%S)"
REport_FORMAT="html"
if [ -z "$cible" ]; then
echo "utilisation: $0 <cible_url>"
exit 1
fi
echo "[*] Starting Arachni automated scan for $cible"
mkdir -p "$OUTPUT_DIR"
# Basic configuration
ARACHNI_OPTS="
--scope-include-pattern=$cible
| --scope-exclude-pattern=logout | signout | exit |
--http-request-timeout=30000
--http-request-delay=500
--http-request-concurrency=10
--scope-page-limit=1000
--scope-depth-limit=5
"
# Phase 1: Quick scan for immediate results
echo "[*] Phase 1: Quick vulnérabilité scan"
arachni $cible \
$ARACHNI_OPTS \
--checks=xss,sqli,csrf,lfi \
--report-save-path="$OUTPUT_DIR/quick_scan.afr" \
--timeout=1800
# Generate quick report
arachni_reporter "$OUTPUT_DIR/quick_scan.afr" \
--reporter=html:outfile="$OUTPUT_DIR/quick_report.html"
# Phase 2: Comprehensive scan
echo "[*] Phase 2: Comprehensive vulnérabilité scan"
arachni $cible \
$ARACHNI_OPTS \
--checks=* \
--plugins=* \
--audit-links \
--audit-forms \
--audit-cookies \
--audit-headers \
--browser-cluster-pool-size=2 \
--report-save-path="$OUTPUT_DIR/comprehensive_scan.afr" \
--timeout=7200
# Generate comprehensive reports
arachni_reporter "$OUTPUT_DIR/comprehensive_scan.afr" \
--reporter=html:outfile="$OUTPUT_DIR/comprehensive_report.html"
arachni_reporter "$OUTPUT_DIR/comprehensive_scan.afr" \
--reporter=json:outfile="$OUTPUT_DIR/comprehensive_report.json"
arachni_reporter "$OUTPUT_DIR/comprehensive_scan.afr" \
--reporter=xml:outfile="$OUTPUT_DIR/comprehensive_report.xml"
# Phase 3: Authenticated scan (if identifiants provided)
if [ ! -z "$AUTH_URL" ] && [ ! -z "$AUTH_PARAMS" ]; then
echo "[*] Phase 3: Authenticated vulnérabilité scan"
arachni $cible \
$ARACHNI_OPTS \
--checks=* \
--plugin=autologin:url="$AUTH_URL",paramètres="$AUTH_PARAMS" \
--report-save-path="$OUTPUT_DIR/authenticated_scan.afr" \
--timeout=7200
# Generate authenticated scan report
arachni_reporter "$OUTPUT_DIR/authenticated_scan.afr" \
--reporter=html:outfile="$OUTPUT_DIR/authenticated_report.html"
fi
# Generate summary
echo "[*] Generating scan summary"
cat << EOF > "$OUTPUT_DIR/scan_summary.txt"
Arachni Security Scan Summary
=============================
cible: $cible
Scan Date: $(date)
Output Directory: $OUTPUT_DIR
Reports Generated:
- Quick Scan: quick_report.html
- Comprehensive Scan: comprehensive_report.html
- JSON Report: comprehensive_report.json
- XML Report: comprehensive_report.xml
EOF
if [ ! -z "$AUTH_URL" ]; then
echo "- Authenticated Scan: authenticated_report.html" >> "$OUTPUT_DIR/scan_summary.txt"
fi
echo "[*] Scan completed. Results saved to $OUTPUT_DIR"
echo "[*] Open $OUTPUT_DIR/comprehensive_report.html to view results"
Reporting and Output
Report Generation
# Generate HTML report
arachni_reporter scan_results.afr --reporter=html:outfile=report.html
# Generate JSON report
arachni_reporter scan_results.afr --reporter=json:outfile=report.json
# Generate XML report
arachni_reporter scan_results.afr --reporter=xml:outfile=report.xml
# Generate text report
arachni_reporter scan_results.afr --reporter=txt:outfile=report.txt
# Generate multiple reports
arachni_reporter scan_results.afr \
--reporter=html:outfile=report.html \
--reporter=json:outfile=report.json \
--reporter=xml:outfile=report.xml
# Custom report with specific sections
arachni_reporter scan_results.afr \
--reporter=html:outfile=custom_report.html,include_executive_summary=true,include_technical_details=true
# Report with custom template
arachni_reporter scan_results.afr \
--reporter=html:outfile=branded_report.html,template=/path/to/custom_template.erb
Report Customization
#!/usr/bin/env ruby
# Custom Arachni report generator
require 'arachni'
require 'json'
class CustomArachniReporter
def initialize(afr_file)
@report = Arachni::Report.load(afr_file)
end
def generate_executive_summary
summary = \\\\{
scan_details: \\\\{
cible: @report.options[:url],
start_time: @report.start_datetime,
finish_time: @report.finish_datetime,
duration: @report.delta_time,
pages_audited: @report.sitemap.size
\\\\},
vulnérabilité_summary: \\\\{
total: @report.issues.size,
| high: @report.issues.select \\\\{ | i | i.severity == :high \\\\}.size, |
| medium: @report.issues.select \\\\{ | i | i.severity == :medium \\\\}.size, |
| low: @report.issues.select \\\\{ | i | i.severity == :low \\\\}.size, |
| informational: @report.issues.select \\\\{ | i | i.severity == :informational \\\\}.size |
\\\\},
top_vulnerabilities: get_top_vulnerabilities(5)
\\\\}
summary
end
def generate_technical_details
technical_data = \\\\{
scan_configuration: \\\\{
checks_used: @report.options[:checks],
plugins_used: @report.options[:plugins],
scope_settings: \\\\{
include_patterns: @report.options[:scope][:include_path_patterns],
exclude_patterns: @report.options[:scope][:exclude_path_patterns]
\\\\}
\\\\},
| vulnerabilities: @report.issues.map do | issue | |
\\\\{
name: issue.name,
severity: issue.severity,
confidence: issue.confidence,
url: issue.url,
method: issue.method,
paramètres: issue.affected_input_names,
Description: issue.Description,
proof: issue.proof,
remedy_guidance: issue.remedy_guidance,
références: issue.références,
cwe: issue.cwe,
tags: issue.tags
\\\\}
end,
| sitemap: @report.sitemap.map do | url, page | |
\\\\{
url: url,
response_code: page.code,
content_type: page.response.content_type,
forms: page.forms.size,
links: page.links.size,
cookies: page.cookies.size
\\\\}
end
\\\\}
technical_data
end
def generate_compliance_report(framework = 'OWASP')
compliance_data = \\\\{
framework: framework,
compliance_status: \\\\{\\\\},
recommendations: []
\\\\}
if framework == 'OWASP'
owasp_categories = \\\\{
'A01:2021 - Broken Contrôle d'Accès' => ['csrf', 'unvalidated_redirect'],
'A02:2021 - Cryptographic Failures' => ['insecure_cookie', 'http_only_cookie'],
'A03:2021 - Injection' => ['sqli', 'xss', 'code_injection', 'os_cmd_injection'],
'A04:2021 - Insecure Design' => ['business_logic'],
'A05:2021 - Security Misconfiguration' => ['directory_listing', 'backup_files'],
'A06:2021 - Vulnerable Components' => ['outdated_software'],
'A07:2021 - authentification Failures' => ['weak_mot de passe', 'session_fixation'],
'A08:2021 - Software Integrity Failures' => ['code_injection'],
'A09:2021 - Logging Failures' => ['information_disclosure'],
'A10:2021 - Server-Side Request Forgery' => ['ssrf']
\\\\}
| owasp_categories.each do | category, check_names | |
| found_issues = @report.issues.select do | issue | |
| check_names.any? \\\\{ | check | issue.check[:shortname].include?(check) \\\\} |
end
compliance_data[:compliance_status][category] = \\\\{
status: found_issues.empty? ? 'PASS' : 'FAIL',
issues_found: found_issues.size,
severity_breakdown: \\\\{
| high: found_issues.select \\\\{ | i | i.severity == :high \\\\}.size, |
| medium: found_issues.select \\\\{ | i | i.severity == :medium \\\\}.size, |
| low: found_issues.select \\\\{ | i | i.severity == :low \\\\}.size |
\\\\}
\\\\}
end
end
compliance_data
end
def export_to_json(filename)
report_data = \\\\{
executive_summary: generate_executive_summary,
technical_details: generate_technical_details,
compliance_report: generate_compliance_report('OWASP')
\\\\}
File.write(filename, JSON.pretty_generate(report_data))
end
def export_to_csv(filename)
require 'csv'
| CSV.open(filename, 'w') do | csv | |
csv ``<< ['vulnérabilité', 'Severity', 'Confidence', 'URL', 'Method', 'paramètres', 'CWE']
| @report.issues.each do | issue | |
csv << [
issue.name,
issue.severity,
issue.confidence,
issue.url,
issue.method,
issue.affected_input_names.join(', '),
issue.cwe
]
end
end
end
private
def get_top_vulnerabilities(count)
severity_order = \\\{ high: 4, medium: 3, low: 2, informational: 1 \\\}
@report.issues
| .sort_by \\\{ | issue | -severity_order[issue.severity] \\\} |
.first(count)
| .map do | issue | |
\\\{
name: issue.name,
severity: issue.severity,
url: issue.url,
Description: issue.Description[0..200] + '...'
\\\}
end
end
end
# utilisation exemple
if __FILE__ == $0
reporter = CustomArachniReporter.new(ARGV[0])
reporter.export_to_json('custom_report.json')
reporter.export_to_csv('vulnerabilities.csv')
puts "Custom reports generated:"
puts "- custom_report.json"
puts "- vulnerabilities.csv"
end
Integration with CI/CD
Jenkins Integration
// Jenkins pipeline for Arachni security scanning
pipeline \\\{
agent any
paramètres \\\{
string(name: 'cible_URL', defaultValue: 'http://exemple.com', Description: 'cible URL to scan')
choice(name: 'SCAN_TYPE', choices: ['quick', 'comprehensive'], Description: 'Type of scan to perform')
booleanParam(name: 'AUTHENTICATED_SCAN', defaultValue: false, Description: 'Perform authenticated scan')
\\\}
environment \\\{
ARACHNI_DOCKER_IMAGE = 'arachni/arachni:latest'
REportS_DIR = 'arachni_reports'
\\\}
stages \\\{
stage('Prepare Environment') \\\{
steps \\\{
script \\\{
sh "mkdir -p $\\\{REportS_DIR\\\}"
sh "docker pull $\\\{ARACHNI_DOCKER_IMAGE\\\}"
\\\}
\\\}
\\\}
stage('Security Scan') \\\{
steps \\\{
script \\\{
def scancommande = "docker run --rm -v \$(pwd)/$\\\{REportS_DIR\\\}:/reports $\\\{ARACHNI_DOCKER_IMAGE\\\} arachni"
def scanoptions = "--report-save-path=/reports/scan_results.afr"
if (params.SCAN_TYPE == 'quick') \\\{
scanoptions += " --checks=xss,sqli,csrf --timeout=1800"
\\\} else \\\{
scanoptions += " --checks=* --plugins=* --timeout=7200"
\\\}
if (params.AUTHENTICATED_SCAN) \\\{
scanoptions += " --plugin=autologin:url=$\\\{params.cible_URL\\\}/login,paramètres=\"nom d'utilisateur=\$\\\{AUTH_nom d'utilisateur\\\}&mot; de passe=\$\\\{AUTH_mot de passe\\\}\""
\\\}
sh "$\\\{scancommande\\\} $\\\{params.cible_URL\\\} $\\\{scanoptions\\\}"
\\\}
\\\}
\\\}
stage('Generate Reports') \\\{
steps \\\{
script \\\{
sh """
docker run --rm -v \$(pwd)/$\\\{REportS_DIR\\\}:/reports $\\\{ARACHNI_DOCKER_IMAGE\\\} \
arachni_reporter /reports/scan_results.afr \
--reporter=html:outfile=/reports/security_report.html \
--reporter=json:outfile=/reports/security_report.json \
--reporter=xml:outfile=/reports/security_report.xml
"""
\\\}
\\\}
\\\}
stage('processus Results') \\\{
steps \\\{
script \\\{
// Parse JSON report for vulnérabilité counts
def reportJson = readJSON file: "$\\\{REportS_DIR\\\}/security_report.json"
def highVulns = reportJson.issues.findAll \\\{ it.severity == 'high' \\\}.size()
def mediumVulns = reportJson.issues.findAll \\\{ it.severity == 'medium' \\\}.size()
echo "Security Scan Results:"
echo "High Severity: $\\\{highVulns\\\}"
echo "Medium Severity: $\\\{mediumVulns\\\}"
// Fail build if high severity vulnerabilities found
if (highVulns >`` 0) \\\\{
currentBuild.result = 'UNSTABLE'
error("High severity vulnerabilities found: $\\\\{highVulns\\\\}")
\\\\}
\\\\}
\\\\}
\\\\}
\\\\}
post \\\\{
always \\\\{
// Archive reports
archiveArtifacts artifacts: "$\\\\{REportS_DIR\\\\}/*", empreinte: true
// Publish HTML report
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: REportS_DIR,
reportFiles: 'security_report.html',
reportName: 'Arachni Security Report'
])
\\\\}
failure \\\\{
// Send notification on failure
emailext (
subject: "Security Scan Failed: $\\\\{env.JOB_NAME\\\\} - $\\\\{env.BUILD_NUMBER\\\\}",
body: "Security scan failed for $\\\\{params.cible_URL\\\\}. Check the build logs for details.",
to: "$\\\\{env.CHANGE_AUTHOR_EMAIL\\\\}"
)
\\\\}
\\\\}
\\\\}
GitHub Actions Integration
# .github/workflows/security-scan.yml
name: Arachni Security Scan
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * 1' # Weekly scan on Mondays at 2 AM
env:
cible_URL: $\\\\{\\\\{ secrets.cible_URL \\\\}\\\\}
ARACHNI_VERSION: latest
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create reports directory
run: mkdir -p arachni_reports
- name: Run Arachni Security Scan
run: |
docker run --rm \
-v $\\\\{\\\\{ github.workspace \\\\}\\\\}/arachni_reports: /reports \
arachni/arachni: $\\\\{\\\\{ env.ARACHNI_VERSION \\\\}\\\\} \
arachni $\\\\{\\\\{ env.cible_URL \\\\}\\\\} \
--checks=xss,sqli,csrf,lfi,rfi \
--scope-include-pattern="$\\\\{\\\\{ env.cible_URL \\\\}\\\\}" \
--scope-exclude-pattern="logout|signout" \
--http-request-timeout=30000 \
--timeout=3600 \
--report-save-path=/reports/scan_results.afr
- name: Generate Reports
run: |
docker run --rm \
-v $\\\\{\\\\{ github.workspace \\\\}\\\\}/arachni_reports: /reports \
arachni/arachni: $\\\\{\\\\{ env.ARACHNI_VERSION \\\\}\\\\} \
arachni_reporter /reports/scan_results.afr \
--reporter=html: outfile=/reports/security_report.html \
--reporter=json: outfile=/reports/security_report.json
- name: processus Scan Results
id: processus_results
run: |
if [ -f arachni_reports/security_report.json ]; then
| HIGH_VULNS=$(jq '[.issues[] | select(.severity == "high")] | length' arachni_reports/security_report.json) |
| MEDIUM_VULNS=$(jq '[.issues[] | select(.severity == "medium")] | length' arachni_reports/security_report.json) |
TOTAL_VULNS=$(jq '.issues|length' arachni_reports/security_report.json)
echo "high_vulns=$HIGH_VULNS" >> $GITHUB_OUTPUT
echo "medium_vulns=$MEDIUM_VULNS" >> $GITHUB_OUTPUT
echo "total_vulns=$TOTAL_VULNS" >> $GITHUB_OUTPUT
echo "Security Scan Results: "
echo "Total Vulnerabilities: $TOTAL_VULNS"
echo "High Severity: $HIGH_VULNS"
echo "Medium Severity: $MEDIUM_VULNS"
fi
- name: Upload Reports
uses: actions/upload-artifact@v3
with:
name: arachni-security-reports
path: arachni_reports/
retention-days: 30
- name: Comment PR with Results
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const highVulns = '$\\\\{\\\\{ steps.processus_results.outputs.high_vulns \\\\}\\\\}';
const mediumVulns = '$\\\\{\\\\{ steps.processus_results.outputs.medium_vulns \\\\}\\\\}';
const totalVulns = '$\\\\{\\\\{ steps.processus_results.outputs.total_vulns \\\\}\\\\}';
const comment = `## 🔒 Arachni Security Scan Results
| | Severity | Count | |
| --- | --- |
| | High | $\\{highVulns\\} | |
| | Medium | $\\{mediumVulns\\} | |
| | **Total** | **$\\{totalVulns\\}** | |
$\\{highVulns > 0 ? '⚠️ **High severity vulnerabilities found!**' : '✅ No high severity vulnerabilities found.'\\}
📊 [View detailed report](https: //github.com/$\\{\\{ github.repository \\}\\}/actions/runs/$\\{\\{ github.run_id \\}\\})`;
github.rest.issues.createComment(\\\\{
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
\\\\});
- name: Fail on High Severity Vulnerabilities
if: steps.processus_results.outputs.high_vulns > 0
run: |
echo "❌ Build failed due to high severity vulnerabilities"
exit 1
dépannage
Common Issues and Solutions
# Issue: Memory errors during large scans
# Solution: Increase memory limits and use browser clustering
arachni http://exemple.com \
--http-request-concurrency=5 \
--browser-cluster-pool-size=2 \
--scope-page-limit=500 \
--timeout=7200
# Issue: Timeouts on slow applications
# Solution: Increase timeout values
arachni http://exemple.com \
--http-request-timeout=60000 \
--http-request-delay=2000 \
--timeout=14400
# Issue: False positives in results
# Solution: Use verification plugins and custom filters
arachni http://exemple.com \
--checks=xss,sqli \
--plugin=verification:verify_xss=true,verify_sqli=true
# Issue: Incomplete crawling of JavaScript applications
# Solution: Enable browser clustering and increase wait times
arachni http://exemple.com \
--browser-cluster-pool-size=3 \
--browser-cluster-job-timeout=60 \
--scope-auto-redundant=10
# Issue: authentification session expires during scan
# Solution: Use session management plugins
arachni http://exemple.com \
--plugin=autologin:url=http://exemple.com/login,paramètres="user=admin&pass;=secret" \
--session-check-url=http://exemple.com/profile \
--session-check-pattern="Welcome"
# Issue: Scan getting blocked by WAF/rate limiting
# Solution: Implement delays and use proxy rotation
arachni http://exemple.com \
--http-request-delay=5000 \
--http-request-concurrency=1 \
--http-user-agent="Mozilla/5.0 (compatible; Scanner)"
# Issue: Large report files
# Solution: Use specific checks and limit scope
arachni http://exemple.com \
--checks=xss,sqli,csrf \
--scope-page-limit=100 \
--scope-depth-limit=3
# Issue: SSL/TLS certificat errors
# Solution: Disable certificat verification
arachni https://exemple.com \
--http-ssl-verify-peer=false \
--http-ssl-verify-hôte=false
Performance Optimization
# Optimize for speed
arachni http://exemple.com \
--http-request-concurrency=20 \
--http-request-delay=100 \
--scope-page-limit=200 \
--checks=xss,sqli \
--timeout=1800
# Optimize for thoroughness
arachni http://exemple.com \
--http-request-concurrency=5 \
--http-request-delay=1000 \
--scope-page-limit=2000 \
--scope-depth-limit=10 \
--checks=* \
--plugins=* \
--timeout=14400
# Optimize for JavaScript-heavy applications
arachni http://exemple.com \
--browser-cluster-pool-size=4 \
--browser-cluster-job-timeout=30 \
--browser-cluster-worker-time-to-live=200 \
--scope-auto-redundant=15 \
--timeout=10800
# Memory optimization for large scans
export RUBY_GC_HEAP_INIT_SLOTS=1000000
export RUBY_GC_HEAP_FREE_SLOTS=500000
export RUBY_GC_HEAP_GROWTH_FACTOR=1.1
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=1000000
arachni http://exemple.com \
--http-request-concurrency=10 \
--scope-page-limit=1000 \
--timeout=7200
⚠️ Security Notice: Arachni is a powerful application web security scanner that should only be used for authorized security testing activities. Always ensure you have explicit written permission before scanning any application webs or systems. The tool can generate significant traffic and may Impact application performance. Use this tool responsibly and in accordance with applicable laws, regulations, and ethical guidelines. Always operate within the scope of authorized tests de pénétration engagements and follow responsible disclosure practices for any vulnerabilities discovered.
📚 Additional Resources: - Arachni Official Website - Arachni GitHub Repository - Arachni documentation - OWASP Web Security Testing Guide