<style> h1 {text-align:center} p {text-align:center} form {text-align:center} </style>
<head> <body> <h1>Fully automatic rp system</h1> <p>Come and get your rp value today!</p> <hr></hr> <formaction="show.php"method="post"> <inputtype="hidden"id="rp"name="rp"value="rp"> <inputtype="submit"value="Get today's rp!"> </form> </body> </head>
<script> functionran(){ var rp = Math.floor( Math.random() * 100); document.getElementById("rp").setAttribute('value',rp); } ran(); </script>
<!-- ------------------------------------------------------- Maybe there are some Easter eggs? So where are them? -->
rp是0到99的整数,但是post100会得到
1 2 3 4 5 6 7 8 9 10 11 12 13
<title>W&M exclusive robot</title>
<style> h1 {text-align:center} p {text-align:center} </style>
<h1>Fully automatic rp system</h1> <p>Come and get your rp value today!</p> <hr></hr>
<p>Your rp value:100</p> <p>Wow! Golden legend!<!-- so why not try to post 'flag' as rp? --></p>
没有分析出什么东西,稍微梳理一下
0~19
Ah-ha! There is a idiot!
20~39
Gee, this is too miserable.
40~59
Oh, you almost passed it!
60~79
Fortunately, you passed 60.
80~99
You are Koi! Congratulations!
100
Wow! Golden legend!<!-- so why not try to post 'flag' as rp? -->
flag
1 2 3 4 5
Your rp value:1620418829165478
What happend to my bot?????
Let me find something in my backpack which can fix this bug!
defexDigit(String): d = 0 for j in String: if'0' <= j <= '9': d = d * 10 + int(j) return d
x = 999999999999999999999999999999999 url = "http://47.104.243.99:10000/show.php" r = requests.post(url, {"rp": 2017515922459700}) for i inrange(65537): if'flag'in r.text or'WMCTF'in r.text or'wmctf'in r.text or'1620418829165478'in r.text: print(r.text) print(x) line = r.text[205:][:37] t = exDigit(line) if t < x: x = t print(t) payload = { "rp": t } r = requests.post(url, payload)
# nc 47.104.243.99 9999 import random import string import sys import os from hashlib import sha256 import uuid from Crypto.Util.number import * from pwn import * from itertools import product
defproof_of_work(): # sha256(XXXX+cgDUNjezTPNSj91D) == 30fc93b19ef81e8755f3ee0e3df72722f66556b7636b5037f34d1beb981235b0 proof = sh.recvline() tail = proof[12:28].decode() HASH = proof[23:97] for i in product(string.ascii_letters + string.digits, repeat=4): head = ''.join(i) t = hashlib.sha256((head + tail).encode()).hexdigest() if t == HASH: sh.sendline(head.encode()) break
defproof_of_work2(): # sha256(XXXX+cgDUNjezTPNSj91D) == 30fc93b19ef81e8755f3ee0e3df72722f66556b7636b5037f34d1beb981235b0 proof = sh.recvline() tail = 'eqbj8j6Z9xvz3YiV' HASH = 'b5808aff39327c9ac49d209d10fe3e27c898d49faffc956bbf1d73523c44ce77' for i in product(string.ascii_letters + string.digits, repeat=4): head = ''.join(i) t = hashlib.sha256((head + tail).encode()).hexdigest() if t == HASH: sh.sendline(head.encode()) break
context.log_level = 'debug' sh = remote("47.104.243.99", 9999) proof_of_work2()
e = 0x10001 n = 124478026101165354098037876421627662624056206605515177686194103211430464934743129994417330643128683345849733014275487857184516763016301408033382676283620282332485581507315430690690813831282519976585364463744017296315372258981215919387679949709396064987889800074036410663927631478105899096723790945928412829187822284593750473740315866322998068351563015099367643886154042581191841533888375305195743073059105310700318861167337672659772641786687582718180589854118978820530842381081568922213227168617789474006973152602334271699398178963791154954792676067153150646411025449463253194489657095241613282942586704728903727611399 c = 90647155870804971113806442051901226002120015769259333554192477899450971338831255790857101662710560234954831825416787459228033373486077151217415092360097814474283515220281223555587026056325099266316005605716929634353603643319859645167427538563242884591102004934790399528462112789803351851769047685792159647390050985871679243422993775721776244067168064933786611606433105514418429089777322132633028815660525070271128628044386434106685643657668695364607215033856398608992051550288297119711825866170869469834444973857013360900452988222767960318998636640763573797297203544581343736625672669946528644260077687270041162148579 gift1 = 430643544402084432319325961880416327356872029175895120742910502784460696485981655831364057771978842374920289740546998744096646780935886278222230684528731470188637076148307527311922452490801045278988434801896164340653915198079023711297016090027381126073802620204314765869166624636941907534206046998568042400815444697126334029985946496452932477337335924863188276040631646131204436116708742280199903183210826719901897273260766069768314579353548171372586771188839003301749872795307598319516051259672117483195538538878148292313730887085591272354625175614366936749367007177827223031514498275753340915542939818624965339274541 gift2 = 279643881521430665779764628210196159031443254319916096260435206316116655701344325784134050728686231352816394212502789612947929220430466611004330150352137570405484127780364316335386736272544877793446702006665399064591475517610575894857804921152265901610537191780251376268112843688812459951190257679817490601282013470378644045696567456486059374094892490322848884260103728441765221196492288890565220765116737467020984854284776188063793107604665880577892150257025900438921323929874583349697921571156857890185078774883450481945134786456867498237937223992977125106207044050316201931335150865420643200300919950666792333800421 gift3 = 237902069859826089956710602458488697197969935460375469157966706791637991891038954423106099106663742928616105443683571279895168734280020803510641968762322744746722455831059684745613465616901995570874116303439549541932451281441959514629564655972962203744852006794160278105621063202850402448076034174743227230202591123961117876362833492478366233652816443873213201410433457033307944305406209168085355438156499669719905462067847881209129983251184647052314353242784174374088582263983943733709287614092898665984536781786084591414804290805713181580225096207601673326693693442261927044483426965621699507399608913104482509541829 gift4 = 131184496439376311814751172869309509301398236134030748081290782986296909958428702969677021306310259793511587606469385852829507392096577310273567455635233040499932518933927338330158300947934921792366825549482737059128276134653805578959896357503546949681198843822945160611138388841031519307824760189249466171835761078895545203381195921789823129815826662876576368032722825159838976137103324588326186884693453137115752294499574361951327089081432442184727065530788376603390307277709197418051468405219378610308912749832078805547917787498228816440083434077213552664217150489211767711038795362880479839885325109115335568243823
print(a) # a = 25582847577564670038612582668140373129129959651036453923605273284793860890291221263498753328353767798264241675861426056503889321642277844202986695039010291
a = 25582847577564670038612582668140373129129959651036453923605273284793860890291221263498753328353767798264241675861426056503889321642277844202986695039010291 n = 124478026101165354098037876421627662624056206605515177686194103211430464934743129994417330643128683345849733014275487857184516763016301408033382676283620282332485581507315430690690813831282519976585364463744017296315372258981215919387679949709396064987889800074036410663927631478105899096723790945928412829187822284593750473740315866322998068351563015099367643886154042581191841533888375305195743073059105310700318861167337672659772641786687582718180589854118978820530842381081568922213227168617789474006973152602334271699398178963791154954792676067153150646411025449463253194489657095241613282942586704728903727611399 pbar = a ** 2 kbits = 369 PR.<x> = PolynomialRing(Zmod(n)) f = pbar + x roots = f.small_roots(X=2^kbits, beta=0.4) # 967901962469872165537856438801710756065070673694594801499396171114255660549746759504438698205658088002955084386
接下来RSA的常规步奏得到password
Cou1d_I_get_Th3_passw03d_then_captu7e_the_fla9?
正如一开始所说的e是偶数,还是$2^{12}$,与$\varphi(p)=p-1$不互素
可以尝试平方根,有限域开方,12次Rabin
由于p % 4 = 3符合rabin最基本的条件,所以直接开12次方
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from Crypto.Util.number import long_to_bytes
p = 496584754781581997154645314415051021632937719346451955222548277806458479939882609131615548616817732786901123585586203791585231652481101508165523306207307511005218236201069837205145881515297396218450658339325435517394532697652694250302927324547950654199907918057947165277944713164863611463887879016367147027651 e = 4096 c = 202821697585498721190880385651888326819052363235092021514522019296117832067188656931773131985516119359273814956340533509702817980744398402155886334655033938474295749168241550740096583920405311629354495691732306096266636370938656838375279086916114964255411601403125984312042419408682006688199111243135798564394
mi = []
for i inrange(12): mi.append(pow(c, (p + 1) // 4, p)) mi.append(p - pow(c, (p + 1) // 4, p)) c = pow(c, (p + 1) // 4, p)
for i in mi: t = long_to_bytes(i) ifb'WMCTF'in t: print(t) break
有限域开方也可以
1 2 3 4 5 6 7 8 9 10 11 12
from Crypto.Util.number import * p = 496584754781581997154645314415051021632937719346451955222548277806458479939882609131615548616817732786901123585586203791585231652481101508165523306207307511005218236201069837205145881515297396218450658339325435517394532697652694250302927324547950654199907918057947165277944713164863611463887879016367147027651 e = 4096 c = 202821697585498721190880385651888326819052363235092021514522019296117832067188656931773131985516119359273814956340533509702817980744398402155886334655033938474295749168241550740096583920405311629354495691732306096266636370938656838375279086916114964255411601403125984312042419408682006688199111243135798564394 R.<x> = Zmod(p)[] f = x ^ e - c f = f.monic() res1 = f.roots() print(res1) # res1 = [(496584754781581997154645314415051021632937719346451955222548277806458479939882609131615548616817732786901123585586203791585231652481101508165523306207307511005218236201069837205145881515297396218450658339313214656968189495352306293673615992017103882095004555948437432049586089024300970437646867574391499674950, 1), (12220860426343202300387956629311332530846772104903362109509733228358624140562641026241011441975647352701, 1)] c = 12220860426343202300387956629311332530846772104903362109509733228358624140562641026241011441975647352701 print(long_to_bytes(c))