Skip to main content

A Python library for basic and mostly passive security scanning like DNS and e-mail

Project description

BasicSec

A Python library and CLI tool for basic and mostly passive security scanning like DNS and e-mail.

Features

  • DNS Security Checks: MX records, SPF, DMARC, DNSSEC validation
  • Passive Scanning: DNS-only checks that don't connect to target servers
  • Active Scanning: Includes SMTP connection testing and STARTTLS validation
  • Batch Processing: Scan multiple domains efficiently
  • CLI Tool: Easy-to-use command line interface
  • Library API: Integrate security checks into your Python applications

Installation

pip install basicsec

Quick Start

Command Line Usage

# Passive scan of a single domain
basicsec example.com

# Active scan with SMTP tests
basicsec example.com --active

# Scan multiple domains
basicsec example.com google.com --multiple

# Quick checks only
basicsec example.com --quick --checks live mx spf

# JSON output
basicsec example.com --json

Python Library Usage

from basicsec import EmailSecurityScanner

# Initialize scanner
scanner = EmailSecurityScanner()

# Passive scan
result = scanner.passive_scan("example.com")
print(f"SPF Valid: {result['spf_valid']}")
print(f"DMARC Valid: {result['dmarc_valid']}")
print(f"DNSSEC Enabled: {result['dnssec_enabled']}")

# Active scan (includes SMTP tests)
result = scanner.active_scan("example.com")
print(f"SMTP Connection: {result['has_smtp_connection']}")
print(f"STARTTLS Support: {result['supports_starttls']}")

# Quick batch check
result = scanner.quick_domain_check(
    ["example.com", "google.com"],
    check_types=["live", "mx", "spf", "dmarc"]
)

Security Checks

DNS Records

  • MX Records: Mail exchange server configuration
  • SPF Records: Sender Policy Framework validation
  • DMARC Records: Domain-based Message Authentication validation
  • DNSSEC: DNS Security Extensions status and validation

SMTP Tests (Active Mode)

  • Connection Testing: Verify SMTP server connectivity
  • STARTTLS Support: Check for encrypted connection capability
  • Multiple Ports: Test common SMTP ports (25, 465, 587)

CLI Options

usage: basicsec [-h] [--active | --passive | --quick] [--multiple]
                [--checks {live,mx,spf,dmarc,dnssec} [{live,mx,spf,dmarc,dnssec} ...]]
                [--json] [--timeout TIMEOUT] [--verbose]
                domains [domains ...]

positional arguments:
  domains               Domain(s) to scan

optional arguments:
  --active              Perform active scan (includes SMTP tests)
  --passive             Perform passive scan (DNS only, default)
  --quick               Quick check mode (fastest)
  --multiple            Scan multiple domains
  --checks              Types of quick checks to perform
  --json                Output results in JSON format
  --timeout TIMEOUT     DNS timeout in seconds (default: 5.0)
  --verbose, -v         Enable verbose logging

Exit Codes

The CLI returns exit codes based on security issues found:

  • 0: No issues detected
  • 1-3: Number of security issues found (SPF, DMARC, DNSSEC)

Requirements

  • Python 3.8+
  • dnspython>=2.3.0
  • email-validator>=2.0.0

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
flake8 basicsec/
black basicsec/

# Type checking
mypy basicsec/

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

Security Considerations

This tool is designed for defensive security analysis only. It performs:

  • Passive DNS lookups
  • Standard protocol connections (SMTP)
  • Public record validation

It does not perform:

  • Vulnerability exploitation
  • Unauthorized access attempts
  • Aggressive scanning techniques

Always ensure you have permission to scan the target domains.

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

basicsec-1.1.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basicsec-1.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file basicsec-1.1.0.tar.gz.

File metadata

  • Download URL: basicsec-1.1.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for basicsec-1.1.0.tar.gz
Algorithm Hash digest
SHA256 edc0f55db1cc47a41443f375efe0688bd5542b3627c6001f9355b2f3ded2c7d1
MD5 5569f4d136db9d9e7af415c0633e09da
BLAKE2b-256 e7fd02199287e570e8face755ded9ba375dfd3fa386d29e61d4211e1ce86819a

See more details on using hashes here.

File details

Details for the file basicsec-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: basicsec-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for basicsec-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7003532597ebbbd85c63e84d67a1dacc8a74ac57aeec8baf0bc258d008137dd8
MD5 8280f74f630e36e07f22c43dd30cc03d
BLAKE2b-256 2b49ed64562edf69eda6436ead9a4aed6e238e1db1a165485c6e05f6fd39037d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page