NullSec CryptoAudit

February 27, 2026 ยท View on GitHub

Cryptographic Implementation Analyzer

A static analysis tool for detecting weak cryptographic implementations written in Scala, demonstrating functional-OOP hybrid patterns for security code analysis.

Scala Security Version License

๐ŸŽฏ Overview

NullSec CryptoAudit scans source code to identify weak or deprecated cryptographic algorithms. It detects broken hashes, weak ciphers, insufficient key sizes, and insecure random number generators.

โœจ Features

  • Hash Analysis - Detect MD5, SHA-1, MD4 usage
  • Cipher Detection - Find DES, 3DES, RC4, Blowfish
  • Key Size Check - Flag RSA < 2048 bits
  • PRNG Analysis - Identify Math.random(), rand()
  • CWE Mapping - Common Weakness Enumeration
  • MITRE ATT&CK - Technique references

๐Ÿ” Detection Capabilities

AlgorithmTypeStatusCWE
MD5HashBrokenCWE-328
SHA-1HashDeprecatedCWE-328
DESCipherBrokenCWE-327
3DESCipherDeprecatedCWE-327
RC4CipherBrokenCWE-327
RSA-1024AsymmetricWeakCWE-326
Math.randomPRNGWeakCWE-338
PBKDF1KDFDeprecatedCWE-916

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/bad-antics/nullsec-cryptoaudit
cd nullsec-cryptoaudit

# Compile with scalac
scalac CryptoAudit.scala

# Run
scala nullsec.cryptoaudit.CryptoAudit

# Or use Ammonite
amm CryptoAudit.scala

๐Ÿš€ Usage

# Analyze directory
scala CryptoAudit.scala /path/to/code

# Recursive scan
scala CryptoAudit.scala -r project/

# JSON output
scala CryptoAudit.scala -j src/

# Verbose mode
scala CryptoAudit.scala -v app/

# Run demo
scala CryptoAudit.scala

๐Ÿ’ป Example Output

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘         NullSec CryptoAudit - Cryptographic Analyzer             โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

[Demo Mode]

Analyzing sample code for weak cryptography...

  [CRITICAL] MD5
    File:     auth.java:45
    Code:     MessageDigest md = MessageDigest.getInstance("MD5");
    Status:   Broken
    CWE:      CWE-328
    MITRE:    T1110
    Fix:      Use SHA-256 or SHA-3

  [CRITICAL] DES
    File:     encrypt.js:30
    Code:     const key = crypto.createCipheriv('des', secret, iv);
    Status:   Broken
    CWE:      CWE-327
    MITRE:    T1573
    Fix:      Use AES-256

  [HIGH] Math.random()
    File:     random.js:55
    Code:     const id = Math.random().toString(36);
    Status:   Weak
    CWE:      CWE-338
    MITRE:    T1558
    Fix:      Use crypto.getRandomValues() or SecureRandom

  [MEDIUM] SHA-1
    File:     crypto.py:120
    Code:     hash = hashlib.sha1(password.encode())
    Status:   Deprecated
    CWE:      CWE-328
    MITRE:    T1110
    Fix:      Use SHA-256 or SHA-3

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

  Summary:
    Files Analyzed: 10
    Total Findings: 8
    Critical:       4
    High:           1
    Medium:         3
    Low:            0

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Source Code Input                         โ”‚
โ”‚              Java | Python | JavaScript | Go | Ruby          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Pattern Matching Engine                     โ”‚
โ”‚            Regex patterns for crypto functions              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Algorithm Database Lookup                    โ”‚
โ”‚           Status | CWE | MITRE | Recommendation             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Finding Generation                        โ”‚
โ”‚           Severity based on algorithm status                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฏ Scala Features Demonstrated

  • Sealed Traits - Severity, AlgorithmType, AlgorithmStatus
  • Case Classes - Immutable Algorithm, Finding, AnalysisResult
  • Case Objects - Singleton severity levels
  • Pattern Matching - Exhaustive match expressions
  • For Comprehensions - Monadic composition with Option
  • Immutable Collections - List, Map operations
  • Higher-Order Functions - flatMap, groupBy, sortBy
  • String Interpolation - s"..." for output formatting

๐Ÿ”ง Data Structures

case class Algorithm(
  name: String,
  algType: AlgorithmType,
  status: AlgorithmStatus,
  keySize: Option[Int],
  cwe: String,
  recommendation: String
)

case class Finding(
  file: String,
  line: Int,
  code: String,
  algorithm: Algorithm,
  severity: Severity,
  description: String,
  mitre: Option[String]
)

๐Ÿ“Š Severity Mapping

StatusSeverityDescription
BrokenCriticalCryptographically broken
WeakHighKnown vulnerabilities
DeprecatedMediumShould not be used
SecureInfoAcceptable algorithms

๐Ÿ›ก๏ธ Security Use Cases

  • Code Review - Automated crypto weakness detection
  • SAST Integration - CI/CD security scanning
  • Compliance - Crypto policy enforcement
  • Migration Planning - Identify legacy crypto
  • Security Auditing - Comprehensive crypto inventory

This tool is intended for:

  • โœ… Authorized code review
  • โœ… Security assessments
  • โœ… Compliance verification
  • โœ… Educational purposes

Only analyze code you're authorized to review.

๐Ÿ“„ License

MIT License - See LICENSE file for details.

๐Ÿท๏ธ Version History

  • v1.0.0 - Initial release with crypto weakness detection and CWE mapping

Part of the NullSec Security Toolkit