2022 网鼎杯初赛(青龙组) Writeup By Xp0int xp0int Posted on Aug 26 2022 ## 1. Crypto ### 1.1 crypto405 `Author: k1rit0` 利用flag头 flag{ 列出五个关于K的方程,用sagemath一个一个的解出k来,然后爆破所有可能的p,直到找到flag ```python k0 = var('k0') k1 = var('k1') k2 = var('k2') k3 = var('k3') k4 = var('k4') K = [k0,k1,k2,k3,k4] flag = [ord('f'),ord('l'),ord('a'),ord('g'),ord('{')] F = [] for i in range(5): grasshopper = flag[i] for j in range(5): grasshopper = grasshopper * K[j] K[j] = grasshopper F.append(K[-1] - known[i]) F[0].solve(k0) # F[1].solve(k1) 需要解出上一条把k0代回去 ``` 上面这个脚本能解出所有的k ```python import re P = [...] # 利用gmpy2的next_prime把所有素数列出来,太多了渲染会卡所以用...省略了 output = '''Grasshopper#00:2066 Grasshopper#01:a222 Grasshopper#02:cbb1 Grasshopper#03:dbb4 Grasshopper#04:deb4 Grasshopper#05:b1c5 Grasshopper#06:33a4 Grasshopper#07:c051 Grasshopper#08:3b79 Grasshopper#09:6bf8 Grasshopper#10:2131 Grasshopper#11:2c40 Grasshopper#12:91ba Grasshopper#13:7b44 Grasshopper#14:5f25 Grasshopper#15:0208 Grasshopper#16:7edb Grasshopper#17:62b5 Grasshopper#18:cec5 Grasshopper#19:5ab3 Grasshopper#20:3c46 Grasshopper#21:c272 Grasshopper#22:714b Grasshopper#23:9e0b Grasshopper#24:48ee Grasshopper#25:44cc Grasshopper#26:05a0 Grasshopper#27:3da3 Grasshopper#28:11b1 Grasshopper#29:259f Grasshopper#30:899d Grasshopper#31:a130 Grasshopper#32:e58f Grasshopper#33:23f3 Grasshopper#34:5829 Grasshopper#35:6beb Grasshopper#36:3681 Grasshopper#37:0054 Grasshopper#38:a189 Grasshopper#39:2765 Grasshopper#40:c63d Grasshopper#41:bc68'''.split('\n') known = [int(re.findall(r'\:(.*)',i)[0],16) for i in output] k0 = (396091111351853546729322486681828125/16752324664863145168406201892534453994427707392) k1 = 41892628622080799/1618763711678683806046238092129608000/k0^4 k2 = 216245315/118532050972475400824098480128/(k0^6*k1^3) k3 = 20753/48479538609216/(k0^4*k1^3*k2^2) k4 = 4147/51/(k0*k1*k2*k3) K = [k0,k1,k2,k3,k4] for p in P: _K = [i % p for i in K] flag = '' # solve x for i in range(len(known)): inv = 1 for j in range(5): inv = inv * inverse_mod(Integer(_K[j]),Integer(p)) x = (known[i] * inv) % p if 0x20 < x < 0x7e: flag+=chr(x) for j in range(5): x = x * _K[j] % p _K[j] = x if len(flag) == 42: print(flag) ''' flag{749d39d4-78db-4c55-b4ff-bca873d0f18e} ''' ``` ### 1.2 crypto091 `Author: k1rit0` 盲猜sha256 ```python from hashlib import sha256 HASH = 'c22a563acc2a587afbfaaaa6d67bc6e628872b00bd7e998873881f7c6fdc62fc' phone_base = '86170' for i in range(10 ** 8): phone = phone_base + str(i).zfill(8) if sha256(phone.encode()).hexdigest() == HASH: print(phone) ''' 8617091733716 ''' ``` ### 1.3 crypto162 `Author: k1rit0` 好好的一个递推式子要弄成递归...直接换成递推,题目只需要后2000位,所以只需要计算后2000位,这样就能快速的算了(还是还要两三分钟 ```python cof_t = [...] S = 0 for V in cof_t: print(cof_t.index(V)) res = [1,2,3] for _ in range(3,200000+1): res.append((V[2] * res[-3] + V[1] * res[-2] + V[0] * res[-1]) % 10 ^ 2002) S += res[-1] s=str(S)[-2000:-1000] key = md5(s).hexdigest().decode('hex') check = sha256(key).hexdigest() verify = '2cf44ec396e3bb9ed0f2f3bdbe4fab6325ae9d9ec3107881308156069452a6d5' print(check) assert(check == verify) aes = AES.new(key,AES.MODE_ECB) c = long_to_bytes(0x4f12b3a3eadc4146386f4732266f02bd03114a404ba4cb2dabae213ecec451c9d52c70dc3d25154b5af8a304afafed87) print (aes.decrypt(c)) ''' flag{519427b3-d104-4c34-a29d-5a7c128031ff} ''' ``` ## 2. Pwn ### 2.1 pwn135 / BabyV8 `Author: xf1les` 非预期 ![title](https://leanote.com/api/file/getImage?fileId=630892beab644108379e7fe5) ### 2.2 pwn497 / minishell `Author: xf1les` 非预期 ![title](https://leanote.com/api/file/getImage?fileId=630892d2ab644108379e7fe7) ### 2.3 pwn349 `Author: xf1les` 还是非预期(估计没完全修好 pwn497 的非预期解) ![title](https://leanote.com/api/file/getImage?fileId=630893b0ab644108379e7ffe) ## 3. Reverse ### 3.1 re693 `Author: JANlittle` go源文件直接给,按题目要求直接vscode硬搜,第一个函数是`ZlXDJkH3OZN4Mayd`,第二个是`UhnCm82SDGE0zLYO`,然后直接按逻辑梭出flag就行 ### 3.2 re694 `Author: JANlittle` 魔改upx,懒得找改了哪里,x64dbg一路F8,最后有个长跳转,跳到这里: ![title](https://leanote.com/api/file/getImage?fileId=6308934aab644108379e7ff6) 然后scylla直接dump出程序丢IDA,逻辑差不多是检测flag长度是不是20,然后异或0x66、加10、异或0x50,然后比较。 ```python >>> c=[0x0000004B, 0x00000048, 0x00000079, 0x00000013, 0x00000045, 0x00000030, 0x0000005C, 0x00000049, 0x0000005A, 0x00000079, 0x00000013, 0x00000070, 0x0000006D, 0x00000078, 0x00000013, 0x0000006F, 0x00000048, 0x0000005D, 0x00000064, 0x00000064] >>> for i in range(len(c)): ... c[i]^=0x50 ... c[i]-=10 ... >>> bytes(c) b'\x11\x0e\x1f9\x0bV\x02\x0f\x00\x1f9\x163\x1e95\x0e\x03**' >>> for i in range(len(c)): ... c[i]^=0x66 ... >>> bytes(c) b'why_m0dify_pUx_SheLL' ``` 打赏还是打残,这是个问题 赏 Wechat Pay Alipay 2022 0CTF/TCTF Writeup By Xp0int 2022 强网杯初赛 Writeup By Xp0int
没有帐号? 立即注册