# moond4rk/hackbrowserdata architecture

> Architecture diagram of the GitHub repository moond4rk/hackbrowserdata, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moond4rk/hackbrowserdata
- Repository: https://github.com/moond4rk/hackbrowserdata

## Overview

##### Project’s Nature and Purpose
- HackBrowserData is a command-line tool for decrypting and exporting sensitive browser data (e.g., passwords, cookies, history, bookmarks, credit cards, downloads, localStorage, and extensions) across multiple popular browsers on Windows, macOS, and Linux.
- It is designed for security research, so while it includes decryption and extraction logic, its architecture must clearly show the various processing and platform-specific adaptations it employs.

##### File Structure to Identify Main Components
- cmd Folder: Contains the main executable (hack-browser-data) that serves as the entry point. This is the CLI component that orchestrates the overall operations.
- browser Folder: Contains code for dealing with browser-specific logic. Notice that there are separate files for different operating systems (e.g., browser.go, browser_darwin.go, etc.) and submodules (e.g., chromium, firefox), highlighting platform-specific implementations.
- browserdata Folder: Houses modules dedicated to extracting different types of browser data (bookmarks, cookies, credit cards, downloads, extensions, history, localStorage, sessionStorage, and passwords). This layer is central to the data extraction process.
- crypto Folder: Contains cryptographic routines for decryption, including platform-specific implementations. This layer is invoked during the decryption process of secured browser information.
- extractor Folder: Likely coordinates high-level registration of various extraction routines and feeds into the overall processing flow.
- log, types, and utils Folders: Provide support functionality such as logging, type definitions, and utility functions (e.g., file and byte handling) that enhance the robustness and maintainability of the system.

##### Relationships and Interactions Between Components
- Command-Line Interface (CLI) Component: Initiates the process based on user input (e.g., parameters such as browser type, output format, and profile path).
- Data Orchestration Layer: The CLI calls into the extractor module, which then coordinates tasks like detecting the appropriate browser, selecting the correct extraction method (from the browser or browserdata modules), and managing OS-specific code paths.
- Browser Integration & Data Extraction: The code in the browser and browserdata directories work together. The browser modules abstract browser specifics and delegate tasks to corresponding browserdata modules. For example, the chromium or firefox submodules in “browser” are closely linked to extraction routines in “browserdata.”
- Cryptography Module: As sensitive data is typically encrypted, the crypto module is invoked to decrypt data pulled from browser profiles. Its OS-specific implementations (crypto_darwin.go, crypto_linux.go, crypto_windows.go) ensure compatibility across platforms.
- Logging & Utility Services: The log module captures activities and errors, while the utils modules (fileutil, byteutil, typeutil) provide supportive functionalities used across the main components.
- CI/CD & Build Configuration: Although not part of the runtime architecture, note that there are GitHub workflows, goreleaser configuration, and other build scripts. You may choose to represent an “Infrastructure/Automation” component that illustrates how continuous integration, testing, and release processes are automated. This is useful for complete architectural understanding even if it’s not involved in data extraction per se.

