Skip to content

Commit

Permalink
modified parse_options function
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewmarcus committed Jul 16, 2018
1 parent 9afbddf commit 25383d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
19 changes: 9 additions & 10 deletions hydra-http-form.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ char *stringify_headers(ptr_header_node *ptr_head) {
return headers_str;
}

ptr_header_node parse_options(char *miscptr) {
ptr_header_node ptr_head = NULL;
int32_t parse_options(char *miscptr, ptr_header_node *ptr_head) {
char *ptr, *ptr2;

/*
Expand Down Expand Up @@ -429,14 +428,14 @@ ptr_header_node parse_options(char *miscptr) {
* - (optional1 + 2) contains the header's name
* - ptr contains the header's value
*/
if (add_header(&ptr_head, miscptr + 2, hydra_strrep(ptr, "\\:", ":"), HEADER_TYPE_USERHEADER)) {
if (add_header(ptr_head, miscptr + 2, hydra_strrep(ptr, "\\:", ":"), HEADER_TYPE_USERHEADER)) {
// Success: break the switch and go ahead
miscptr = ptr2;
break;
}
// Error: abort execution
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (h).");
return NULL;
return 0;
case 'H':
// add a new header, or replace an existing one's value
ptr = miscptr + 2;
Expand All @@ -460,19 +459,18 @@ ptr_header_node parse_options(char *miscptr) {
* - (optional1 + 2) contains the header's name
* - ptr contains the header's value
*/
if (add_header(&ptr_head, miscptr + 2, hydra_strrep(ptr, "\\:", ":"), HEADER_TYPE_USERHEADER_REPL)) {
if (add_header(ptr_head, miscptr + 2, hydra_strrep(ptr, "\\:", ":"), HEADER_TYPE_USERHEADER_REPL)) {
// Success: break the switch and go ahead
miscptr = ptr2;
break;
}
// Error: abort execution
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).");
return NULL;
return 0;
// no default
}
}

return ptr_head;
return 1;
}

char *prepare_http_request(char *type, char *path, char *params, char *headers) {
Expand Down Expand Up @@ -1178,7 +1176,7 @@ int32_t service_http_form_init(char *ip, int32_t sp, unsigned char options, char
}

ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) {
ptr_header_node ptr_head;
ptr_header_node ptr_head = NULL;
char *ptr, *ptr2, *proxy_string;

if (use_proxy > 0 && proxy_count > 0)
Expand Down Expand Up @@ -1278,7 +1276,8 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) {
* Parse the user-supplied options.
* Beware of the backslashes (\)!
*/
ptr_head = parse_options(optional1);
if (!parse_options(optional1, &ptr_head))
return NULL;

/* again: no snprintf to be portable. don't worry, buffer can't overflow */
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL) {
Expand Down
5 changes: 3 additions & 2 deletions hydra-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_HTTP, mysslport = PORT_HTTP_SSL;
char *ptr, *ptr2;
ptr_header_node ptr_head;
ptr_header_node ptr_head = NULL;

hydra_register_socket(sp);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
Expand Down Expand Up @@ -310,7 +310,8 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
*ptr++ = 0;
optional1 = ptr;

ptr_head = parse_options(optional1);
if (!parse_options(optional1, &ptr_head))
run = 4;

while (1) {
next_run = 0;
Expand Down
2 changes: 1 addition & 1 deletion hydra-http.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern char *webtarget;
extern char *slash;
extern char *optional1;

extern ptr_header_node parse_options(char *miscptr);
extern int32_t parse_options(char *miscptr, ptr_header_node * ptr_head);
extern int32_t add_header(ptr_header_node * ptr_head, char *header, char *value, char type);
extern char *stringify_headers(ptr_header_node *ptr_head);
#endif

0 comments on commit 25383d7

Please sign in to comment.