바이너리에 숨겨진 keygen 알고리즘의 암호를 찾으려고합니다. 그래서, 나는 어셈블리에서 공식을 추출하고이를 해결하기 위해 작은 파이썬 스크립트 (정확하게, 희망) 번역 :Z3py 수식에서 ZeroExt (n, a)를 올바르게 사용하는 방법?
Traceback (most recent call last):
File "./alt.py", line 13, in <module>
state[i+1] = (ZeroExt(24, pwd[i])^state[i]) % 0xcafe
File "/usr/lib/python2.7/dist-packages/z3.py", line 3115, in __xor__
return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
File "/usr/lib/python2.7/dist-packages/z3core.py", line 1743, in Z3_mk_bvxor
raise Z3Exception(lib().Z3_get_error_msg_ex(a0, err))
z3types.Z3Exception: Argument (bvadd (bvxor pwd3 #x37) #xed) at position 1 does not match declaration (declare-fun bvxor ((_ BitVec 32) (_ BitVec 32)) (_ BitVec 32))
:
#!/usr/bin/env python
from z3 import *
# Password initialization
pwd = BitVecs('pwd0 pwd1 pwd2 pwd3 pwd4 pwd5', 8)
# Internal states
state = BitVecs('state0 state1 state2 state3 state4 state5 state6', 32)
# Building the formula
state[0] = (pwd[3]^0x1337) + 0x5eeded
for i in range(6):
state[i+1] = (ZeroExt(24, pwd[i])^state[i]) % 0xcafe
# Solving the formula under constraint
solve(state[6] == 0xbad1dea)
불행하게도, ZeroExt(n,a)
다음과 같은 오류 메시지를 생성하는 것
내가 뭘 잘못했는데이 문제를 해결하는 방법은 무엇입니까?
참고 : 도전 과제의 상수를 변경하여 쉽게 찾을 수 없도록했습니다 (속임수가 아님!). 그래서,이 문제는 만족스러운 해결책이 없을 수도 있습니다 ...
물론 !!! 'pwd [3] '을 확장하는 것은 ... 나는 단지 때로는 맹목적이다! 죄송합니다!!! 젠장 ... 고마워! – perror