CyberStudents Wordmark

angry elf

Category

Points

Author

Reverse engineering

50

q

qvipin

Solves (76)

1Profile Picture for minipifminipif12/14 3:20 pm
2Profile Picture for andreicatandreicat12/14 3:21 pm
3Profile Picture for _vow__vow_12/14 3:25 pm
4Profile Picture for mr_mphmr_mph12/14 3:28 pm
5Profile Picture for raul_26raul_2612/14 3:29 pm
6Profile Picture for heartstollerheartstoller12/14 3:42 pm
7Profile Picture for dharneesh5555dharneesh555512/14 3:49 pm
8Profile Picture for godlyavengergodlyavenger12/14 4:13 pm
9Profile Picture for infernosalexinfernosalex12/14 5:16 pm
10Profile Picture for tudortudor12/14 6:00 pm
11Profile Picture for batterseabattersea12/14 7:58 pm
12Profile Picture for pligonsteinpligonstein12/15 6:11 am
13Profile Picture for sleuth123sleuth12312/15 7:32 am
14Profile Picture for saturn9saturn912/15 7:53 am
15Profile Picture for branoodlebranoodle12/15 12:39 pm
16Profile Picture for whofulwhoful12/15 1:23 pm
17Profile Picture for zarnex__zarnex__12/15 1:23 pm
18Profile Picture for boomanten10boomanten1012/15 3:03 pm
19Profile Picture for ShrelicShrelic12/15 8:55 pm
20Profile Picture for test123450604test12345060412/16 4:36 am
21Profile Picture for _avyra_avyra12/16 6:38 am
22Profile Picture for rex_i_arex_i_a12/16 3:40 pm
23Profile Picture for unpwnblunpwnbl12/16 5:16 pm
24Profile Picture for f00varf00var12/16 10:14 pm
25Profile Picture for silence_silence_12/17 4:00 am
26Profile Picture for puwanai.spuwanai.s12/17 4:08 am
27Profile Picture for zzunaidd023zzunaidd02312/17 4:50 am
28Profile Picture for colonneilcolonneil12/17 10:53 am
29Profile Picture for nouxianouxia12/17 12:17 pm
30Profile Picture for _4n3s_4n3s12/17 4:09 pm
31Profile Picture for elijah5399elijah539912/17 11:03 pm
32Profile Picture for vuxnx_91621vuxnx_9162112/17 11:49 pm
33Profile Picture for andreww4364andreww436412/18 1:16 am
34Profile Picture for theb4tmitetheb4tmite12/18 4:24 am
35Profile Picture for kush001607kush00160712/18 5:10 am
36Profile Picture for .hackboredzz.hackboredzz12/18 9:40 am
37Profile Picture for trixaitrixai12/18 10:29 am
38Profile Picture for booklover997booklover99712/18 12:01 pm
39Profile Picture for damian.28damian.2812/18 2:15 pm
40Profile Picture for fzhshzh_163fzhshzh_16312/18 8:04 pm
41Profile Picture for athawathaw12/18 9:14 pm
42Profile Picture for zytbxlzytbxl12/18 9:58 pm
43Profile Picture for johndoe6826johndoe682612/18 10:00 pm
44Profile Picture for benny_46903_75418benny_46903_7541812/19 3:27 am
45Profile Picture for mrmakaremrmakare12/19 5:30 am
46Profile Picture for ots3299ots329912/19 10:20 am
47Profile Picture for rocky2020.rocky2020.12/19 10:59 am
48Profile Picture for georgechkhaidzegeorgechkhaidze12/19 9:48 pm
49Profile Picture for mage9298mage929812/20 10:05 am
50Profile Picture for masquerade8077masquerade807712/20 11:24 am
51Profile Picture for ryuun1cornryuun1corn12/21 3:49 am
52Profile Picture for hqky.2kruoihqky.2kruoi12/21 7:10 am
53Profile Picture for kar_bkar_b12/21 11:36 pm
54Profile Picture for mtwiss_32447mtwiss_3244712/22 11:44 am
55Profile Picture for .mindsystem.mindsystem12/22 3:59 pm
56Profile Picture for awdyan_awdyan_12/22 5:20 pm
57Profile Picture for manu7738manu773812/23 6:02 am
58Profile Picture for captainblcaptainbl12/23 7:50 am
59Profile Picture for spectre06872spectre0687212/23 7:59 am
60Profile Picture for obetobet12/23 8:19 am
61Profile Picture for re_tiredre_tired12/24 11:49 am
62Profile Picture for awwliveyetawwliveyet12/25 12:24 pm
63Profile Picture for monstermanyana_47633monstermanyana_4763312/25 3:03 pm
64Profile Picture for darkitydarkity12/25 3:33 pm
65Profile Picture for zabatmoncefzabatmoncef12/25 3:41 pm
66Profile Picture for tildenjacksontildenjackson12/25 6:16 pm
67Profile Picture for yugi200yugi20012/26 4:45 am
68Profile Picture for mattewastakenmattewastaken12/26 12:14 pm
69Profile Picture for isee9917isee991712/26 11:41 pm
70Profile Picture for fakeaviationistfakeaviationist12/27 3:38 am
71Profile Picture for .jstr_.jstr_12/27 4:05 am
72Profile Picture for qwerty2119581qwerty211958112/28 8:18 am
73Profile Picture for hotikerhotiker12/28 11:05 am
74Profile Picture for fazectfazect12/29 6:48 am
75Profile Picture for wilsonwei_cswilsonwei_cs12/29 8:20 am
76Profile Picture for nian_30889nian_3088912/30 8:39 am