##### Important Architectural Patterns and Technologies
- Modularity & Separation of Concerns: The clear separation between input handling (CLI in cmd), browser-specific logic, extraction routines, and cryptographic operations follows a modular design that enhances maintainability.
- Cross-Platform Strategy: The use of OS-specific files/modules (e.g., browser_* and crypto_*) illustrates conditional compilation and platform abstraction, a vital design principle for a cross-platform tool.
- Utility and support layers: Logging, type abstraction, and utility functions support the primary modules and ensure consistent execution and error management.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Subgraphs

    subgraph "Command-Line Layer"
        CLI["Command-Line Interface (CLI)"]:::cli
    end

    subgraph "Orchestration Layer"
        Extr["Extraction Coordinator"]:::coordinator
        Reg["Registration Module"]:::coordinator
    end

    subgraph "Browser Integration Layer"
        BI["Browser Integration"]:::browser
        BI_Darwin["OS-specific (Darwin)"]:::platform
        BI_Linux["OS-specific (Linux)"]:::platform
        BI_Windows["OS-specific (Windows)"]:::platform
        BI_Chromium["Chromium Module"]:::browser
        BI_Firefox["Firefox Module"]:::browser
    end

    subgraph "Data Extraction Modules"
        DE["Data Extraction Modules"]:::extraction
        DE_Bookmarks["Bookmarks"]:::extraction
        DE_Cookies["Cookies"]:::extraction
        DE_CreditCards["Credit Cards"]:::extraction
        DE_Downloads["Downloads"]:::extraction
        DE_Extensions["Extensions"]:::extraction
        DE_History["History"]:::extraction
        DE_LocalStorage["LocalStorage"]:::extraction
        DE_SessionStorage["SessionStorage"]:::extraction
        DE_Passwords["Passwords"]:::extraction
    end

    subgraph "Cryptography Layer"
        Crypto["Cryptography Module"]:::crypto
        Crypto_Darwin["Crypto (Darwin)"]:::platform
        Crypto_Linux["Crypto (Linux)"]:::platform
        Crypto_Windows["Crypto (Windows)"]:::platform
        Crypto_ASN1["ASN1 PBE"]:::crypto
        Crypto_PBKDF2["PBKDF2"]:::crypto
    end

    subgraph "Support Services"
        Log["Logging Services"]:::logging
        Logger["Logger"]:::logging
        LogLevels["Log Levels"]:::logging
        Utils["Utilities"]:::utils
        Types["Type Definitions"]:::utils
    end

    subgraph "CI/CD Pipeline"
        CICD["CI/CD Pipeline & Build Configuration"]:::cicd
    end

    %% Connections

    %% CLI initiates extraction
    CLI -->|"initiates"| Extr
    Extr -->|"handles registration"| Reg

    %% Extraction Coordinator links to core modules
    Extr -->|"coordinates"| BI
    Extr -->|"coordinates"| DE

    %% Browser Integration internal connections
    BI -->|"delegates to"| BI_Darwin
    BI -->|"delegates to"| BI_Linux
    BI -->|"delegates to"| BI_Windows
    BI -->|"includes"| BI_Chromium
    BI -->|"includes"| BI_Firefox

    %% Data Extraction internal breakdown
    DE -->|"extracts"| DE_Bookmarks
    DE -->|"extracts"| DE_Cookies
    DE -->|"extracts"| DE_CreditCards
    DE -->|"extracts"| DE_Downloads
    DE -->|"extracts"| DE_Extensions
    DE -->|"extracts"| DE_History
    DE -->|"extracts"| DE_LocalStorage
    DE -->|"extracts"| DE_SessionStorage
    DE -->|"extracts"| DE_Passwords

    %% Both Browser Integration and Data Extraction call Cryptography
    BI -->|"decrypts"| Crypto
    DE -->|"decrypts"| Crypto

    %% Cryptography module internal details
    Crypto -->|"OS-specific"| Crypto_Darwin
    Crypto -->|"OS-specific"| Crypto_Linux
    Crypto -->|"OS-specific"| Crypto_Windows
    Crypto -->|"provides"| Crypto_ASN1
    Crypto -->|"provides"| Crypto_PBKDF2

    %% Logging: All major components log their activities
    Extr -->|"logs"| Log
    BI -->|"logs"| Log
    DE -->|"logs"| Log
    Crypto -->|"logs"| Log

    Log --> Logger
    Log --> LogLevels

    %% Support Utilities connections (dotted style)
    CLI --- Utils
    Extr --- Utils
    BI --- Utils
    DE --- Utils
    Crypto --- Utils
    Log --- Utils

    CLI --- Types
    Extr --- Types
    BI --- Types
    DE --- Types
    Crypto --- Types
    Log --- Types

    %% CI/CD Pipeline triggers automation for key modules
    CICD -->|"automates"| CLI
    CICD -->|"automates"| Extr

    %% Styling classes
    classDef cli fill:#f7d6a0,stroke:#333,stroke-width:2px;
    classDef coordinator fill:#a0d6f7,stroke:#333,stroke-width:2px;
    classDef browser fill:#d6a0f7,stroke:#333,stroke-width:2px;
    classDef extraction fill:#a0f7d6,stroke:#333,stroke-width:2px;
    classDef crypto fill:#f7a0a0,stroke:#333,stroke-width:2px;
    classDef logging fill:#f7f7a0,stroke:#333,stroke-width:2px;
    classDef utils fill:#a0f7f7,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d6f7a0,stroke:#333,stroke-width:2px;
    classDef platform fill:#e0e0e0,stroke:#333,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/moond4rk/hackbrowserdata/blob/main/cmd/hack-browser-data/main.go"
    click BI "https://github.com/moond4rk/hackbrowserdata/blob/main/browser/browser.go"
    click BI_Darwin "https://github.com/moond4rk/hackbrowserdata/blob/main/browser/browser_darwin.go"
    click BI_Linux "https://github.com/moond4rk/hackbrowserdata/blob/main/browser/browser_linux.go"
    click BI_Windows "https://github.com/moond4rk/hackbrowserdata/blob/main/browser/browser_windows.go"
    click BI_Chromium "https://github.com/moond4rk/hackbrowserdata/tree/main/browser/chromium/"
    click BI_Firefox "https://github.com/moond4rk/hackbrowserdata/blob/main/browser/firefox/firefox.go"
    click DE "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/browserdata.go"
    click DE_Bookmarks "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/bookmark/bookmark.go"
    click DE_Cookies "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/cookie/cookie.go"
    click DE_CreditCards "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/creditcard/creditcard.go"
    click DE_Downloads "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/download/download.go"
    click DE_Extensions "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/extension/extension.go"
    click DE_History "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/history/history.go"
    click DE_LocalStorage "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/localstorage/localstorage.go"
    click DE_SessionStorage "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/sessionstorage/sessionstorage.go"
    click DE_Passwords "https://github.com/moond4rk/hackbrowserdata/blob/main/browserdata/password/password.go"
    click Crypto "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/crypto.go"
    click Crypto_Darwin "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/crypto_darwin.go"
    click Crypto_Linux "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/crypto_linux.go"
    click Crypto_Windows "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/crypto_windows.go"
    click Crypto_ASN1 "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/asn1pbe.go"
    click Crypto_PBKDF2 "https://github.com/moond4rk/hackbrowserdata/blob/main/crypto/pbkdf2.go"
    click Extr "https://github.com/moond4rk/hackbrowserdata/blob/main/extractor/extractor.go"
    click Reg "https://github.com/moond4rk/hackbrowserdata/blob/main/extractor/registration.go"
    click Log "https://github.com/moond4rk/hackbrowserdata/blob/main/log/log.go"
    click Logger "https://github.com/moond4rk/hackbrowserdata/blob/main/log/logger.go"
    click LogLevels "https://github.com/moond4rk/hackbrowserdata/blob/main/log/level/level.go"
    click Utils "https://github.com/moond4rk/hackbrowserdata/tree/main/utils/"
    click Types "https://github.com/moond4rk/hackbrowserdata/blob/main/types/types.go"
    click CICD "https://github.com/moond4rk/hackbrowserdata/tree/main/.github/"
```
