phi = (N - 1) d = inverse(e, phi) m = pow(c, d, N) print(long_to_bytes(m).decode('utf-8'))
# By harnessing the grodno{m@thematical_pr0perties_0f_l@rge_prime_numb3rs}, RSA provides a robust and efficient method for encrypting and decrypting information.
Actually, I’m a fan of astronomy. But where would we be today without cybersecurity… Determine the hash type and get the original string - the password.
# 从文件中读取所有行并存储到列表中 withopen("Rivest_91.txt", "r") as f: lines = f.read().splitlines()
# 使用字典来映射MD5值到原始字符串 md5_dict = {line: ''for line in lines}
defprintable_char_combinations(): # 定义可打印字符范围,从ASCII的32(空格)到126(波浪号'~') printable_chars = [chr(i) for i inrange(32, 127)]
# 生成所有1到3位的字符组合 for r inrange(1, 4): # r表示组合的长度 for combination in itertools.product(printable_chars, repeat=r): yield''.join(combination)
# 遍历所有可能的字符串组合 for combo in printable_char_combinations(): md5_hash = md5(combo.encode()).hexdigest() # 计算字符串的MD5值 if md5_hash in md5_dict: md5_dict[md5_hash] = combo # 如果MD5值在字典中,更新字典以映射到原始字符串
# 输出所有找到的匹配字符串 print(''.join(md5_dict.values()))
# MD5 processes a variable-length message into afixed-lethoutput of 128 bits. grodno{no,_MD5_ws_n0t_invet3d_by_me,_its_invent_by_R1vesin_1991.} Theinput mesgs broken up io chunks of 512-bit blocks (siteen 32t wos);the agpadd so tha i lengt is diviible by 5. Thdding works flows:first, a sinle bit,, is appeed tohe end thsae. This followby as may zearequireo b lf tmee uto 64 fewerthamulof 512. Tremaints are flle u wi bs rpreh of orgial ge, mdul2**64.
The rules of conduct when using Google services, as well as Google’s rights and responsibilities, are set forth in the “Terms of Use”. Violation of the Terms of Use of Google Services is a direct road to a ban on their use for you
This is a style of using English that has spread on the Internet. The main differences are the replacement of Latin letters with similar numbers and symbols, imitation and parody of errors typical for fast typing, imitation of the jargon of hackers and gamers. More details - see. Wikipedia or about converters with Leet
A “professional” Leet can use combinations of cryptological techniques that make what is written fundamentally incomprehensible to the uninitiated. Only a chosen one will be able to understand their letter.
# chatGPT: defreverse_engineer(m, key): for r inrange(key): if (m - r) % (1 + r // key) == 0: n = (m - r) // (1 + r // key) if n % key == r: returnchr(n) returnNone# 如果没有找到有效的字符
defdecrypt(encrypted, initial_key): result = [] key = initial_key
for value in encrypted: m = int(value) for r inrange(key): if (m - r) % (1 + r // key) == 0: n = (m - r) // (1 + r // key) if n % key == r: result.append(chr(n)) break key += 1
return''.join(result)
withopen("terror.txt", "r") as f: c = f.read().split(" ")
m = decrypt(c, 2 * len(c)) print(m)
''' def encrypt(text): # flag is: grodno{xa-xa-xa-terrorist} key = randint(1, 2 * len(text)) result = [] for c in text: result.append(ord(c) + (ord(c) % key)) key = key + 1 return result '''
grodno{xa-xa-xa-terrorist}
Mutated Caesar
题目:
The Caesar Cipher has mutated. Now it works not only with English alphabet characters, but also with some subset of ASCII characters
Caesare.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
from hashlib import md5 from random import randint from secret import flag
hash = md5(flag.encode()).hexdigest()
n1, n2 = randint(0x20, 0x41), randint(0x7d, 0x7e) CN = {chr(i + n1): i for i inrange(0, n2 - n1 + 1)} NC = {i: chr(i + n1) for i inrange(0, n2 - n1 + 1)}
N = len(CN.keys()) key = randint(0, N) cipher = "".join([NC[(CN[c] + key) % N] for c in flag])
# 尝试所有可能的 n1 和 n2 范围内的值 for n1 inrange(0x20, 0x42): # 包括0x41 for n2 inrange(0x7d, 0x7f): # 包括0x7e if n1 >= n2: continue
# 生成映射字典 CN = {chr(i + n1): i for i inrange(0, n2 - n1 + 1)} NC = {i: chr(i + n1) for i inrange(0, n2 - n1 + 1)}
N = len(CN.keys())
# 尝试所有可能的 key for key inrange(N): try: # 尝试解密 decrypted = "".join([NC[(CN[c] - key) % N] for c in cipher]) # 检查解密后的字符串是否符合 flag 格式 if decrypted.startswith('grodno{') and decrypted.endswith('}'): if md5(decrypted.encode()).hexdigest() == md5str: print(f"Found flag: {decrypted} with n1={n1}, n2={n2}, key={key}") except KeyError: # 如果 cipher 中有字符不在 CN 中,会抛出 KeyError continue
# Found flag: grodno{This_is_probably_fever_from_the_upper_Nile} with n1=38, n2=125, key=32 # Found flag: grodno{This_is_probably_fever_from_the_upper_Nile} with n1=39, n2=126, key=32