REdo 1
.c文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #include <stdio.h> #include <string.h>
#define STR_LEN 34
#define EXIT printf("Sorry that's not the flag\n"); return 1; #define SUCCESS printf("THAT'S THE FLAG!\n"); return 0; #define PARAMS printf("Usage: ./code <flag>\n"); return 1; #define POINTER char* flag = (char*)(&a);
int main(int argc, char** argv) { int a[] = {0x65676967,0x00000000,0x34427b6d,0x5f433153,0x616c5f43,0x00000000,0x4175476e,0x525f4567,0x00000000,0x78305f45,0x53414c47,0x00007d53};
if(argc != 2){ PARAMS } if(strlen(argv[1]) != STR_LEN){ EXIT }
POINTER
for(int i = 0; i < STR_LEN; i++) { int idx = i; if(i >= 4 && i <= 15){ idx += 4; } if(i >= 16 && i <= 23){ idx += 8; } if(i > 23){ idx += 12; }
if(argv[1][i] != flag[idx]){ EXIT } }
SUCCESS }
|
有个大小端问题
手动调整一下顺序就好了
1 2 3 4 5 6 7 8 9 10
| data=[0x65676967,0x34427b6d,0x5f433153,0x616c5f43, 0x4175476e,0x525f4567,0x78305f45,0x53414c47,0x00007d53] data_byte=[] for i in range(9): data_byte.append((data[i] & 0x000000FF)) data_byte.append((data[i] & 0x0000FF00) >> 8) data_byte.append((data[i] & 0x00FF0000) >> 16) data_byte.append ((data[i] & 0xFF000000) >> 24) print(data_byte) flag=''.join(chr(i)for i in data_byte) print(flag)
|
gigem{B4S1C_C_lanGuAgE_RE_0xGLASS}