每天一道ctf,能多不能少
题目链接 首先拖入ida 打开以后查看main函数 如图 可以看出,Dercy函数里的信息很重要,双击进入Dercy函数,
unsigned __int64 Decry () { char v1; int v2; int v3; int i; int v5; char src[8 ]; __int64 v7; int v8; __int64 v9; __int64 v10; int v11; unsigned __int64 v12; v12 = __readfsqword(0x28 u); *(_QWORD *)src = 'SLCDN' ; v7 = 0LL ; v8 = 0 ; v9 = 'wodah' ; v10 = 0LL ; v11 = 0 ; text = join(key3, (const char *)&v9); strcpy (key, key1); strcat (key, src); v2 = 0 ; v3 = 0 ; getchar(); v5 = strlen (key); for ( i = 0 ; i < v5; ++i ) { if ( key[v3 % v5] > 64 && key[v3 % v5] <= 90 ) key[i] = key[v3 % v5] + 32 ; ++v3; } printf ("Please input your flag:" , src); while ( 1 ) { v1 = getchar(); if ( v1 == '\n' ) break ; if ( v1 == ' ' ) { ++v2; } else { if ( v1 <= 96 || v1 > 122 ) { if ( v1 > 64 && v1 <= 90 ) str2[v2] = (v1 - 39 - key[v3++ % v5] + 97 ) % 26 + 97 ; } else { str2[v2] = (v1 - 39 - key[v3++ % v5] + 97 ) % 26 + 97 ; } if ( !(v3 % v5) ) putchar (' ' ); ++v2; } } if ( !strcmp (text, str2) ) puts ("Congratulation!\n" ); else puts ("Try again!\n" ); return __readfsqword(0x28 u) ^ v12; }
分析一下代码,join函数是一个自定义函数,点进去看一下, 分析的到处,该函数可以将两个参数拼接在一起。继续往下分析,先是将两个字符串拼接成keys,然后转化为小写,然后将其进行了加密。比较的text就是我们的得到的flag。直接写照着代码解密就可以了。
text = 'killshadow' key = 'adsfkndcls' key_ = '' v3=0 for i in range (len (key)): flag = ord (key[v3%len (key)]) if flag > 64 and flag <=90 : key_ += chr (ord (key[v3%len (key)])+32 ) v3=v3+1 ans = '' for i in range (len (key)): for j in range (0 ,15 ): tmp=chr (ord (text[i]) - 97 + 26 *j - 97 + ord (key [v3%len (key)]) + 39 ) if ord (tmp)>64 and ord (tmp) <91 : ans+=tmp break v3=v3+1 print ans
好了,运行得到flag。