better error msgs

This commit is contained in:
vanhauser-thc 2014-06-03 13:37:23 +02:00
commit 6f0c841485

48
hydra.c
View file

@ -2980,12 +2980,16 @@ int main(int argc, char *argv[]) {
if (hydra_options.colonfile == NULL) {
if (hydra_options.loginfile != NULL) {
if ((lfp = fopen(hydra_options.loginfile, "r")) == NULL)
bail("File for logins not found!");
if ((lfp = fopen(hydra_options.loginfile, "r")) == NULL) {
fprintf(stderr, "[ERROR] File for logins not found: %s", hydra_options.loginfile);
exit(-1);
}
hydra_brains.countlogin = countlines(lfp, 0);
hydra_brains.sizelogin = size_of_data;
if (hydra_brains.countlogin == 0)
bail("File for logins is empty!");
if (hydra_brains.countlogin == 0) {
fprintf(stderr, "[ERROR] File for logins is empty: %s", hydra_options.loginfile);
exit(-1);
}
if (hydra_brains.countlogin > MAX_LINES) {
fprintf(stderr, "[ERROR] Maximum number of logins is %d, this file has %lu entries.\n", MAX_LINES, hydra_brains.countlogin);
exit(-1);
@ -3005,12 +3009,16 @@ int main(int argc, char *argv[]) {
hydra_brains.countlogin = 1;
}
if (hydra_options.passfile != NULL) {
if ((pfp = fopen(hydra_options.passfile, "r")) == NULL)
bail("File for passwords not found!");
if ((pfp = fopen(hydra_options.passfile, "r")) == NULL) {
fprintf(stderr, "[ERROR] File for passwords not found: %s", hydra_options.passfile);
exit(-1);
}
hydra_brains.countpass = countlines(pfp, 0);
hydra_brains.sizepass = size_of_data;
if (hydra_brains.countpass == 0)
bail("File for passwords is empty!");
if (hydra_brains.countpass == 0) {
fprintf(stderr, "[ERROR] File for passwords is empty: %s", hydra_options.passfile);
exit(-1);
}
if (hydra_brains.countpass > MAX_LINES) {
fprintf(stderr, "[ERROR] Maximum number of passwords is %d, this file has %lu entries.\n", MAX_LINES, hydra_brains.countpass);
exit(-1);
@ -3048,12 +3056,16 @@ int main(int argc, char *argv[]) {
}
}
} else {
if ((cfp = fopen(hydra_options.colonfile, "r")) == NULL)
bail("File with login:password information not found!");
if ((cfp = fopen(hydra_options.colonfile, "r")) == NULL) {
fprintf(stderr, "[ERROR] File for colon files (login:pass) not found: %s", hydra_options.colonfile);
exit(-1);
}
hydra_brains.countlogin = countlines(cfp, 1);
hydra_brains.sizelogin = size_of_data;
if (hydra_brains.countlogin == 0)
bail("File for login:password information is empty!");
if (hydra_brains.countlogin == 0) {
fprintf(stderr, "[ERROR] File for colon files (login:pass) is empty: %s", hydra_options.colonfile);
exit(-1);
}
if (hydra_brains.countlogin > MAX_LINES / 2) {
fprintf(stderr, "[ERROR] Maximum number of colon file entries is %d, this file has %lu entries.\n", MAX_LINES / 2, hydra_brains.countlogin);
exit(-1);
@ -3089,11 +3101,15 @@ int main(int argc, char *argv[]) {
}
if (hydra_options.infile_ptr != NULL) {
if ((ifp = fopen(hydra_options.infile_ptr, "r")) == NULL)
bail("File for IP addresses not found!");
if ((ifp = fopen(hydra_options.infile_ptr, "r")) == NULL) {
fprintf(stderr, "[ERROR] File for targets not found: %s", hydra_options.infile_ptr);
exit(-1);
}
hydra_brains.targets = countservers = countinfile = countlines(ifp, 0);
if (countinfile == 0)
bail("File for IP addresses is empty!");
if (countinfile == 0) {
fprintf(stderr, "[ERROR] File for targets is empty: %s", hydra_options.infile_ptr);
exit(-1);
}
hydra_targets = malloc(sizeof(hydra_targets) * (countservers + 2) + 8);
if (hydra_targets == NULL)
bail("Could not allocate enough memory for target data");