彩笔
2022-12-15

rCTF2022密码学习

碎碎念:

rCTF一Misc题(feedback)flag就在给的链接里 但只有1/7的队伍做出来
令人唏嘘

ezPVZ应该第二关需要单独修改数据且如果发现不是所修改的数据应该还原回修改前的状态,或者使用时间齿轮,不然会闪退

题面

guess

Can you guess it? OwO
nc 190.92.234.114 23334

Crypto_guess_payload是f61d写的 加了些注释方便自己学习, 非预期解

Thr — 2022/12/17 04:31

If you just stare at the guess challenge, you can’t understand the intent because it doesn’t work exactly as author intended
It was expected to be a difficult challenge, but due to a stupid mistake, the solution is very simple

Shadowwws — 2022/12/17 01:59

this is rctf_ in increasing order by ascii value
Tr:这是按 ascii 值递增顺序排列的 rctf_

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
# nc 190.92.234.114 23334
控制台测试后返回的结果
q = 791985421179360689560703292714936952174214706011
T = [687389374070793745608366173478847219133847752342, 148590987283476044133101935375756165664783673752, 784392004785393404485830658895671207295260347718, 235022566135895330511553214902835196820734396613, 16218048682530523514225399085269661293528606569, 788874394822905148540107611798233724443767953932, 15269640353640111378997754170382041458989544553, 30886132099470743925485139708047885189639441574, 532788759672326845559913320275260749880181539579, 662140136411549634985066770585710914277832755203, 117066081828359056986114035139023801093078750722, 684475140743747781984169837795870167223794167462, 179498553567808393768939433049295644610117602432, 393982000294754398306780674368422917365011955241, 31796929643669670050880466265900216198619636710, 250790178362771218697794903975549256318799040292, 747104066998256925123412873324651199898520327580, 451239066708254897614717171993474979080838707483, 114819318350415279179997506867421609982087283622, 73840617095420511181676972086303868313741827818, 121689020309766913504856401840433099812155795942, 386367671563453771080486215551961490187141071188, 605026913996676793242873719734852463953582583289, 789107510266866575423558418737430032413362987082, 262653761971162958214390304326209982811981655483, 15310006345664873449925474785704428687793880201, 711070944168345655472710171081018642056489401961, 772592061455002063411227661074527421616128511859, 267436376509814049006455202892609058372860757044, 613728623311273878401399549846204826258987284023, 730859104098445325072320673938479353660625003944, 613076697578822110540196439202612114174674394895, 661142732741960454238883381927920740639398459593, 213239100206145828369936380257487889913507439022, 105670467078782480704992401679932214405980493586, 392190013580106344891470079352622555135040493932, 426850371433861625664450692728596526913013081637, 323064802925362396328824176654583697357911510238, 550561691173711236641598158962801373467135473786, 765276108794413757399949760082346692135776673154, 538739836386265479423914663703941494202025819949, 386796731718487395681678208096630359590125803655, 293167264481502671761181616963858983508746436412, 620172260844788849968537485129937722989031659492, 463584821266055916079985709538233601600564876204,
126095290614894269309948363290984138215143753669, 114401599786639801568460901327861781266292576007, 500142845606317140469931246824912993833861238964, 686888217977664505793890871364195175592509400052, 546838778470030355696129335937096151735479284476, 18354766489874630467046006175271857636422573480, 366047662932711672149621633445066064765288396864, 603055642650093117113233464452229122868635575890, 270224257074219398914219496533148577051570247329, 125002405344117886394194303190596310509688869137, 70201301887963774951225786457996357972031708472, 82668695511202372302087976909922010982275534484, 635935477069788764042322625434595558804224881696, 757846477696211668794763728472403936813270022806, 208475044917038905862193592195625297647984045191, 91168103025941478066462612459475250973455567140, 40855195748235855149410324860643052535409655176, 228962740599413128638754393025724129159651687437, 370183179151359464712545324218891653886503779495, 513137243380566726892064282317503839965413954351, 445034878483775072558491813149478776689819671518, 127027507310966119804804411760272287009965037570, 722391156067789383135351106918663079877699216864, 618266096061811454287696379984084640943371516398, 724876542116949198330706934003286540762576529604, 433501905574672335845296042705106819485897114913, 518810714058517824604960149242050166262356143760, 699486964938388550986876611796749730497168927766, 786499166491365310745821258021462696978230695264, 378632707569584052495256755673680823406023051368, 297390843388625627654106641020691327511712918756, 199167537340346661738887864127173042263453128549, 304011275786865506832270143495748884997275651595, 524368827420566653849937001847082000130061500564, 133202414389835135825011149299308307042933709489, 102819181636508442192906918253885287780402893696, 127102817960317821491381946718817446847824278438, 16247832800609837350480819429445804404244000386, 366703243501494269716871191893004520785061515489, 531663072026633098954739544851070620242098088015, 481796734664890505884764143567925822468228952314, 592557595496256433486314149473892838712753186521, 334786893534330951913803578304874431562278353561, 701934288388191323390258074961301466712044243205, 377494803775243176859218689144245091510048037224]
U = [193091050308013228888464448608678526694981857425501392082021669772895880970949164286878404412853, 41739937920419613937133725174405437312068910952826383829015527345072851118958742107833783257025, 220339565565674700248384022862624632042605531176988129632271448910687544998979892989274944546002, 66018992805365652530088480511015121575750189318998553292758419106125563377656535187488036458805, 4555729506714475088218535100332606280025688191594125299525375731970465350564650010198134914507, 221598690936070925305831886763926718643308646257221105087539901766169969085726659931442761256828, 4289316950375690335532244549978472897610709675814156887010050375173610466846708233125224367189, 8676066159883112252012436825903073173375187645493212611382736104352576889421081424187026421939, 149662978623289032540176447406991125813030589224739553876382825999023859422508843694040500939757, 185998415473949045989371142948827156998468660170599512468762165507012624899596294763686351432815, 32884437188512110265665583171396802031810504480657934264446179848685966503384505709480509656224, 192272427857349672978253211529337343845919395424281645442977717629628624546926819085427786468517, 50422025048073748667775647116572587725356246017098578465959312006226044894472335676425969508119, 110671478362904189744679580111891265569627353114532357478131448201377168648047668153036660246359, 8931913662130386362317175115063281559584911729326313147047008500814425785029977656315706231636, 70448192500011175210213426125388756816334592613779616001782458443970924407648252182009598294239, 209865200754797484255850789972615589264831171553724282215307522210866596240706456996003576086991, 126755269454792449970564345777012158014591745505213801991643344610208130176372175140011083603760, 32253310295786577772564131488980145764307549734977005724922122092992916182727252047466935481436, 20742191904872486628241813824494779831279573052065503778446720425507037861198990769348616583072, 34183043306901774972460615555190129723447736824047641000657009810241507193500947208394604297977, 108532576035377231133483751447191773072471647977062571802471216498293766236427965832426224715391, 169955030867559728443429577190165063088663904786463588889439224977690389800205508988456430136786, 221664174208893375003554847461288224621961331778357543329735565692844481896141617081258808204772, 73780731386661709289931935682796368548402929650633918613972354248274854920793736358744713937951, 4300655955735385440675890343536316386662955423123833757136600820526426279516391006570630212582, 199743319626636997015328192373733333098764718256437942981400718817361551552948542556167741777106, 217024903545592844480461473089800142688397372860459847330410448426303204965797673827011138264897, 75124191293551984687730781638824107422501576303545699242587243986461988372687547774248128499778, 172399383740051947369706943256513951682363397764731154587156751173963152975067501819126930707260, 205301910912298001929342524424557279017679419786805968312136499241851931687028288151057945732320, 172216254600803763002477411312096142432450013777944627478258114086934258801653196297468648592084, 185718239885837311773960876494308523769602572341749872034431315279651672918397151003466633728322, 59899910267306283997647254307520520134056360955043957316958807599002887916139518331552664600102, 29683353052063688053531915920244298818239976621209751387892722957825904292397790704877871585838, 110168100495975215914097591221204193405169663253138903900698413731663579242420180325650836644178, 119904365201958197399193077552809208315379269327248139416883131967370890107986313650602624946252, 90750489413275339291973067835520043251744959389260061138875824346043310838020976725744986269707, 154655482348406622890741390312346921540770373087533194730069129252021364161170049829391905104329, 214969816521377057695799114545830902750274358997099204957902300275283836824084418481631765537286, 151334665292451343218541973461434187404086216985323559694530060104424979516674529351103911516018, 108653101139642560000377907782264046849880816268917307218897300104913245161695182568065176842444, 82352124065319690094786265619789871830070053770164274400051967602392238372358365362687580570281, 174209433161942489242982638649860723463927792619187297109989507850149786483970744634202818172316, 130223252528626274698029142445607536191776328429990453648790917375640058404662070288096233531706,
35420786270717835649094670034551057453676230149896369743559450532051933854933834214351638415602, 32135971100193695507998401864238643703546409600858307810797546097316686019442935323810095045145, 140492581068348432198760748700997294862899596648506206411833200791980185614416439211336963364949, 192950273100740572878362101890086998448051794536825368032496641644723094958351433977358629282393, 153609697890172109171710927410362352574040782238498745250976523483262903319086087788592205520647, 5155944030236360719821729909438710460622430840257607361843887086779949505629032157319751104296, 102824585838290193204943949641230950674498696380347845223802880184168900336410402960504261341697, 169401291067219532502823996817195535977880230518458260479645600146215333753543381290638347142175, 75907320632788591907214993275691240856015768939608991056221850983850926515025105859763013458350, 35113789432011050872175046396633056539174031156267821118481855948573947118670865074401614706173, 19719890393797086002115198232713136516087972017329642402023185169689315148781746048749029964134, 23222042478368932853162654666288434500294724961253063262094347851648532948484015744234482127176, 178637397998076363738072161143020166658021410296000750470210702970495840542072593472223933495604, 212882796665866211361062005691533513171210236529206615726382386349302732713576121809661258490099, 58561663744740222629334837157967207932252252535166246251556037754645070994433805292841774497905, 25609567781964580960143043337243405594220123667952364318031106904986380757776294225070015032011, 11476425087644544472669950195538885728882539456773657813020343604992364043350003451979634220625, 64316758057986272001212792727553560375677791154147535048046127853101181834957112887708401120705, 103986272649792003515403291793115515821447954959962072646941633898606149445404316488386460415758, 144142771206567751527598433722442332451136178425437438737481904386517286428460079723971187716400, 125012482519523301110210191491818597414935878399154595115175294622926947514971899991615337755815, 35682650517895798588011089702038316387046390937748585071656137438860368957277585026161722666155, 202923222732249656016985479738839794677530497865983260894915656286404819529716910470187652693824, 173673982114997232212177497408887758391668518703760417216865480180160519811462201883139219364619, 203621379876883851302962323712305390858511149251242860193483453687175707956534064312653161329082, 121772813801625485699449708359386566914063138117767491946631438841764012041580623261406370009171, 145736476977155454746382600543570465908701482429280998442952185638269741454939049093583412562224, 196489322982766466372664140638168011550625821689584535828131848402755226739696085730975741733879, 220931477635198539961706820753516837757921204955162628561021570703440284629472228967053975765820, 106359786670266753207562101938836083641453603920332459861181652489435800512463585863821472225463, 83538548118408341428111545248823780511479478393364894424840082839229279434948332283086482161755, 55947139165912205398003754054020559870985522154574570305740641351270923488817457725259621494382, 85398260085875678515685838298352527106746778164892982339466719219968217912501044619725415064042, 147297778311293448948034455774989894442419178517226630948890447460907022144242181679160206215293, 37417212235590329115148310968135559958335424514905566266212642522120429158935027410456856518624, 28882412971311231482575103275695593600969449521199102290520247535811961883425248883755706447910, 35703805649079425123455913785906774794669776989629829560107151605297504690481080279268686026148, 4564096011725127606792289881567879226611387595922333603490967787044026130560098036359386785733, 103008741639009218278011953090969374697263669203178890009146725933230337615705542211648766798149, 149346767436405927735920043062667499806946271219292027838399581906346594150768470549838714805011, 135339068424170482227265259615107107854923593923672976241707994760027915863052450253784365132444, 166452338075536238395033508208267787888371213092892075222190588890154712184050789896541916380405, 94043282221647043414739539594976106567334808737112980053573556573424719769876418439894783371877, 197176788156351153440542487582833909600440029947913027096337550921321602378712992875686702257187, 106040143907246496732240787037359743361230151137702099201436574884090733904550622876337466172907]
# 已知一个q,多组T,多组U,求x的值
# 检测T中有几个元素 语法为len(set(T))
print(len(set(T))) # 90
print(len(set(U))) # 90
'''
from Crypto.Util.number import *
from pwn import *


r = remote('190.92.234.114', 23334, level='debug') # 本地调试 debug下 自动打印接收到的数据
for i in range(3): # 3组数据
exec(r.recvline()) # 执行一行 ;exec()函数用来执行一个字符串表达式,并返回表达式的值; recvline()接收一行 -> 这句也就是执行了接收到的str, 也就刚好存下了q,T和U
r.recvuntil(b'x = ') # 接收到x = ; recvuntil()接收到指定的数据
k = [long_to_bytes(j) for j in set([U[i]//T[i]
for i in range(90)])] # 求出k -> k= U/T
k = k[0].decode() # 转换为字符串
k = k.split('_')[0] + '_cfrt' # 拼接 _cfrt 原因暂时未知
print('k=', k)
print(str(bytes_to_long(k.encode())).encode())
r.sendline(str(bytes_to_long(k.encode())).encode()) # 发送
print(r.recvall()) # 接收所有