From 1965e69d9203437c6b148b449b304015c7d5cc81 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 27 Mar 2015 14:45:03 +0100 Subject: [PATCH] fix xmpp for servers that send multiple lines --- hydra-xmpp.c | 93 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/hydra-xmpp.c b/hydra-xmpp.c index c800f57..1557d18 100644 --- a/hydra-xmpp.c +++ b/hydra-xmpp.c @@ -96,6 +96,7 @@ int start_xmpp(int s, char *ip, int port, unsigned char options, char *miscptr, /* server now would ask for the password */ if ((strstr(buf, CHALLENGE_STR) != NULL) || (strstr(buf, CHALLENGE_STR2) != NULL)) { char *ptr = strstr(buf, CHALLENGE_STR); + if (!ptr) ptr = strstr(buf, CHALLENGE_STR2); char *ptr_end = strstr(ptr, CHALLENGE_END_STR); @@ -334,56 +335,54 @@ void service_xmpp(char *target, char *ip, int sp, unsigned char options, char *m } //some server is longer to answer usleep(300000); - buf = hydra_receive_line(sock); + do { + if ((buf = hydra_receive_line(sock)) == NULL) { + /* no auth method identified */ + hydra_report(stderr, "[ERROR] no authentication methods can be identified %s\n", buf); + free(buf); + hydra_child_exit(1); + } - if (buf == NULL) - hydra_child_exit(1); + if (strstr(buf, "SCRAM-SHA-1") != NULL) { + xmpp_auth_mechanism = AUTH_SCRAMSHA1; + } + if (strstr(buf, "CRAM-MD5") != NULL) { + xmpp_auth_mechanism = AUTH_CRAMMD5; + } + if (strstr(buf, "DIGEST-MD5") != NULL) { + xmpp_auth_mechanism = AUTH_DIGESTMD5; + } + if (strstr(buf, "PLAIN") != NULL) { + xmpp_auth_mechanism = AUTH_PLAIN; + } + if (strstr(buf, "LOGIN") != NULL) { + xmpp_auth_mechanism = AUTH_LOGIN; + } + } free(buf); - hydra_child_exit(1); - } - - if (strstr(buf, "SCRAM-SHA-1") != NULL) { - xmpp_auth_mechanism = AUTH_SCRAMSHA1; - } - if (strstr(buf, "CRAM-MD5") != NULL) { - xmpp_auth_mechanism = AUTH_CRAMMD5; - } - if (strstr(buf, "DIGEST-MD5") != NULL) { - xmpp_auth_mechanism = AUTH_DIGESTMD5; - } - if (strstr(buf, "PLAIN") != NULL) { - xmpp_auth_mechanism = AUTH_PLAIN; - } - if (strstr(buf, "LOGIN") != NULL) { - xmpp_auth_mechanism = AUTH_LOGIN; - } - } - if (xmpp_auth_mechanism == AUTH_ERROR) { - /* no auth method identified */ - hydra_report(stderr, "[ERROR] no authentication methods can be identified %s\n", buf); - free(buf); - hydra_child_exit(1); - } - free(buf); + } while (xmpp_auth_mechanism == AUTH_ERROR); if ((miscptr != NULL) && (strlen(miscptr) > 0)) { int i;