Description

Elf Glaki went rouge! At 2:56 PM EST, he locked up all our flags! Luckily you're not an idiot and you can fix this in 3 minutes. Stop this Angry Elf ASAP!

nc ctf.csd.lol 1147 (uhh kinda broken but works, will fix soon)

Attachments

Hint

There are no penalties for viewing hints. Hints are released 12 hours and 24 hours after the challenge releases.

Submit flag

Discuss this challenge with others in #🎄丨advent-of-ctf on our Discord server.

Write-up

.jstr_ (Jester)'s write-up was selected as the best write-up submitted for this challenge.

View this write-up on GitHub

The first thing we do is to run it through dogbolt to see the source code of the program.

The main part of the program is:

__int64 __fastcall validate_passcode(__int64 a1)
{
  int j; // [rsp+14h] [rbp-1Ch]
  int i; // [rsp+14h] [rbp-1Ch]
  int v4; // [rsp+18h] [rbp-18h]
  char v5[11]; // [rsp+1Dh] [rbp-13h]
  unsigned __int64 v6; // [rsp+28h] [rbp-8h]

  v6 = __readfsqword(0x28u);
  v4 = 0;
  while ( v4 != 2 )
  {
    if ( v4 )
    {
      for ( i = 0; i <= 10; ++i )
      {
        if ( v5[i] != obfuscated_key[i] )
          return 0LL;
      }
      v4 = 2;
    }
    else
    {
      for ( j = 0; j <= 10; ++j )
        v5[j] = *(_BYTE *)(j + a1) ^ 0x7F;
      v4 = 1;
    }
  }
  return 1LL;
}
// 1253: conditional instruction was optimized away because %var_18.4<3u
// 125D: conditional instruction was optimized away because %var_18.4<3u
// 126D: conditional instruction was optimized away because %var_18.4<2u
// 1279: conditional instruction was optimized away because %var_18.4==1
// 4010: using guessed type _BYTE obfuscated_key[11];
// 1229: using guessed type char var_13[11];

//----- (0000000000001321) ----------------------------------------------------
int __fastcall main(int argc, const char **argv, const char **envp)
{
  FILE *stream; // [rsp+8h] [rbp-A8h]
  char s[16]; // [rsp+10h] [rbp-A0h] BYREF
  char v6[136]; // [rsp+20h] [rbp-90h] BYREF
  unsigned __int64 v7; // [rsp+A8h] [rbp-8h]

  v7 = __readfsqword(0x28u);
  printf("Enter passcode: ");
  __isoc99_scanf("%15s", s);
  if ( strlen(s) == 11 )
  {
    if ( (unsigned int)validate_passcode((__int64)s) )
    {
      puts("Access Granted!");
      stream = fopen("flag.txt", "r");
      if ( stream )
      {
        if ( fgets(v6, 128, stream) )
          printf("Here is your flag: %s\n", v6);
        fclose(stream);
      }
      else
      {
        puts("Error: Could not read flag file.");
      }
    }
    else
    {
      puts("Access Denied!");
    }
    return 0;
  }
  else
  {
    puts("Invalid passcode length!");
    return 1;
  }
}

So, to find a key to the app, we need a key that is 11 characters long. Since the code Obfuscates the input passcode using a bitwise XOR operation with 0x7F and compares the result to a the obfuscated key. So, to find the key, we have to reverse the obfuscation.

To do this, we can:

Go on CyberChef. Input the numbers that are separated with commas. (15,13,22,17,24,19,26,12,79,70,92) Add From Decimal and put Comma as the delimeter. Add XOR and put 0x7F aa the key.

The output we get is pringles09#. Now input the decrypted text into the NetCat to get the answer:

jstr$ nc ctf.csd.lol 1147
pringles09#
Enter passcode: Access Granted!
Here is your flag: csd{4N9ry_3lf5_5h0uLdNT_83_M3553D_w1tH}

Flag: csd{4N9ry_3lf5_5h0uLdNT_83_M3553D_w1tH}

Need help with a challenge? Is a challenge broken? DM @ModMail in our Discord server.