百度杯二月Reverse場Project的writeup
在看完題解之後學習的一發,然後全部按照自己的writeup再次整理做題,鞏固一發
開啟IDA和OD,希望搜尋到有用的字串(Input the flag的提示資訊),但是發現根本找不到,搜尋strings會找到這個:
根據查到的資料,這24個字元構成了一種編碼方式:base24
所以找到這個字串的使用的地方:00404820函式處
可以看到如下幾個特徵:
這兒是很明顯的兩位一個值,然後把v6和v7拼起來的(相當於base24解碼),最終存在了v15裡面(v5是個變數值,作為計數器使用的)
那麼,我們需要構造的輸入,是兩位兩位一組的,然後使用base24解碼,可以得到某種需要處理的值
看到這裡四個方向,然後v8的值是v15 & 0xf,主要是底下一個是加號,一個是減號,然後的跳轉都是LABEL_11
上面的兩個跳轉都是LABEL_14,可以猜想到是不是4個方向,上下左右控制的(百度杯好多這種方向題)
那麼,v8是控制步長的,v15>>4是控制方向的
看到0xC的404AA0函式,有這種的程式碼:
可以猜想,40A6EC這個值是記錄我在迷宮裡總共走了多少步的,40A018這個值是記錄我在迷宮裡的位置的(這個17,就會是一行總共17個元素,相當於向下走了一行)
根據這樣的方向,0xC對應向下,0xE對應向上,0xD對應向左,0xF對應向右
那麼地圖的資料從哪兒來的?
看到v3這個值,是由四個資料構成的,然後我們找到這些資料的所在地方,根據資料計算得到地圖:
所以起點在(1,0),終點在(15,16)
然後再看到我們的結束條件是什麼?
我們在迷宮中總的移動步數是54步,最終的位置座標是271,也就是(15,16)
那麼我們只需要得到行走的路徑(使用ACM的廣搜或者深搜都是可以的)
然後得到往上走幾步,往下走幾步的一個移動路徑,使得可以滿足:從起點到終點的移動總步數為54步
因為這個會是整數值,比如3表示往右走3步,17表示往下走一步
然後根據題意得四個方向以及base24編碼的加密原理,對我們的移動路徑加密即可
路徑為:
( 1 , 0 )--> ( 1 , 1 )--> ( 1 , 2 )--> ( 1 , 3 )--> ( 2 , 3 )--> ( 3 , 3 )--> ( 3 , 4 )--> ( 3 , 5 )--> ( 2 , 5 )--> ( 1 , 5 )--> ( 1 , 6 )--> ( 1 , 7 )--> ( 1 , 8 )--> ( 1 , 9 )--> ( 1 , 10 )--> ( 1 , 11 )--> ( 2 , 11 )--> ( 3 , 11 )--> ( 4 , 11 )--> ( 5 , 11 )--> ( 5 , 10 )--> ( 5 , 9 )--> ( 5 , 8 )--> ( 5 , 7 )--> ( 5 , 6 )--> ( 5 , 5 )--> ( 6 , 5 )--> ( 7 , 5 )--> ( 7 , 4 )--> ( 7 , 3 )--> ( 8 , 3 )--> ( 9 , 3 )--> ( 9 , 2 )--> ( 9 , 1 )--> ( 10 , 1 )--> ( 11 , 1 )--> ( 12 , 1 )--> ( 13 , 1 )--> ( 13 , 2 )--> ( 13 , 3 )--> ( 13 , 4 )--> ( 13 , 5 )--> ( 14 , 5 )--> ( 15 , 5 )--> ( 15 , 6 )--> ( 15 , 7 )--> ( 15 , 8 )--> ( 15 , 9 )--> ( 15 , 10 )--> ( 15 , 11 )--> ( 15 , 12 )--> ( 15 , 13 )--> ( 15 , 14 )--> ( 15 , 15 )--> (15 , 16)
路徑整數值為:
goto = [3,34,2,-34,6,68,-6,34,-2,34,-2,68,4,34,11]
最終的flag為:
X6T7X7W7X2T4V2T7V7T7V7T4X4T7XT
然後附錄上自己的py程式碼:
d_6a0 = [0x87,0xae,0x99,0x3c,0x59,0x41,0x2e,0x1d,0x84,0x23,0x30,0x23,0x26,0x10,0x83,0x5,0x29,0x9d,0xa0,0x16,0xdb,0x41,0x72,0xe7,0x4f,0x64,0x7b,0x8b,0xfe,0x4b,0xff,0x8b,0xf8,0x70,0xa8,0xf3,0x1d,0x20,0x4,0x2a,0x46,0x12,0x74,0x17,0xaa,0x2f,0x23,0xd,0x8e,0xce,0xd5,0x1c,0xe8,0x34,0x7a,0xfa,0x27,0x40,0xe2,0x81,0x3a,0xcb,0xaf,0xff,0x6,0x3,0xe0,0xdd,0x43,0xe9,0xd8,0x9b,0x39,0x52,0xdb,0x57,0x9c,0x73,0x98,0x80,0x46,0xdd,0xa5,0xd8,0xec,0x51,0xde,0x98,0xd7,0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13,0x1c,0x11,0x77,0x27,0x60,0x6,0x93,0x5f,0x56,0xe,0x7d,0x5c,0x29,0x7a,0x10,0x62,0x9e,0x87,0xa3,0xb9,0x6b,0x63,0xbf,0x53,0x4d,0xad,0x16,0xb0,0x15,0x7c,0x71,0xbf,0x2,0xa4,0x2b,0x46,0x55,0x74,0x9d,0x43,0xa1,0x83,0x99,0x94,0x62,0x2d,0x5b,0x14,0x4f,0x18,0x3c,0x7,0x33,0xbc,0x29,0xb8,0x78,0x22,0x94,0xa0,0x5,0x2b,0x69,0x8a,0x4a,0x55,0x44,0x75,0x18,0xba,0xa1,0x3a,0x77,0x99,0x94,0x2e,0x72,0x59,0xba,0xa,0xb6,0x4b,0x6f,0x9,0x9b,0x30,0x41,0x92,0x2,0xbb,0x25,0x97,0xa0,0x58,0xa9,0x3d,0x99,0xac,0x6a,0x7d,0x51,0x5f,0x7,0xa,0x3f,0x58,0x15,0xb4,0x3,0x47,0x14,0x4c,0x79,0xa9,0x62,0x89,0x8e,0x87,0x2f,0xaa,0x12,0x40,0xb1,0x9d,0x4f,0x89,0x99,0x20,0x1a,0xb2,0x85,0x26,0x27,0xab,0x77,0x7c,0x21,0x6,0x46,0xac,0x3a,0x3e,0x13,0x21,0x0,0xb9,0x7f,0x4d,0xb2,0x8a,0x1b,0x88,0x51,0x3a,0x21,0x3a,0x7a,0x48,0xa1,0x7a,0xb2,0xae,0xbd,0x77,0x83,0x26,0x19,0x17,0x7,0xad,0xe,0x5f,0x42,0x7,0x5e,0x13,0x34,0x3,0xad,0x9e,0x6f,0x40,0x2e,0x73,0x27,0x70,0x5b,0x75,0x48,0x1c,0x69,0x95,0x8c,0x29,0x3b,0x3a,0x4c,0x19,0x56,0xa5,0x16,0x94,0x95,0x55,0x1,0x29,0x1d,0x28,0x3d,0x90,0x94,0x44,0x6e,0x32,0x8e,0x35,0xbb,0x2a,0x88,0x57,0xa1,0x4e,0x99,0x77,0x8e,0xa9,0xa5,0xb5,0x2b,0x8b,0x14,0x6c,0xb9,0x44,0x43,0x15,0x9f,0x2c,0xb9,0xa9,0x2,0x66,0x5c,0x86,0x97,0xa6,0xa4,0x14,0xb5,0xb1,0x51,0xa8,0x6f,0xa4,0x19,0xa9,0x20,0x38,0xa5,0xb1,0x7]
d_410 = [0x4c,0x11,0x29,0x16,0x5d,0x51,0x4d,0x3e,0x6f,0x3e,0x59,0x65,0x57,0x2c,0x5d,0x2c,0x46,0x56,0x3b,0x41,0x40,0x0,0x36,0x25,0x50,0x5a,0x4c,0x33,0x79,0x28,0x46,0x5e,0x6f,0x20,0xd,0x3a,0x8,0x13,0x3f,0x3e,0x6d,0x50,0x2,0x48,0x15,0x46,0x19,0x61,0x74,0x68,0x35,0x42,0x6f,0x56,0xd,0x18,0x14,0x39,0x30,0x5,0x8,0x6e,0x1a,0x67,0x40,0x68,0x6,0x5c,0x74,0x4f,0x4,0x6,0x51,0x6d,0x4b,0xb,0x6f,0x4b,0x50,0x60,0x2,0x17,0x18,0x48,0x54,0x49,0x4a,0x17,0x73,0x7,0x8,0x3c,0x26,0x45,0x7f,0x7e,0x26,0x30,0x3d,0x6,0xb,0x4d,0x43,0x1e,0x5,0x5d,0x5c,0x38,0x4c,0x5,0x2d,0x32,0x5a,0x2b,0xc,0x58,0x57,0x23,0x16,0x2b,0x55,0xb,0x7b,0x61,0x3d,0x73,0x1d,0x2c,0x9,0x42,0x5a,0x3f,0x34,0x54,0x25,0xf,0x6f,0x68,0x5c,0x56,0x16,0x3a,0x55,0x5e,0x62,0x6c,0x3b,0x7c,0x60,0x2a,0x18,0x5a,0x22,0xe,0x32,0x7a,0x34,0x41,0x1b,0x78,0x51,0x64,0x4,0x10,0x57,0x2e,0x52,0x5f,0x79,0x56,0x74,0x6e,0x34,0x33,0x73,0x6c,0x4,0x22,0x4a,0x3b,0x57,0x28,0x79,0x2f,0x42,0x58,0x55,0x12,0x73,0x77,0x22,0x6b,0x67,0x5f,0x63,0x7f,0x5d,0x21,0x71,0x19,0xa,0x6e,0x4b,0x7,0xe,0x38,0x2d,0x65,0x27,0x14,0x64,0x1e,0x24,0x63,0x60,0x2f,0x1d,0x31,0xb,0x2e,0x62,0x5d,0x59,0xb,0x31,0x7a,0x20,0x17,0x2c,0x76,0x2b,0x42,0x9,0x79,0xa,0x29,0xc,0x10,0x2b,0x50,0x32,0xb,0x2f,0x2b,0x30,0x24,0x76,0x64,0x1b,0x61,0x7c,0x58,0x69,0x3b,0x69,0x63,0x18,0x7f,0x63,0x5d,0x2d,0x75,0x27,0x64,0x60,0x40,0x58,0x5c,0x16,0x5,0x16,0x35,0xf,0x4f,0x53,0x6c,0x61,0x32,0x62,0x55,0x25,0x2f,0x51,0x17,0x70,0x58,0x79,0x78,0x5]
d_550 = [0x4a,0x77,0x58,0x61,0x19,0x1f,0x69,0x23,0x2b,0x5c,0x27,0x22,0x6,0x53,0x5b,0x30,0x70,0x2a,0x0,0xa,0x43,0x13,0x3b,0x74,0x17,0xd,0x15,0x65,0x69,0x31,0x42,0x4e,0x29,0x55,0x2d,0x72,0x42,0x1b,0x39,0x38,0x1,0x17,0x61,0x2c,0x1e,0x62,0x66,0x52,0x70,0x45,0x34,0xc,0x36,0x42,0x5f,0x32,0x1e,0x3,0x63,0x39,0x30,0x0,0x6a,0x51,0x13,0xf,0x77,0x41,0x6d,0x1b,0x3c,0x8,0x9,0x11,0x34,0x37,0x63,0x1f,0x53,0x27,0x72,0x4a,0x73,0x17,0x3f,0x29,0x0,0x21,0x5f,0x2b,0x4c,0x16,0xe,0xe,0x1a,0x57,0x1e,0x39,0x2f,0x16,0x5d,0x52,0xe,0x39,0x6c,0x6c,0x7,0x2a,0x21,0x16,0xe,0x43,0x30,0x3e,0x70,0x66,0x2,0x40,0x3d,0x11,0x77,0x18,0xc,0x8,0x6b,0x64,0x62,0x1,0x53,0x4c,0x35,0x4,0x73,0x3e,0x3f,0x1d,0x6f,0x4a,0xd,0x18,0x4b,0x1,0x13,0x14,0x33,0x0,0x23,0x6f,0x3b,0x40,0x6b,0x6f,0x5a,0x5b,0x34,0x5a,0x3b,0x56,0x23,0x55,0x6,0x73,0x77,0x36,0x5a,0x6c,0x25,0x6b,0x3d,0x6c,0x50,0x59,0x4d,0x64,0x51,0x6e,0x69,0x5,0x4a,0x4a,0x60,0x1f,0x2a,0xd,0x24,0x51,0x2b,0x3,0x1c,0x2c,0xe,0x72,0x1b,0x1e,0x25,0x23,0x48,0x4,0x6a,0x6a,0x58,0x64,0x16,0x65,0x11,0x75,0xc,0x55,0x6a,0x3a,0x8,0x3d,0x10,0x69,0x3d,0x2e,0x44,0x4c,0x50,0x6b,0xd,0x52,0x74,0x4,0x65,0x5f,0x39,0x35,0x33,0x66,0x68,0x5,0x2d,0x5a,0x13,0x5a,0x6e,0x36,0x2a,0x1,0x24,0x64,0x35,0x40,0x77,0x17,0x77,0x71,0x48,0x65,0x5b,0x4c,0x50,0x15,0x6c,0x62,0x49,0xe,0x76,0xc,0x51,0x38,0x6a,0x78,0x13,0x5,0x9,0x51,0x1a,0x42,0x9,0xc,0x41,0x6,0x59,0x17,0x42,0x3c,0x4c,0x13,0x5a,0xa,0x63,0x73,0x6c,0x51,0x4a,0x6f,0x13]
t = []
for i in xrange(289):
tmp = ((d_6a0[i] ^ d_2c0[i]) - d_410[i]) & 0xff
if tmp == d_550[i]:
t += [i]
#print t
s = ''
mp = ''
for i in xrange(289):
if i in t:
s += '0'
mp += '0'
else:
s += '1'
mp += '1'
if i % 17 == 16:
s += '\n'
else:
s += ' '
print s
mapsize = 30
dirsize = 4
a = [[0] * mapsize for i in range(mapsize)]
dx = [1,0,0,-1]
dy = [0,1,-1,0]
def printans(i,j):
global point
point += 1
x = i - dx[a[i][j] - 1]
y = j - dy[a[i][j] - 1]
if x == 1 and y== 0:
print '(',x,',',y,')-->',
return
else:
printans(x,y)
print '(',x,',',y,')-->',
def printans2(i,j):
global goto
x = i - dx[a[i][j] - 1]
y = j - dy[a[i][j] - 1]
if x == 1 and y== 0:
goto += [a[i][j]]
return
else:
printans2(x,y)
#print a[i][j],
goto += [a[i][j]]
def getans(i,j):
global a
#global flag
#if flag == True:
#return
if i==15 and j==16:
print 'Yes'
printans(i,j)
print '(15 , 16)'
printans2(i,j)
#flag = True
return
else:
for k in range(0,dirsize):
newi = i + dx[k]
newj = j + dy[k]
if (newi > 0 and newi < 17 and newj > 0 and newj < 17 and mp[newi*17+newj] == '0' and a[newi][newj] == 0):
a[newi][newj] = k+1
getans(newi,newj)
point = 1
goto = []
simple = []
getans(1,0)
print goto
dirc = [0,17,1,-1,-17]
tmp = 0
number = 0
for i in goto:
if number == 0:
tmp = i
number += 1
elif i == tmp:
number += 1
else:
simple += [dirc[tmp] * number]
tmp = i
number = 1
simple += [dirc[tmp] * number]
print simple
string = 'BCDFGHJKMPQRTVWXY2346789'
def decode(num):
global flag
if num > 0:
if num % 17 == 0:
flag += string[0xc] + string[23 - num / 17]
else:
flag += string[0xf] + string[23 - num]
else:
if num % 17 == 0:
flag += string[0xe] + string[23 + num / 17]
else:
flag += string[0xd] + string[23 + num]
flag = ''
for i in simple:
decode(i)
print flag
題目連結:
官方題解: