Browse Source

multiple search addresses

pull/90/head
wipedlifepotato 1 year ago
parent
commit
3acfdccac3
  1. 287
      vain.cpp
  2. 21
      vanity.hpp

287
vain.cpp

@ -3,24 +3,10 @@
#include<getopt.h> #include<getopt.h>
#include<string> #include<string>
#include<boost/filesystem.hpp> #include<boost/filesystem.hpp>
//#include<boost/algorithm/string/predicate.hpp>
//#include<format> // is not supports for me //#include<format> // is not supports for me
/// Crypto InitCrypto. TODO: to makefile/another place get the macro // some global vars in vanitygen.hpp
#ifndef PRECOMPUTATION_CRYPTO
#define PRECOMPUTATION_CRYPTO false
#endif
#ifndef AESNI_CRYPTO
#define AESNI_CRYPTO false
#endif
#ifndef AVX_CRYPTO
#define AVX_CRYPTO false
#endif
#ifndef FORCE_CRYPTO
#define FORCE_CRYPTO false
#endif
#define DEF_OUT_FILE "private.dat"
static struct{ static struct{
bool reg=false; bool reg=false;
int threads=-1; int threads=-1;
@ -240,6 +226,7 @@ void usage(void){
"-o --output output file(default " DEF_OUT_FILE ")\n" "-o --output output file(default " DEF_OUT_FILE ")\n"
//"--usage usage\n" //"--usage usage\n"
//"--prefix -p\n" //"--prefix -p\n"
"--multiplymode -m - multiple addresses search"
""; "";
puts(help); puts(help);
} }
@ -253,18 +240,22 @@ void parsing(int argc, char ** args){
{"threads", required_argument, 0, 't'}, {"threads", required_argument, 0, 't'},
{"signature", required_argument,0,'s'}, {"signature", required_argument,0,'s'},
{"output", required_argument,0,'o'}, {"output", required_argument,0,'o'},
{"multiplymode", no_argument, 0, 'm'},
//{"usage", no_argument,0,0}, //{"usage", no_argument,0,0},
{0,0,0,0} {0,0,0,0}
}; };
int c; int c;
while( (c=getopt_long(argc,args, "hrt:s:o:", long_options, &option_index))!=-1){ while( (c=getopt_long(argc,args, "hrt:s:o:m", long_options, &option_index))!=-1){
switch(c){ switch(c){
//case 0: //case 0:
// if ( std::string(long_options[option_index].name) == std::string("usage") ){ // if ( std::string(long_options[option_index].name) == std::string("usage") ){
// usage(); // usage();
// exit(1); // exit(1);
// } // }
case 'm':
multipleSearchMode=true;
break;
case 'h': case 'h':
usage(); usage();
exit(0); exit(0);
@ -357,129 +348,145 @@ int main (int argc, char * argv[])
if ( !std::regex_match( std::string(argv[1]), std::regex("[a-zA-Z0-9\\.]{1,}")) ) { if ( !std::regex_match( std::string(argv[1]), std::regex("[a-zA-Z0-9\\.]{1,}")) ) {
std::cerr << "Please, change the outputfile name" << std::endl; std::cerr << "Please, change the outputfile name" << std::endl;
} }
auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature); //
// IDK type, and don't want to check. so... if ( options . outputpath . empty () ) options . outputpath . assign ( DEF_OUT_FILE ) ;
auto createDumpFile = [/*keys*/](std::string outFile, i2p::data::PrivateKeys keys){ static std::string outPutFileName = options.outputpath;
std::cout <<" Create a outFile " << outFile << std::endl; auto doSearch = [argc,argv] () {
std::ofstream f(outFile, std::ofstream::binary | std::ofstream:: out); auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature);
if (!f) { // IDK type, and don't want to check. so...
std::cerr << "Can't to create a dump file before search address" << std::endl; auto createDumpFile = [/*keys*/](std::string outFile, i2p::data::PrivateKeys keys){
exit(1); std::cout <<" Create a outFile " << outFile << std::endl;
} std::ofstream f(outFile, std::ofstream::binary | std::ofstream:: out);
size_t len = keys.GetFullLen (); if (!f) {
uint8_t * buf = new uint8_t[len]; std::cerr << "Can't to create a dump file before search address" << std::endl;
len = keys.ToBuffer (buf, len); exit(1);
f.write ((char *)buf, len); }
delete[] buf; size_t len = keys.GetFullLen ();
}; // is double of code. we can found simillar in keygen.cpp. WE would to create a library like uint8_t * buf = new uint8_t[len];
// libi2pdtools len = keys.ToBuffer (buf, len);
// TODO: create libi2pd_tools f.write ((char *)buf, len);
// If file not exists we create a dump file. (a bug was found in issues) delete[] buf;
switch(options.signature) }; // is double of code. we can found simillar in keygen.cpp. WE would to create a library like
{ // libi2pdtools
case i2p::data::SIGNING_KEY_TYPE_DSA_SHA1: // TODO: create libi2pd_tools
case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA512_P521: // If file not exists we create a dump file. (a bug was found in issues)
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA256_2048: switch(options.signature)
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072: {
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096: case i2p::data::SIGNING_KEY_TYPE_DSA_SHA1:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512: case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA512_P521:
std::cout << "Sorry, i don't can generate adress for this signature type" << std::endl; case i2p::data::SIGNING_KEY_TYPE_RSA_SHA256_2048:
return 0; case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
break; case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
} case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
std::cout << "Sorry, i don't can generate adress for this signature type" << std::endl;
//TODO: for other types. return 0;
switch(options.signature) break;
{ }
case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256:
break; //TODO: for other types.
case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA384_P384: switch(options.signature)
break; {
case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA512_P521: case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256:
break; break;
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA256_2048: case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA384_P384:
break; break;
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072: case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA512_P521:
break; break;
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA256_2048:
break; break;
case i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
MutateByte=320; break;
break; case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_CRYPTO_PRO_A_GOSTR3411_256: break;
break; case i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519:
} MutateByte=320;
// there we gen key to buffer. That we mem allocate... break;
KeyBuf = new uint8_t[keys.GetFullLen()]; case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_CRYPTO_PRO_A_GOSTR3411_256:
keys.ToBuffer (KeyBuf, keys.GetFullLen ()); break;
/// there was some things for cpu 665% usage, but is not helpful even }
std::cout << "Start vanity generator in " << options.threads << " threads" << std::endl; // there we gen key to buffer. That we mem allocate...
// there we start to change byte in our private key. we can change another bytes too KeyBuf = new uint8_t[keys.GetFullLen()];
// but we just change 1 byte in all key. So. TODO: change all bytes not one? keys.ToBuffer (KeyBuf, keys.GetFullLen ());
unsigned short attempts = 0;// it can be disabled, it's just for a statistic. For CPU this is a trash? /// there was some things for cpu 665% usage, but is not helpful even
while(!found) std::cout << "Start vanity generator in " << options.threads << " threads" << std::endl;
{//while // there we start to change byte in our private key. we can change another bytes too
{//stack(for destructors(vector/thread)) // but we just change 1 byte in all key. So. TODO: change all bytes not one?
unsigned short attempts = 0;// it can be disabled, it's just for a statistic. For CPU this is a trash?
std::vector<std::thread> threads(options.threads); while(!found)
unsigned long long thoughtput = 0x4F4B5A37; // is a magic number. {//while
{//stack(for destructors(vector/thread))
for ( unsigned int j = options.threads;j--;)
{ std::vector<std::thread> threads(options.threads);
// our buf is our key, but in uint8 type, unsigned integ... another argument unsigned long long thoughtput = 0x4F4B5A37; // is a magic number.
// is our prefix that we search in address
// and j is magic number, is thread id. for ( unsigned int j = options.threads;j--;)
// thoughtput is our magic number that we increment on 1000 everytime {
// so we just change a one a byte in key and convert private key to address // our buf is our key, but in uint8 type, unsigned integ... another argument
// after we check it. // is our prefix that we search in address
threads[j] = std::thread(thread_find,KeyBuf,argv[1],j,thoughtput); // and j is magic number, is thread id.
thoughtput+=1000; // thoughtput is our magic number that we increment on 1000 everytime
}//for // so we just change a one a byte in key and convert private key to address
// after we check it.
//There will be proccessFlipper by accetone threads[j] = std::thread(thread_find,KeyBuf,argv[1],j,thoughtput);
// if I correctly understand it's drop a payload things in a prefix/search data thoughtput+=1000;
// or simmilar. We can just use regex. I would to use regex }//for
// So I put it ^^^ //There will be proccessFlipper by accetone
for(unsigned int j = 0; j < (unsigned int)options.threads;j++) // if I correctly understand it's drop a payload things in a prefix/search data
threads[j].join(); // or simmilar. We can just use regex. I would to use regex
if(FoundNonce == 0) // So I put it ^^^
{ for(unsigned int j = 0; j < (unsigned int)options.threads;j++)
RAND_bytes( KeyBuf+MutateByte , 90 ); // FoundNonce is threads[j].join();
std::cout << "Attempts #" << ++attempts << std::endl;
} if(FoundNonce == 0)
{
}//stack RAND_bytes( KeyBuf+MutateByte , 90 ); // FoundNonce is
}//while std::cout << "Attempts #" << ++attempts << std::endl;
// before we write result we would to create private.dat a file. dump file. we can use for it keygen }
// so.
memcpy (KeyBuf + MutateByte, &FoundNonce, 4); }//stack
std::cout << "Hashes: " << hashescounter << std::endl; }//while
// before we write result we would to create private.dat a file. dump file. we can use for it keygen
// IDK. what for acetone change this line to if (options.output...empty() ... assign // so.
// cplusplus.com/reference/string/string/assign yes we can. but I would don't change this memcpy (KeyBuf + MutateByte, &FoundNonce, 4);
//if(options.outputpath.size() == 0) options.outputpath = DEF_OUT_FILE; std::cout << "Hashes: " << hashescounter << std::endl;
if ( options . outputpath . empty () ) options . outputpath . assign ( DEF_OUT_FILE ) ;
// IDK. what for acetone change this line to if (options.output...empty() ... assign
// there we generate a key, like as in keygen.cpp // cplusplus.com/reference/string/string/assign yes we can. but I would don't change this
// before a mining we would to create a dump file //if(options.outputpath.size() == 0) options.outputpath = DEF_OUT_FILE;
options.outputpath = options.outputpath + std::to_string(foundKeys) + std::string(".dat");
std::cout << "outpath for a now: " << options.outputpath << std::endl;
if( ! boost::filesystem::exists(options.outputpath) ) createDumpFile(options.outputpath, keys); //if ( ! boost::algorithm::ends_with(options.outputpath, ".dat") )
// options.outputpath = options.outputpath + ".dat";
std::ofstream f (options.outputpath, std::ofstream::binary | std::ofstream::out);
if (f) // there we generate a key, like as in keygen.cpp
{ // before a mining we would to create a dump file
f.write ((char *)KeyBuf, keys.GetFullLen ());
delete [] KeyBuf; std::cout << "outpath for a now: " << options.outputpath << std::endl;
} if( ! boost::filesystem::exists(options.outputpath) ) createDumpFile(options.outputpath, keys);
else
std::cout << "Can't create file " << options.outputpath << std::endl; std::ofstream f (options.outputpath, std::ofstream::binary | std::ofstream::out);
if (f)
i2p::crypto::TerminateCrypto (); {
f.write ((char *)KeyBuf, keys.GetFullLen ());
return 0; delete [] KeyBuf;
}
else
std::cout << "Can't create file " << options.outputpath << std::endl;
}; // void doSearch lamda
do {
doSearch();
foundKeys++;
options.outputpath.assign(outPutFileName);
found = false;
FoundNonce = 0;
} while(multipleSearchMode);
i2p::crypto::TerminateCrypto ();
return 0;
} }

21
vanity.hpp

@ -41,8 +41,27 @@
//static i2p::data::SigningKeyType type; //static i2p::data::SigningKeyType type;
//static i2p::data::PrivateKeys keys; //static i2p::data::PrivateKeys keys;
static bool found=false;
// for InitCrypto. TODO: to makefile/another place get the macro
#ifndef PRECOMPUTATION_CRYPTO
#define PRECOMPUTATION_CRYPTO false
#endif
#ifndef AESNI_CRYPTO
#define AESNI_CRYPTO false
#endif
#ifndef AVX_CRYPTO
#define AVX_CRYPTO false
#endif
#ifndef FORCE_CRYPTO
#define FORCE_CRYPTO false
#endif
// def out file name
#define DEF_OUT_FILE "private"
// Global vars
static bool found=false;
static bool multipleSearchMode = false;
static unsigned int foundKeys = 0;
static size_t MutateByte; static size_t MutateByte;
static uint32_t FoundNonce=0; static uint32_t FoundNonce=0;

Loading…
Cancel
Save