The babycmd challenge was an x64 ELF binary supporting 4 commands: ping, dig, host, and exit. In the case of ping, dig and host, it just calls the corresponding binary with a user-controlled argument.
This binary uses signal(2) 0xE (SIGALRM – Timer signal from alarm(2)) and alarm() in order to terminate the process after 45 seconds. This was a bit annoying while working on this binary, so I replaced the original argument 0x2d for alert() with a 0; as explained in the alarm(2) documentation, if the seconds argument is 0, no new alarm is scheduled.
.text:0000000000001267 mov edi, 0Eh .text:000000000000126C call _signal .text:0000000000001271 mov edi, 0x2d .text:0000000000001276 call _alarm
.text:0000000000001267 mov edi, 0Eh .text:000000000000126C call _signal .text:0000000000001271 mov edi, 0 .text:0000000000001276 call _alarm
For all the supported commands, this program does some basic validation of the user-provided argument before calling the corresponding binary. This filter is a kind of blacklist which rejects user input if it contains characters like “&”, “;” and “|”, which may be abused to inject OS commands. You should note that this function also removes spaces (char 0x20) from the user input.