0x03 How to locate the position of iv and key

0 20
All vulnerabilities involved in the article have been repaired, all sensitive in...

All vulnerabilities involved in the article have been repaired, all sensitive information has been coded, and the article is only for the purpose of sharing experience, please do not take it seriously. Unauthorized attacks are illegal!

0x01 Significance of encryption and decryption

At present, the penetration testing has enabled me to find that more and more systems not only focus on vulnerability repair, but also encrypt some parameters to interfere with the operation of crawlers or penetration testing.

0x03 How to locate the position of iv and key

At my beginner stage, when I saw the encryption method shown in the figure below, my first reaction was to decode it with base64, and if it doesn't work, then this system is secure

1722412277_66a9ecf5e340350047e32.png!small?1722412277969

But in fact, these are AES encrypted, and the general style is like this

AAAAA+AAAAA/AAA=

It can be understood that among the characters and features of base64 and "==", the general inclusion of characters such as "+" and "/" suggests AES encryption

0x02 Overview of ciphertext principle

The key to decrypting AES lies in obtaining its parameters: secret key (KEY) and offset (IV)
However, AES has different modes, and here are the two most common ones: CBC, ECB
CBC requires both the secret key (KEY) and the offset (IV) to decrypt
ECB only needs the secret key (KEY) to decrypt
1722414373_66a9f525cc235c31218bd.png!small?1722414373659Then you can debug through the encryption and decryption website

Online AES encryption and decryption, AES online encryption and decryption, AES encryption and decryption -- Chacuo.net

1722414625_66a9f621446707b27aeab.png!small?1722414625163

For a specific explanation of AES, please refer to the following article
Detailed introduction and implementation of AES encryption algorithm - CSDN blog

0x03 How to locate the position of iv and key

I usually open the F12 console directly to search for the following keywords

crypt (This is a framework often cited by AES, so searching for this term often leads to the discovery of encryption and decryption method names similar to encrypt or decrypt)

1722415647_66a9fa1fb73540c96b2a5.png!small?1722415648250

1722415934_66a9fb3e87e74085b9893.png!small?1722415934531

When you are not very good at it at first, just set breakpoints on all such related methods

1722416100_66a9fbe4ccc1c0d227aa1.png!small?1722416100813

Then the encryption function will start in debug mode

1722416270_66a9fc8e70c6160773be4.png!small?1722416270381

Or when you reach this step of decrypt decryption method, you can directly call the encryption data in the console as well
1722416409_66a9fd19936495eedb199.png!small?1722416409481Just input the encrypted data as shown in decrypt(data) above, for example decrypt("AAAA+AAA/AA=")
1722416402_66a9fd123e0faed8b8492.png!small?1722416407278

0x04 AES batch encryption

For batch encryption with AES, you can use the BURP plugin BurpCrypto1722416708_66a9fe447f52a21b3b8e6.png!small?1722416708247Or if you want to encrypt locally, you can use python
I wrote this, lazy people can use it

import base64
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding

def encrypt_file(input_filename, output_filename, key, iv):
backend = default_backend()
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)

with open(input_filename, 'r', encoding='utf-8') as input_file, open(output_filename, 'w', encoding='utf-8') as output_file:
for line in input_file:
encryptor = cipher.encryptor() # Create a new Encryptor for each line
padder = padding.PKCS7(128).padder()
padded_data = padder.update(line.encode('utf-8')) + padder.finalize()
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()

# Convert binary data to a Base64 encoded string
encoded_data = base64.b64encode(encrypted_data).decode('utf-8')
output_file.write(encoded_data + '\n') # Add a newline character after each line

# Use predefined key and IV
key = b'5rer641QMOG9FI62PCfkzB4Rx9B3akti' # Ensure it is 32 bytes long
iv = b'12hOaPl0RDfSx4pJ' # Ensure it is 16 bytes long

input_filename = 'plaintext.txt'
output_filename = 'ciphertext.txt'

encrypt_file(input_filename, output_filename, key, iv)
你可能想看:

How to use truffleHog to search for high-entropy strings and sensitive data in Git repositories to protect the security of code repositories

4.5 Main person in charge reviews the simulation results, sorts out the separated simulation issues, and allows the red and blue teams to improve as soon as possible. The main issues are as follows

b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo

d) Adopt identification technologies such as passwords, password technologies, biometric technologies, and combinations of two or more to identify users, and at least one identification technology sho

It is possible to perform credible verification on the system boot program, system program, important configuration parameters, and application programs of computing devices based on a credible root,

Internal and external cultivation | Under the high-confrontation offensive and defensive, internal network security cannot be ignored

b) It should have a login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal login attempts, and automatically logging out w

(3) Is the national secret OTP simply replacing the SHA series hash algorithms with the SM3 algorithm, and becoming the national secret version of HOTP and TOTP according to the adopted dynamic factor

3 JD open-source hotkey—Automatic detection of hotkey, distributed consistency caching solution

Data security can be said to be a hot topic in recent years, especially with the rapid development of information security technologies such as big data and artificial intelligence, the situation of d

最后修改时间:
admin
上一篇 2025年03月25日 03:39
下一篇 2025年03月25日 04:02

评论已关闭