Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed matryoshka and print-flag #1

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>

Check failure on line 1 in chapters/binary-analysis/executables-and-processes/drills/06-challenge-matryoshka/sol/inner.c

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#include <stdlib.h>
#include <string.h>

static const unsigned char key[] = "I laugh in the face of danger";
static const unsigned char enc_msg[] = { 0x1a, 0x73, 0x3f, 0x3e, 0x36, 0x33, 0x2e, 0x5b, 0x00, 0x00, 0x7f, 0x07, 0x18, 0x04, 0x43, 0x03, 0x3e, 0x0d, 0x0a, 0x7f, 0x00, 0x08, 0x45, 0x3b, 0x02, 0x0f, 0x09, 0x3a, 0x1a, 0x2c, 0x41, 0x1e, 0x3e, 0x0c, 0x08, 0x1d, 0x7f, 0x0b, 0x0b, 0x4c, 0x17, 0x00, 0x18, 0x2a, };

Check failure on line 6 in chapters/binary-analysis/executables-and-processes/drills/06-challenge-matryoshka/sol/inner.c

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:LONG_LINE: line length of 307 exceeds 120 columns

static void xor_encrypt(const unsigned char *in, unsigned char *out,
size_t len, const unsigned char *key, size_t key_len)
{
size_t i;

for (i = 0; i < len; i++)
out[i] = in[i] ^ key[i % key_len];
}

int main(void)
{
unsigned char *dec_msg;

dec_msg = calloc(sizeof(enc_msg) + 1, sizeof(enc_msg[0]));

Check failure on line 21 in chapters/binary-analysis/executables-and-processes/drills/06-challenge-matryoshka/sol/inner.c

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:ALLOC_ARRAY_ARGS: calloc uses number as first arg, sizeof is generally wrong

xor_encrypt(enc_msg, dec_msg, sizeof(enc_msg) / sizeof(enc_msg[0]),
key, strlen((const char *) key));

printf("Flag is: %s\n", dec_msg);

return 0;
}
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Loading