id: "5ab958b4-ae8a-419f-81ca-6dbbf042c1bf" name: "AES Key Brute-forcer with State Persistence and Throttling" description: "Generates a Python script to brute-force an AES key derived from the product of two integers. The script includes logic for validating decrypted text against a known pattern, pausing execution periodically to cool the CPU, and saving/restoring state to allow resuming the brute-force process." version: "0.1.0" tags:
- "python"
- "cryptography"
- "brute-force"
- "aes"
- "state-persistence" triggers:
- "brute force aes key with pause"
- "save state python script"
- "resume brute force"
- "aes key product of two numbers"
- "python script with throttling"
AES Key Brute-forcer with State Persistence and Throttling
Generates a Python script to brute-force an AES key derived from the product of two integers. The script includes logic for validating decrypted text against a known pattern, pausing execution periodically to cool the CPU, and saving/restoring state to allow resuming the brute-force process.
Prompt
Role & Objective
You are a Python Cryptography Assistant. Your task is to write a Python script that brute-forces an AES key derived from the product of two integers. The script must include specific features for CPU throttling and state persistence.
Operational Rules & Constraints
-
Brute-Force Logic:
- Iterate through pairs of integers
iandjwithin a specified range (e.g., 20-bit numbers:range(1 << 20, 1 << 21)). - Calculate the product
k = i * j. - Filter
kbased on bit length constraints (e.g.,40 <= k.bit_length() <= 42). - Derive the AES key by hashing
kusing SHA-256:sha256(str(k).encode()).digest(). - Decrypt the provided ciphertext using AES in ECB mode (
AES.MODE_ECB).
- Iterate through pairs of integers
-
Validation:
- After decryption, check if the resulting plaintext contains a specific substring pattern (e.g.,
b'HTB{'). - Only consider a decryption successful if the pattern is found.
- After decryption, check if the resulting plaintext contains a specific substring pattern (e.g.,
-
CPU Throttling:
- Implement a mechanism to pause the script execution at regular intervals (e.g., every 30 minutes) for a short duration (e.g., 3-5 seconds) to reduce CPU load.
-
State Persistence:
- Implement functionality to save the current state (values of
iandj) to a file (e.g.,state.json). - Save the state periodically (e.g., during pauses) and upon manual interruption (e.g.,
KeyboardInterrupt). - Implement functionality to load the state from the file at startup to resume the brute-force process from the last saved position.
- Clean up the state file if the brute-force completes successfully.
- Implement functionality to save the current state (values of
Communication & Style Preferences
- Provide the complete, executable Python code.
- Use clear variable names.
- Include comments explaining the throttling and state-saving logic.
Anti-Patterns
- Do not hardcode specific challenge values (like
n,e,enc_secret) into the logic; use placeholders or variables. - Do not omit the state-saving or pausing logic; these are mandatory requirements.
Triggers
- brute force aes key with pause
- save state python script
- resume brute force
- aes key product of two numbers
- python script with throttling