From 08b7de53f2f279ab297af47e39a65a8bc7eccf32 Mon Sep 17 00:00:00 2001 From: x1phosura Date: Wed, 27 Apr 2022 01:08:57 -0700 Subject: [PATCH] Also implement fixed-xor bruteforcer --- set1/Makefile | 1 - set1/src/ch3-brute-force.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 set1/src/ch3-brute-force.c diff --git a/set1/Makefile b/set1/Makefile index cc27bd7..e01c43e 100644 --- a/set1/Makefile +++ b/set1/Makefile @@ -20,7 +20,6 @@ EXT_INCLUDES = -Iaes-libs/tiny-AES-c #EXT_LIBS = -Laes-libs/tiny-AES-c #LDLIBS = -laes -#%: $(SRC_DIR)/%.c %: $(SRC_DIR)/%.c $(CC) $(CFLAGS) -o $(OUT_DIR)/$@ $< diff --git a/set1/src/ch3-brute-force.c b/set1/src/ch3-brute-force.c new file mode 100644 index 0000000..ed75679 --- /dev/null +++ b/set1/src/ch3-brute-force.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int main() +{ + uint8_t i = 0; + size_t k; + int8_t ciphertext[] = "\x1b\x37\x37\x33\x31\x36\x3f\x78\x15\x1b\x7f\x2b" + "\x78\x34\x31\x33\x3d\x78\x39\x78\x28\x37\x2d\x36" + "\x3c\x78\x37\x3e\x78\x3a\x39\x3b\x37\x36"; + int8_t attempt[sizeof(ciphertext) - 1]; + + do { + printf("i = %d\n", i); + for (k = 0; k < sizeof(attempt); ++k) { + attempt[k] = ciphertext[k] ^ i; + } + for (k = 0; k < sizeof(attempt); ++k) { + putchar(attempt[k]); + } + putchar('\n'); + ++i; + } while (i < 255); + + return EXIT_SUCCESS; +} +