mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-05 20:41:39 -07:00
code indent
This commit is contained in:
parent
531ee7734b
commit
720bdb3f96
83 changed files with 6377 additions and 6240 deletions
85
bfg.c
85
bfg.c
|
@ -1,17 +1,18 @@
|
|||
|
||||
/* code original by Jan Dlabal <dlabaljan@gmail.com>, partially rewritten by vh */
|
||||
/* code original by Jan Dlabal <dlabaljan@gmail.com>, partially rewritten by vh
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#ifdef __sun
|
||||
#include <sys/int_types.h>
|
||||
#include <sys/int_types.h>
|
||||
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
|
||||
#include <inttypes.h>
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include "bfg.h"
|
||||
|
||||
|
@ -21,20 +22,26 @@ bf_option bf_options;
|
|||
|
||||
extern int32_t debug;
|
||||
|
||||
static int32_t add_single_char(char ch, char flags, int32_t* crs_len) {
|
||||
static int32_t add_single_char(char ch, char flags, int32_t *crs_len) {
|
||||
if ((ch >= '2' && ch <= '9') || ch == '0') {
|
||||
if ((flags & BF_NUMS) > 0) {
|
||||
printf("[ERROR] character %c defined in -x although the whole number range was already defined by '1', ignored\n", ch);
|
||||
printf("[ERROR] character %c defined in -x although the whole number "
|
||||
"range was already defined by '1', ignored\n",
|
||||
ch);
|
||||
return 0;
|
||||
}
|
||||
//printf("[WARNING] adding character %c for -x, note that '1' will add all numbers from 0-9\n", ch);
|
||||
// printf("[WARNING] adding character %c for -x, note that '1' will add all
|
||||
// numbers from 0-9\n", ch);
|
||||
}
|
||||
if (tolower((int32_t) ch) >= 'b' && tolower((int32_t) ch) <= 'z') {
|
||||
if (tolower((int32_t)ch) >= 'b' && tolower((int32_t)ch) <= 'z') {
|
||||
if ((ch <= 'Z' && (flags & BF_UPPER) > 0) || (ch > 'Z' && (flags & BF_UPPER) > 0)) {
|
||||
printf("[ERROR] character %c defined in -x although the whole letter range was already defined by '%c', ignored\n", ch, ch <= 'Z' ? 'A' : 'a');
|
||||
printf("[ERROR] character %c defined in -x although the whole letter "
|
||||
"range was already defined by '%c', ignored\n",
|
||||
ch, ch <= 'Z' ? 'A' : 'a');
|
||||
return 0;
|
||||
}
|
||||
//printf("[WARNING] adding character %c for -x, note that '%c' will add all %scase letters\n", ch, ch <= 'Z' ? 'A' : 'a', ch <= 'Z' ? "up" : "low");
|
||||
// printf("[WARNING] adding character %c for -x, note that '%c' will add all
|
||||
// %scase letters\n", ch, ch <= 'Z' ? 'A' : 'a', ch <= 'Z' ? "up" : "low");
|
||||
}
|
||||
(*crs_len)++;
|
||||
if (BF_CHARSMAX - *crs_len < 1) {
|
||||
|
@ -66,7 +73,8 @@ int32_t bf_init(char *arg) {
|
|||
}
|
||||
bf_options.from = atoi(arg);
|
||||
if (bf_options.from < 1 || bf_options.from > 127) {
|
||||
fprintf(stderr, "Error: minimum length must be between 1 and 127, format: -x min:max:types\n");
|
||||
fprintf(stderr, "Error: minimum length must be between 1 and 127, format: "
|
||||
"-x min:max:types\n");
|
||||
return 1;
|
||||
}
|
||||
arg = tmp + 1;
|
||||
|
@ -86,7 +94,8 @@ int32_t bf_init(char *arg) {
|
|||
tmp++;
|
||||
|
||||
if (bf_options.from > bf_options.to) {
|
||||
fprintf(stderr, "Error: you specified a minimum length higher than the maximum length!\n");
|
||||
fprintf(stderr, "Error: you specified a minimum length higher than the "
|
||||
"maximum length!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -166,23 +175,23 @@ int32_t bf_init(char *arg) {
|
|||
|
||||
bf_options.crs_len = crs_len;
|
||||
bf_options.current = bf_options.from;
|
||||
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
|
||||
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
||||
if (debug)
|
||||
printf("[DEBUG] bfg INIT: from %u, to %u, len: %u, set: %s\n", bf_options.from, bf_options.to, bf_options.crs_len, bf_options.crs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint64_t bf_get_pcount() {
|
||||
int32_t i;
|
||||
double count = 0;
|
||||
uint64_t foo;
|
||||
|
||||
for (i = bf_options.from; i <= bf_options.to; i++)
|
||||
count += (pow((double) bf_options.crs_len, (double) i));
|
||||
count += (pow((double)bf_options.crs_len, (double)i));
|
||||
if (count >= 0xffffffff) {
|
||||
fprintf(stderr, "\n[ERROR] definition for password bruteforce (-x) generates more than 4 billion passwords\n");
|
||||
fprintf(stderr, "\n[ERROR] definition for password bruteforce (-x) "
|
||||
"generates more than 4 billion passwords\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -190,12 +199,10 @@ uint64_t bf_get_pcount() {
|
|||
return foo;
|
||||
}
|
||||
|
||||
int accu(int value)
|
||||
{
|
||||
int accu(int value) {
|
||||
int i = 0, a;
|
||||
for (a=1; a<=value; ++a)
|
||||
{
|
||||
i+=a;
|
||||
for (a = 1; a <= value; ++a) {
|
||||
i += a;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -204,29 +211,27 @@ char *bf_next(_Bool rainy) {
|
|||
int32_t i, pos = bf_options.current - 1;
|
||||
|
||||
if (bf_options.current > bf_options.to)
|
||||
return NULL; // we are done
|
||||
return NULL; // we are done
|
||||
|
||||
if ((bf_options.ptr = malloc(BF_CHARSMAX)) == NULL) {
|
||||
fprintf(stderr, "Error: Can not allocate memory for -x data!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(rainy)
|
||||
{
|
||||
for (i = 0; i < bf_options.current; i++){
|
||||
bf_options.ptr[i] = bf_options.crs[(bf_options.state[i]+bf_options.rain)%bf_options.crs_len];
|
||||
bf_options.rain += i+1;
|
||||
}
|
||||
if(bf_options.crs_len%10 == 0)
|
||||
bf_options.rain-=accu(bf_options.current)-2;
|
||||
else if(bf_options.crs_len%2 == 0)
|
||||
bf_options.rain-=accu(bf_options.current)-4;
|
||||
else if(bf_options.crs_len%2)
|
||||
bf_options.rain-=accu(bf_options.current)-1;
|
||||
}
|
||||
else
|
||||
if (rainy) {
|
||||
for (i = 0; i < bf_options.current; i++) {
|
||||
bf_options.ptr[i] = bf_options.crs[(bf_options.state[i] + bf_options.rain) % bf_options.crs_len];
|
||||
bf_options.rain += i + 1;
|
||||
}
|
||||
if (bf_options.crs_len % 10 == 0)
|
||||
bf_options.rain -= accu(bf_options.current) - 2;
|
||||
else if (bf_options.crs_len % 2 == 0)
|
||||
bf_options.rain -= accu(bf_options.current) - 4;
|
||||
else if (bf_options.crs_len % 2)
|
||||
bf_options.rain -= accu(bf_options.current) - 1;
|
||||
} else
|
||||
for (i = 0; i < bf_options.current; i++)
|
||||
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
|
||||
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
|
||||
bf_options.ptr[bf_options.current] = 0;
|
||||
|
||||
if (debug) {
|
||||
|
@ -243,7 +248,7 @@ char *bf_next(_Bool rainy) {
|
|||
|
||||
if (pos < 0) {
|
||||
bf_options.current++;
|
||||
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
|
||||
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
||||
}
|
||||
|
||||
return bf_options.ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue