Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Crypt function reverce challange.

Featured Replies

Posted

           

			int i = 0;
            unsigned char input_buffer[BINSIZE + 1] = {0};
            unsigned char output_buffer[BINSIZE * 2] = {0};
			DWORD data_size = BINSIZE;

             for(i = 0; i < data_size; i = i + 16)
            {
                Decrypt(AESKey, input_buffer + i, output_buffer + i, 16);
            }

            for(i = 0; i < data_size - 16; i++)
            {
                output_buffer[i + 16] = output_buffer[i + 16] ^ input_buffer[i];
            }

The goal is to reverse the algorithm and obtain input_buffer if we have only the output_buffer after the xor manipulation and the AESKey outsource for the Encrypt function. Looks easy but it is not that easy after all.

Edited by HostageOfCode

Key details to solving this challenge:

  1. The block size is 16 bytes.
  2. The first block is only Decrypted, not xor'ed.
  3. Each of the following blocks is Decrypted then xor'ed with the previous block

Solving it would boil down to Encrypting a block then xor'ing it with the next block, which would roughly be as below

unsigned char output_buffer[BINSIZE * 2] = {0};
unsigned char result_buffer[BINSIZE + 1] = {0};
DWORD data_size = BINSIZE;

for(int i = 0; i < data_size; i = i + 16)
{
    Encrypt(AESKey, result_buffer + i, output_buffer + i, 16);

    for(int j = i; j < i + 16; j++)
    {
        output_buffer[j + 16] = output_buffer[j + 16] ^ result_buffer[j];
    }
}

 

  • Author

 

               int count = 0;
                memcpy(output_buffer, input_buffer, data_size);
                Encrypt(AESKey, output_buffer, output_buffer, 16);

                for (i = 0; i < data_size - 16; i++)
                {

                    output_buffer[i + 16] = input_buffer[i + 16] ^ output_buffer[i];

                    count++;

                    if (count == 16)
                    {

                        Encrypt(AESKey, output_buffer+ i + 1, output_buffer+ i + 1, 16);
                        count = 0;
                    }

                }

This is my solution.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.