Skip to content

Commit

Permalink
ipv6 pretty print
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Jul 6, 2017
1 parent 4c6cbf0 commit 4ab31cd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
1 change: 0 additions & 1 deletion hydra-firebird.c
@@ -1,4 +1,3 @@

/*
Firebird Support - by David Maciejak @ GMAIL dot com
Expand Down
4 changes: 2 additions & 2 deletions hydra-http-proxy-urlenum.c
Expand Up @@ -210,8 +210,8 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
if (*ptr == '2' || (*ptr == '3' && (*(ptr + 2) == '1' || *(ptr + 2) == '2')) || strncmp(ptr, "404", 4) == 0 || strncmp(ptr, "403", 4) == 0) {
hydra_report_found_host(port, ip, "http-proxy", fp);
if (fp != stdout)
fprintf(fp, "[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string(ip), url);
printf("[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string(ip), url);
fprintf(fp, "[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string_beautiful(ip), url);
printf("[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string_beautiful(ip), url);
hydra_completed_pair_found();
} else {
if (strncmp(ptr, "407", 3) == 0 /*|| strncmp(ptr, "401", 3) == 0 */ ) {
Expand Down
23 changes: 23 additions & 0 deletions hydra-mod.c
Expand Up @@ -1208,6 +1208,29 @@ char *hydra_address2string(char *address) {
struct sockaddr_in target;
struct sockaddr_in6 target6;

if (address[0] == 4) {
memcpy(&target.sin_addr.s_addr, &address[1], 4);
return inet_ntoa((struct in_addr) target.sin_addr);
} else
#ifdef AF_INET6
if (address[0] == 16) {
memcpy(&target6.sin6_addr, &address[1], 16);
inet_ntop(AF_INET6, &target6.sin6_addr, ipstring, sizeof(ipstring));
return ipstring;
} else
#endif
{
if (debug)
fprintf(stderr, "[ERROR] unknown address string size!\n");
return NULL;
}
return NULL; // not reached
}

char *hydra_address2string_beautiful(char *address) {
struct sockaddr_in target;
struct sockaddr_in6 target6;

if (address[0] == 4) {
memcpy(&target.sin_addr.s_addr, &address[1], 4);
return inet_ntoa((struct in_addr) target.sin_addr);
Expand Down
1 change: 0 additions & 1 deletion hydra-postgres.c
@@ -1,4 +1,3 @@

/*
* PostgresSQL Support - by Diaul (at) devilopers.org
*
Expand Down
8 changes: 4 additions & 4 deletions hydra-ssh.c
Expand Up @@ -172,7 +172,7 @@ int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *misc
ssh_session session = ssh_new();

if (verbose || debug)
printf("[INFO] Testing if password authentication is supported by ssh://%s@%s:%d\n", miscptr == NULL ? "hydra" : miscptr, hydra_address2string(ip), port);
printf("[INFO] Testing if password authentication is supported by ssh://%s@%s:%d\n", miscptr == NULL ? "hydra" : miscptr, hydra_address2string_beautiful(ip), port);
ssh_options_set(session, SSH_OPTIONS_PORT, &port);
ssh_options_set(session, SSH_OPTIONS_HOST, hydra_address2string(ip));
if (miscptr == NULL)
Expand All @@ -182,7 +182,7 @@ int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *misc
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none");
if (ssh_connect(session) != 0) {
fprintf(stderr, "[ERROR] could not connect to ssh://%s:%d - %s\n", hydra_address2string(ip), port, ssh_get_error(session));
fprintf(stderr, "[ERROR] could not connect to ssh://%s:%d - %s\n", hydra_address2string_beautiful(ip), port, ssh_get_error(session));
return 2;
}
rc = ssh_userauth_none(session, NULL);
Expand All @@ -193,11 +193,11 @@ int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *misc

if ((method & SSH_AUTH_METHOD_INTERACTIVE) || (method & SSH_AUTH_METHOD_PASSWORD)) {
if (verbose || debug)
printf("[INFO] Successful, password authentication is supported by ssh://%s:%d\n", hydra_address2string(ip), port);
printf("[INFO] Successful, password authentication is supported by ssh://%s:%d\n", hydra_address2string_beautiful(ip), port);
return 0;
}

fprintf(stderr, "[ERROR] target ssh://%s:%d/ does not support password authentication.\n", hydra_address2string(ip), port);
fprintf(stderr, "[ERROR] target ssh://%s:%d/ does not support password authentication.\n", hydra_address2string_beautiful(ip), port);
return 1;
#else
return 0;
Expand Down
5 changes: 1 addition & 4 deletions hydra-svn.c
Expand Up @@ -103,10 +103,7 @@ int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char
svn_auth_open(&ctx->auth_baton, providers, pool);

revision.kind = svn_opt_revision_head;
if (ipv6)
snprintf(URL, sizeof(URL), "svn://[%s]:%d/%s", hydra_address2string(ip), port, URLBRANCH);
else
snprintf(URL, sizeof(URL), "svn://%s:%d/%s", hydra_address2string(ip), port, URLBRANCH);
snprintf(URL, sizeof(URL), "svn://%s:%d/%s", hydra_address2string_beautiful(ip), port, URLBRANCH);
dirents = SVN_DIRENT_KIND;
canonical = svn_uri_canonicalize(URL, pool);
//err = svn_client_list2(canonical, &revision, &revision, svn_depth_unknown, dirents, FALSE, print_dirdummy, NULL, ctx, pool);
Expand Down
3 changes: 2 additions & 1 deletion hydra.c
Expand Up @@ -211,6 +211,7 @@ extern char *hydra_strcasestr(const char *haystack, const char *needle);
extern void hydra_tobase64(unsigned char *buf, int32_t buflen, int32_t bufsize);
extern char *hydra_string_replace(const char *string, const char *substr, const char *replacement);
extern char *hydra_address2string(char *address);
extern char *hydra_address2string_beautiful(char *address);
extern int32_t colored_output;
extern char quiet;
extern int32_t do_retry;
Expand Down Expand Up @@ -638,7 +639,7 @@ void hydra_debug(int32_t force, char *string) {
hydra_target* target = hydra_targets[i];
printf
("[DEBUG] Target %d - target %s ip %s login_no %llu pass_no %llu sent %llu pass_state %d redo_state %d (%d redos) use_count %d failed %d done %d fail_count %d login_ptr %s pass_ptr %s\n",
i, STR_NULL(target->target), hydra_address2string(target->ip),
i, STR_NULL(target->target), hydra_address2string_beautiful(target->ip),
target->login_no, target->pass_no, target->sent,
target->pass_state, target->redo_state, target->redo,
target->use_count, target->failed, target->done,
Expand Down

0 comments on commit 4ab31cd

Please sign in to comment.