Login
Immutable PageDiscussionInfoAttachments

Your search query "linkto:"ytoku/CTF/Writeup/AdventCalendarCTF2014/2014-12-19"" didn't return any results. Please change some terms and refer to HelpOnSearching for more information.
(!) Consider performing a full-text search with your search terms.

Clear message
ytoku/CTF/Writeup/AdventCalendarCTF2014/2014-12-19

MMA

guesskey

問題

Guess the key.

guesskey

メモ

解法

   1 #include <ctype.h>
   2 #include <stdio.h>
   3 
   4 int g804a0a0[256];
   5 int g804a4a0;
   6 
   7 void generate_table() {
   8     while (g804a4a0 <= 0xfe) {
   9         if (g804a0a0[g804a4a0] == 0) {
  10             g804a0a0[g804a4a0] = 0xdeadbeef; // *0x804a070
  11         } else if ( ((g804a4a0 + 1) & 2) != 0 ) {
  12             g804a0a0[g804a4a0] += g804a0a0[g804a4a0 - 2];
  13         }
  14         int ecx = g804a4a0 + 1;
  15         int ebx = 2 * g804a4a0 * g804a0a0[g804a4a0];
  16         g804a0a0[ecx] = g804a0a0[g804a4a0] / (g804a4a0 + 1) + ebx;
  17         g804a4a0++;
  18     }
  19 }
  20 int get_nextkey() {
  21     return g804a0a0[g804a4a0++];
  22 }
  23 
  24 int g804a040[] = {
  25 0x8711597e, 0xf82e6b11, 0xfb84adf9, 0x4b1fbd36, 0x3883b5e6, 0xda3cb6d8, 0xacaf25bd, 0x7e88fa4a,
  26 0xcd7069e4, 0x9751e9ff, 0x7de09e8b, 0x7e63456f, 0xdeadbeef, 0x3a434347, 0x62552820, 0x75746e75,
  27 0x382e3420, 0x312d322e, 0x75627539, 0x3175746e, 0x2e342029, 0x00322e38, 0x68732e00, 0x74727473,
  28 0x2e006261, 0x65746e69, 0x2e007072, 0x65746f6e, 0x4942412e, 0x6761742d, 0x6f6e2e00, 0x672e6574,
  29 };
  30 int main() {
  31     int len = 12;
  32     int i, j;
  33     int c;
  34     generate_table();
  35     printf("ADCTF_");
  36     for (i = 0; i < len; i++) {
  37         int found = 0;
  38         for (c = 0; c <= 0x7e; c++) {
  39             //if (!isalnum(c)) continue;
  40             g804a4a0 = (int)c + i;
  41             int v24 = 0;
  42             for (j = 0; j < len; j++) {
  43                 v24 += get_nextkey();
  44             }
  45             if (g804a040[i] == v24) {
  46                 found = 1;
  47                 break;
  48             }
  49         }
  50         if (!found) return 1;
  51         printf("%c", c);
  52     }
  53     printf("\n");
  54 }