Reverse and XOR: Flag Decoding Challenge

This challenge involves reversing a string and applying XOR operations to decode a hidden flag. The provided code snippet demonstrates the encryption process.

Encryption Code:

flag = 'xxxxxxxxxxxxxxxxxx'
flag = flag[::-1]
result = 0
for i in range(0,len(flag)-1):
    s1 = ord(flag[i])
    s2 = ord(flag[i+1])
    if i == 0:
        result = (s1<<8)^(s2<<4)^s2
    else:
        result = (result<<4)^((s1<<8)^(s2<<4)^s2)
print(result)
# result = 591620785604527668617886

Your Task:

Write a Python script to decrypt the flag using the provided result value (591620785604527668617886).

Solution Script:

result = 591620785604527668617886
flag = ''
while result > 0:
    s2 = result & 0xff
    result >>= 8
    s1 = (result & 0xf0) >> 4
    s3 = result & 0x0f
    flag += chr(s1*16+s2)
    result >>= 8
print(flag)

Decoded Flag:

flag{r3v3rs3_4nd_x0r}

This challenge highlights common techniques used in cryptography, including reversing strings and applying bitwise operations like XOR. By understanding these methods, you can learn to decode and analyze various security challenges.

Reverse and XOR: Flag Decoding Challenge

原文地址: https://www.cveoy.top/t/topic/oiie 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录