170708 reverse-South Mail CTF reverse (Maze)

Source: Internet
Author: User

1625-5 Prince Aung July 8, 2017 "Summary of the NO. 279 consecutive day"
A. South Mail CTF Reverse (5, 6)
B. 5:
again Maze, dragged to IDA analysis and found the main content is in main:

if (strlen (&input)! = | | | strncmp (&input, "nctf{", 5uLL) | |
    * (&BYTE_6010BF +)! =) {label_22:puts ("wrong flag!");
  Exit (-1);
  } v3 = 5LL;
  if (strlen (&input)-1 > 5)//V9 is Line//V9 next byte is column                      {while (1) {in = * (&input + v3); Take the first byte//capital O is x-1//lowercase
                                                O is x+1//. is Y-1//0 is y+1
      v5 = 0;
        if (in > +) {in = (unsigned __int8) in;   if ((unsigned __int8) in = =)//O {V6 = sub_400650 ((_dword *) &V9 + 1);
        V6=V9 next byte of >0//V9 Next byte-1 goto label_14; } if (in = = 111)//o {v6 = sub_400660 (int *) &V9 + 1);
        V9 the next byte of +1//v6=v9 the next byte <8 goto label_14;
        }} else {in = (unsigned __int8) in;
        if ((unsigned __int8) in = = 46)//.                 {v6 = sub_400670 (&AMP;V9);
        v6=v9>0//v9=v9-1 goto label_14;          } if (in = =)//0 {v6 = sub_400680 ((int *) &AMP;V9);
          V9+1//V6=v9<8 label_14:v5 = V6;
        Goto label_15; }} label_15:if (! (
                                                unsigned __int8) sub_400690 ((__int64) asc_601060, Shidword (v9), v9)//[a1+a2+8*a3]==32 or 35
      Each step of the landing limit goto label_22;
if (++v3 >= strlen (&input)-1) {        if (V5)//V6 requires a non-0 break;
        Label_20:v7 = "wrong flag!";
      Goto label_21;
  }}} if (* (* (&AMP;ASC_601060[8 * (signed int) V9] + Shidword (v9))! = 35)//The last step needs to be a goto label_20;
V7 = "congratulations!";
  Label_21:puts (V7);
return 0LL; }

First judge the format nctf{} and the length, and then the characters in it are continuously accepted, four characters oO0. Represents operations on V9 and * (&v9+1). By the Last Judgment when the map address 601060+8*v9+shidword (V9) can be guessed, v9 for the number of lines, 8 characters per line, Shidword to take the next byte of V9 (query to know the macro definition)
Look directly at the 601060 discovery is a long string with only three characters in it 32, 35, and 42
Requires each step to fall on the 32 or 35, the last step on the 35 and cannot be out of bounds (that is, the horizontal ordinate more than 8)
So it's easy to print out the map with an IDC script:

Walk from the upper left corner and end up at 2, just 18 steps. Get flag

6:ida Open, found the same elf, this time F5 into unresponsive and error in the
Take a rough look at the assembly:
First get input, flag initial value is 1, and then determine whether the length is 0x19, not so flag=0
Then a lot of data processing, in which the input string processing is mixed in, the rest is invalid
Finally, the strings of the input string and 0x694060 are compared, so the flag=0
If Flag=1 is correct
Look at the data processing, 0x694060 string is not processed, so just get the string and then dump the input string processing and then inverse transform to get the string to be entered
However, it is not known how to selectively drag out the assembly instructions ...
Temporary release
C. Plans for tomorrow
National University student Information Security Competition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.