a = '1122332212232211011111010000010112110111222323303323221111122333'# 迷宫 b = [] # 暴破出 算法部分 -- 后来知道就是4转16进制而已 for i inrange(0, len(a), 4): for x inrange(0, 256): # t = (x ^ 0x15) & 0xff v1 = str((x >> 0) & 3) v2 = str((x >> 2) & 3) v3 = str((x >> 4) & 3) v4 = str((x >> 6) & 3) tmp = v4 + v3 + v2 + v1 if tmp == a[i:i + 4]: b.append(x) print(tmp) # 逆推 异或的部分 for i inrange(len(b)): b[i] ^= 0x15
for i in b: print(str(hex(i))[2:], end=' ') # 将其写入nk.ctf中 # 4f ef 7e b0 0 44 15 4 70 0 be a9 ee b0 43 aa
最后写入文件 用010插入
运行 OK
babyrust - rust/subprocess
什么鬼 ? 我又没学过 rust
我是请教了别的师傅
用python的subprocess模块
进行暴破的
又学到一招 嘿嘿
Orz Orz
拖入ida64 分析 然后 我靠
自己看了看 发现确实能看懂个差不多
但我这嫌麻烦 直接暴破了
贴exp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import subprocess
encData = ")&n_qFb'NZXpj)*bLDmLnVj]@^_H"
dict = {} if __name__ == '__main__': asc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{}_" lst = [] for i inrange(len(asc)): p = subprocess.Popen(['babyrust.exe'], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) a = p.communicate((asc[i].encode()))[0] dict[a.decode()[134:135]] = asc[i] print(dict) for i in encData: print(dict[i], end="") # NKCTF{WLcomE_NOWayBaCk_RuST}
#!/usr/bin/env python # visit https://tool.lu/pyc/ for more information # Version: Python 3.8
import libnum import base64 import hashlib from ctypes import *
defencrypt(text): data_xor_iv = bytearray() sbox = [] j = 0 x = y = k = 0 key = '911dcd09ad021d68780e3efed1aa8549' for i inrange(256): sbox.append(i) for i inrange(256): j = j + sbox[i] + ord(key[i % len(key)]) & 255 sbox[i] = sbox[j] sbox[j] = sbox[i] for idx in text: x = x + 1 & 255 y = y + sbox[x] & 255 sbox[x] = sbox[y] sbox[y] = sbox[x] k = sbox[sbox[x] + sbox[y] & 255] data_xor_iv.append(idx ^ k) return data_xor_iv
if __name__ == '__main__': flag = input('%e8%af%b7%e8%be%93%e5%85%a5flag> ') pub_key = [ 0x1B6A7561D99E6FC35BA3C241159424698BF3CAC017CFCE8BB325CC9AF9CBCBDB3997B08D922C8705FC3EEAEF50D60ADAB2757A7204715483A1D612502970595358BCFE9CD11C98CAD293EB921D777F4F910905D79CDCA5C1EC1FBA5DA74DB165F82BBE29EA0B2E597860FC6D2C51C12D46BF11AFA5018496DDFC3474B10B4457L, 0x6C8E1CC5B384DE3B3316C22CF72D9895406298E172B5F4D890BDC04889BB43CD4892689DE701C84ED68B4CBC7193926BCCB0A4F259D2E752FAEF3CD590A793F120D15424AEB3CD53F5D59B5D41D699694ABF4F01532F0F1CE127B07958FB874982E757EF97643335376790BC990CEE9D7F0D05DA90AD62084C88BFA9C9BEB683L] m = libnum.s2n(flag) c = str(pow(m, pub_key[0], pub_key[1])) q = b'EeJWrgtF+5ue9MRiq7drUAFPtrLATlBZMBW2CdWHRN73Hek7DPVIYDHtMIAfTcYiEV87W7poChqpyUXYI3+/zf5yyDOyE9ARLfa5qilXggu60lmQzFqvFv+1uOaeI2hs2wx+QZtxqGZzC0VCVWvbTQ52nA2UdUtnk8VezRMPMfmf7rOqPxDTv/aacLnI3RdLG2TbT52qtN4+naejI7Xe8HLOL765OZKdDBERKwd5ARQ3UL6YPbuOKOQahIFddnIX6rZ7dTNqCUDOjfJbMdrzJVDNjmNlkLNtYFo7M65Wfwj6PV5vvtT33FsmH50/YLEasnlCiJujYOgi2KCdf5msz1dPEvrXDDL6Csnjo+6m/44RzlluzcqMS5ZJFdrHEh68LIqtu+HCO+69Dyq4e22APq8wgN9kU6R8kikXSn/Ej0N/jOvomFCbkHskRl8xP1KgWFW0SMVDlaDCM4EKG812VgDWgSYOUnVhVpz65uOtg4Z8PrPI+BW4398dQYhD24D9EIPgvtmhNrHiEHouB46ElTGQgZBhtn6y9tL1sw==' v = encrypt(base64.b64encode(c.encode('utf-8'))) v = base64.b64encode(v) if v == q: print('You are right!') input('') else: print('winer winer winnie dinner') print('Do you think the encryption and decryption are the same?')
# coding:utf-8 import gmpy2 from Crypto.Util.number import long_to_bytes import libnum deftransform(x, y): # 使用辗转相处将分数 x/y 转为连分数的形式 res = [] while y: res.append(x//y) x, y = y, x % y return res
defcontinued_fraction(sub_res): numerator, denominator = 1, 0 for i in sub_res[::-1]: # 从sublist的后面往前循环 denominator, numerator = numerator, i*numerator+denominator return denominator, numerator # 得到渐进分数的分母和分子,并返回
# 求解每个渐进分数 defsub_fraction(x, y): res = transform(x, y) # 将连分数的结果逐一截取以求渐进分数 res = list(map(continued_fraction, (res[0:i] for i inrange(1, len(res))))) return res