kor*_*ora 2 python reverse-engineering
逆向工程:
是否可以编写一些python代码来获取未知的c变量值!
方程:(((ord(c) << 5) | (ord(c) >> 3)) ^ 111) & 255 = 233
这是我的逻辑:
ord(c)<<5 = a这会给我们ord(c) = a >> 5的话c = chr(a >> 5)(ord(c) << 5) | (ord(c) >> 3))会回来 (ord(c) << 5)& 做一个"按位和",但是&不可逆.如果有人帮助我,找出并解决方程,我会很高兴的.
这就是整个问题的pastebin链接
是的,可以反转方程式,但仅限原始值<= 255.
def fwd(c):
return (((ord(c) << 5) | (ord(c) >> 3)) ^ 111) & 255
def rev(ans):
i = ans ^ 111 # perform the xor first, then the bit-shifts after
return ((i << 3) | (i >> 5)) & 255
print(fwd(chr(0xa5))) # sample byte to test this out with =>219
print(rev(219)) # can we reverse 219 to get back to 0xa5 or 165?
print(rev(233)) # now for the value from the OP
Run Code Online (Sandbox Code Playgroud)
输出:
219
165
52
Run Code Online (Sandbox Code Playgroud)
似乎未知的c是52(或ascii中的字符'4')
为了防止pastebin链接消失,看起来OP正在尝试对密码进行反向工程:
secret = [233, 129, 9, 5, 130, 194, 195, 39, 75, 229]
inp = ''.join(chr(rev(s)) for s in secret)
print(inp)
Run Code Online (Sandbox Code Playgroud)
输出:
4w3SomeB!T
Run Code Online (Sandbox Code Playgroud)