标签:max canvas ica bof 读取 first field parent repeat-x
bof
同第一题fd,
ssh连接,ls -l查看文件, cat col.c得到代码如下
1 #include <stdio.h> 2 #include <string.h> 3 unsigned long hashcode = 0x21DD09EC; 4 unsigned long check_password(const char* p){ 5 int* ip = (int*)p; 6 int i; 7 int res=0; 8 for(i=0; i<5; i++){ 9 res += ip[i]; 10 } 11 return res; 12 } 13 14 int main(int argc, char* argv[]){ 15 if(argc<2){ 16 printf("usage : %s [passcode]\n", argv[0]); 17 return 0; 18 } 19 if(strlen(argv[1]) != 20){ 20 printf("passcode length should be 20 bytes\n"); 21 return 0; 22 } 23 24 if(hashcode == check_password( argv[1] )){ 25 system("/bin/cat flag"); 26 return 0; 27 } 28 else 29 printf("wrong passcode.\n"); 30 return 0; 31 }
经分析,check_password()函数的作用为将长度为20的argv[1]分为5段,每段有4个字符,这些字符是以小端的形式存储的,以int *指针的形式每次读取4个字符,将5次读取的值求和
python -c "print ‘\x01‘*16+‘\xE8\x05\xD9\x1D‘"
\x和0x表示16进制的区别:
标签:max canvas ica bof 读取 first field parent repeat-x
原文地址:http://www.cnblogs.com/WangAoBo/p/6366882.html