mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-06 04:51:40 -07:00
modified parse_options function
This commit is contained in:
parent
9afbddfa95
commit
25383d76d9
3 changed files with 13 additions and 13 deletions
|
@ -388,8 +388,7 @@ char *stringify_headers(ptr_header_node *ptr_head) {
|
||||||
return headers_str;
|
return headers_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr_header_node parse_options(char *miscptr) {
|
int32_t parse_options(char *miscptr, ptr_header_node *ptr_head) {
|
||||||
ptr_header_node ptr_head = NULL;
|
|
||||||
char *ptr, *ptr2;
|
char *ptr, *ptr2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -429,14 +428,14 @@ ptr_header_node parse_options(char *miscptr) {
|
||||||
* - (optional1 + 2) contains the header's name
|
* - (optional1 + 2) contains the header's name
|
||||||
* - ptr contains the header's value
|
* - 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
|
// Success: break the switch and go ahead
|
||||||
miscptr = ptr2;
|
miscptr = ptr2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Error: abort execution
|
// Error: abort execution
|
||||||
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (h).");
|
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (h).");
|
||||||
return NULL;
|
return 0;
|
||||||
case 'H':
|
case 'H':
|
||||||
// add a new header, or replace an existing one's value
|
// add a new header, or replace an existing one's value
|
||||||
ptr = miscptr + 2;
|
ptr = miscptr + 2;
|
||||||
|
@ -460,19 +459,18 @@ ptr_header_node parse_options(char *miscptr) {
|
||||||
* - (optional1 + 2) contains the header's name
|
* - (optional1 + 2) contains the header's name
|
||||||
* - ptr contains the header's value
|
* - 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
|
// Success: break the switch and go ahead
|
||||||
miscptr = ptr2;
|
miscptr = ptr2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Error: abort execution
|
// Error: abort execution
|
||||||
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).");
|
hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).");
|
||||||
return NULL;
|
return 0;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
return ptr_head;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *prepare_http_request(char *type, char *path, char *params, char *headers) {
|
char *prepare_http_request(char *type, char *path, char *params, char *headers) {
|
||||||
|
@ -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 initialize(char *ip, unsigned char options, char *miscptr) {
|
||||||
ptr_header_node ptr_head;
|
ptr_header_node ptr_head = NULL;
|
||||||
char *ptr, *ptr2, *proxy_string;
|
char *ptr, *ptr2, *proxy_string;
|
||||||
|
|
||||||
if (use_proxy > 0 && proxy_count > 0)
|
if (use_proxy > 0 && proxy_count > 0)
|
||||||
|
@ -1278,7 +1276,8 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) {
|
||||||
* Parse the user-supplied options.
|
* Parse the user-supplied options.
|
||||||
* Beware of the backslashes (\)!
|
* 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 */
|
/* again: no snprintf to be portable. don't worry, buffer can't overflow */
|
||||||
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL) {
|
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL) {
|
||||||
|
|
|
@ -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 run = 1, next_run = 1, sock = -1;
|
||||||
int32_t myport = PORT_HTTP, mysslport = PORT_HTTP_SSL;
|
int32_t myport = PORT_HTTP, mysslport = PORT_HTTP_SSL;
|
||||||
char *ptr, *ptr2;
|
char *ptr, *ptr2;
|
||||||
ptr_header_node ptr_head;
|
ptr_header_node ptr_head = NULL;
|
||||||
|
|
||||||
hydra_register_socket(sp);
|
hydra_register_socket(sp);
|
||||||
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
||||||
|
@ -310,7 +310,8 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
|
||||||
*ptr++ = 0;
|
*ptr++ = 0;
|
||||||
optional1 = ptr;
|
optional1 = ptr;
|
||||||
|
|
||||||
ptr_head = parse_options(optional1);
|
if (!parse_options(optional1, &ptr_head))
|
||||||
|
run = 4;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
next_run = 0;
|
next_run = 0;
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern char *webtarget;
|
||||||
extern char *slash;
|
extern char *slash;
|
||||||
extern char *optional1;
|
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 int32_t add_header(ptr_header_node * ptr_head, char *header, char *value, char type);
|
||||||
extern char *stringify_headers(ptr_header_node *ptr_head);
|
extern char *stringify_headers(ptr_header_node *ptr_head);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue