forked from vanhauser-thc/thc-hydra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
531ee77
commit 720bdb3
Showing
83 changed files
with
6,381 additions
and
6,244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: false | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 512 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
- Regex: '.*' | ||
Priority: 1 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IndentCaseLabels: false | ||
IndentPPDirectives: None | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
TabWidth: 2 | ||
UseTab: Never | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
|
||
/* code original by Jan Dlabal <[email protected]>, partially rewritten by vh */ | ||
/* code original by Jan Dlabal <[email protected]>, 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,36 +175,34 @@ 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); | ||
} | ||
|
||
foo = count / 1; | ||
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.