I am playing a CTF wargame and unfortunatley got stuck at this level, so I want to "crowdsource" it. No need for complete answer, but hints would be enough.
How can I:
- Make strcmp to be 0 (evaluate if to false)
- Somehow surpress singals?
I want shell to be executed:
execl("/bin/sh", "sh", NULL);
Any ideas?
Binary is setuid and /levels/level08.pass is readable only on higher level.
-r-sr-x--- 1 level9 level8 7696 Apr 25 2015 level08
-r-------- 1 level8 level8 412 Apr 25 2015 level08.c
-r-------- 1 level9 level9 13 Apr 25 2015 level08.pass
Program code for level08.c is below.
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
char buf[64];
FILE *fp;
signal(SIGABRT, SIG_DFL);
fp = fopen("/levels/level08.pass", "r");
fgets(buf, 64, fp);
buf[strcspn(buf, "\n")] = '\0';
if(strcmp(buf, argv[1]))
raise(SIGABRT);
execl("/bin/sh", "sh", NULL);
}
ulimit -c unlimited
?strcmp()
to return zero, which means the strings must be equal.