Skip to content

Security: sivaadityacoder/osint_tracking

Security

docs/SECURITY.md

OSINT Master Tool - Security Considerations

Overview

This document outlines important security considerations when using the OSINT Master Tool. OSINT (Open Source Intelligence) gathering must be conducted ethically and legally.

Legal Compliance

⚠️ Important Legal Notice

Always ensure you have proper authorization before investigating any targets.

  • Personal Data: Only investigate data you own or have explicit permission to analyze
  • Jurisdictional Laws: Comply with local, state, and federal privacy laws
  • Terms of Service: Respect the terms of service of all platforms and APIs used
  • Professional Use: Follow your organization's policies and ethical guidelines

Recommended Use Cases

Authorized Activities:

  • Investigating your own digital footprint
  • Security assessments with written authorization
  • Threat intelligence for your organization
  • Academic research with proper approvals
  • Bug bounty programs within scope

Prohibited Activities:

  • Stalking or harassment
  • Unauthorized personal investigations
  • Corporate espionage
  • Identity theft or fraud
  • Violating privacy laws (GDPR, CCPA, etc.)

Data Protection

API Key Security

# ✅ Good: Use environment variables
export HIBP_API_KEY="your_secure_key"

# ❌ Bad: Never hardcode keys in source code
HIBP_API_KEY = "abc123def456"  # Never do this!

Secure Configuration

  1. Environment Variables: Store all sensitive data in environment variables
  2. File Permissions: Restrict access to configuration files
  3. Key Rotation: Regularly rotate API keys
  4. Access Logging: Monitor API key usage
# Secure .env file permissions
chmod 600 .env

# Verify permissions
ls -la .env
# Should show: -rw------- 1 user user .env

Data Handling

# ✅ Good: Sanitize sensitive data in logs
logger.info(f"Investigating email: {email[:3]}***@{email.split('@')[1]}")

# ❌ Bad: Logging sensitive data
logger.info(f"API key: {api_key}")  # Never log API keys!

Network Security

HTTPS Requirements

All API communications must use HTTPS:

# ✅ Good: Always use HTTPS
async with session.get("https://api.service.com/data") as resp:
    # Handle response

# ❌ Bad: Never use HTTP for sensitive data
async with session.get("http://api.service.com/data") as resp:  # Insecure!
    # Handle response

Certificate Verification

# Default behavior includes certificate verification
connector = aiohttp.TCPConnector(ssl=True)  # ✅ Good
session = aiohttp.ClientSession(connector=connector)

# Never disable SSL verification in production
connector = aiohttp.TCPConnector(ssl=False)  # ❌ Dangerous!

Rate Limiting and Responsible Usage

API Rate Limits

Respect API rate limits to avoid service disruption:

class ResponsiblePlugin(PluginBase):
    def __init__(self):
        self.rate_limiter = asyncio.Semaphore(5)  # Max 5 concurrent requests
        self.last_request = 0
        self.min_interval = 1.0  # 1 second between requests
    
    async def run(self, query, session):
        async with self.rate_limiter:
            # Implement delay between requests
            now = time.time()
            elapsed = now - self.last_request
            if elapsed < self.min_interval:
                await asyncio.sleep(self.min_interval - elapsed)
            
            self.last_request = time.time()
            # Make API request...

Ethical Considerations

  • Minimize Requests: Cache results when possible
  • Respect Robots.txt: Honor website crawling restrictions
  • User Agent: Use descriptive, honest user agent strings
  • Error Handling: Gracefully handle rate limit responses
# ✅ Good: Honest user agent
headers = {
    "User-Agent": "OSINT-Master-Tool/1.0 (Security Research)"
}

# ❌ Bad: Deceptive user agent
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"  # Misleading
}

Input Validation

Sanitize User Input

Always validate and sanitize input data:

import re
from urllib.parse import urlparse

def validate_email(email: str) -> bool:
    """Validate email format"""
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(pattern, email) is not None

def validate_domain(domain: str) -> bool:
    """Validate domain format"""
    try:
        # Remove protocol if present
        if '://' in domain:
            domain = urlparse(domain).netloc
        
        # Basic domain validation
        pattern = r'^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
        return re.match(pattern, domain) is not None
    except:
        return False

def validate_ip(ip: str) -> bool:
    """Validate IP address format"""
    try:
        import ipaddress
        ipaddress.ip_address(ip)
        return True
    except ValueError:
        return False

Prevent Injection Attacks

