Scramble input

main
Clément FRÉVILLE 2 years ago
parent 31c10f1446
commit c128927730

@ -10,6 +10,15 @@
#include <zlib.h>
#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 {

@ -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.

Loading…
Cancel
Save