【问题标题】:Reverse Bitwise Operators反向位运算符
【发布时间】:2018-07-08 15:31:18
【问题描述】:

逆向工程:

是否可以编写一些python代码来获取未知的c变量值!
方程:(((ord(c) << 5) | (ord(c) >> 3)) ^ 111) & 255 = 233

这是我的逻辑:

  1. ord(c)<<5 = a 这将给我们 ord(c) = a >> 5 ,然后是 c = chr(a >> 5)
  2. 通常(ord(c) << 5) | (ord(c) >> 3)) 将返回(ord(c) << 5)
  3. & 执行“按位与”,但 & 不可逆。

如果有人帮助我找出并解决方程式,我会很高兴。
这就是整个问题 pastebin link

【问题讨论】:

    标签: python reverse-engineering


    【解决方案1】:

    是的,可以反转等式,但前提是原始值

    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
    

    输出:

    219
    165
    52
    

    似乎未知的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)
    

    输出:

    4w3SomeB!T
    

    【讨论】:

    • 谢谢你,非常感谢你的帮助,你让我很开心。
    • 很高兴为您服务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-09
    • 2013-03-29
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多