mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-22 06:13:55 -07:00
fix Out of memory
This commit is contained in:
parent
eaa8f297d8
commit
cd814fe6af
2 changed files with 32 additions and 17 deletions
|
@ -386,6 +386,7 @@ char *stringify_headers(ptr_header_node *ptr_head) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return headers_str;
|
return headers_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,8 +510,17 @@ int32_t parse_options(char *miscptr, ptr_header_node *ptr_head) {
|
||||||
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).\n");
|
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).\n");
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
hydra_report(stderr, "[ERROR] no valid optional parameter type given: %c\n", miscptr[0]);
|
while (*ptr != 0 && *ptr != ':')
|
||||||
return 0;
|
ptr++;
|
||||||
|
|
||||||
|
if (*ptr != 0) {
|
||||||
|
*ptr = 0;
|
||||||
|
ptr += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
miscptr = ptr;
|
||||||
|
// hydra_report(stderr, "[ERROR] no valid optional parameter type given: %c\n", miscptr[0]);
|
||||||
|
// return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
35
hydra-http.c
35
hydra-http.c
|
@ -263,6 +263,8 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
|
||||||
// check status
|
// check status
|
||||||
if (match_status_code != NULL) {
|
if (match_status_code != NULL) {
|
||||||
for (int i = 0; match_status_code[i]; i++) {
|
for (int i = 0; match_status_code[i]; i++) {
|
||||||
|
if(match_status_code[i] == 0)
|
||||||
|
continue;
|
||||||
if (match_status_code[i] == atoi(ptr)) {
|
if (match_status_code[i] == atoi(ptr)) {
|
||||||
if (end_condition_type == -1) {
|
if (end_condition_type == -1) {
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -456,13 +458,14 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *misc = (char *)malloc(strlen(miscptr));
|
char *misc = (char *)malloc(strlen(miscptr) + 1);
|
||||||
|
char *cp = misc;
|
||||||
memset(misc, '\0', strlen(miscptr));
|
memset(misc, '\0', strlen(miscptr));
|
||||||
strcpy(misc, miscptr);
|
strcpy(misc, miscptr);
|
||||||
|
|
||||||
char *delim = ":";
|
char *delim = ":";
|
||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
char *match_text_start = NULL;
|
char* match_text_start = NULL;
|
||||||
memset(match_status_code, '\0', MAX_STATUS_CODE_SIZE);
|
memset(match_status_code, '\0', MAX_STATUS_CODE_SIZE);
|
||||||
|
|
||||||
#if defined __APPLE__ || __linux__ || __unix__
|
#if defined __APPLE__ || __linux__ || __unix__
|
||||||
|
@ -476,7 +479,7 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
if (strstr(p, "r=") != NULL || strstr(p, "R=") != NULL) {
|
if (strstr(p, "r=") != NULL || strstr(p, "R=") != NULL) {
|
||||||
if (strlen(p) < 3) {
|
if (strlen(p) < 3) {
|
||||||
hydra_report(stderr, "Invalid status code, eg: 200 or 200|400.");
|
hydra_report(stderr, "Invalid status code, eg: 200 or 200|400.");
|
||||||
free(misc);
|
free(cp);
|
||||||
misc = NULL;
|
misc = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +495,7 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
|
|
||||||
if ((n != 1 && tmp != '|') || value > 1000) {
|
if ((n != 1 && tmp != '|') || value > 1000) {
|
||||||
hydra_report(stderr, "Invalid status code, eg: 200 or 200|400.");
|
hydra_report(stderr, "Invalid status code, eg: 200 or 200|400.");
|
||||||
free(misc);
|
free(cp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +503,7 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
|
|
||||||
if (pos > MAX_STATUS_CODE_SIZE) {
|
if (pos > MAX_STATUS_CODE_SIZE) {
|
||||||
hydra_report(stderr, "Match up to %d status codes.", MAX_STATUS_CODE_SIZE);
|
hydra_report(stderr, "Match up to %d status codes.", MAX_STATUS_CODE_SIZE);
|
||||||
free(misc);
|
free(cp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,14 +520,17 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
}
|
}
|
||||||
if (strstr(p, "F=") != NULL || strstr(p, "S=") != NULL) {
|
if (strstr(p, "F=") != NULL || strstr(p, "S=") != NULL) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
if (misc != NULL) {
|
if (misc != NULL && strlen(misc) != 0) {
|
||||||
size += strlen(misc) + 1;
|
size += strlen(misc) + 1;
|
||||||
}
|
}
|
||||||
size += strlen(p);
|
size += strlen(p);
|
||||||
match_text_start = (char *)malloc(size);
|
if(size == strlen(p)) {
|
||||||
memset(match_text_start, '\0', strlen(match_text_start));
|
match_text_start = p;
|
||||||
strcat(match_text_start, p);
|
} else {
|
||||||
if (misc != NULL) {
|
match_text_start = (char *) realloc(p, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (misc != NULL && strlen(misc) != 0) {
|
||||||
strcat(match_text_start, ":");
|
strcat(match_text_start, ":");
|
||||||
strcat(match_text_start, misc);
|
strcat(match_text_start, misc);
|
||||||
}
|
}
|
||||||
|
@ -543,8 +549,8 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
|
|
||||||
if (condition_len >= END_CONDITION_MAX_LEN) {
|
if (condition_len >= END_CONDITION_MAX_LEN) {
|
||||||
hydra_report(stderr, "Condition string cannot be bigger than %u.", END_CONDITION_MAX_LEN);
|
hydra_report(stderr, "Condition string cannot be bigger than %u.", END_CONDITION_MAX_LEN);
|
||||||
free(misc);
|
free(cp);
|
||||||
free(match_text_start);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,13 +559,12 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
|
||||||
if (debug)
|
if (debug)
|
||||||
hydra_report(stderr, "End condition is %s, mod is %d\n", end_condition, end_condition_type);
|
hydra_report(stderr, "End condition is %s, mod is %d\n", end_condition, end_condition_type);
|
||||||
|
|
||||||
free(match_text_start);
|
|
||||||
match_text_start = NULL;
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
hydra_report(stderr, "Modificated options:%s\n", miscptr);
|
hydra_report(stderr, "Modificated options:%s\n", miscptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(cp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue