mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-15 19:17:30 -07:00
code indent
This commit is contained in:
parent
531ee7734b
commit
720bdb3f96
83 changed files with 6377 additions and 6240 deletions
68
hydra-ncp.c
68
hydra-ncp.c
|
@ -1,28 +1,25 @@
|
|||
/*
|
||||
* Novell Network Core Protocol Support - by David Maciejak @ GMAIL dot com
|
||||
* Tested on Netware 6.5
|
||||
*
|
||||
*
|
||||
* you need to install libncp and libncp-dev (tested with version 2.2.6-3)
|
||||
*
|
||||
*
|
||||
* you can passed full context as OPT
|
||||
*
|
||||
* example: ./hydra -L login -P passw 172.16.246.129 ncp .O=cx
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hydra-mod.h"
|
||||
|
||||
#ifndef LIBNCP
|
||||
void dummy_ncp() {
|
||||
printf("\n");
|
||||
}
|
||||
void dummy_ncp() { printf("\n"); }
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ncp/nwcalls.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern char *HYDRA_EXIT;
|
||||
extern int32_t child_head_no;
|
||||
|
@ -33,11 +30,10 @@ typedef struct __NCP_DATA {
|
|||
char *context;
|
||||
} _NCP_DATA;
|
||||
|
||||
//uncomment line below to see more trace stack
|
||||
// uncomment line below to see more trace stack
|
||||
//#define NCP_DEBUG
|
||||
|
||||
int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) {
|
||||
|
||||
int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
|
||||
char *login;
|
||||
char *pass;
|
||||
char context[256];
|
||||
|
@ -47,13 +43,11 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
|
|||
|
||||
_NCP_DATA *session;
|
||||
|
||||
|
||||
session = malloc(sizeof(_NCP_DATA));
|
||||
memset(session, 0, sizeof(_NCP_DATA));
|
||||
login = empty;
|
||||
pass = empty;
|
||||
|
||||
|
||||
if (strlen(login = hydra_get_next_login()) == 0) {
|
||||
login = empty;
|
||||
} else {
|
||||
|
@ -71,8 +65,8 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
|
|||
}
|
||||
}
|
||||
|
||||
//login and password are case insensitive
|
||||
//str_upper(login);
|
||||
// login and password are case insensitive
|
||||
// str_upper(login);
|
||||
|
||||
if (strlen(pass = hydra_get_next_password()) == 0)
|
||||
pass = empty;
|
||||
|
@ -91,27 +85,27 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
|
|||
|
||||
memset(session->spec.password, 0, sizeof(session->spec.password));
|
||||
memcpy(session->spec.password, pass, strlen(pass) + 1);
|
||||
//str_upper(session->spec.password);
|
||||
// str_upper(session->spec.password);
|
||||
|
||||
ncp_lib_error_code = ncp_login_conn(session->conn, session->spec.user, object_type, session->spec.password);
|
||||
switch (ncp_lib_error_code & 0x0000FFFF) {
|
||||
case 0x0000: /* Success */
|
||||
case 0x0000: /* Success */
|
||||
#ifdef NCP_DEBUG
|
||||
printf("Connection success (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code);
|
||||
#endif
|
||||
ncp_close(session->conn);
|
||||
hydra_report_found_host(port, ip, "ncp", fp); //ok
|
||||
hydra_report_found_host(port, ip, "ncp", fp); // ok
|
||||
hydra_completed_pair_found();
|
||||
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
||||
return 3; //exit
|
||||
return 3; // exit
|
||||
free(session);
|
||||
return 2; //next
|
||||
return 2; // next
|
||||
break;
|
||||
case 0x89DE: /* PASSWORD INVALID */
|
||||
case 0x89F0: /* BIND WILDCARD INVALID */
|
||||
case 0x89FF: /* NO OBJ OR BAD PASSWORD */
|
||||
case 0xFD63: /* FAILED_AUTHENTICATION */
|
||||
case 0xFDA7: /* NO_SUCH_ENTRY */
|
||||
case 0x89DE: /* PASSWORD INVALID */
|
||||
case 0x89F0: /* BIND WILDCARD INVALID */
|
||||
case 0x89FF: /* NO OBJ OR BAD PASSWORD */
|
||||
case 0xFD63: /* FAILED_AUTHENTICATION */
|
||||
case 0xFDA7: /* NO_SUCH_ENTRY */
|
||||
#ifdef NCP_DEBUG
|
||||
printf("Incorrect password (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code);
|
||||
#endif
|
||||
|
@ -119,7 +113,7 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
|
|||
hydra_completed_pair();
|
||||
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
|
||||
free(session);
|
||||
return 2; //next
|
||||
return 2; // next
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -131,10 +125,10 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
|
|||
break;
|
||||
}
|
||||
free(session);
|
||||
return 1; //reconnect
|
||||
return 1; // reconnect
|
||||
}
|
||||
|
||||
void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
|
||||
void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
|
||||
int32_t run = 1, next_run = 1, sock = -1;
|
||||
int32_t myport = PORT_NCP;
|
||||
|
||||
|
@ -144,7 +138,7 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
|
|||
|
||||
while (1) {
|
||||
switch (run) {
|
||||
case 1: /* connect and service init function */
|
||||
case 1: /* connect and service init function */
|
||||
if (sock >= 0)
|
||||
sock = hydra_disconnect(sock);
|
||||
if (port != 0)
|
||||
|
@ -152,14 +146,15 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
|
|||
sock = hydra_connect_tcp(ip, myport);
|
||||
port = myport;
|
||||
if (sock < 0) {
|
||||
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
|
||||
if (quiet != 1)
|
||||
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
|
||||
hydra_child_exit(1);
|
||||
}
|
||||
next_run = 2;
|
||||
break;
|
||||
case 2:
|
||||
/*
|
||||
* Here we start the password cracking process
|
||||
* Here we start the password cracking process
|
||||
*/
|
||||
next_run = start_ncp(sock, ip, port, options, miscptr, fp);
|
||||
break;
|
||||
|
@ -183,13 +178,13 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
|
|||
|
||||
#endif
|
||||
|
||||
int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
|
||||
int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
|
||||
// called before the childrens are forked off, so this is the function
|
||||
// which should be filled if initial connections and service setup has to be
|
||||
// performed once only.
|
||||
//
|
||||
// fill if needed.
|
||||
//
|
||||
//
|
||||
// return codes:
|
||||
// 0 all OK
|
||||
// -1 error, hydra will exit, so print a good error message here
|
||||
|
@ -197,6 +192,7 @@ int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *misc
|
|||
return 0;
|
||||
}
|
||||
|
||||
void usage_ncp(const char* service) {
|
||||
printf("Module ncp is optionally taking the full context, for example \".O=cx\"\n\n");
|
||||
void usage_ncp(const char *service) {
|
||||
printf("Module ncp is optionally taking the full context, for example "
|
||||
"\".O=cx\"\n\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue