|
@@ -87,7 +87,7 @@ void intro() {
|
|
|
|
|
|
static unsigned int maxlones = 0;
|
|
|
|
|
|
-static dataKey pDatakey;
|
|
|
+static dataKey m_dataKey;
|
|
|
|
|
|
static struct {
|
|
|
bool reg = false;
|
|
@@ -104,22 +104,23 @@ static inline bool NotThat(const char *what, const std::regex ®) {
|
|
|
}
|
|
|
|
|
|
static inline bool NotThat(const char *a, const char *b) {
|
|
|
- while (*b)
|
|
|
- if (*a++ != *b++)
|
|
|
- return true;
|
|
|
- return false;
|
|
|
+ //while (*b)
|
|
|
+ // if (*a++ != *b++)
|
|
|
+ // return true;
|
|
|
+ //return false;
|
|
|
+ return strstr(a, b) == 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
void usage(void) {
|
|
|
const constexpr char *help = NAMEPROGRAM
|
|
|
- " [text-pattern|regex-pattern] [options]\n"
|
|
|
+ " [text-pattern(for just search by text, like to 200:ffff)] [options]\n"
|
|
|
"-h --help, help menu\n"
|
|
|
- "-r --reg, regexp instead just text pattern (e.g. '(one|two).*')\n"
|
|
|
+ "-r --reg, (^2.*ffff.*$) regexp instead just text pattern (e.g. '(one|two).*')\n"
|
|
|
"--threads -t, (default count of system)\n"
|
|
|
"-o --output output file (default keys.txt)\n"
|
|
|
"--usage this menu\n"
|
|
|
"--highhead -H mode of high head...\n"
|
|
|
- "--searchadress -s (default) mode\n"
|
|
|
+ //"--searchadress -s (default) mode\n"
|
|
|
"--limitfound=n -lN limit found\n"
|
|
|
"--ncurses -n start ncurses interface\n"
|
|
|
//"--prefix -p\n"
|
|
@@ -132,19 +133,26 @@ void parsing(int argc, char **args) {
|
|
|
|
|
|
static struct option long_options[] = {
|
|
|
{"help", no_argument, 0, 'h'},
|
|
|
- {"reg", no_argument, 0, 'r'},
|
|
|
+ {"reg", required_argument, 0, 'r'},
|
|
|
{"threads", required_argument, 0, 't'},
|
|
|
{"output", required_argument, 0, 'o'},
|
|
|
{"usage", no_argument, 0, 0},
|
|
|
{"highhead", no_argument, 0, 'H'},
|
|
|
- {"searchadress", no_argument, 0, 's'},
|
|
|
+ // {"searchadress", no_argument, 0, 's'},
|
|
|
{"limitfound", required_argument, 0, 'l'},
|
|
|
{"ncurses", no_argument, 0, 'n'},
|
|
|
{0, 0, 0, 0}};
|
|
|
|
|
|
int c;
|
|
|
OptionBox ncursesoptions;
|
|
|
- while ((c = getopt_long(argc, args, "hrt:s:o:Hsl:n", long_options,
|
|
|
+ auto setRegExp = [](const char*searchbytext){
|
|
|
+ options.reg = true;
|
|
|
+ options.searchtextby = new char[MAXBUF];
|
|
|
+ memcpy(options.searchtextby, searchbytext, strlen(searchbytext) );
|
|
|
+ std::cout << "RegExp pattern: "<<searchbytext << std::endl;
|
|
|
+ options.regex = std::regex( options.searchtextby );
|
|
|
+ };
|
|
|
+ while ((c = getopt_long(argc, args, "hr:t:o:Hsl:n", long_options,
|
|
|
&option_index)) != -1) {
|
|
|
switch (c) {
|
|
|
case 0:
|
|
@@ -162,11 +170,16 @@ void parsing(int argc, char **args) {
|
|
|
break;
|
|
|
case RegExp:
|
|
|
options.reg = true;
|
|
|
+ setRegExp(ncursesoptions.searchtext);
|
|
|
+ //goto REGEXP;
|
|
|
break;
|
|
|
+ case Exit:
|
|
|
+ exit(0);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ options.searchtextby = new char[MAXBUF];
|
|
|
+ memcpy(options.searchtextby, ncursesoptions.searchtext, MAXBUF);
|
|
|
}
|
|
|
- options.searchtextby = new char[MAXBUF];
|
|
|
- memcpy(options.searchtextby, ncursesoptions.searchtext, MAXBUF);
|
|
|
-
|
|
|
break;
|
|
|
|
|
|
case 'l':
|
|
@@ -176,16 +189,16 @@ void parsing(int argc, char **args) {
|
|
|
options.mode = ProgramMode::high;
|
|
|
options.outputpath = defaultHighSearchFileName;
|
|
|
break;
|
|
|
- case 's':
|
|
|
+ /*case 's':
|
|
|
options.mode = ProgramMode::search;
|
|
|
options.outputpath = defaultSearchFileName;
|
|
|
- break;
|
|
|
+ break;*/
|
|
|
case 'h':
|
|
|
usage();
|
|
|
exit(0);
|
|
|
break;
|
|
|
case 'r':
|
|
|
- options.reg = true;
|
|
|
+ setRegExp(optarg);
|
|
|
break;
|
|
|
case 't':
|
|
|
options.threads = atoi(optarg);
|
|
@@ -235,8 +248,7 @@ void convertSHA512ToSum(unsigned char hash[SHA512_DIGEST_LENGTH],
|
|
|
sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
|
|
|
}
|
|
|
}
|
|
|
-char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH],
|
|
|
- BoxKeys myKeys, int &cOnes) {
|
|
|
+char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH], int &cOnes) {
|
|
|
// char hash[128];
|
|
|
// convertSHA512ToSum(h, hash);
|
|
|
unsigned char byte;
|
|
@@ -279,37 +291,31 @@ char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH],
|
|
|
cOnes = lOnes;
|
|
|
return addr;
|
|
|
}
|
|
|
-char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH],
|
|
|
- BoxKeys myKeys) {
|
|
|
+char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH]) {
|
|
|
int o;
|
|
|
- return convertSHA512ToIPv6(hash, myKeys, o);
|
|
|
+ return convertSHA512ToIPv6(hash, o);
|
|
|
}
|
|
|
|
|
|
std::mutex m_writeMutex;
|
|
|
-static inline void addKeyPair(BoxKeys data, std::string ipv6) {
|
|
|
+static inline void addKeyPair() {
|
|
|
std::lock_guard<std::mutex> guard(m_writeMutex);
|
|
|
std::ofstream f(options.outputpath, std::ofstream::out | std::ofstream::app);
|
|
|
if (f) {
|
|
|
- f << "~" << std::endl;
|
|
|
- f << (options.mode == ProgramMode::high ? "HighMode" : "SearchMode")
|
|
|
- << std::endl;
|
|
|
- f << "Your keys: " << std::endl;
|
|
|
- f << "Secret key: ";
|
|
|
- for (int i = 0; i < KEYSIZE; ++i) {
|
|
|
- f << std::setw(2) << std::setfill('0') << std::hex
|
|
|
- << (int)data.PrivateKey[i];
|
|
|
- }
|
|
|
- f << std::endl;
|
|
|
-
|
|
|
- f << "Public Key: ";
|
|
|
- for (int i = 0; i < 32; ++i) {
|
|
|
- f << std::setw(2) << std::setfill('0') << std::hex
|
|
|
- << (int)data.PublicKey[i];
|
|
|
- }
|
|
|
-
|
|
|
- f << std::endl;
|
|
|
- f << "IPv6: " << ipv6 << std::endl;
|
|
|
- f << "~" << std::endl;
|
|
|
+ f << "Your keys: " << std::endl;
|
|
|
+ f << "Public Key: ";
|
|
|
+ for(int i = 0; i < 32; ++i)
|
|
|
+ {
|
|
|
+ f << std::setw(2) << std::setfill('0') << std::hex << (int)m_dataKey.pk[i];
|
|
|
+ }
|
|
|
+ f << std::endl;
|
|
|
+
|
|
|
+ f << "Secret key: ";
|
|
|
+ for(int i = 0; i < KEYSIZE; ++i)
|
|
|
+ {
|
|
|
+ f << std::setw(2) << std::setfill('0') << std::hex << (int)m_dataKey.sk[i];
|
|
|
+ }
|
|
|
+ f << std::endl;
|
|
|
+ f << "IPv6: " <<m_dataKey.ip << std::endl;
|
|
|
} else
|
|
|
std::cout << "Can't create/reopen file " << options.outputpath << std::endl;
|
|
|
}
|
|
@@ -318,14 +324,8 @@ static inline void miner(const char *prefix) {
|
|
|
if (options.reg && prefix[0] != '^' && options.mode != ProgramMode::high) {
|
|
|
std::cerr << "WARNING: "
|
|
|
<< "IF YOU DONT KNOW REGEXP PLEASE SEE IT -> https://regexr.com/"
|
|
|
- << std::endl;
|
|
|
+ << std::endl << prefix << std::endl;
|
|
|
sleep(15); // magic number
|
|
|
- } else if (prefix[0] != '2' && options.mode != ProgramMode::high) {
|
|
|
- std::cerr << "WARNING: "
|
|
|
- << "YOU WANT TO FOUND ADRESS WHICH NOT EXIST IN YGGDRASIL, ARE "
|
|
|
- "YOU OKEY?!"
|
|
|
- << std::endl;
|
|
|
- sleep(30); // magic number
|
|
|
}
|
|
|
auto clearconsole = [](int defsleep = 1) {
|
|
|
#ifndef __linux__
|
|
@@ -352,26 +352,30 @@ static inline void miner(const char *prefix) {
|
|
|
auto myKeys = getKeyPair();
|
|
|
unsigned char hash[SHA512_DIGEST_LENGTH];
|
|
|
getSHA512(myKeys.PublicKey, hash);
|
|
|
- char *ipv6 = convertSHA512ToIPv6(hash, myKeys);
|
|
|
+
|
|
|
+ /*volatile */int ones;
|
|
|
+ auto ipv6 = options.mode == ProgramMode::high ? convertSHA512ToIPv6(hash, ones) : convertSHA512ToIPv6(hash);
|
|
|
+ //printf("%s\n", ipv6);
|
|
|
if (options.mode == ProgramMode::high) {
|
|
|
- int ones;
|
|
|
- ipv6 = convertSHA512ToIPv6(hash, myKeys, ones);
|
|
|
if (ones > maxlones) {
|
|
|
clearconsole();
|
|
|
maxlones = ones;
|
|
|
std::cout << "Found new max high-addr: "
|
|
|
<< "(" << maxlones << ") " << ipv6 << std::endl;
|
|
|
- addKeyPair(myKeys, ipv6);
|
|
|
+ ADDKEYS(m_dataKey, myKeys, ipv6);//To inline?
|
|
|
+ addKeyPair();
|
|
|
}
|
|
|
} else {
|
|
|
- ipv6 = convertSHA512ToIPv6(hash, myKeys);
|
|
|
+ //ipv6 = convertSHA512ToIPv6(hash);
|
|
|
if ((options.reg ? !NotThat(ipv6, options.regex)
|
|
|
: !NotThat(ipv6, prefix))) {
|
|
|
clearconsole();
|
|
|
std::cout << "Address found: "
|
|
|
<< "(" << ++foundAddreses << ") " << ipv6;
|
|
|
std::cout << std::flush;
|
|
|
- addKeyPair(myKeys, ipv6);
|
|
|
+ ADDKEYS(m_dataKey, myKeys, ipv6);
|
|
|
+
|
|
|
+ addKeyPair();
|
|
|
// delete newKey.sk; // not need. not-heap..
|
|
|
}
|
|
|
}
|
|
@@ -387,20 +391,17 @@ int main(int argc, char **argv) {
|
|
|
options.outputpath = defaultSearchFileName;
|
|
|
parsing(argc, argv);
|
|
|
|
|
|
- if (options.reg)
|
|
|
- options.regex = std::regex(argv[1]);
|
|
|
+
|
|
|
if (options.threads < 0)
|
|
|
options.threads = std::thread::hardware_concurrency();
|
|
|
;
|
|
|
std::vector<std::thread> threads(options.threads);
|
|
|
|
|
|
for (unsigned int j = options.threads; j--;) {
|
|
|
- // std::cout << "thread " << j << " start" << std::endl;
|
|
|
threads[j] = std::thread(
|
|
|
static_cast<void (*)(const char *)>(miner),
|
|
|
options.searchtextby == nullptr ? argv[1] : options.searchtextby);
|
|
|
- // std::cout << "thread " << j << " started" << std::endl;
|
|
|
- } // for
|
|
|
+ }
|
|
|
for (unsigned int j = 0; j < (unsigned int)options.threads; j++)
|
|
|
threads[j].join();
|
|
|
}
|