From 39d9e069e4e32332e374fc979cc891c0e5f30cf5 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 3 Sep 2009 10:42:28 -0600 Subject: [PATCH] frobbed executable puzzle --- games/compaq/memfrob/Makefile | 9 +++++++++ games/compaq/memfrob/frob.c | 13 +++++++++++++ games/compaq/memfrob/key | 1 + games/compaq/memfrob/main.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 games/compaq/memfrob/Makefile create mode 100644 games/compaq/memfrob/frob.c create mode 100644 games/compaq/memfrob/key create mode 100644 games/compaq/memfrob/main.c diff --git a/games/compaq/memfrob/Makefile b/games/compaq/memfrob/Makefile new file mode 100644 index 0000000..201b694 --- /dev/null +++ b/games/compaq/memfrob/Makefile @@ -0,0 +1,9 @@ +LDFLAGS = -static + +all: frob main + +main: CFLAGS = -Dfrobbed='"$(shell tr -d '\n' < key | ./frob)"' + +clean: + rm -rf main frob + diff --git a/games/compaq/memfrob/frob.c b/games/compaq/memfrob/frob.c new file mode 100644 index 0000000..aa737d2 --- /dev/null +++ b/games/compaq/memfrob/frob.c @@ -0,0 +1,13 @@ +#include + +int +main(int argc, char *argv[]) +{ + char c; + + while (read(0, &c, 1)) { + c ^= 3; + write(1, &c, 1); + } + return 0; +} diff --git a/games/compaq/memfrob/key b/games/compaq/memfrob/key new file mode 100644 index 0000000..c4b3aba --- /dev/null +++ b/games/compaq/memfrob/key @@ -0,0 +1 @@ +lawful forths Amanda diff --git a/games/compaq/memfrob/main.c b/games/compaq/memfrob/main.c new file mode 100644 index 0000000..c63319b --- /dev/null +++ b/games/compaq/memfrob/main.c @@ -0,0 +1,29 @@ +#include +#include + +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; +}