Lumen Documentation

repository·master·Indexed 22 days ago

https://github.com/naim94a/lumen

Lumen is a private Lumina server designed for IDA Pro (7.2+), allowing teams to store and share function signatures privately using a PostgreSQL database. It supports Docker deployment, Rust-based builds, and custom TLS configuration via hexrays.crt for IDA Pro communication. The server includes features for pulling and pushing function metadata, managing function histories, and an optional API web server.

Tokens
7.6K
Snippets
36
Records
40
Agent score
78%

What's inside Lumen

  1. Install Lumen using Docker (Recommended)

    master

    The recommended way to run Lumen is via Docker Compose. This method uses precompiled images and handles the database setup automatically.

    1. Ensure docker-engine and docker-compose are installed.
    2. Custom TLS (Optional): If using a custom TLS certificate, copy your .p12 or .pfx private key to the ./dockershare directory. Set the password for this key in your .env file using the PKCSPASSWD variable.
    3. Custom Configuration (Optional): If you have a custom Lumen configuration, copy it to ./dockershare/config.toml.
    4. Run the stack:
      docker-compose up
    5. Note on TLS: If TLS is enabled in your config.toml, a hexrays.crt file will be generated in ./dockershare. You must copy this file to your IDA Pro installation directory to enable communication.
    docker-compose up
  2. Generate and configure TLS certificates for Lumen and IDA

    master

    Because IDA Pro uses a pinned certificate for Lumina communication, you cannot use standard root CA certificates. Instead, you must provide a specific certificate file named hexrays.crt in the IDA installation directory.

    Follow these steps to generate the necessary files:

    1. Create a self-signed certificate and key:
      openssl req -x509 -newkey rsa:4096 -keyout lumen_key.pem -out lumen_crt.pem -days 365 -nodes
    2. Convert to PKCS12 for Lumen: Lumen requires a .p12 or .pfx file for its lumen.tls configuration.
      openssl pkcs12 -export -out lumen.p12 -inkey lumen_key.pem -in lumen_crt.pem
    3. Export public key for IDA: Convert the certificate to a DER-encoded format and name it hexrays.crt. Copy this file to your IDA installation folder.
      openssl x509 -in lumen_crt.pem -out hexrays.crt
    # 1. Create certificate
    openssl req -x509 -newkey rsa:4096 -keyout lumen_key.pem -out lumen_crt.pem -days 365 -nodes
    
    # 2. Convert to pkcs12 for lumen
    openssl pkcs12 -export -out lumen.p12 -inkey lumen_key.pem -in lumen_crt.pem
    
    # 3. Export public-key for IDA
    openssl x509 -in lumen_crt.pem -out hexrays.crt
  3. Configure IDA Pro >= 8.1 to use Lumen

    master

    For IDA Pro version 8.1 and above, follow these steps:

    1. Cleanup: If you previously used Lumina, remove any existing LUMINA settings from your ida.cfg or idauser.cfg files to avoid configuration warnings.
    2. Environment Setup:
      • Linux: Create a wrapper script (e.g., ida_lumen.sh) to disable TLS if not using it:
        #!/bin/sh
        export LUMINA_TLS=false
        $1
        Run it via: ./ida_lumen.sh ./ida.
      • Windows: Create a batch file (e.g., ida_lumen.bat):
        set LUMINA_TLS=false
        %1
        Run it via: ./ida_lumen.bat ida.exe.
    3. IDA UI Configuration:
      • Open IDA Pro.
      • Navigate to Options > General > Lumina.
      • Select "Use a private server".
      • Set the host and port to your Lumen server address.
      • Use guest as both the username and password.
    # Linux wrapper example
    #!/bin/sh
    export LUMINA_TLS=false
    $1
  4. Build Lumen from source with Rust

    master

    To build Lumen manually, you need a Rust toolchain and a PostgreSQL database.

    1. Clone the repository:
      git clone https://github.com/naim94a/lumen.git
      cd lumen
    2. Install the Rust toolchain from https://rustup.rs/.
    3. Database Setup:
      • Install PostgreSQL.
      • Install diesel-cli with the postgres feature:
        cargo install diesel_cli --no-default-features -Fpostgres
      • Run migrations using the provided configuration:
        diesel --config-file common/diesel.toml \
           --database-url postgres://postgres:password@localhost/lumen \
           migration run
    4. Build the release binary:
      cargo build --release
    # Run migrations
    diesel --config-file common/diesel.toml --database-url postgres://postgres:password@localhost/lumen migration run
    
    # Build
    cargo build --release
  5. Run Lumen using Docker Compose

    master

    You can deploy the Lumen stack using Docker Compose. The setup includes a PostgreSQL database service (db) and the Lumen application service (lumina). The lumina service depends on the db service being healthy before it starts.

    To run the stack, ensure you have a .env file or environment variable set for PKCSPASSWD (used for PKCS#12 certificate passwords) and execute:

    docker-compose up
  6. Configure Lumen environment variables

    master

    When running via Docker Compose, the lumina service uses the following environment variables:

    • PKCSPASSWD: The password for the PKCS#12 certificate. This should be passed from your host environment.
    • DATABASE_URL: The connection string for the PostgreSQL database. The default is postgres://lumina:1@db/lumina.

    The database service (db) uses these credentials:

    • POSTGRES_USER: lumina
    • POSTGRES_DB: lumina
    • POSTGRES_PASSWORD: 1
  7. Configure server timeouts and limits

    master

    The limits section controls various timeout durations for the server. If not provided, the following default values are used:

    • command_timeout: Maximum time to wait on an idle connection between commands (Default: 3600s).
    • pull_md_timeout: Maximum time allowed for all PULL_MD queries (Default: 240s).
    • hello_timeout: Maximum time to wait for a HELO message (Default: 15s).
    • tls_handshake_timeout: Maximum time allowed until the TLS handshake completes (Default: 10s).
    limits = {
      command_timeout = 60,
      pull_md_timeout = 120,
      hello_timeout = 5,
      tls_handshake_timeout = 5
    }
  8. Configure the Database connection

    master

    The database section defines how the server connects to its data store. It requires connection information and TLS settings for the database connection itself.

    Key fields:

    • connection_info: A string containing the connection details.
    • use_tls: Boolean indicating if TLS should be used for the database connection.
    • server_ca: (Optional) Path to the server's CA certificate.
    • client_id: (Optional) Path to the client identity/certificate.
    database = {
      connection_info = "host=localhost user=lumen dbname=lumen",
      use_tls = true,
      server_ca = "/path/to/ca.crt"
    }
  9. Configure the Lumina server settings

    master

    The lumina section of the configuration defines the core server behavior. You can specify the binding address, enable TLS, and control feature limits like function history retrieval.

    Key fields:

    • bind_addr: The SocketAddr the server listens on.
    • use_tls: (Optional) Boolean to enable/disable TLS.
    • tls: (Optional) A TlsIdentity object containing the server_cert path.
    • server_name: (Optional) The server name.
    • allow_deletes: (Optional) Boolean to allow delete operations.
    • get_history_limit: (Optional) Limits the number of function histories returned per function. Setting this to None or Some(0) disables the feature.
    lumina = {
      bind_addr = "0.0.0.0:8080",
      use_tls = true,
      tls = { server_cert = "/path/to/cert.pem" },
      get_history_limit = 50
    }
  10. Push function metadata with `push_funcs`

    master

    Use push_funcs to upload function metadata and scores to the database. This method performs an upsert: if a function with the same checksum and db_id already exists, it updates the name, metadata, rank, and timestamp.

    Note: The method automatically chunks large requests into groups of 3000 to avoid PostgreSQL binding limits. It returns a Vec<bool> indicating whether each function in the request was newly created.

    // user: RpcHello, funcs: PushMetadata, scores: &[u32]
    let is_new_vec: Vec<bool> = db.push_funcs(user, funcs, &scores).await?;