Skip to content

Minor changes on top of small_optimizations PR#45

Merged
jeFF0Falltrades merged 2 commits into
masterfrom
pr-44-fixups
May 23, 2026
Merged

Minor changes on top of small_optimizations PR#45
jeFF0Falltrades merged 2 commits into
masterfrom
pr-44-fixups

Conversation

@jeFF0Falltrades
Copy link
Copy Markdown
Owner

@jeFF0Falltrades jeFF0Falltrades commented May 23, 2026

Summary

Follow-up changes on top of #44:

  • config_normalization: Strip underscores from alias keys at map-build time so aliases like mutex_string actually resolve to Mutex. Restore unconditional underscore-stripping on the returned key to
    preserve the prior behavior for unrecognized keys.
  • rat_config_parser._attempt_decryption: Replace the unreachable conditional trailing return with an unconditional raise to make the "decrypt-or-raise" invariant explicit.
  • config_decryptor_aes_with_iv: Restore the -> list[bytes] and -> dict[str, str] return type hints that were dropped during reformatting, and document why key_size/block_size/algo are
    extracted once and shared across all metadata candidates.
  • config_decryptor_aes_with_iv.decrypt_encrypted_strings: Fix a regression introduced in Small optimizations #44 where the new successfully_decrypted_count == 0 guard caused template/builder samples (e.g. unconfigured
    AsyncRAT builds whose config values are all placeholders like %Anti%) to fall through to the plaintext decryptor and lose the reported salt. Now tracks attempted decryptions separately and only raises when at least one decryption was attempted and all attempts failed.

- config_normalization: strip underscores from alias keys at map-build
  time so "mutex_string" (and similar) actually resolves to "Mutex".
  Restore unconditional underscore-stripping on the returned key to
  preserve prior behavior for unrecognized keys.
- rat_config_parser._attempt_decryption: replace the unreachable
  conditional trailing return with an unconditional raise to make the
  "decrypt-or-raise" invariant explicit.
- config_decryptor_aes_with_iv: restore the -> list[bytes] and
  -> dict[str, str] return type hints that were dropped during
  reformatting.
- config_decryptor_aes_with_iv._get_aes_metadata: document why
  key_size/block_size/algo are extracted once and shared across all
  metadata candidates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the decryption attempt logic to raise an exception directly if all decryptors fail, updates configuration key normalization to strip underscores during both map construction and lookup, and includes minor formatting and documentation improvements. The review feedback suggests further enhancing the normalization process by making it case-insensitive to ensure more robust key mapping.

Comment thread src/rat_king_parser/config_parser/utils/config_normalization.py
Comment thread src/rat_king_parser/config_parser/utils/config_normalization.py
PR #44 introduced a `successfully_decrypted_count == 0` guard at the end
of `decrypt_encrypted_strings` that raises if no string was successfully
decrypted. For template/builder samples (e.g. unconfigured AsyncRAT
builds where every config value is a placeholder like `%Anti%`), every
value fails the b64/length filter and is passed through unchanged
without any decryption being attempted. The guard then raised, causing
`_attempt_decryption` to discard the AES decryptor and fall through to
the plaintext decryptor, which has no salt -- so `report["salt"]` was
reported as "None" instead of the actual extracted salt.

Track attempted decryptions separately and only raise when at least one
string was actually attempted but every attempt failed. Template samples
have zero attempts and now fall through cleanly with the AES decryptor
intact, restoring the master behavior of reporting the salt.

Verified against all 14 known sample expected outputs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jeFF0Falltrades jeFF0Falltrades merged commit 3f71a4a into master May 23, 2026
2 checks passed
@jeFF0Falltrades jeFF0Falltrades deleted the pr-44-fixups branch May 23, 2026 23:12
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.

1 participant