From 470aa85ccbd889ebc2be3f0f2d5c186f5df676be Mon Sep 17 00:00:00 2001 From: strunk Date: Fri, 27 Feb 2015 21:29:21 +0100 Subject: [PATCH 1/4] Doubly-linked list for cookies. --- hydra-http-form.c | 114 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 13 deletions(-) diff --git a/hydra-http-form.c b/hydra-http-form.c index 6c619b1..3946af1 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -68,6 +68,13 @@ typedef struct header_node { struct header_node *next; } t_header_node, *ptr_header_node; +typedef struct cookie_node { + char *name; + char *value; + struct cookie_node *prev; + struct cookie_node *next; +} t_cookie_node, *ptr_cookie_node; + int success_cond = 0; int getcookie = 1; int auth_flag = 0; @@ -107,6 +114,82 @@ ptr_header_node header_exists(ptr_header_node * ptr_head, char *header_name, cha return found_header; } +int append_cookie(char *name, char *value, ptr_cookie_node *last_cookie) +{ + ptr_cookie_node new_ptr = (ptr_cookie_node) malloc(sizeof(t_cookie_node)); + if (!new_ptr) + return 0; + new_ptr->name = name; + new_ptr->value = value; + new_ptr->next = NULL; + new_ptr->prev = NULL; + + if (*last_cookie == NULL) + *last_cookie = new_ptr; + else + (*last_cookie)->next = new_ptr; + + return 1; +} + +void traverse_cookies(ptr_cookie_node ptr_cookie) +{ + printf("-- COOKIES START --\n"); + ptr_cookie_node cur_ptr = NULL; + for (cur_ptr = ptr_cookie; cur_ptr; cur_ptr = cur_ptr->next) + printf("Cookie: %s=%s\n", cur_ptr->name, cur_ptr->value); + printf("-- COOKIES END --\n"); +} + +/* + * Cookie list layout: + * +----------+ +--------+ +------+ + * | ptr_head | --> | next | --> | NULL | + * +----------+ | header | +------+ + * | value | + * +--------+ + * Returns 1 if success, or 0 otherwise. + */ +int add_or_update_cookie(ptr_cookie_node * ptr_cookie, char * cookie_expr) +{ +// printf("[DEBUG] Added cookie: %s\n", cookie_expr); + ptr_cookie_node cur_ptr = NULL, new_ptr = NULL; + char * cookie_name = NULL, + * cookie_value = strstr(cookie_expr, "="); + if (cookie_value) { + cookie_name = strndup(cookie_expr, cookie_value - cookie_expr); + cookie_value = strdup(cookie_value + 1); +// printf("\t[DEBUG] Name: %s\n", cookie_name); +// printf("\t[DEBUG] Value: %s\n", cookie_value); + + // we've got the cookie's name and value, now it's time to insert or update the list + if (*ptr_cookie == NULL) { + // no cookies + append_cookie(cookie_name, cookie_value, ptr_cookie); +// if (append_cookie(cookie_name, cookie_value, ptr_cookie)) +// printf("New cookie: %s=%s\n", (*ptr_cookie)->name, (*ptr_cookie)->value); + } else { + for (cur_ptr = *ptr_cookie; cur_ptr; cur_ptr = cur_ptr->next) { + if (strcmp(cur_ptr->name, cookie_name) == 0) { +// printf("Cookie %s already exists. Replacing.\n", cookie_name); + free(cur_ptr->value); + cur_ptr->value = cookie_value; + break; + } + if (cur_ptr->next == NULL) { +// printf("Cookie %s does not exist. Adding.\n", cookie_name); + append_cookie(cookie_name, cookie_value, &cur_ptr); + break; + } + } + } + + traverse_cookies(*ptr_cookie); + } else + return 0; + return 1; +} + /* * List layout: * +----------+ +--------+ +--------+ +--------+ @@ -163,6 +246,9 @@ int add_header(ptr_header_node * ptr_head, char *header, char *value, char type) existing_hdr->value = new_value; existing_hdr->type = type; } + // DEBUG + printf("[DEBUG] Added header: %s = %s\n", header, value); + // END DEBUG } else { // we're out of memory, so forcefully end return 0; @@ -438,7 +524,7 @@ void hydra_reconnect(int s, char *ip, int port, unsigned char options) { } } -int start_http_form(int s, char *ip, int port, unsigned char options, char *miscptr, FILE * fp, char *type, ptr_header_node ptr_head) { +int start_http_form(int s, char *ip, int port, unsigned char options, char *miscptr, FILE * fp, char *type, ptr_header_node ptr_head, ptr_cookie_node ptr_cookie) { char *empty = ""; char *login, *pass, clogin[256], cpass[256]; char header[8096], *upd3variables; @@ -475,7 +561,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) - add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); + add_or_update_cookie(&ptr_cookie, cookie); hydra_reconnect(s, ip, port, options); } // now prepare for the "real" request @@ -511,7 +597,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) - add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); + add_or_update_cookie(&ptr_cookie, cookie); hydra_reconnect(s, ip, port, options); } // now prepare for the "real" request @@ -544,7 +630,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) { - add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); + add_or_update_cookie(&ptr_cookie, cookie); normal_request = stringify_headers(&ptr_head); } hydra_reconnect(s, ip, port, options); @@ -583,7 +669,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc } if (strlen(cookie) > 0) - add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); + add_or_update_cookie(&ptr_cookie, cookie); //if page was redirected, follow the location header redirected_cpt = MAX_REDIRECT; @@ -697,8 +783,8 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; found = analyze_server_response(s); - if (strlen(cookie) > 0) - add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); +// if (strlen(cookie) > 0) +// add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); } } @@ -713,7 +799,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; } -void service_http_form(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *type, ptr_header_node * ptr_head) { +void service_http_form(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *type, ptr_header_node * ptr_head, ptr_cookie_node * ptr_cookie) { int run = 1, next_run = 1, sock = -1; int myport = PORT_HTTP, mysslport = PORT_HTTP_SSL; @@ -763,7 +849,7 @@ void service_http_form(char *ip, int sp, unsigned char options, char *miscptr, F break; } case 2: /* run the cracking function */ - next_run = start_http_form(sock, ip, port, options, miscptr, fp, type, *ptr_head); + next_run = start_http_form(sock, ip, port, options, miscptr, fp, type, *ptr_head, *ptr_cookie); break; case 3: /* clean exit */ if (sock >= 0) @@ -795,10 +881,11 @@ void service_http_form(char *ip, int sp, unsigned char options, char *miscptr, F } void service_http_get_form(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port) { - ptr_header_node ptr_head = initialize(ip, options, miscptr); + ptr_cookie_node ptr_cookie = NULL; + ptr_header_node ptr_head = initialize(ip, options, miscptr); if (ptr_head) - service_http_form(ip, sp, options, miscptr, fp, port, "GET", &ptr_head); + service_http_form(ip, sp, options, miscptr, fp, port, "GET", &ptr_head, &ptr_cookie); else { hydra_report(stderr, "[ERROR] Could not launch head. Error while initializing.\n"); hydra_child_exit(1); @@ -806,10 +893,11 @@ void service_http_get_form(char *ip, int sp, unsigned char options, char *miscpt } void service_http_post_form(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port) { - ptr_header_node ptr_head = initialize(ip, options, miscptr); + ptr_cookie_node ptr_cookie = NULL; + ptr_header_node ptr_head = initialize(ip, options, miscptr); if (ptr_head) - service_http_form(ip, sp, options, miscptr, fp, port, "POST", &ptr_head); + service_http_form(ip, sp, options, miscptr, fp, port, "POST", &ptr_head, &ptr_cookie); else { hydra_report(stderr, "[ERROR] Could not launch head. Error while initializing.\n"); hydra_child_exit(1); From a4edb11bb3f5015345749b4444bfdb284d1d0584 Mon Sep 17 00:00:00 2001 From: ajuaristi Date: Wed, 18 Mar 2015 22:30:37 +0100 Subject: [PATCH 2/4] Fixed issue with multiple cookies. --- hydra-http-form.c | 89 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/hydra-http-form.c b/hydra-http-form.c index 3946af1..86c19cd 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -132,13 +132,37 @@ int append_cookie(char *name, char *value, ptr_cookie_node *last_cookie) return 1; } -void traverse_cookies(ptr_cookie_node ptr_cookie) +char * stringify_cookies(ptr_cookie_node ptr_cookie) { - printf("-- COOKIES START --\n"); ptr_cookie_node cur_ptr = NULL; - for (cur_ptr = ptr_cookie; cur_ptr; cur_ptr = cur_ptr->next) - printf("Cookie: %s=%s\n", cur_ptr->name, cur_ptr->value); - printf("-- COOKIES END --\n"); + unsigned int length = 1; + char *cookie_hdr = (char *) malloc(length); + + if (cookie_hdr) { + memset(cookie_hdr, 0, length); + for (cur_ptr = ptr_cookie; cur_ptr; cur_ptr = cur_ptr->next) { + length += 2 + strlen(cur_ptr->name) + strlen(cur_ptr->value); + cookie_hdr = (char *) realloc(cookie_hdr, length); + if (cookie_hdr) { + strcat(cookie_hdr, cur_ptr->name); + strcat(cookie_hdr, "="); + strcat(cookie_hdr, cur_ptr->value); + if (cur_ptr->next) + strcat(cookie_hdr, ";"); + } else + goto bail; + } + goto success; + } + +bail: + if (cookie_hdr) { + free(cookie_hdr); + cookie_hdr = NULL; + } + +success: + return cookie_hdr; } /* @@ -154,6 +178,7 @@ int add_or_update_cookie(ptr_cookie_node * ptr_cookie, char * cookie_expr) { // printf("[DEBUG] Added cookie: %s\n", cookie_expr); ptr_cookie_node cur_ptr = NULL, new_ptr = NULL; + char * cookie = strdup(cookie_expr); char * cookie_name = NULL, * cookie_value = strstr(cookie_expr, "="); if (cookie_value) { @@ -183,13 +208,31 @@ int add_or_update_cookie(ptr_cookie_node * ptr_cookie, char * cookie_expr) } } } - - traverse_cookies(*ptr_cookie); } else return 0; return 1; } +int process_cookies(ptr_cookie_node * ptr_cookie, char * cookie_expr) +{ + char *tok = NULL; + char *expr = strdup(cookie_expr); + int res = 0; + + if (strstr(cookie_expr, ";")) { + tok = strtok(expr, ";"); + while (tok) { + res = add_or_update_cookie(ptr_cookie, tok); + if (!res) + return res; + tok = strtok(NULL, ";"); + } + return res; + } else { + return add_or_update_cookie(ptr_cookie, expr); + } +} + /* * List layout: * +----------+ +--------+ +--------+ +--------+ @@ -528,6 +571,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc char *empty = ""; char *login, *pass, clogin[256], cpass[256]; char header[8096], *upd3variables; + char *cookie_header = NULL; char *http_request; int found = !success_cond, i, j; char content_length[MAX_CONTENT_LENGTH], proxy_string[MAX_PROXY_LENGTH]; @@ -561,7 +605,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) - add_or_update_cookie(&ptr_cookie, cookie); + process_cookies(&ptr_cookie, cookie); hydra_reconnect(s, ip, port, options); } // now prepare for the "real" request @@ -575,12 +619,16 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc add_header(&ptr_head, "Content-Length", content_length, HEADER_TYPE_DEFAULT); if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", proxy_string, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { - normal_request = stringify_headers(&ptr_head); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s", cookie_header); + normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; @@ -597,7 +645,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) - add_or_update_cookie(&ptr_cookie, cookie); + process_cookies(&ptr_cookie, cookie); hydra_reconnect(s, ip, port, options); } // now prepare for the "real" request @@ -611,12 +659,16 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc add_header(&ptr_head, "Content-Length", content_length, HEADER_TYPE_DEFAULT); if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", proxy_string, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { - normal_request = stringify_headers(&ptr_head); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s", cookie_header); + normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; @@ -630,7 +682,8 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; i = analyze_server_response(s); // ignore result if (strlen(cookie) > 0) { - add_or_update_cookie(&ptr_cookie, cookie); + //printf("[DEBUG] Got cookie: %s\n", cookie); + process_cookies(&ptr_cookie, cookie); normal_request = stringify_headers(&ptr_head); } hydra_reconnect(s, ip, port, options); @@ -644,12 +697,16 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc add_header(&ptr_head, "Content-Length", content_length, HEADER_TYPE_DEFAULT); if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s\n", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { - normal_request = stringify_headers(&ptr_head); + cookie_header = stringify_cookies(ptr_cookie); + printf("[DEBUG] %s\n", cookie_header); + normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; @@ -669,7 +726,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc } if (strlen(cookie) > 0) - add_or_update_cookie(&ptr_cookie, cookie); + process_cookies(&ptr_cookie, cookie); //if page was redirected, follow the location header redirected_cpt = MAX_REDIRECT; @@ -783,8 +840,8 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc return 1; found = analyze_server_response(s); -// if (strlen(cookie) > 0) -// add_header(&ptr_head, "Cookie", cookie, HEADER_TYPE_DEFAULT_REPL); + if (strlen(cookie) > 0) + process_cookies(ptr_cookie, cookie); } } From 7001f487d028f528e214586d82acb83c52033a19 Mon Sep 17 00:00:00 2001 From: strunk Date: Thu, 19 Mar 2015 01:27:43 +0100 Subject: [PATCH 3/4] Fixed #41 --- hydra-http-form.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/hydra-http-form.c b/hydra-http-form.c index 86c19cd..85215cf 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -289,9 +289,6 @@ int add_header(ptr_header_node * ptr_head, char *header, char *value, char type) existing_hdr->value = new_value; existing_hdr->type = type; } - // DEBUG - printf("[DEBUG] Added header: %s = %s\n", header, value); - // END DEBUG } else { // we're out of memory, so forcefully end return 0; @@ -620,14 +617,20 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", proxy_string, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) @@ -660,14 +663,20 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", proxy_string, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) @@ -698,14 +707,20 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc if (!header_exists(&ptr_head, "Content-Type", HEADER_TYPE_DEFAULT)) add_header(&ptr_head, "Content-Type", "application/x-www-form-urlencoded", HEADER_TYPE_DEFAULT); cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s\n", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("POST", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) return 1; } else { cookie_header = stringify_cookies(ptr_cookie); - printf("[DEBUG] %s\n", cookie_header); + if (!header_exists(&ptr_head, "Cookie", HEADER_TYPE_DEFAULT)) + add_header(&ptr_head, "Cookie", cookie_header, HEADER_TYPE_DEFAULT); + else + hdrrepv(&ptr_head, "Cookie", cookie_header); normal_request = stringify_headers(&ptr_head); http_request = prepare_http_request("GET", url, upd3variables, normal_request); if (hydra_send(s, http_request, strlen(http_request), 0) < 0) @@ -841,7 +856,7 @@ int start_http_form(int s, char *ip, int port, unsigned char options, char *misc found = analyze_server_response(s); if (strlen(cookie) > 0) - process_cookies(ptr_cookie, cookie); + process_cookies(ptr_cookie, cookie); } } From d1328eee8f5bc4e8b8721ee7aa17ea7ac01e1ae9 Mon Sep 17 00:00:00 2001 From: strunk Date: Thu, 19 Mar 2015 01:30:06 +0100 Subject: [PATCH 4/4] Removed comments --- hydra-http-form.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hydra-http-form.c b/hydra-http-form.c index 85215cf..be350da 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -176,7 +176,6 @@ success: */ int add_or_update_cookie(ptr_cookie_node * ptr_cookie, char * cookie_expr) { -// printf("[DEBUG] Added cookie: %s\n", cookie_expr); ptr_cookie_node cur_ptr = NULL, new_ptr = NULL; char * cookie = strdup(cookie_expr); char * cookie_name = NULL, @@ -184,25 +183,19 @@ int add_or_update_cookie(ptr_cookie_node * ptr_cookie, char * cookie_expr) if (cookie_value) { cookie_name = strndup(cookie_expr, cookie_value - cookie_expr); cookie_value = strdup(cookie_value + 1); -// printf("\t[DEBUG] Name: %s\n", cookie_name); -// printf("\t[DEBUG] Value: %s\n", cookie_value); // we've got the cookie's name and value, now it's time to insert or update the list if (*ptr_cookie == NULL) { // no cookies append_cookie(cookie_name, cookie_value, ptr_cookie); -// if (append_cookie(cookie_name, cookie_value, ptr_cookie)) -// printf("New cookie: %s=%s\n", (*ptr_cookie)->name, (*ptr_cookie)->value); } else { for (cur_ptr = *ptr_cookie; cur_ptr; cur_ptr = cur_ptr->next) { if (strcmp(cur_ptr->name, cookie_name) == 0) { -// printf("Cookie %s already exists. Replacing.\n", cookie_name); free(cur_ptr->value); cur_ptr->value = cookie_value; break; } if (cur_ptr->next == NULL) { -// printf("Cookie %s does not exist. Adding.\n", cookie_name); append_cookie(cookie_name, cookie_value, &cur_ptr); break; }