frobbed executable puzzle

This commit is contained in:
Neale Pickett 2009-09-03 10:42:28 -06:00
parent 6b2ba1bcfa
commit 39d9e069e4
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,9 @@
LDFLAGS = -static
all: frob main
main: CFLAGS = -Dfrobbed='"$(shell tr -d '\n' < key | ./frob)"'
clean:
rm -rf main frob

View File

@ -0,0 +1,13 @@
#include <unistd.h>
int
main(int argc, char *argv[])
{
char c;
while (read(0, &c, 1)) {
c ^= 3;
write(1, &c, 1);
}
return 0;
}

1
games/compaq/memfrob/key Normal file
View File

@ -0,0 +1 @@
lawful forths Amanda

View File

@ -0,0 +1,29 @@
#include <stdio.h>
#include <string.h>
int
main(int argc, char *argv[])
{
char reply[256];
printf("What is the password? ");
fflush(stdout);
if (fgets(reply, sizeof(reply), stdin)) {
char *p;
for (p = reply; *p; p += 1) {
if ('\n' == *p) {
*p = '\0';
break;
}
*p = *p ^ 3;
}
if (strcmp(reply, frobbed)) {
printf("No it isn't!\n");
} else {
printf("Congratulations.\n");
}
}
return 0;
}