Skip to content

Commit 2671978

Browse files
committed
pass
1 parent 2fa51a0 commit 2671978

1 file changed

Lines changed: 44 additions & 8 deletions

File tree

lab8/solve.py

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
#!/usr/bin/env python3
22

3-
import angr,sys
3+
def solve():
4+
# 我們需要找到滿足以下條件的 8 個字元:
5+
# 1. (input[0] ^ input[1]) == 0x55
6+
# 2. (input[2] + input[3]) == 200
7+
# 3. (input[4] * 3) == input[5]
8+
# 4. (input[6] - input[7]) == 1
9+
# 5. (input[1] + input[2] - input[3]) == 50
10+
# 6. (input[5] ^ input[6]) == 0x2A
11+
12+
# 嘗試所有可能的值
13+
for a in range(32, 127): # input[0]
14+
for b in range(32, 127): # input[1]
15+
if (a ^ b) != 0x55:
16+
continue
17+
18+
for c in range(32, 127): # input[2]
19+
for d in range(32, 127): # input[3]
20+
if (c + d) != 200:
21+
continue
22+
23+
if (b + c - d) != 50:
24+
continue
25+
26+
for e in range(32, 127): # input[4]
27+
f = e * 3 # input[5]
28+
if f < 32 or f > 126:
29+
continue
30+
31+
for g in range(32, 127): # input[6]
32+
if (f ^ g) != 0x2A:
33+
continue
34+
35+
h = g - 1 # input[7]
36+
if h < 32 or h > 126:
37+
continue
38+
39+
# 所有條件都滿足,輸出密鑰
40+
key = chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g) + chr(h)
41+
return key
42+
43+
return "No solution found!"
444

5-
def main():
6-
secret_key = b""
7-
sys.stdout.buffer.write(secret_key)
8-
9-
10-
if __name__ == '__main__':
11-
main()
45+
if __name__ == "__main__":
46+
key = solve()
47+
print(key)

0 commit comments

Comments
 (0)