DCS-930L Camera/deobfuscate: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
(Created page with "<pre> # 'data' holds the content of the obfuscated configuration file def deobfuscate(data): r = [] for c in data: c = ord(c) c = (c + ord('y')) & 0xff...")
 
 
(No difference)

Latest revision as of 16:02, 28 January 2016

# 'data' holds the content of the obfuscated configuration file
def deobfuscate(data):
    r = []
    for c in data:
        c = ord(c)
        c = (c + ord('y')) & 0xff
        c = (c ^ ord('Z')) & 0xff
        c = (c - ord('e')) & 0xff
        r.append(c)
 
    tmp = None
    i = len(r) - 1
    while i >= 0:
        if i == len(r) - 1:
            x = r[i]
            tmp = ((x & 7) << 5) & 0xff
 
        if i == 0:
            assert tmp is not None
            x = r[0]
            x = (x >> 3) & 0xff
            x = (x + tmp) & 0xff
            r[0] = x
        else:
            c1 = r[i-1]
            c2 = r[i]
            c1 = c1 & 0x7
            c2 = (c2 >> 3) & 0xff
            c1 = (c1 << 5) & 0xff
            c2 = (c2 + c1) & 0xff
            r[i] = c2
        i = i - 1
 
    r = "".join([chr(x) for x in r])
 
    s = ""
    assert (len(r) % 2) == 0
    for i in range(len(r)/2):
        s += r[i+(len(r)/2)] + r[i]
     
    return s
</cut>