mirror of
https://github.com/GOSTSec/vanitygen
synced 2025-02-07 12:24:20 +00:00
Support multiple pattern input files, with different case-sensitivity
settings.
This commit is contained in:
parent
d50e81a149
commit
74e9eaaa6e
@ -80,6 +80,7 @@ version, name);
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_DEVS 32
|
#define MAX_DEVS 32
|
||||||
|
#define MAX_FILE 4
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@ -93,7 +94,6 @@ main(int argc, char **argv)
|
|||||||
int platformidx = -1, deviceidx = -1;
|
int platformidx = -1, deviceidx = -1;
|
||||||
int prompt_password = 0;
|
int prompt_password = 0;
|
||||||
char *seedfile = NULL;
|
char *seedfile = NULL;
|
||||||
FILE *fp = NULL;
|
|
||||||
char **patterns, *pend;
|
char **patterns, *pend;
|
||||||
int verbose = 1;
|
int verbose = 1;
|
||||||
int npatterns = 0;
|
int npatterns = 0;
|
||||||
@ -113,6 +113,13 @@ main(int argc, char **argv)
|
|||||||
int ndevstrs = 0;
|
int ndevstrs = 0;
|
||||||
int opened = 0;
|
int opened = 0;
|
||||||
|
|
||||||
|
FILE *pattfp[MAX_FILE], *fp;
|
||||||
|
int pattfpi[MAX_FILE];
|
||||||
|
int npattfp = 0;
|
||||||
|
int pattstdin = 0;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,
|
while ((opt = getopt(argc, argv,
|
||||||
"vqikNTX:eE:p:P:d:w:t:g:b:VSh?f:o:s:D:")) != -1) {
|
"vqikNTX:eE:p:P:d:w:t:g:b:VSh?f:o:s:D:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
@ -229,11 +236,17 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'f':
|
case 'f':
|
||||||
if (fp) {
|
if (npattfp >= MAX_FILE) {
|
||||||
fprintf(stderr, "Multiple files specified\n");
|
fprintf(stderr,
|
||||||
|
"Too many input files specified\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "-")) {
|
if (!strcmp(optarg, "-")) {
|
||||||
|
if (pattstdin) {
|
||||||
|
fprintf(stderr, "ERROR: stdin "
|
||||||
|
"specified multiple times\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
} else {
|
} else {
|
||||||
fp = fopen(optarg, "r");
|
fp = fopen(optarg, "r");
|
||||||
@ -244,6 +257,9 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pattfp[npattfp] = fp;
|
||||||
|
pattfpi[npattfp] = caseinsensitive;
|
||||||
|
npattfp++;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (result_file) {
|
if (result_file) {
|
||||||
@ -301,23 +317,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp) {
|
|
||||||
if (!vg_read_file(fp, &patterns, &npatterns)) {
|
|
||||||
fprintf(stderr, "Failed to load pattern file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (fp != stdin)
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (optind >= argc) {
|
|
||||||
usage(argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
patterns = &argv[optind];
|
|
||||||
npatterns = argc - optind;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regex) {
|
if (regex) {
|
||||||
vcp = vg_regex_context_new(addrtype, privtype);
|
vcp = vg_regex_context_new(addrtype, privtype);
|
||||||
|
|
||||||
@ -335,9 +334,37 @@ main(int argc, char **argv)
|
|||||||
vcp->vc_output_match = vg_output_match_console;
|
vcp->vc_output_match = vg_output_match_console;
|
||||||
vcp->vc_output_timing = vg_output_timing_console;
|
vcp->vc_output_timing = vg_output_timing_console;
|
||||||
|
|
||||||
if (!vg_context_add_patterns(vcp, (const char ** const)patterns,
|
if (!npattfp) {
|
||||||
npatterns))
|
if (optind >= argc) {
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
patterns = &argv[optind];
|
||||||
|
npatterns = argc - optind;
|
||||||
|
|
||||||
|
if (!vg_context_add_patterns(vcp,
|
||||||
|
(const char ** const) patterns,
|
||||||
|
npatterns))
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < npattfp; i++) {
|
||||||
|
fp = pattfp[i];
|
||||||
|
if (!vg_read_file(fp, &patterns, &npatterns)) {
|
||||||
|
fprintf(stderr, "Failed to load pattern file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (fp != stdin)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
if (!regex)
|
||||||
|
vg_prefix_context_set_case_insensitive(vcp, pattfpi[i]);
|
||||||
|
|
||||||
|
if (!vg_context_add_patterns(vcp,
|
||||||
|
(const char ** const) patterns,
|
||||||
|
npatterns))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!vcp->vc_npatterns) {
|
if (!vcp->vc_npatterns) {
|
||||||
fprintf(stderr, "No patterns to search\n");
|
fprintf(stderr, "No patterns to search\n");
|
||||||
|
@ -1210,6 +1210,12 @@ typedef struct _vg_prefix_context_s {
|
|||||||
int vcp_caseinsensitive;
|
int vcp_caseinsensitive;
|
||||||
} vg_prefix_context_t;
|
} vg_prefix_context_t;
|
||||||
|
|
||||||
|
void
|
||||||
|
vg_prefix_context_set_case_insensitive(vg_context_t *vcp, int caseinsensitive)
|
||||||
|
{
|
||||||
|
((vg_prefix_context_t *) vcp)->vcp_caseinsensitive = caseinsensitive;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vg_prefix_context_clear_all_patterns(vg_context_t *vcp)
|
vg_prefix_context_clear_all_patterns(vg_context_t *vcp)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +139,8 @@ extern void vg_context_wait_for_completion(vg_context_t *vcp);
|
|||||||
/* Prefix context methods */
|
/* Prefix context methods */
|
||||||
extern vg_context_t *vg_prefix_context_new(int addrtype, int privtype,
|
extern vg_context_t *vg_prefix_context_new(int addrtype, int privtype,
|
||||||
int caseinsensitive);
|
int caseinsensitive);
|
||||||
|
extern void vg_prefix_context_set_case_insensitive(vg_context_t *vcp,
|
||||||
|
int caseinsensitive);
|
||||||
extern double vg_prefix_get_difficulty(int addrtype, const char *pattern);
|
extern double vg_prefix_get_difficulty(int addrtype, const char *pattern);
|
||||||
|
|
||||||
/* Regex context methods */
|
/* Regex context methods */
|
||||||
|
71
vanitygen.c
71
vanitygen.c
@ -324,6 +324,8 @@ usage(const char *name)
|
|||||||
version, name);
|
version, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_FILE 4
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -339,7 +341,6 @@ main(int argc, char **argv)
|
|||||||
int prompt_password = 0;
|
int prompt_password = 0;
|
||||||
int opt;
|
int opt;
|
||||||
char *seedfile = NULL;
|
char *seedfile = NULL;
|
||||||
FILE *fp = NULL;
|
|
||||||
char pwbuf[128];
|
char pwbuf[128];
|
||||||
const char *result_file = NULL;
|
const char *result_file = NULL;
|
||||||
const char *key_password = NULL;
|
const char *key_password = NULL;
|
||||||
@ -349,6 +350,13 @@ main(int argc, char **argv)
|
|||||||
vg_context_t *vcp = NULL;
|
vg_context_t *vcp = NULL;
|
||||||
EC_POINT *pubkey_base = NULL;
|
EC_POINT *pubkey_base = NULL;
|
||||||
|
|
||||||
|
FILE *pattfp[MAX_FILE], *fp;
|
||||||
|
int pattfpi[MAX_FILE];
|
||||||
|
int npattfp = 0;
|
||||||
|
int pattstdin = 0;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "vqrikeE:P:NTX:F:t:h?f:o:s:")) != -1) {
|
while ((opt = getopt(argc, argv, "vqrikeE:P:NTX:F:t:h?f:o:s:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
@ -425,12 +433,17 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (fp) {
|
if (npattfp >= MAX_FILE) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Multiple files specified\n");
|
"Too many input files specified\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "-")) {
|
if (!strcmp(optarg, "-")) {
|
||||||
|
if (pattstdin) {
|
||||||
|
fprintf(stderr, "ERROR: stdin "
|
||||||
|
"specified multiple times\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
} else {
|
} else {
|
||||||
fp = fopen(optarg, "r");
|
fp = fopen(optarg, "r");
|
||||||
@ -441,6 +454,9 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pattfp[npattfp] = fp;
|
||||||
|
pattfpi[npattfp] = caseinsensitive;
|
||||||
|
npattfp++;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (result_file) {
|
if (result_file) {
|
||||||
@ -510,23 +526,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp) {
|
|
||||||
if (!vg_read_file(fp, &patterns, &npatterns)) {
|
|
||||||
fprintf(stderr, "Failed to load pattern file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (fp != stdin)
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (optind >= argc) {
|
|
||||||
usage(argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
patterns = &argv[optind];
|
|
||||||
npatterns = argc - optind;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regex) {
|
if (regex) {
|
||||||
vcp = vg_regex_context_new(addrtype, privtype);
|
vcp = vg_regex_context_new(addrtype, privtype);
|
||||||
|
|
||||||
@ -545,9 +544,37 @@ main(int argc, char **argv)
|
|||||||
vcp->vc_output_match = vg_output_match_console;
|
vcp->vc_output_match = vg_output_match_console;
|
||||||
vcp->vc_output_timing = vg_output_timing_console;
|
vcp->vc_output_timing = vg_output_timing_console;
|
||||||
|
|
||||||
if (!vg_context_add_patterns(vcp, (const char ** const) patterns,
|
if (!npattfp) {
|
||||||
npatterns))
|
if (optind >= argc) {
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
patterns = &argv[optind];
|
||||||
|
npatterns = argc - optind;
|
||||||
|
|
||||||
|
if (!vg_context_add_patterns(vcp,
|
||||||
|
(const char ** const) patterns,
|
||||||
|
npatterns))
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < npattfp; i++) {
|
||||||
|
fp = pattfp[i];
|
||||||
|
if (!vg_read_file(fp, &patterns, &npatterns)) {
|
||||||
|
fprintf(stderr, "Failed to load pattern file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (fp != stdin)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
if (!regex)
|
||||||
|
vg_prefix_context_set_case_insensitive(vcp, pattfpi[i]);
|
||||||
|
|
||||||
|
if (!vg_context_add_patterns(vcp,
|
||||||
|
(const char ** const) patterns,
|
||||||
|
npatterns))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!vcp->vc_npatterns) {
|
if (!vcp->vc_npatterns) {
|
||||||
fprintf(stderr, "No patterns to search\n");
|
fprintf(stderr, "No patterns to search\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user