# ✅ Good: Parameterized queries
query = "SELECT * FROM results WHERE email = ?"
cursor.execute(query, (email,))

# ❌ Bad: String concatenation
query = f"SELECT * FROM results WHERE email = '{email}'"  # SQL injection risk!

Audit and Logging

Security Logging

Implement comprehensive security logging:

import logging
from datetime import datetime

def setup_security_logger():
    """Setup security-focused logger"""
    security_logger = logging.getLogger("osint_security")
    handler = logging.FileHandler("security.log")
    formatter = logging.Formatter(
        "[%(asctime)s] SECURITY - %(levelname)s - %(message)s"
    )
    handler.setFormatter(formatter)
    security_logger.addHandler(handler)
    security_logger.setLevel(logging.INFO)
    return security_logger

# Log security events
security_logger = setup_security_logger()

def log_investigation(target_type: str, target_value: str, success: bool):
    """Log investigation attempts"""
    # Sanitize the target value for logging
    if target_type == "email":
        sanitized = f"{target_value[:3]}***@{target_value.split('@')[1]}"
    else:
        sanitized = target_value
    
    security_logger.info(
        f"Investigation - Type: {target_type}, Target: {sanitized}, "
        f"Success: {success}, Timestamp: {datetime.utcnow().isoformat()}"
    )

Audit Trail

Maintain detailed audit trails:

{
  "investigation_id": "uuid-here",
  "timestamp": "2025-07-30T10:30:00.000Z",
  "user_agent": "OSINT-Master-Tool/1.0",
  "source_ip": "192.168.1.100",
  "target_type": "email",
  "target_value": "***@example.com",
  "plugins_used": ["email", "username"],
  "api_calls_made": 5,
  "success": true,
  "execution_time": 2.34
}

Data Retention

Minimize Data Storage

class SecureAuditLogger:
    def __init__(self, retention_days=30):
        self.retention_days = retention_days
    
    def log_investigation(self, data):
        # Store only necessary data
        audit_data = {
            "timestamp": data["timestamp"],
            "target_type": data["target_type"],
            "target_hash": hashlib.sha256(data["target_value"].encode()).hexdigest(),
            "success": data["success"],
            "plugins_used": data["plugins_used"]
        }
        # Store audit_data...
    
    def cleanup_old_logs(self):
        """Remove logs older than retention period"""
        cutoff_date = datetime.utcnow() - timedelta(days=self.retention_days)
        # Remove old entries...

Deployment Security

Production Checklist

  • All API keys stored in environment variables
  • HTTPS enforced for all communications
  • SSL certificate verification enabled
  • Rate limiting implemented
  • Input validation active
  • Audit logging configured
  • Error messages don't expose sensitive information
  • File permissions properly set
  • Regular security updates applied

Docker Security

# Use non-root user
FROM python:3.9-slim
RUN useradd --create-home --shell /bin/bash osint
USER osint

# Set secure file permissions
COPY --chown=osint:osint . /app
WORKDIR /app

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Run with minimal privileges
CMD ["python", "main.py"]

Incident Response

Security Incident Procedures

  1. Immediate Response

    • Disable compromised API keys
    • Review audit logs for unauthorized access
    • Document the incident
  2. Investigation

    • Analyze log files for suspicious activity
    • Check for data exfiltration
    • Identify root cause
  3. Recovery

    • Rotate all API keys
    • Update security measures
    • Implement additional monitoring
  4. Prevention

    • Review and update security policies
    • Provide additional security training
    • Implement lessons learned

Compliance Requirements

GDPR Compliance

  • Data Minimization: Collect only necessary data
  • Purpose Limitation: Use data only for stated purposes
  • Consent: Ensure proper consent for data processing
  • Right to Erasure: Implement data deletion capabilities
  • Data Protection by Design: Build privacy into the system

Industry Standards

  • NIST Cybersecurity Framework: Follow security best practices
  • OWASP Guidelines: Implement secure coding practices
  • ISO 27001: Align with information security standards

Reporting Security Issues

If you discover a security vulnerability:

  1. Do NOT create a public issue
  2. Send details to: security@example.com
  3. Include:
    • Description of the vulnerability
    • Steps to reproduce
    • Potential impact
    • Suggested fix (if known)

We will acknowledge receipt within 24 hours and provide a timeline for resolution.


Remember: With great power comes great responsibility. Use OSINT tools ethically and legally. 🔐

There aren’t any published security advisories