Basic - 神秘的文件

Haf.But the ciontent is lspilted ine pieces ca n you makes the pieceys togethers. Now thist is the fleag PCTF{P1hm3c3_7oghte r_i7}. Thei rest is usp to you. Cheer up, eboy.asy,a and I kno w you can eeasily decxompress oft it and fi2nd the con tent in it

输出内容：Haha ext2 file system is easy, and I know you can easily decompress of it and find the content in it.But the content is spilted in pieces can you make the pieces together. Now this is the flag PCTF{P13c3_7oghter_i7}. The rest is up to you. Cheer up, boy.

the word robot can refer to both physical robots and virtual software agents, but the latter are usually referred to as bots. there is no consensus on which machines qualify as robots but there is general agreement among experts, and the public, that robots tend to do some or all of the following: accept electronic programming, process data or physical perceptions electronically, operate autonomously to some degree, move around, operate physical parts of itself or physical processes, sense and manipulate their environment, and exhibit intelligent behavior - especially behavior which mimics humans or other animals. flag is substitutepassisveryeasyyougotit. closely related to the concept of a robot is the field of synthetic biology, which studies entities whose nature is more comparable to beings than to machines.

puts("Notice: Important!!\nThis is a test program for you to test on localhost.\nNotice flag in this test program starts with `FAKE{` and the\nprogram on server has the real flag which starts with `PCTF{`\n\n\n\nWelcome to the super-secret flag guess validation system!\nUnfortunately, it only works for the flag for this challenge though.\nThe correct flag is 50 characters long, begins with `PCTF{` and\nends with `}` (without the quotes). All characters in the flag\nare lowercase hex (so they are in [0-9a-f]).\n\nBefore you can submit your flag guess, you have to encode the\nwhole guess with hex again (including the `PCTF{` and the `}`).\nThis protects the flag from corruption through network nodes that\ncan't handle non-hex traffic properly, just like in email.\n");

while ( 1 )

{

printf("guess> ");

if ( !fgets(inbuf, 4096, stdin) )

break;

rtrim(inbuf);

correct = is_flag_correct(inbuf);//进入判断函数

if ( correct )

puts("Yaaaay! You guessed the flag correctly! But do you still remember what you entered? If not, feel free to try again!");

else

puts("Nope.");

}

}

读入字符串，然后丢到判断函数中，如果判断正确就输出正确的提示，如果错误就输出错误的提示，while(1)可以循环判断。

is_flag_correct函数:

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

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

__int64 __fastcall is_flag_correct(char *flag_hex)

{

unsigned int v1; // eax@2

char given_flag[50]; // [sp+10h] [bp-190h]@4

char flag[50]; // [sp+50h] [bp-150h]@4

char bin_by_hex[256]; // [sp+90h] [bp-110h]@4

char value2; // [sp+192h] [bp-Eh]@5

char value1; // [sp+193h] [bp-Dh]@5

int i_0; // [sp+194h] [bp-Ch]@11

char diff; // [sp+19Bh] [bp-5h]@11

int i; // [sp+19Ch] [bp-4h]@4

if ( strlen(flag_hex) != 100 )

{

v1 = strlen(flag_hex);

printf("bad input, that hexstring should be 100 chars, but was %d chars long!\n", v1);

exit(0);

}

qmemcpy(bin_by_hex, &byte_401100, sizeof(bin_by_hex));

*(_DWORD *)flag = 'EKAF';

*(_DWORD *)&flag[4] = '3b9{';

*(_DWORD *)&flag[8] = '3e55';

*(_DWORD *)&flag[12] = '2d49';

*(_DWORD *)&flag[16] = 'e070';

*(_DWORD *)&flag[20] = 'd0db';

*(_DWORD *)&flag[24] = '591f';

*(_DWORD *)&flag[28] = '2b8d';

*(_DWORD *)&flag[32] = '0543';

*(_DWORD *)&flag[36] = '2cc9';

*(_DWORD *)&flag[40] = '2729';

*(_DWORD *)&flag[44] = '14cb';

*(_WORD *)&flag[48] = '}2';

bzero(given_flag, 50uLL);

for ( i = 0; i <= 49; ++i ) // 限制50字节循环

{

value1 = bin_by_hex[flag_hex[2 * i]];

value2 = bin_by_hex[flag_hex[2 * i + 1]];

if ( value1 == -1 || value2 == -1 )

{

puts("bad input 鈥one of the characters you supplied was not a valid hex character!");