|
|
@ -10,6 +10,15 @@
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <zlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define BUF_LEN 1024
|
|
|
|
#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) {
|
|
|
|
void open_connection(const char *hostname, const char *port, const char *msg) {
|
|
|
|
int sfd, s;
|
|
|
|
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");
|
|
|
|
fprintf(stderr, "No compression methods enabled\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char flag[sizeof(SECRET)];
|
|
|
|
|
|
|
|
strcpy(flag, SECRET);
|
|
|
|
|
|
|
|
unscramble(flag);
|
|
|
|
|
|
|
|
|
|
|
|
char buf[BUF_LEN] = {0};
|
|
|
|
char buf[BUF_LEN] = {0};
|
|
|
|
strcat(buf, "GET /");
|
|
|
|
strcat(buf, "GET /");
|
|
|
|
strncat(buf, msg, BUF_LEN / 2);
|
|
|
|
strncat(buf, msg, BUF_LEN / 2);
|
|
|
|
strcat(buf, " HTTP/1.1\r\nHost: iut.local\r\n");
|
|
|
|
strcat(buf, " HTTP/1.1\r\nHost: iut.local\r\n");
|
|
|
|
strcat(buf, "Connection: close\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");
|
|
|
|
strcat(buf, "\r\n");
|
|
|
|
SSL_write(ssl, buf, strlen(buf));
|
|
|
|
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);
|
|
|
|
uLong ucompSize = strlen(buf);
|
|
|
|
// Use a compression level of 9
|
|
|
|
// Use a compression level of 9
|
|
|
|
uLong compSize = compressBound(ucompSize);
|
|
|
|
uLong compSize = compressBound(ucompSize);
|
|
|
|
char *comp = malloc(compSize);
|
|
|
|
Bytef *comp = malloc(compSize);
|
|
|
|
compress(comp, &compSize, buf, ucompSize);
|
|
|
|
compress(comp, &compSize, (unsigned char *)buf, ucompSize);
|
|
|
|
free(comp);
|
|
|
|
free(comp);
|
|
|
|
printf("Sent %lu data bytes\n", compSize);
|
|
|
|
printf("Sent %lu data bytes\n", compSize);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|