diff --git a/ModeFactory.cpp b/ModeFactory.cpp index 4e48e18..5a41326 100644 --- a/ModeFactory.cpp +++ b/ModeFactory.cpp @@ -88,3 +88,10 @@ mode ModeFactory::doubles() { r.function = ModeFunction::Doubles; return r; } + +mode ModeFactory::startEnd(const char hex) { + mode r; + r.function = ModeFunction::StartEnd; + r.data1[0] = static_cast(hexValue(hex)); + return r; +} diff --git a/ModeFactory.hpp b/ModeFactory.hpp index 351dd64..afe2090 100644 --- a/ModeFactory.hpp +++ b/ModeFactory.hpp @@ -23,6 +23,7 @@ class ModeFactory { static mode letters(); static mode numbers(); static mode doubles(); + static mode startEnd(const char charLeading); }; #endif /* HPP_MODEFACTORY */ diff --git a/README.md b/README.md index 7b33fa7..17ea175 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ usage: ./ERADICATE2 [OPTIONS] Modes with arguments: --leading Score on hashes leading with given hex character. --matching Score on hashes matching given hex string. + --start-end Score on hashes start & end with given hex character. Advanced modes: --leading-range Scores on hashes leading with characters within diff --git a/eradicate2.cl b/eradicate2.cl index 6de4cfe..2e4858e 100644 --- a/eradicate2.cl +++ b/eradicate2.cl @@ -1,5 +1,5 @@ enum ModeFunction { - Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange + Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd }; typedef struct { @@ -23,6 +23,7 @@ void eradicate2_score_matching(const uchar * const hash, __global result * const void eradicate2_score_range(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round); void eradicate2_score_leadingrange(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round); void eradicate2_score_mirror(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round); +void eradicate2_score_startend(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round); void eradicate2_score_doubles(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round); __kernel void eradicate2_iterate(__global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) { @@ -69,6 +70,10 @@ __kernel void eradicate2_iterate(__global result * const pResult, __global const eradicate2_score_mirror(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round); break; + case StartEnd: + eradicate2_score_startend(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round); + break; + case Doubles: eradicate2_score_doubles(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round); break; @@ -228,6 +233,37 @@ void eradicate2_score_mirror(const uchar * const hash, __global result * const p eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round); } +void eradicate2_score_startend(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) { + const size_t id = get_global_id(0); + int score = 0; + int err = 0; + + for (int i = 0; i < 10 && !err; ++i) { + const uchar leftLeft = (hash[i] & 0xF0) >> 4; + const uchar leftRight = (hash[i] & 0x0F); + + const uchar rightLeft = (hash[19 - i] & 0xF0) >> 4; + const uchar rightRight = (hash[19 - i] & 0x0F); + + if (leftLeft != rightRight || leftLeft != pMode->data1[0]) { + err = 1; + break; + } + + score += 2; + + if (leftRight != rightLeft || leftRight != pMode->data1[0]) { + if(leftRight == pMode->data1[0]) ++score; + err = 1; + break; + } + + score += 2; + } + + eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round); +} + void eradicate2_score_doubles(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) { const size_t id = get_global_id(0); int score = 0; diff --git a/eradicate2.cpp b/eradicate2.cpp index 56cdb32..7cb39ab 100644 --- a/eradicate2.cpp +++ b/eradicate2.cpp @@ -189,6 +189,7 @@ int main(int argc, char * * argv) { bool bModeRange = false; bool bModeMirror = false; bool bModeDoubles = false; + std::string strModeStartEnd; int rangeMin = 0; int rangeMax = 0; std::vector vDeviceSkipIndex; @@ -211,6 +212,7 @@ int main(int argc, char * * argv) { argp.addSwitch('7', "range", bModeRange); argp.addSwitch('8', "mirror", bModeMirror); argp.addSwitch('9', "leading-doubles", bModeDoubles); + argp.addSwitch('z', "start-end", strModeStartEnd); argp.addSwitch('m', "min", rangeMin); argp.addSwitch('M', "max", rangeMax); argp.addMultiSwitch('s', "skip", vDeviceSkipIndex); @@ -270,6 +272,8 @@ int main(int argc, char * * argv) { mode = ModeFactory::mirror(); } else if (bModeDoubles) { mode = ModeFactory::doubles(); + } else if (!strModeStartEnd.empty()) { + mode = ModeFactory::startEnd(strModeStartEnd.front()); } else { std::cout << g_strHelp << std::endl; return 0; diff --git a/help.hpp b/help.hpp index 77fd147..af37e32 100644 --- a/help.hpp +++ b/help.hpp @@ -28,6 +28,7 @@ usage: ./ERADICATE2 [OPTIONS] Modes with arguments: --leading Score on hashes leading with given hex character. --matching Score on hashes matching given hex string. + --start-end Score on hashes start & end with given hex character. Advanced modes: --leading-range Scores on hashes leading with characters within diff --git a/types.hpp b/types.hpp index a2468c4..6a68e27 100644 --- a/types.hpp +++ b/types.hpp @@ -11,7 +11,7 @@ #endif enum class ModeFunction { - Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange + Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd }; typedef struct {