Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new transformation for creating new fields from Hashes field #294

Merged

Conversation

slincoln-aiq
Copy link
Contributor

Add HashesFieldsDetectionItemTransformation class

Description

This pull request introduces a new transformation class, HashesFieldsDetectionItemTransformation, to enhance the processing of hash values in Sigma rules. This transformation is designed to handle the 'Hashes' field more effectively by creating separate detection items for each hash type.

Features

  • Transforms the generic 'Hashes' field into specific fields for each hash algorithm
  • Supports various hash formats (e.g., 'ALGO=VALUE', 'ALGO|VALUE', or just 'VALUE')
  • Auto-detects hash types based on their length
  • Allows customization of field prefixes and the option to drop algorithm prefixes
  • Handles multiple hash values within a single detection item

Implementation Details

  • The transformation extends the DetectionItemTransformation class
  • It processes each hash value, extracts the algorithm and value, and creates new detection items
  • Supports common hash algorithms: MD5, SHA1, SHA256, and SHA512 (customizable)
  • Provides flexibility in naming the resulting fields

Usage Example

Input Sigma rule:

selection:
  Hashes:
    - 'SHA1=5F1CBC3D99558307BC1250D084FA968521482025'
    - 'MD5=987B65CD9B9F4E9A1AFD8F8B48CF64A7'

->

selection:
  FileSHA1: '5F1CBC3D99558307BC1250D084FA968521482025'
  FileMD5: '987B65CD9B9F4E9A1AFD8F8B48CF64A7'

Copy link
Member

@thomaspatzke thomaspatzke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for it!

@thomaspatzke thomaspatzke merged commit f178cb2 into SigmaHQ:main Oct 21, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants