Browse Source

Improve `vain` output format and instructions

- Clarify usage and instructions, add better examples
- Move hardcoded defaults to vanity.hpp definitions
- Fix typos (e.g., binded => bound) and make output look nicer
pull/78/head
xanoni 3 years ago
parent
commit
a5b0dd1a34
No known key found for this signature in database
GPG Key ID: 2E7CE32A81C3E127
  1. 2
      vanity.hpp
  2. 38
      vanitygen.cpp

2
vanity.hpp

@ -38,6 +38,8 @@
S[(70 - i) % 8], S[(71 - i) % 8], \ S[(70 - i) % 8], S[(71 - i) % 8], \
W[i] + k) W[i] + k)
#define DEF_OUTNAME "private.dat"
//static i2p::data::SigningKeyType type; //static i2p::data::SigningKeyType type;
//static i2p::data::PrivateKeys keys; //static i2p::data::PrivateKeys keys;

38
vanitygen.cpp

@ -143,7 +143,7 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
* Orignal is sensei of crypto ;) * Orignal is sensei of crypto ;)
*/ */
mtx.lock(); mtx.lock();
std::cout << "Thread " << id_thread << " binded" << std::endl; std::cout << "[+] thread " << id_thread << " bound" << std::endl;
mtx.unlock(); mtx.unlock();
/* /*
union union
@ -200,7 +200,7 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
// if(result) // if(result)
{ {
ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52); ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52);
std::cout << "Address found " << addr << std::endl; std::cout << "\nFound address: " << addr << std::endl;
found=true; found=true;
FoundNonce=*nonce; FoundNonce=*nonce;
// free(hash); // free(hash);
@ -222,12 +222,14 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
} }
void usage(void){ void usage(void){
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n" const constexpr char * help="Usage:\n"
"-h --help help menu\n" " vain [text-pattern|regex-pattern] [options]\n\n"
"-r --reg regexp instead just text pattern (e.g. '(one|two).*')\n" "OPTIONS:\n"
"-t --threads (default count of system)\n" " -h --help show this help (same as --usage)\n"
// "--signature -s, (signature type)\n" NOT IMPLEMENTED FUCKING PLAZ! " -r --reg use regexp instead of simple text pattern, ex.: vain '(one|two).*' -r\n"
"-o --output output file (default private.dat)\n" " -t --threads number of threads to use (default: one per processor)\n"
// " -s --signature (signature type)\n" // NOT IMPLEMENTED FUCKING PLAZ!
" -o --output privkey output file name (default: ./" DEF_OUTNAME ")\n"
""; "";
puts(help); puts(help);
} }
@ -308,7 +310,7 @@ int main (int argc, char * argv[])
//For while //For while
if(options.signature != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519) if(options.signature != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519)
{ {
std::cout << "For a while only ED25519-SHA512" << std::endl; std::cout << "ED25519-SHA512 are currently the only signing keys supported." << std::endl;
return 0; return 0;
} }
/////////////// ///////////////
@ -324,7 +326,7 @@ int main (int argc, char * argv[])
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512: case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
std::cout << "Sorry, I don't can generate address for this signature type" << std::endl; std::cout << "Sorry, selected signature type is not supported for address generation." << std::endl;
return 0; return 0;
break; break;
} }
@ -371,7 +373,7 @@ int main (int argc, char * argv[])
#endif #endif
} }
std::cout << "Start vanity generator in " << options.threads << " threads" << std::endl; std::cout << "Initializing vanity generator (" << options.threads << " threads)\n" << std::endl;
unsigned short attempts = 0; unsigned short attempts = 0;
while(!found) while(!found)
@ -381,28 +383,28 @@ int main (int argc, char * argv[])
std::vector<std::thread> threads(options.threads); std::vector<std::thread> threads(options.threads);
unsigned long long thoughtput = 0x4F4B5A37; unsigned long long thoughtput = 0x4F4B5A37;
for ( unsigned int j = options.threads;j--;) std::cout << "Starting attempt #" << ++attempts << ":" << std::endl;
for (unsigned int j = options.threads;j--;)
{ {
threads[j] = std::thread(thread_find,KeyBuf,argv[1],j,thoughtput); threads[j] = std::thread(thread_find,KeyBuf,argv[1],j,thoughtput);
thoughtput+=1000; thoughtput+=1000;
} // for } // for
for(unsigned int j = 0; j < (unsigned int)options.threads;j++) for (unsigned int j = 0; j < (unsigned int)options.threads;j++)
threads[j].join(); threads[j].join();
if(FoundNonce == 0) if (FoundNonce == 0)
{ {
RAND_bytes( KeyBuf+MutateByte , 90 ); RAND_bytes( KeyBuf+MutateByte , 90 );
std::cout << "Attempts #" << ++attempts << std::endl;
} }
} // stack } // stack
} // while } // while
memcpy (KeyBuf + MutateByte, &FoundNonce, 4); memcpy (KeyBuf + MutateByte, &FoundNonce, 4);
std::cout << "Hashes: " << hashescounter << std::endl; std::cout << "Hashes calculated: " << hashescounter << std::endl;
if(options.outputpath.size() == 0) options.outputpath="private.dat"; if(options.outputpath.size() == 0) options.outputpath.assign(DEF_OUTNAME);
std::ofstream f (options.outputpath, std::ofstream::binary | std::ofstream::out); std::ofstream f (options.outputpath, std::ofstream::binary | std::ofstream::out);
if (f) if (f)
@ -411,7 +413,7 @@ int main (int argc, char * argv[])
delete [] KeyBuf; delete [] KeyBuf;
} }
else else
std::cout << "Can't create file " << options.outputpath << std::endl; std::cout << "Can't create output file: " << options.outputpath << std::endl;
i2p::crypto::TerminateCrypto (); i2p::crypto::TerminateCrypto ();

Loading…
Cancel
Save