old htb folders
This commit is contained in:
2023-08-29 21:53:22 +02:00
parent 62ab804867
commit 82b0759f1e
21891 changed files with 6277643 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import string
def encryption(msg):
ct = []
for char in msg:
ct.append((123 * ord(char) + 18) % 256)
return bytes(ct)
dict = {}
for elem in string.printable:
enc = encryption(elem)[0]
dict[elem] = enc
dict[enc] = elem
print(dict)
f = open('./msg.enc','r')
ct = f.readline()
ct = [int(ct[i:i+2],16) for i in range(0, len(ct), 2)]
solve = ""
for elem in ct:
solve += dict[elem]
print(solve)

View File

@@ -0,0 +1,15 @@
import string
from secret import MSG
def encryption(msg):
ct = []
for char in msg:
ct.append((123 * char + 18) % 256)
return bytes(ct)
ct = encryption(MSG)
f = open('./msg.enc','w')
f.write(ct.hex())
f.close()

View File

@@ -0,0 +1 @@
6e0a9372ec49a3f6930ed8723f9df6f6720ed8d89dc4937222ec7214d89d1e0e352ce0aa6ec82bf622227bb70e7fb7352249b7d893c493d8539dec8fb7935d490e7f9d22ec89b7a322ec8fd80e7f8921

View File

@@ -0,0 +1,31 @@
import os
from Crypto.Cipher import ChaCha20
def encrypt_message(message, key, nonce):
cipher = ChaCha20.new(key=key, nonce=nonce)
ciphertext = cipher.encrypt(message)
return ciphertext
def chosen_plaintext_attack(ciphertext, key, nonce):
# Create a dictionary of known plaintexts and their corresponding ciphertexts
known_plaintexts = {b"Our counter agencies have": b"", b"example2": b""}
for plaintext in known_plaintexts:
# Encrypt the known plaintext using the same key and nonce as the original ciphertext
known_ciphertext = encrypt_message(plaintext, key, nonce)
# Compare the known ciphertext with the original ciphertext
if known_ciphertext == ciphertext:
# If the ciphertexts match, the original plaintext is likely the known plaintext
return plaintext
return None
if __name__ == "__main__":
message = b"Our counter agencies have intercepted your messages and a lot"
key, nonce = os.urandom(32), os.urandom(12)
encrypted_message = encrypt_message(message, key, nonce)
# Perform the chosen plaintext attack
recovered_message = chosen_plaintext_attack(encrypted_message, key, nonce)
if recovered_message is not None:
print("Recovered message:", recovered_message)
else:
print("Failed to recover message")

View File

@@ -0,0 +1,3 @@
c4a66edfe80227b4fa24d431
7aa34395a258f5893e3db1822139b8c1f04cfab9d757b9b9cca57e1df33d093f07c7f06e06bb6293676f9060a838ea138b6bc9f20b08afeb73120506e2ce7b9b9dcd9e4a421584cfaba2481132dfbdf4216e98e3facec9ba199ca3a97641e9ca9782868d0222a1d7c0d3119b867edaf2e72e2a6f7d344df39a14edc39cb6f960944ddac2aaef324827c36cba67dcb76b22119b43881a3f1262752990
7d8273ceb459e4d4386df4e32e1aecc1aa7aaafda50cb982f6c62623cf6b29693d86b15457aa76ac7e2eef6cf814ae3a8d39c7

View File

@@ -0,0 +1,28 @@
from Crypto.Cipher import ChaCha20
from secret import FLAG
import os
def encryptMessage(message, key, nonce):
cipher = ChaCha20.new(key=key, nonce=iv)
ciphertext = cipher.encrypt(message)
return ciphertext
def writeData(data):
with open("out.txt", "w") as f:
f.write(data)
if __name__ == "__main__":
message = b"Our counter agencies have intercepted your messages and a lot "
message += b"of your agent's identities have been exposed. In a matter of "
message += b"days all of them will be captured"
key, iv = os.urandom(32), os.urandom(12)
encrypted_message = encryptMessage(message, key, iv)
encrypted_flag = encryptMessage(FLAG, key, iv)
data = iv.hex() + "\n" + encrypted_message.hex() + "\n" + encrypted_flag.hex()
writeData(data)