Magicians love to create things out of thin air. This time our secret wizards have created a playground. Test out your wizardry here! Comment Suggest edit
Author: jloh02
nc challs.nusgreyhats.org 31113
Solve
Basicailly its a math question, finding cofficients of quadratic, cubic and quintic equation. I used chatgpt to write the script ot calculate the cofficient.
Note, I dont fully understand the math behind this, was just solving cause my team were busy with other challenges.
Script
from pwn import*host, port ="challs.nusgreyhats.org",31113conn =remote(host,port)conn.recvuntil(b"Here's your first problem...\n")deflevel1(root1,root2): sum_of_roots = root1 + root2 product_of_roots = root1 * root2 b_over_a =-sum_of_roots c_over_a = product_of_roots b = b_over_a c = c_over_a a =1return a, b, cdeflevel2(roots): sum_of_roots =sum(roots) product_of_pairs = roots[0]* roots[1]+ roots[0]* roots[2]+ roots[1]* roots[2] product_of_all = roots[0]* roots[1]* roots[2] b_over_a =-sum_of_roots c_over_a = product_of_pairs d_over_a =-product_of_all b = b_over_a c = c_over_a d = d_over_a a =1return a, b, c, ddeflevel3(roots): sum_of_roots =sum(roots) product_of_pairs =sum(roots[i] * roots[j] for i inrange(len(roots)) for j inrange(i +1, len(roots))) product_of_triples = sum(roots[i] * roots[j] * roots[k] for i in range(len(roots)) for j in range(i + 1, len(roots)) for k in range(j + 1, len(roots)))
product_of_all = roots[0]* roots[1]* roots[2]* roots[3] b_over_a =-sum_of_roots c_over_a = product_of_pairs d_over_a =-product_of_triples e_over_a = product_of_all b = b_over_a c = c_over_a d = d_over_a e = e_over_a a =1return a, b, c, d, edeflevel4(roots): sum_of_roots =sum(roots) product_of_pairs =sum(roots[i] * roots[j] for i inrange(len(roots)) for j inrange(i +1, len(roots))) product_of_triples = sum(roots[i] * roots[j] * roots[k] for i in range(len(roots)) for j in range(i + 1, len(roots)) for k in range(j + 1, len(roots)))
product_of_quadruples = sum(roots[i] * roots[j] * roots[k] * roots[l] for i in range(len(roots)) for j in range(i + 1, len(roots)) for k in range(j + 1, len(roots)) for l in range(k + 1, len(roots)))
product_of_all = roots[0]* roots[1]* roots[2]* roots[3]* roots[4] b_over_a =-sum_of_roots c_over_a = product_of_pairs d_over_a =-product_of_triples e_over_a = product_of_quadruples f_over_a =-product_of_all b = b_over_a c = c_over_a d = d_over_a e = e_over_a f = f_over_a a =1return a, b, c, d, e, fwhileTrue: p ='' p = conn.recvuntil(b'Present the coefficients of your amazing equation: ') p = p.split(b'\n') roots = p[2] levels =int(p[1].strip(b':').split(b' ')[1]) numbers = roots.split(b' ')[1].split(b',')if levels <21: conn.sendline(f'1,{int(numbers[0]) *-1}')elif20< levels <41: a,b,c =level1(int(numbers[0]),int(numbers[1])) conn.sendline(f'{a},{b},{c}')elif40< levels <61: a,b,c,d =level2([int(numbers[0]),int(numbers[1]),int(numbers[2])]) conn.sendline(f'{a},{b},{c},{d}')elif60< levels <81: a,b,c,d,e =level3([int(numbers[0]),int(numbers[1]),int(numbers[2]),int(numbers[3])]) conn.sendline(f'{a},{b},{c},{d},{e}')elif80< levels <100: test = [int(numbers[0]),int(numbers[1]),int(numbers[2]),int(numbers[3]),int(numbers[4])] a,b,c,d,e,f =level4(test) conn.sendline(f'{a},{b},{c},{d},{e},{f}')if levels ==100: test = [int(numbers[0]),int(numbers[1]),int(numbers[2]),int(numbers[3]),int(numbers[4])] a,b,c,d,e,f =level4(test) conn.sendline(f'{a},{b},{c},{d},{e},{f}') conn.recvuntil(b"Here's your flag!\n")print(conn.recvline())quit()