Skip to content

Instantly share code, notes, and snippets.

@mspraggs
Created August 23, 2025 12:56
Show Gist options
  • Select an option

  • Save mspraggs/8c738831690070dc199a7bebc01200d3 to your computer and use it in GitHub Desktop.

Select an option

Save mspraggs/8c738831690070dc199a7bebc01200d3 to your computer and use it in GitHub Desktop.
Decompiled main function of refreshments CTF challenge
void main()
{
void* fsbase;
int64_t var_20 = *(uint64_t*)((char*)fsbase + 0x28);
setup();
banner();
int64_t s;
__builtin_memset(&s, 0, 0x50);
char var_81 = 0;
while (true)
{
printf(&data_4025a0, (uint64_t)(int32_t)var_81);
int64_t rax_5 = read_num();
if (rax_5 == 4)
{
printf("\nChoose glass: ");
int64_t rax_34 = read_num();
if (rax_34 >= (int64_t)var_81)
error("This glass is unavailable!");
else if ((&s)[rax_34])
{
printf("\nGlass content: ");
write(1, (&s)[rax_34], 0x58);
putchar(0xa);
}
else
error("Cannot view empty glass!");
}
else
{
if (rax_5 == 3)
{
printf("\nChoose glass to customize: ");
int64_t rax_25 = read_num();
if (rax_25 >= (int64_t)var_81)
{
error("This glass is unavailable!");
continue;
}
else if ((&s)[rax_25])
{
printf("\nAdd another drink: ");
read(0, (&s)[rax_25], 0x59);
putchar(0xa);
continue;
}
else
{
error("Cannot customize empty glass!");
continue;
}
}
else
{
if (rax_5 == 1)
{
if (var_81 > 0xf)
{
error("You cannot take any more glasses…");
exit(0x45);
}
else
{
(&s)[(int64_t)var_81] = calloc(1, 0x58);
if ((&s)[(int64_t)var_81])
{
var_81 += 1;
printf("\nHere is your refreshing juice!…");
continue;
}
else
{
error("Something went wrong with the ju…");
continue;
}
}
goto label_401622;
}
if (rax_5 == 2)
{
label_401622:
printf("\nChoose glass to empty: ");
int64_t rax_16 = read_num();
if (rax_16 >= (int64_t)var_81)
{
error("This glass is unavailable!");
continue;
}
else if ((&s)[rax_16])
{
free((&s)[rax_16]);
(&s)[rax_16] = 0;
puts("\nGlass is empty now!\n");
continue;
}
else
{
error("This glass is already empty!");
continue;
}
}
}
error("Have a great day!\n");
exit(0x45);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment