初次接触CTFReverse,啥也不会,到处碰壁;
本题是关于pyc文件的处理以及需要一些逆向思维;
需要先了解pyc文件如何转成py文件
之后在pycharm中打开该py文件获得下面代码:
from flag import *
length = len(flag)
arr = []
enc = [238, 257, 150, 137, 167, 169, 184, 193, 210, 147, 219, 128, 140, 135, 185, 242, 204, 128, 132, 159, 222, 173, 226, 159, 207, 169, 154, 156, 216, 139, 168, 187, 220, 237, 207, 187, 218, 138, 218, 178, 246, 239, 246, 241]
for i in range(length):
arr.append(ord(flag[i]))
for i in range(0, 16):
for j in range(0, length):
arr[j] += enc[j]
enc[j] += enc[j]
enc = enc[::-1]
print(arr)
以及获得的上边代码的有关输出:
刚看见这个代码一脸懵,本来还以为能运行呢,没想到又入坑了;
通过分析输出,我们发现,arr列表有44个元素,同时enc列表也有44个元素,这句代码:length = len(flag)是重点,arr列表经过length次循环后获得了元素,并且都是以flag[i]转换的十进制作为其元素,如此一来,问题的答案便浮出水面了。
我们可以知道flag有44个字符,并且最终的输出是通过
for i in range(0, 16):
for j in range(0, length):
arr[j] += enc[j]
enc[j] += enc[j]
enc = enc[::-1]
print(arr)
进行的,并且我们已经知道了arr列表最终的元素,那么就需要逆向推出其原来的元素了,直接上代码:
arr=[15728448, 16362025, 13718731, 13740602, 11425044, 13216326, 10048823, 13740603, 12757531, 12255100, 15138636, 12408061, 11228430, 10289095, 10114289, 14723575, 11272070, 9524519, 10267251, 12517282, 11796345, 13653174, 12495389, 13172636, 11468724, 9458930, 8956506, 12320680, 15291551, 11119205, 9568155, 10201663, 10398270, 14745427, 10944395, 13260012,13194479, 11053619, 12145871, 11184688, 11359448, 11774503, 16602251, 15662990]
enc = [238, 257, 150, 137, 167, 169, 184, 193, 210, 147, 219, 128, 140, 135, 185, 242, 204, 128, 132, 159, 222, 173, 226, 159, 207, 169, 154, 156, 216, 139, 168, 187, 220, 237, 207, 187, 218, 138, 218, 178, 246, 239, 246, 241]
for i in range(0, 16):
for j in range(0, 44):
enc[j] += enc[j]
enc = enc[::-1]
print(enc)
for i in range(0,16):
enc = enc[::-1]
for j in range(0,44):
enc[43-j]=enc[43-j]/2 #注意不要写成-=,否则全为0,这一个坑一定要躲过去!!!
arr[43-j]-=enc[43-j]
print(arr)
print(enc)
最终输出的arr=[48.0, 120.0, 71.0, 97.0, 109.0, 101.0, 123.0, 98.0, 51.0, 55.0, 51.0, 101.0, 100.0, 100.0, 54.0, 45.0, 50.0, 99.0, 101.0, 97.0, 45.0, 49.0, 49.0, 101.0, 99.0, 45.0, 56.0, 100.0, 51.0, 100.0, 45.0, 48.0, 50.0, 52.0, 50.0, 97.0, 99.0, 49.0, 51.0, 48.0, 48.0, 48.0, 51.0, 125.0];这些全部都是十进制数字,需要再转为ascII码即可得出flag:
0xGame{b373edd6-2cea-11ec-8d3d-0242ac130003}
|