Scramble input
This commit is contained in:
20
client.c
20
client.c
@@ -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 {
|
||||
|
Reference in New Issue
Block a user