diff --git a/client.c b/client.c index 407c30c..1aa8e0f 100644 --- a/client.c +++ b/client.c @@ -10,6 +10,15 @@ #include #define BUF_LEN 1024 +#define SECRET "eiph0aChThu17ah9rua4Naiv4" + +char *unscramble(char *s) { + for (char *str = s + 1; *str != 0; str += 2) { + *s++ = *str; + } + *s = '\0'; + return s; +} void open_connection(const char *hostname, const char *port, const char *msg) { int sfd, s; @@ -64,12 +73,17 @@ void open_connection(const char *hostname, const char *port, const char *msg) { fprintf(stderr, "No compression methods enabled\n"); } + char flag[sizeof(SECRET)]; + strcpy(flag, SECRET); + unscramble(flag); + char buf[BUF_LEN] = {0}; strcat(buf, "GET /"); strncat(buf, msg, BUF_LEN / 2); strcat(buf, " HTTP/1.1\r\nHost: iut.local\r\n"); strcat(buf, "Connection: close\r\n"); - strcat(buf, "Cookie: flag=bAr5\r\n"); + strcat(buf, "Cookie: flag="); + strcat(buf, flag); strcat(buf, "\r\n"); SSL_write(ssl, buf, strlen(buf)); @@ -77,8 +91,8 @@ void open_connection(const char *hostname, const char *port, const char *msg) { uLong ucompSize = strlen(buf); // Use a compression level of 9 uLong compSize = compressBound(ucompSize); - char *comp = malloc(compSize); - compress(comp, &compSize, buf, ucompSize); + Bytef *comp = malloc(compSize); + compress(comp, &compSize, (unsigned char *)buf, ucompSize); free(comp); printf("Sent %lu data bytes\n", compSize); } else { diff --git a/sujet_tp.typ b/sujet_tp.typ index c91fc1f..f94d2c5 100644 --- a/sujet_tp.typ +++ b/sujet_tp.typ @@ -8,7 +8,7 @@ Cloner le dépôt Git à l'IUT ou sur votre machine. ```bash git clone https://codefirst.iut.uca.fr/git/clement.freville2/http-crime -cd crime-http +cd http-crime ``` Compiler le projet avec Make, et générez un certificat auto-signé à l'aide d'OpenSSL.