a = int(input("Input the exponent: ")) print("i **", a, "=", i_pow(a), sep=" ")
题目:XYCTF 2025 - Misc - sins
题目内容:(没必要看)
1 2 3
“Come now, let us settle the matter,” says the LORD. “Though your sins are like scarlet, they shall be as white as snow; though they are red as crimson, they shall be like wool. - Isaiah 1:18
print('For there are three that bear record in heaven, the Father, the Word, and the Holy Ghost') print('But here we have four cases bearing witness')
defi_pow(n): if n % 4 == 0: # as the 40 days of flood return'1' elif n % 4 == 1: # as the 1 true God return'i' elif n % 4 == 2: # as the 2 tablets of stone return'-1' elif n % 4 == 3: # as the 3 days in the tomb return'-i'
inp = input("wash away your sins: ") assertall(i in"i0123456789+-*%/^=<>~&|:()[]'"for i in inp), "invalid char" assertlen(inp) < 16, "too long" R = eval(f"lambda i: {inp}", {}, {}) assertall(R(i) == i_pow(i) for i inrange(int.from_bytes(b'The_adwa_shall_forgive_thee') // 2**195)) print(flag)
题解 WriteUp
分析代码可知,我们需要编写一个 Python Lambda 表达式,题目对这个表达式的要求是:
只能包含 i0123456789+-*%/^=<>~&|:()[] 这些字符,不可以出现 逗号,、空格、除了 i 的其它字母 等等。