Narthex

Modular dictionary generator
git clone git@git.mcdim.xyz:/var/www/git/Narthex.git
Log | Files | Refs | README | LICENSE

commit 9a0bb594f3fe1ae8268f9e5bf4f762a2579ffb62
parent 73798058c0dc51f7eb2acc9597a7fc0939b5c424
Author: Michael Constantine Dimopoulos <mk@mcdim.xyz>
Date:   Mon, 26 Jul 2021 09:31:59 +0000

Updated everything

Diffstat:
MREADME.md | 14+++++++-------
Acom/ncom.c | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Menhance/nhan.c | 8++++----
Minc/nin.c | 7++++---
Mleet/nleet.c | 15+++++++++------
5 files changed, 168 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md @@ -1,13 +1,13 @@ # Narthex -Narthex (Greek: Νάρθηξ, νάρθηκας) is a modular & minimal dictionary generator for Unix and Unix-like operating system written in C and Shell. It contains autonomous Unix-style programs for the creation of a personalised dictionaries that can be used for password recovery & security assessment. The programs make use of Unix text streams for the collaboration with each other, according to the Unix philosophy. It is licensed under the GPL v3.0. Currently under development! +Narthex (Greek: Νάρθηξ, νάρθηκας) is a modular & minimal dictionary generator for Unix and Unix-like operating system written in C and Shell. It contains autonomous Unix-style programs for the creation of personalised dictionaries that can be used for password recovery & security assessment. The programs make use of Unix text streams for the collaboration with each other, according to the Unix philosophy. It is licensed under the GPL v3.0. Currently under development! ## The tools -+ Nenchanc - A capitalization tool that appends the results to the bottom of the dictionary (stdout). -+ Ninc - A incrementation tool that multiplies alphabetical lines and appends an n++ at the end of each line. -+ Ncom - A combination tool that creates different combinations between the existing lines of the dictionary. -+ Nrev - A reversing tool, that appends the reserved versions of the lines at the end of the dictionary. -+ Nleet - A leetifier. Replaces characters with Leet equivalents, such as @ instead of a, or 3 instead of e. Also appends -+ Nwiz - A wizard that asks for the infromation and combines the tools together to create a final dictionary. ++ nchanc - A capitalization tool that appends the results to the bottom of the dictionary (stdout). ++ ninc - A incrementation tool that multiplies alphabetical lines and appends an n++ at the end of each line. ++ ncom - A combination tool that creates different combinations between the existing lines of the dictionary. ++ nrev - A reversing tool, that appends the reserved versions of the lines at the end of the dictionary. ++ nleet - A leetifier. Replaces characters with Leet equivalents, such as @ instead of a, or 3 instead of e. Also appends ++ nwiz - A wizard that asks for the infromation and combines the tools together to create a final dictionary. ## Install In order to install, execute the following commands: diff --git a/com/ncom.c b/com/ncom.c @@ -0,0 +1,144 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <ctype.h> + +/* + * Ncom - Narthex combinator (?) + * + * By Michael Constantine Dimopoulos + * https://mcdim.xyz <mk@mcdim.xyz> + * License: GNU GPL v3 + * + * Currently under development + * :) + * + */ + +#define VERSION "v1.0" +#define BUFFER_SIZE 256 + +static FILE * +save_stdin(FILE *f) +{ + FILE *f2 = tmpfile(); + char buffer[BUFFER_SIZE]; + while(fgets(buffer, sizeof(buffer), f) != NULL) { + fprintf(f2, "%s", buffer); + } + fclose(f); + return f2; +} + +static int +isnumber(char * str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (isdigit(str[i]) != 0) + return 1; + } + return 0; +} + +static void +com(FILE *f2, FILE *f3, int d, int u, int m, int n) +{ + char buffer[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + while (fgets(buffer, sizeof(buffer), f2) != NULL) { + strtok(buffer, "\n"); + while (fgets(buffer2, sizeof(buffer2), f3) != NULL) { + strtok(buffer2, "\n"); + if ((n == 0 && isnumber(buffer) == 0) || n == 1) { + printf("%s%s\n", buffer, buffer2); + if (d == 1) printf("%s%s%s\n", buffer, ".", buffer2); + if (m == 1) printf("%s%s%s\n", buffer, "-", buffer2); + if (u == 1) printf("%s%s%s\n", buffer, "-", buffer2); + } + } + rewind(f3); + } +} + +static void +print_only(FILE *f) +{ + char buffer[BUFFER_SIZE]; + while(fgets(buffer, sizeof(buffer), f) != NULL) { + printf("%s", buffer); + } +} + +static void +help(char * exename) +{ + printf( "Ninc - Narthex incrementor %s\n" + "By Michael C. Dim. <mk@mcdim.xyz>\n\n" + + "-d Use dot separator\n" + "-u Use underscore separator\n" + "-m Use hyphen separator\n" + "-n Exclude numerical bases\n" + "-h Print this panel & exit\n" + "-v Print current version & exit\n\n" + + "Usage: cat [FILENAME] | %s [OPTIONS]\n", + VERSION, exename); + exit(EXIT_SUCCESS); +} + +void +die(char * str) +{ + printf("%s\n", str); + exit(EXIT_SUCCESS); +} + +void +main(int argc, char * argv[]) +{ + int d=0, u=0, m=0, n=1; + char *cvalue = NULL; + int index; + int c; + + opterr = 0; + + while ( (c = getopt (argc, argv, "dumnvhh:")) != -1 ) + switch (c) { + case 'v': + die(VERSION); + case 'h': + help(argv[0]); + case 'd': + d=1; + break; + case 'u': + u=0; + break; + case 'm': + m=1; + break; + case 'n': + n=1; + break; + case '?': + fprintf (stderr, "Unknown option `\\x%x'.\n", optopt); + exit(EXIT_FAILURE); + } + FILE * f2, * f3; + f2 = save_stdin(stdin); + rewind(f2); + f3 = save_stdin(f2); + + rewind(f2); + print_only(f2); + rewind(f2); + rewind(f3); + com(f2, f3, d, u, m, n); + + fclose(f2); + + exit(EXIT_SUCCESS); +} diff --git a/enhance/nhan.c b/enhance/nhan.c @@ -67,7 +67,7 @@ enhance(FILE *f, int full_upper) void die(char * str) { printf("%s\n", str); - exit(0); + exit(EXIT_SUCCESS); } void help(char * exename) @@ -81,7 +81,7 @@ void help(char * exename) "Usage: cat [FILENAME] | %s [OPTIONS]\n" " %s [OPTIONS] [FILENAME]\n", VERSION, exename, exename); - exit(0); + exit(EXIT_SUCCESS); } void @@ -107,7 +107,7 @@ main(int argc, char* argv[]) f2 = save_stdin(f); } else { fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); - exit(1); + exit(EXIT_FAILURE); } } else { f2 = save_stdin(stdin); @@ -123,5 +123,5 @@ main(int argc, char* argv[]) } fclose(f2); - exit(0); + exit(EXIT_SUCCESS); } diff --git a/inc/nin.c b/inc/nin.c @@ -52,13 +52,14 @@ help(char * exename) "Usage: cat [FILENAME] | %s [MIN] [MAX] [OPTIONS]\n", VERSION, exename); - exit(0); + exit(EXIT_SUCCESS); } void die(char * str) { printf("%d\n", str); + exit(EXIT_SUCCESS); } void @@ -83,11 +84,11 @@ main(int argc, char * argv[]) numerical = 1; } else { fprintf(stderr, "%s: wrong number of arguments\n", argv[0]); - exit(0); + exit(EXIT_FAILURE); } if (min <= max) { ninc(stdin, min, max, numerical); } - exit(0); + exit(EXIT_SUCCESS); } diff --git a/leet/nleet.c b/leet/nleet.c @@ -74,13 +74,15 @@ leetify(FILE *f, int full_upper) } } -void die(char * str) +static void +die(char * str) { printf("%s\n", str); - exit(0); + exit(EXIT_SUCCESS); } -void help(char * exename) +static void +help(char * exename) { printf( "Nhance - Narthex leetfier %s\n" "By Michael C. Dim. <mk@mcdim.xyz>\n\n" @@ -90,7 +92,7 @@ void help(char * exename) "Usage: cat [FILENAME] | %s\n" " %s [FILENAME]\n", VERSION, exename, exename); - exit(0); + exit(EXIT_SUCCESS); } void @@ -114,7 +116,7 @@ main(int argc, char* argv[]) f2= save_stdin(f); else fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); - exit(1); + exit(EXIT_FAILURE); } else { f2 = save_stdin(stdin); } @@ -127,7 +129,8 @@ main(int argc, char* argv[]) rewind(f2); leetify(f2,1); } + fclose(f2); - exit(0); + exit(EXIT_SUCCESS); }