flag = '' enc = b'\x1a\x15\x05\t\x17\t\xf5\xa2-\x06\xec\xed\x01-\xc7\xcc2\x1eXA\x1c\x157[\x06\x13/!-\x0b\xd4\x91-\x06\x8b\xd4-\x1e+*\x15-pm\x1f\x17\x1bY' s = stream() for i inrange(48): water = s[(i // 2) ** 6] % 256 #print(water) flag += chr(water ^ enc[i])
index = list(range(16)) shuffle(index) e=0 for i in index: im = Image.open(f"source/picture{i}.png") key = nonce[randint(0, 2)] encImg = xorImg(key, im) encImg.save(f'pics/enc{e}.png') e+=1
只有16张图片,直接爆破
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from PIL import Image width=379#宽度和高度查看图片属性可知 height=234
defxorImg(keyImg, sourceImg): img = Image.new('RGB', (width, height)) for i inrange(height): for j inrange(width): p1, p2 = keyImg.getpixel((j, i)), sourceImg.getpixel((j, i)) img.putpixel((j, i), tuple([(p1[k] ^ p2[k]) for k inrange(3)])) return img for j inrange(16): key = Image.open(f"pics/enc{j}.png") for i inrange(16): encimg=Image.open(f"pics/enc{i}.png")
Sure enough, you still remember what we talked a bout at that time! This is part of the secret: ` hgame{U_ Kn0w_LSB&W`.I put the rest of th e content here, https://drive.google.com/file/d/13kBos3Ixlfwkf3e0z0kJTEqBxm7RUk-G/view?usp=sharing, if you directly access the g oogle drive cloud disk download in China, it will be very slow, you can try to u se Scientific Internet access solves the problem of slow or inaccessible accesstoexternal network resources. This is my favorite music, there is another part of the secret in the music, I use Steghide to encrypt, the passwordisalso the 6-digit password we agreed at the time, even if someone else finds out here, it should not be so easy to
p =65428327184555679690730137432886407240184329534772421373193521144693375074983 q =98570810268705084987524975482323456006480531917292601799256241458681800554123 c =0x4e072f435cbffbd3520a283b3944ac988b98fb19e723d1bd02ad7e58d9f01b26d622edea5ee538b2f603d5bf785b0427de27ad5c76c656dbd9435d3a4a7cf556 e = 2 R.<x> = Zmod(p)[] #将x作为需要求得的未知数,p为素数 f = x^e-c r1 = [int(i[0]) for i in f.roots()] #f.roots()返回求解出来的所有解的列表 R.<x> = Zmod(q)[] f = x^e-c r2 = [int(i[0]) for i in f.roots()] m = [] for i in r1: for j in r2: m.append(crt([i,j],[p,q])) #crt求解中国剩余定理,第一个参数为余数列表,第二个参数为模数列表 print(m) #将所有可能的m输出,复制到python里long_to_bytes()
到Python中
1 2 3 4
from Crypto.Util.number import * flag=[2372237455851842898349117425227584430588749791480564189568122389688124352290664541063989455711371754963358673223097609351443007448201859216160320647129068, 202822073494981439416400155064048668390596366869305553433016288033759387909443994349181, 6449323225107597053933443750923454260964062647115639999185223478236408615216462580775151285384372189740266233875418656692511620093103204244355042080455728, 4077085769255754155584326325695869830375312855635075809617101088548487084999293021150578229828064483445298157019190352894501628932935104416104165427675841] for i in flag: print(long_to_bytes(i))
hgame{That'5_s0_3asy_to_s@lve_r@bin}
RSA 大冒险1
4关挑战,通过拿flag
直接上解题代码
challenge 1
1 2 3 4 5 6 7 8 9 10 11
import libnum c=0x56908e6a818ea207ac312c0b204d94ee651cd7b26313fbfdcfb2406828ad379fa12529cf3db2a4d903 n=209770295744242916299788862153266483138979976716588739416239543100484342323180172904935777216735461 p=333053352923682535111489833655011123013 e = 65537
d = libnum.invmod(e, (p-1)) m = pow(c, d, p) print(libnum.n2s(m))
#m<n_But_also_m<p
challenge 2
1 2 3 4 5 6 7 8 9 10 11 12 13
import libnum import math
c1 = 0xa757143e3ea0753ac3c15e0dd05bc6eb58bdf947203c321417fb2739a9072ee5969b7ae017bb68c46969ceddccb0b3e8e27f0b79ba011065e9e0c0d6ec04c7735bc7d2d3d55119f3852c78264c40c9b36fffbc8741515d6d43f4aeba50186ceb45952617d8f4d15e0c0e84397d58aad6b9d8df15adc1f29c4c37addfb6f901d c2 = 0xca21ea2228e901614120f89036e62c36f385343c9b15a43c47d23097bb6eb6df4cc6aac315f283b35bf3e00612fea7ee2711248615c10b61475e96f57a94ecfb49b1b60495353c6232510e995251c6a3744193f0e3c10bc1cb9f8bbab19b7cd2a67fab178ca7fe6263aa22c460b0b51af14c9dc2adbe6aa9539e05b214dc1bf n1 = 99117167225742621252747360705927288427226074291111147359767727530232979959246961303002594953502494314944737381744946594792258965951764387793904602632138990093085873703735789929744541078195532792040220263365256453293757661668916687151993893223835585293806890903078811527485480385874789904018025085480072921947 n2 = 90708232882117493164546448126493812176926972474525609918179199222944319390160880291246879414964890005116911514705462257621255399480873008530781044973928567730151038933999620333681189161328502592514982955942546631546678204758589280772127887941509353870320299744541746637191024740549289281821158392283041483783 p = math.gcd(n1, n2) e = 65537 d = libnum.invmod(e, (p - 1)) m = pow(c1, d, p) print(libnum.n2s(m)) #make_all_modulus_independent
challenge 3
1 2 3 4 5 6 7 8 9 10 11 12
import gmpy2 n = 114515838473805006712847594704380677940280499969617865451903741803970304896753055873744402239365107537263730326351655179037631201887020732179784578687179230556396662015803684388855028443206818232761239630564571111262306517782298740762072717669765284942698987218518593869320732633953301487410854175666320988421 e = 3 c = 0xfec61958cefda3eb5f709faa0282bffaded0a323fe1ef370e05ed3744a2e53b55bdd43e9594427c35514505f26e4691ba86c6dcff6d29d69110b15b9f84b0d8eb9ea7c03aaf24fa957314b89febf46a615f81ec031b12fe725f91af9d269873a69748 for i inrange(200000000): if gmpy2.iroot(c + n * i, 3)[1] == 1: res = gmpy2.iroot(c + n * i, 3)[0] print(i, res) print(libnum.n2s(int(res))) break
#encrypt_exponent_should_be_bigger
challenge 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#共模攻击 from gmpy2 import * import libnum
n = 82359994555957061700863027886322811457676109608256083872064055426219259168794095530809575147825700925031273940545355557102788577532782300265260138429958167909187144110770618006792214374768047428973415244582649583493180328548963991180770977787901825467721537824736537797481709634514539903832239828285924506839 e1 = 108289 e2 = 81013 s = gcdext(e1, e2) s1 = s[1] s2 = -s[2]
from Crypto.Util.number import long_to_bytes from gmpy2 import gcdext m = 1528637222531038332958694965114330415773896571891017629493424 b0 = 69356606533325456520968776034730214585110536932989313137926 c = 93602062133487361151420753057739397161734651609786598765462162 winv = gcdext(b0, m)[1] v = c * winv % m >> 1#乘上w的逆元再除以2 flag = 'hgame{' + long_to_bytes(int(bin(v)[2:][::-1], 2)).decode() + '}' print(flag) #hgame{1t's_4n_3asy_ba9_isn7_it?}
Sign In Pro Max
附件如下
1 2 3 4 5
Part1, is seems like baseXX: QVl5Y3BNQjE1ektibnU3SnN6M0tGaQ== Part2, a hash functionwith128bit digest size and512bitblock size: c629d83ff9804fb62202e90b0945a323 Part3, a hash functionwith160bit digest size and512bitblock size: 99f3b3ada2b4675c518ff23cbd9539da05e2f1f8 Part4, the next generation hash functionof part3 with256bitblock size and64 rounds: 1838f8d5b547c012404e53a9d8c76c56399507a2b017058ec7f27428fda5e7db Ufwy5 nx 0gh0jf61i21h, stb uzy fqq ymj ufwyx ytljymjw, its'y ktwljy ymj ktwrfy.
1 2 3 4 5
Part1是base加密:base32+base58+base64 f51d3a18 Part2,a hash functionwith128bit digest size and512bitblock size 是md5 f91c Part3,a hash functionwith160bit digest size and512bitblock size 是sha-14952 Part4,the next generation hash functionof part3是sha-2,256bitblock size and64 rounds是sha-256 a3ed 最后一句是凯撒加密,位移5,Part5 is0bc0ea61d21c, now put all the parts together, don't forget the format