diff --git a/.travis.yml b/.travis.yml index 19f1e15..ad0b541 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ dist: trusty os: - linux - osx +arch: + - amd64 + - ppc64le compiler: - clang - gcc diff --git a/CHANGES b/CHANGES index 8ca1b75..f537d9b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,14 @@ Changelog for hydra ------------------- -Release 9.1-dev + +Release 9.2-dev +* fix for http-post-form optional parameters * enable gcc 10 support for xhydra too :) +* msys support + + +Release 9.1-dev * rdb: support for libfreerdp3 (thanks to animetauren) * new module: smb2 which also supports smb3 (uses libsmbclient-dev) (thanks to Karim Kanso for the module!) * oracle: added success condition (thanks to kazkansouh), compile on Cygwin (thanks to maaaaz) diff --git a/hydra-http-form.c b/hydra-http-form.c index 3034c5a..6a019dd 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -400,6 +400,10 @@ int32_t parse_options(char *miscptr, ptr_header_node *ptr_head) { * Beware of the backslashes (\)! */ while (*miscptr != 0) { + if (strlen(miscptr) < 3 || miscptr[1] != '=') { + hydra_report(stderr, "[ERROR] optional parameters must have the format X=value: %s\n", miscptr); + return 0; + } switch (miscptr[0]) { case 'a': // fall through case 'A': // only for http, not http-form! @@ -504,7 +508,9 @@ int32_t parse_options(char *miscptr, ptr_header_node *ptr_head) { // Error: abort execution hydra_report(stderr, "[ERROR] Out of memory for HTTP headers (H).\n"); return 0; - // no default + default: + hydra_report(stderr, "[ERROR] no valid optional parameter type given: %c\n", miscptr[0]); + return 0; } } return 1; @@ -576,6 +582,8 @@ char *html_encode(char *string) { ret = hydra_strrep(ret, "#", "%23"); if (index(ret, '=') != NULL) ret = hydra_strrep(ret, "=", "%3D"); + if (index(ret, '+') != NULL) + ret = hydra_strrep(ret, "+", "%2B"); return ret; } @@ -1197,7 +1205,7 @@ void service_http_get_form(char *ip, int32_t sp, unsigned char options, char *mi service_http_form(ip, sp, options, miscptr, fp, port, hostname, "GET", &ptr_head, &ptr_cookie); else { hydra_report(stderr, "[ERROR] Could not launch head. Error while initializing.\n"); - hydra_child_exit(1); + hydra_child_exit(2); } } @@ -1209,7 +1217,7 @@ void service_http_post_form(char *ip, int32_t sp, unsigned char options, char *m service_http_form(ip, sp, options, miscptr, fp, port, hostname, "POST", &ptr_head, &ptr_cookie); else { hydra_report(stderr, "[ERROR] Could not launch head. Error while initializing.\n"); - hydra_child_exit(1); + hydra_child_exit(2); } } @@ -1224,6 +1232,8 @@ int32_t service_http_form_init(char *ip, int32_t sp, unsigned char options, char // 0 all OK // -1 error, hydra will exit, so print a good error message here + if (initialize(ip, options, miscptr) == NULL) return 1; + return 0; } @@ -1281,22 +1291,17 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) { ptr++; if (*ptr != 0) *ptr++ = 0; - - if ((ptr2 = rindex(ptr, ':')) != NULL) { - cond = ptr2 + 1; - *ptr2 = 0; + + cond = ptr; + + if ((ptr2 = index(ptr, ':')) != NULL) { + *ptr2++ = 0; + if (*ptr2) + optional1 = ptr2; + else + optional1 = NULL; } else - cond = ptr; - /* - while (*ptr != 0 && (*ptr != ':' || *(ptr - 1) == '\\')) - ptr++; - if (*ptr != 0) - *ptr++ = 0; - */ - if (ptr == cond) optional1 = NULL; - else - optional1 = ptr; if (strstr(url, "\\:") != NULL) { if ((ptr = malloc(strlen(url))) != NULL) { @@ -1332,7 +1337,7 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) { sprintf(cookieurl, "%.1000s", url); // conditions now have to contain F or S to set the fail or success condition - if (*cond != 0 && (strpos(cond, "F=") == 0)) { + if (strpos(cond, "F=") == 0) { success_cond = 0; cond += 2; } else if (*cond != 0 && (strpos(cond, "S=") == 0)) { diff --git a/hydra-smb2.c b/hydra-smb2.c index a09490d..7c22bf1 100644 --- a/hydra-smb2.c +++ b/hydra-smb2.c @@ -126,8 +126,13 @@ bool smb2_run_test(creds_t *cr, const char *server, uint16_t port) { */ switch (errno) { + case ENOENT: + // Noticed this when connecting to older samba servers on linux + // where any credentials are accepted. + hydra_report(stderr, "[WARNING] %s might accept any credential\n", server); case EINVAL: // 22 - // probably password ok + // probably password ok, nominal case when connecting to a windows + // smb server with good credentials. smbc_free_context(ctx, 1); return true; break; @@ -147,6 +152,9 @@ bool smb2_run_test(creds_t *cr, const char *server, uint16_t port) { case ECONNREFUSED: // there are probably more codes that could be added here to // indicate connection errors. + hydra_report(stderr, + "[ERROR] Error %s (%d) while connecting to %s\n", + strerror(errno), errno, server); smbc_free_context(ctx, 1); EXIT_CONNECTION_ERROR; break; @@ -202,6 +210,11 @@ int32_t service_smb2_init(char *ip, int32_t sp, unsigned char options, char *mis continue; } if (CMP(tkn_workgroup, miscptr)) { + if (workgroup != default_workgroup) { + // miscptr has already been processed, goto end + miscptr += strlen(miscptr) + 1; + continue; + } miscptr += sizeof(tkn_workgroup) - 1; char *p = strchr(miscptr, '}'); if (p == NULL) { @@ -217,6 +230,11 @@ int32_t service_smb2_init(char *ip, int32_t sp, unsigned char options, char *mis continue; } if (CMP(tkn_netbios, miscptr)) { + if (netbios_name != NULL) { + // miscptr has already been processed, goto end + miscptr += strlen(miscptr) + 1; + continue; + } miscptr += sizeof(tkn_netbios) - 1; char *p = strchr(miscptr, '}'); if (p == NULL) { diff --git a/hydra.c b/hydra.c index 8c1c38c..c4778af 100644 --- a/hydra.c +++ b/hydra.c @@ -225,7 +225,7 @@ char *SERVICES = "adam6500 asterisk afp cisco cisco-enable cvs firebird ftp[s] " #define RESTOREFILE "./hydra.restore" #define PROGRAM "Hydra" -#define VERSION "v9.1" +#define VERSION "v9.2-dev" #define AUTHOR "van Hauser/THC" #define EMAIL "" #define AUTHOR2 "David Maciejak"