From 622b0865725e5ace680fcd229fe00f7f0050f455 Mon Sep 17 00:00:00 2001 From: binarymaster Date: Sat, 2 Sep 2017 09:26:04 +0300 Subject: [PATCH] Add option for output file --- README.md | 1 + src/pixiewps.c | 10 +++++++++- src/pixiewps.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20a25dc..5c17f85 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Optional Arguments: -b, --e-bssid : Enrollee BSSID -S, --dh-small : Small Diffie-Hellman keys (PKr not needed) [No] -v, --verbosity : Verbosity level 1-3, 1 is quietest [3] + -o, --output : Write output to file -h : Display this usage screen --help : Verbose help and more usage examples diff --git a/src/pixiewps.c b/src/pixiewps.c index eeeed48..babf26d 100644 --- a/src/pixiewps.c +++ b/src/pixiewps.c @@ -41,7 +41,7 @@ uint32_t ecos_rand_simple(uint32_t *seed); uint32_t ecos_rand_knuth(uint32_t *seed); uint_fast8_t crack(struct global *g, unsigned int *pin); -static const char *option_string = "e:r:s:z:a:n:m:b:Sfv:Vh?"; +static const char *option_string = "e:r:s:z:a:n:m:b:Sfo:v:Vh?"; static const struct option long_options[] = { { "pke", required_argument, 0, 'e' }, { "pkr", required_argument, 0, 'r' }, @@ -53,6 +53,7 @@ static const struct option long_options[] = { { "e-bssid", required_argument, 0, 'b' }, { "dh-small", no_argument, 0, 'S' }, { "force", no_argument, 0, 'f' }, + { "output", required_argument, 0, 'o' }, { "verbosity", required_argument, 0, 'v' }, { "version", no_argument, 0, 'V' }, { "help", no_argument, 0, 0 }, @@ -167,6 +168,13 @@ memory_err: case 'f': wps->bruteforce = 1; break; + case 'o': + if (!freopen(optarg, "w", stdout)) + { + snprintf(wps->error, 256, "\n [!] Failed to open file for writing -- %s\n\n", optarg); + goto usage_err; + } + break; case 'v': if (get_int(optarg, &wps->verbosity) != 0 || wps->verbosity < 1 || wps->verbosity > 3) { snprintf(wps->error, 256, "\n [!] Bad verbosity level -- %s\n\n", optarg); diff --git a/src/pixiewps.h b/src/pixiewps.h index 353a1ac..1976328 100644 --- a/src/pixiewps.h +++ b/src/pixiewps.h @@ -132,6 +132,7 @@ char usage[] = " -b, --e-bssid : Enrollee BSSID\n" " -S, --dh-small : Small Diffie-Hellman keys (PKr not needed) [No]\n" " -v, --verbosity : Verbosity level 1-3, 1 is quietest [3]\n" + " -o, --output : Write output to file\n" "\n" " -h : Display this usage screen\n" " --help : Verbose help and more usage examples\n"