ZCrypto Research Library

repository·master·Indexed 41 days ago

https://github.com/zmap/zcrypto

A specialized Golang research library for data collection, analysis, and prototyping in TLS and Certificate Transparency (CT) domains. It provides modified versions of standard cryptographic libraries, including zcrypto/tls for handshake logging and older TLS version support, zcrypto/x509 for JSON serialization, and zcrypto/encoding/asn1 for permissive decoding. Designed for research and experimentation, it is not intended for production security.

Tokens
1K
Snippets
3
Records
9
Agent score
97%

What's inside ZCrypto

  1. Overview of ZCrypto

    master

    ZCrypto is a research-oriented Golang library containing specialized versions of tls and x509. It is primarily based on the standard Golang crypto/tls library and is designed for data collection, analysis, experimentation, and prototyping.

    ⚠️ WARNING: EXPERIMENTAL ZCrypto is a research library. It should not be used to provide security for production systems.

  2. Use permissive ASN.1 decoding with zcrypto/encoding/asn1

    master
    The encoding/asn1 package in zcrypto is a fork of the Go standard library's encoding/asn1 package. It is designed to allow more permissive decoding of ASN.1 encoded data, which can be useful when dealing with non-standard or slightly malformed certificates and structures that the standard library might reject.
  3. Use zcrypto/x509 for JSON serialization and CT support

    master

    The zcrypto/x509 package is a fork of the Go standard library crypto/x509. It provides enhanced functionality for:

    • Serializing certificates to JSON.
    • Integration with Certificate Transparency (CT) workflows.
  4. Understand the compatibility of the zcrypto/x509 package

    master

    The zcrypto/x509 package is a fork of the standard go/crypto/x509 library. It has diverged from the standard library and is not updated in direct correspondence with new Go releases.

    It provides approximate support for all features found in the github.com/golang/go/crypto/x509 package as it existed at:

    • Branch: release-branch.go1.10
    • Revision: dea961ebd9f871b39b3bdaab32f952037f28cd71

    When using this package, be aware that newer features or security updates present in modern Go standard library x509 implementations may not be available here.

  5. Use zcrypto/ct for Certificate Transparency research

    master
    The zcrypto/ct package is a fork of the Google Certificate Transparency Golang library. It has been modified to integrate seamlessly with the rest of the ZCrypto ecosystem.
  6. Use zcrypto/tls for research and data collection

    master

    The zcrypto/tls package (formerly known as ZTLS) is a research-focused TLS library based on the Go standard library crypto/tls.

    Key features include:

    • Support for older TLS versions.
    • Support for export ciphers.
    • Handshake message logging.
    • High configurability (many internal components are exposed as public variables for research purposes).

    It is commonly used for large-scale data collection and is a dependency for ZGrab. It relies on zcrypto/x509.

  7. Build the log scanner binary

    master

    You can compile the log scanner tool into an executable binary using the go build command targeting the scanner's main entry point.

    go build github.com/google/certificate-transparency/go/scanner/main/scanner.go
  8. Install the Certificate Transparency client and scanner

    master

    To use the Certificate Transparency client or scanner in your Go projects, you must import them into your Go workspace using go get.

    Note: You need Go version 1.1 or higher to compile this code.

    go get github.com/google/certificate-transparency/go/client
    go get github.com/google/certificate-transparency/go/scanner
  9. Use the CT client CLI to fetch and parse log entries

    master

    The ct/client/main package provides a CLI tool to interact with Certificate Transparency (CT) logs. It allows you to specify a CT log URI and an index to retrieve and parse entries (either X.509 certificates or Precertificates) into JSON format.

    CLI Flags

    • -log_uri: The base URI of the CT log (default: http://ct.googleapis.com/aviator).
    • -index: The starting index to parse (default: 1).

    Workflow

    1. Initialize a client.New(logURI).
    2. Call logClient.GetEntries(startIndex, endIndex) to retrieve a range of entries.
    3. Iterate through the returned ct.LogEntry objects.
    4. Use processEntry logic to differentiate between ct.X509LogEntryType and ct.PrecertLogEntryType to extract the certificate data using x509.ParseCertificate.
    # Example command to fetch entries starting from index 10 at a specific log
    ./ct_client_binary -log_uri "http://example.com/ct-log" -index 10