How g0ldencybersec/cloudrecon works
Project Type and Purpose
• CloudRecon is a command-line suite of Go utilities (scrape, store, retr) designed for red-teamers and bug hunters. It scans IP addresses or CIDRs, performs TLS handshakes to retrieve SSL certificate metadata (CN, SAN, Org), optionally stores results in a local SQLite database, and enables keyword searches against the stored data.
File Structure Analysis
• Top-level files:
• main.go: CLI entry point, command dispatch (scrape, store, retr).
• scrape.go: Implements live scanning and JSON output.
• store.go: Similar to scrape, but writes metadata into a local DB.
• retr.go: Queries the local DB based on search flags.
• util.go: Common helpers (parsing IP lists, managing timeouts, goroutine pools).
• go.mod / go.sum: Go module definitions.
• README.md, LICENSE, .gitignore: Documentation & project metadata.
README Insights
• Three subcommands with distinct responsibilities.
• Dependencies: Go (with CGO enabled), SQLite3 (via cgo and gcc).
• Concurrency via configurable goroutine pools.
• Input sources: file or inline IP/CIDR lists.
• Output: JSON to stdout or queries to SQLite DB file.
a. Main Components
1. CLI Layer (main.go)
2. Subcommand Executors (Scrape, Store, Retr)
3. Input Parser (utils.go)
4. Certificate Fetcher (TLS handshake module)
5. Data Parser/Serializer (JSON marshaller, DB mapper)
6. Storage Layer (SQLite database via database/sql + sqlite3 driver)
7. Output Layer (stdout JSON or CLI table)
b. Relationships & Data Flow
• User issues “cloudrecon <cmd> -options → CLI Layer → invokes specific Executor.
• Executor loads Input Parser → generates work queue of IP:port tasks.
• Certificate Fetcher picks tasks concurrently → performs TLS handshake → returns raw cert data.
• Data Parser extracts CN, SAN, Org →
• Scrape: serializes to JSON → Output Layer → stdout / file
• Store: maps records to DB schema → Storage Layer (SQLite)
• Retr: Query Storage Layer → Data Parser formats results → Output Layer.
c. Architectural Patterns & Design Principles
• Modular subcommands following the “single responsibility” principle.
• Concurrent worker pool (goroutines + channels) for high-throughput I/O.
• Layered architecture: CLI → Executor → Fetcher → Parser → Storage/Output.
• Dependency injection for testability (passing interfaces for DB, network, parser).
d. Key Technologies & Frameworks
• Language: Go modules
• Concurrency: Goroutines & channels
• TLS: crypto/tls package
• Database: database/sql + mattn/go-sqlite3 (cgo)
• JSON: encoding/json
Detailed Architectural Capture
• Configurable parameters (goroutine count, timeout, ports) near the Worker Pool.
• External artifacts: IPv4 range file input, TLS endpoints on port 443 (or custom).
• Wherever possible, annotate the Go packages in use (e.g., “crypto/tls”, “database/sql”).