""" The New Zealand Herald published on March 7, 2009, identified RPM as the last season of the Power Rangers run. Production manager Sally Campbell stated in an interview, "...at this stage we will not be shooting another season."[buckeye{m1gh7y_m0rph1n_w1k1p3d14_p4g3}][23] A September """
import Crypto.Util.number as cun import random import ast
defevaluate_polynomial(polynomial: list, x: int, p: int): return ( sum( (coefficient * pow(x, i, p)) % p for i, coefficient inenumerate(polynomial) ) % p )
N_SHARES = 3
defmain(): print( f"I wrote down a list of people who are allowed to get the flag and split it into {N_SHARES} using Shamir's Secret Sharing." ) MESSAGE = cun.bytes_to_long(b"qxxxb, BuckeyeCTF admins, and NOT YOU")
p = cun.getPrime(512)
polynomial = [MESSAGE] + [random.randrange(1, p) for _ inrange(N_SHARES - 1)] points = [(i, evaluate_polynomial(polynomial, i, p)) for i inrange(1, N_SHARES + 1)]
print("Your share is:") print(points[0]) print("The other shares are:") for i inrange(1, len(points)): print(points[i])
print() print("Now submit your share for reconstruction:") your_input = ast.literal_eval(input(">>> ")) if ( type(your_input) isnottuple orlen(your_input) != 2 ortype(your_input[0]) isnotint ortype(your_input[1]) isnotint or your_input[0] != 1 ornot (0 <= your_input[1] < p) ): print("Bad input") return
points[0] = your_input
xs = [point[0] for point in points] ys = [point[1] for point in points]
y_intercept = 0 for j inrange(N_SHARES): product = 1 for i inrange(N_SHARES): if i != j: product = (product * xs[i] * pow(xs[i] - xs[j], -1, p)) % p y_intercept = (y_intercept + ys[j] * product) % p
reconstructed_message = cun.long_to_bytes(y_intercept) if reconstructed_message == b"qxxxb, BuckeyeCTF admins, and ME": print("Here's your flag:") print("buckeye{?????????????????????????????????????????}") else: print(f"Sorry, only these people can see the flag: {reconstructed_message}")
main()
简单来说就是要求我们输入一个新的秘密分片。从而将解的的秘密修改。但是我们不知道模数,这点就很烦了。
1 2 3 4 5 6 7 8 9
I wrote down a list of people who are allowed to get the flag and split it into 3 using Shamir's Secret Sharing. Your share is: (1, 4606841840792655741097335098615362105611241060090579768729749798744970453857096222319491682007964447453172274966991930716097294236308788531966428690778079) The other shares are: (2, 4756354074373237467895340117578308603595140714341760525573566385495771532267815165432109346493025885413182472403095126874117192693469522589916267535361022) (3, 448536700741745180394015056888839493951698962753542270531449760308834795408073603079157806360778988603183244270431724096406965890008305428978180913324978)
Now submit your share for reconstruction: >>>
现在我们直到三个密文,和三个x。对于这个x,我们在其解密算法中有:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
for j inrange(3): product = 1 for i inrange(3): if i != j: print(xs[i], xs[i] - xs[j]) print("\n")
output = [] for item in lines: output.append(list(map(int,item.split()[1:])))
for i inrange(len(output)): x = output[i] if i < 10: nonce = str(i) * 28 else: nonce = str(i) * 14
print("".join( chr(a^ord(b)) for a,b inzip(x, nonce) ))
""" indows of thine age shall se eDespite of wrinkles this th y golden time.But if thou li buckeye{some_say_somefish:)} ve, remember’d not to be,D ie single, and thine image d """
FLAG = cun.bytes_to_long(b"buckeye{??????????????????????????????????????????????????????????????????????}") c_1 = pow(FLAG, e, n_1) c_2 = pow(FLAG, e, n_2)
assertpow(c_1, d_1, n_1) == FLAG assertpow(c_2, d_2, n_2) == FLAG
from Crypto.Util.number import * from functools import reduce
e = 0x10001
deftransform(x, y): # 使用辗转相除将分数x/y转为连分数的形式 res = [] while y: res.append(x // y) x, y = y, x % y return res
defcontinued_fraction(sub_res): numerator, denominator = 1, 0 for i in sub_res[::-1]: # 从sublist的后面往前循环 denominator, numerator = numerator, i * numerator + denominator return denominator, numerator # 得到渐进分数的分母和分子,并返回
# 求解每个渐进分数 defsub_fraction(x, y): res = transform(x, y) res = list(map(continued_fraction, (res[0:i] for i inrange(1, len(res))))) # 将连分数的结果逐一截取以求渐进分数 return res
defwienerAttack(n1, n2): for (q2, q1) in sub_fraction(n1, n2): # 用一个for循环来注意试探n1/n2的连续函数的渐进分数,直到找到一个满足条件的渐进分数 if q1 == 0: # 可能会出现连分数的第一个为0的情况,排除 continue if n1 % q1 == 0and q1 != 1: # 成立条件 return (q1, q2) print("该方法不适用")
if (this.drinks[var1].status == soda.Drink.DrinkStatus.DROPPED) { soda.printFlag(); } else { System.out.println(">> No flags in here... was the prophecy a lie...?"); }
} elseif (var1[0].equalsIgnoreCase("grab")) { if (var0.dropped > 0) { System.out.println(">> Alright!! Let's see what I got!"); var0.retrieve(); } else { System.out.println(">> There's nothing to grab..."); }
要求我们输入"grab"指令并且要有掉落的饮料才可进入。
那么这个drop要怎么修改呢。我们接着跟踪。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
} elseif (var1[0].equalsIgnoreCase("reach")) { if (bystanders) { System.out.println(">> I can't do that with people around!\n>> They'll think I'm stealing!"); } else { var6 = var0.reach(); var0.dropped += var6; if (var6 > 0) { System.out.println(">> Ok, here goes... gonna reach through the door and try to knock it down..."); pause(3); System.out.println(">> !!! I heard something fall!"); } else { System.out.println(">> There's nothing to reach for"); } }
try { var6 = Integer.parseInt(var1[1]); } catch (Exception var5) { System.out.println(">> Not sure what you mean"); return; }
pause(var6); if (var6 >= 10) { bystanders = false; System.out.println(">> ...Looks like nobody's around..."); } else { bystanders = true; System.out.println(">> People are walking down the street."); }