前言
继续ctf的旅程
攻防世界Misc高手进阶区的5分题
本篇是A-Weird-C-Program的writeup
发现攻防世界的题目分数是动态的
就仅以做题时的分数为准了
解题过程
得到一段代码
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
#include <codeme.h>
/*int main( int argc, char **argv )
{*/
#define EEr_Rs 0x4b
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define LINE_new '\n'
#include <assert.h>
#include <time.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
int main(){ int run;
run>>=5;run=0;
run&=01; int FELICITY[10000];
run>>=5;
using namespace std;
char *res[6] = {"Nothing_" ,
" and _no _one _is _perfect. ",
"It_ just _takes_ a_good _eye_",
"to_find_" ,
"those_ hidden_" ,
"imperfections. :)" };
int i = 0,j=0;
for( i=0;i < 6 ; i++)for(j=0;j<strlen(res[i]);j++)
{int t=(int)res[i][j];if(t == '_' )FELICITY[run++]=32;else if((t==32||t==9)&&(j!=27))FELICITY[run++]=-1;
else FELICITY[run++]= t ;}
for( i=0; i< run ;i++ )
if(FELICITY[i]+1)printf("%c",(char)FELICITY[i]); i-=1 ;
printf("\n") ;
return 0;
}
/*END*/
注意到有奇怪的间距
又代码里说有隐藏信息
猜测这个空格和制表符是0和1
尝试得到
x = "000001110100 000001101000 000001100101 000001011111 000001100110 000001101100 000001100001 000001100111 000001011111 000001101001 000001110011 000001011111 000001010111 000001110000 000001010101 000001000001 000001001001 000001110100 000001110011 000001100001 000001100100 000001101101 000001101000 000001100001 000001101011 000001010 "
print(''.join([ chr(int(i,2)) for i in x.split() ]))
得到flag
结语
代码里的间隔符和制表符来代表二进制