diff --git a/Makefile b/Makefile index a763527..472ba93 100644 --- a/Makefile +++ b/Makefile @@ -3,32 +3,37 @@ CC=gcc -#all: inc/nin.c enhance/nhan.c leet/nleet.c rev/nrev.sh +#all: inc/nin.c enhance/nhan.c leet/nleet.c com/ncom.c rev/nrev.sh # $(CC) enhance/nhan.c -o nhance # $(CC) inc/nin.c -o ninc # $(CC) leet/nleet.c -o nleet +# $(CC) com/ncom.c -o ncom -install: inc/nin.c enhance/nhan.c leet/nleet.c rev/nrev.sh wiz/nwiz.sh inc/ninc.1 enhance/nhance.1 rev/nrev.1 leet/nleet.1 +install: inc/nin.c enhance/nhan.c leet/nleet.c com/ncom.c rev/nrev.sh wiz/nwiz.sh inc/ninc.1 enhance/nhance.1 rev/nrev.1 leet/nleet.1 com/ncom.1 $(CC) enhance/nhan.c -o nhance $(CC) inc/nin.c -o ninc $(CC) leet/nleet.c -o nleet + $(CC) com/ncom.c -o ncom sudo mv nhance /bin sudo mv ninc /bin sudo mv nleet /bin - sudo mv rev/nrev.sh /bin/nrev - sudo mv wiz/nwiz.sh /bin/nwiz + sudo mv ncom /bin + sudo cp rev/nrev.sh /bin/nrev + sudo cp wiz/nwiz.sh /bin/nwiz mkdir -p /var/lib/narthex/ cp wiz/elder.txt /var/lib/narthex/ sudo cp enhance/nhance.1 /usr/share/man/man1 sudo cp inc/ninc.1 /usr/share/man/man1 sudo cp leet/nleet.1 /usr/share/man/man1 + sudo cp com/ncom.1 /usr/share/man/man1 sudo cp rev/nrev.1 /usr/share/man/man1 sudo mandb -uninstall: /bin/ninc /bin/nhance /bin/nrev /bin/nleet /bin/nwiz /usr/share/man/man1/ninc.1 /usr/share/man/man1/nhance.1 /usr/share/man/man1/nrev.1 /usr/share/man/man1/nleet.1 +uninstall: /bin/ninc /bin/nhance /bin/nrev /bin/nleet /bin/ncom /bin/nwiz /usr/share/man/man1/ninc.1 /usr/share/man/man1/nhance.1 /usr/share/man/man1/nrev.1 /usr/share/man/man1/nleet.1 /usr/share/man/man1/ncom.1 rm /bin/ninc /usr/share/man/man1/ninc.1 rm /bin/nhance /usr/share/man/man1/nhance.1 rm /bin/nleet /usr/share/man/man1/nleet.1 rm /bin/nrev /usr/share/man/man1/nrev.1 + rm /bin/ncom /usr/share/man/man1/ncom.1 rm /bin/nwiz - rm -r $${HOME}/.config/narthex/ + rm -r /var/lib/narthex/ diff --git a/README.md b/README.md index 87cf1a0..c991e62 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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 -+ nchanc - A capitalization tool that appends the results to the bottom of the dictionary (stdout). ++ nchance - 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. diff --git a/com/ncom.1 b/com/ncom.1 new file mode 100644 index 0000000..b1ec9e2 --- /dev/null +++ b/com/ncom.1 @@ -0,0 +1,32 @@ +.\" Manpage for ncom + +.TH man 8 "26 Jul 2021" "1.0" "ncom manual page" +.SH NAME +ncom \- Narthex combinator +.SH SYNOPSIS +cat dictionary.txt | ncom [OPTIONS] > output.txt +.SH DESCRIPTION +ncom iterates over stdin and after printing the dictionary as is, it will print it again but will also append every line of stdin to each iteration creating, that way, a list of combinations (pairs) of the lines. + +.SH OPTIONS +-d use dot separator + +-u use underscore separator + +-m use hyphen separator + +-n exclude numerical bases, so if the base is '2002' and the part to be appended is 'word', the operation will not be executed. + +-b do not operate when the base is the same with the appended part + +-v print version and exit + +-h print help panel and exit + +.SH AUTHOR +Michael Constantine Dimopoulos + +https://mcdim.xyz + +.SH LICENSE +GNU Public License 3.0 (GPL-3.0) diff --git a/com/ncom.c b/com/ncom.c index 207d67b..9435ff4 100644 --- a/com/ncom.c +++ b/com/ncom.c @@ -5,14 +5,26 @@ #include /* - * Ncom - Narthex combinator (?) + * ncom - Narthex combinator (?) * * By Michael Constantine Dimopoulos * https://mcdim.xyz * License: GNU GPL v3 * - * Currently under development - * :) + * ncom iterates over stdin and after + * printing the dictionary as is, it will + * print it again but will also append + * every line of stdin to each iteration + * creating, that way, a list of combi- + * nations (pairs) of the lines. + * + * By default, it will append when the + * base is the same as the appended part + * (i.e wordword), but that can be + * switched off with the -b flag. It + * can also use other separators, such + * as a hyphen or a dot, all with their + * own flags. * */ @@ -27,7 +39,6 @@ save_stdin(FILE *f) while(fgets(buffer, sizeof(buffer), f) != NULL) { fprintf(f2, "%s", buffer); } - fclose(f); return f2; } @@ -42,7 +53,7 @@ isnumber(char * str) } static void -com(FILE *f2, FILE *f3, int d, int u, int m, int n) +com(FILE *f2, FILE *f3, int d, int u, int m, int n, int b) { char buffer[BUFFER_SIZE]; char buffer2[BUFFER_SIZE]; @@ -51,10 +62,12 @@ com(FILE *f2, FILE *f3, int d, int u, int m, int 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); + if ((b == 1 && strcmp(buffer,buffer2) != 0) || b == 0) { + 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); @@ -73,13 +86,14 @@ print_only(FILE *f) static void help(char * exename) { - printf( "Ninc - Narthex incrementor %s\n" + printf( "ncom - Narthex combinator %s\n" "By Michael C. Dim. \n\n" "-d Use dot separator\n" "-u Use underscore separator\n" "-m Use hyphen separator\n" "-n Exclude numerical bases\n" + "-b Exclude base-appended\n" "-h Print this panel & exit\n" "-v Print current version & exit\n\n" @@ -98,14 +112,14 @@ die(char * str) void main(int argc, char * argv[]) { - int d=0, u=0, m=0, n=1; + int d=0, u=0, m=0, b=0, n=1; char *cvalue = NULL; int index; int c; opterr = 0; - while ( (c = getopt (argc, argv, "dumnvhh:")) != -1 ) + while ( (c = getopt(argc, argv, "dumnvbhh:")) != -1 ) switch (c) { case 'v': die(VERSION); @@ -123,10 +137,15 @@ main(int argc, char * argv[]) case 'n': n=1; break; + case 'b': + b=1; + break; case '?': - fprintf (stderr, "Unknown option `\\x%x'.\n", optopt); - exit(EXIT_FAILURE); + /*fprintf (stderr, "Unknown option `%c`\n", c); + exit(EXIT_FAILURE);*/ + break; } + FILE * f2, * f3; f2 = save_stdin(stdin); rewind(f2); @@ -136,7 +155,7 @@ main(int argc, char * argv[]) print_only(f2); rewind(f2); rewind(f3); - com(f2, f3, d, u, m, n); + com(f2, f3, d, u, m, n, b); fclose(f2); diff --git a/enhance/nhan.c b/enhance/nhan.c index 16e0ed6..a22c621 100644 --- a/enhance/nhan.c +++ b/enhance/nhan.c @@ -5,12 +5,20 @@ #include /* - * Nhance - Narthex enhancer + * nhance - Narthex enhancer * * By Michael Constantine Dimopoulos * https://mcdim.xyz * License: GNU GPL v3 - * + * + * nhance iterates over stdin and, + * after printing the dictionary as + * is, it will reprint it this time + * with the first letter capitalized. + * It can also append full capitali- + * zations at the end of the dictio- + * nary with the -f flag. + * */ @@ -76,7 +84,7 @@ die(char * str) static void help(char * exename) { - printf( "Nhance - Narthex enhancer %s\n" + printf( "nhance - Narthex enhancer %s\n" "By Michael C. Dim. \n\n" "-f Append full capitalization\n" diff --git a/enhance/nhance.1 b/enhance/nhance.1 index bea1a45..db2c402 100644 --- a/enhance/nhance.1 +++ b/enhance/nhance.1 @@ -2,7 +2,7 @@ .TH man 8 "15 Jul 2021" "1.2" "nhance manual page" .SH NAME -Ninc \- Narthex enhancer +ninc \- Narthex enhancer .SH SYNOPSIS cat dictionary.txt | nhance [OPTIONS] > output.txt nhance [OPTIONS] dictionary.txt @@ -10,7 +10,7 @@ nhance [OPTIONS] dictionary.txt nhance reads from standard input or a file and appends to it the lines capitalized. It prints to standard output. .SH OPTIONS --f Append full capitalizations as well +-f append full capitalizations as well -v print version and exit diff --git a/inc/nin.c b/inc/nin.c index 44b4c0a..c873a30 100644 --- a/inc/nin.c +++ b/inc/nin.c @@ -4,17 +4,40 @@ #include /* - * Ninc - Narthex incrementor + * ninc - Narthex incrementor * * By Michael Constantine Dimopoulos * https://mcdim.xyz * License: GNU GPL v3 * + * ninc will iterate over stdin and + * after printing the dictionary as + * is, it will reprint it but will + * also multiply each line with the + * difference of max-min, and will + * append n to each line, where n is + * increased after every line from + * min to max inclusive. (I know, I + * know. Just try to use it and it + * will make more sense). + * */ #define VERSION "v1.0" #define BUFFER_SIZE 256 +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) { @@ -31,7 +54,6 @@ ninc(FILE *f, int min, int max, int numerical) char buffer[BUFFER_SIZE]; while (fgets(buffer, sizeof(buffer), f) != NULL) { strtok(buffer, "\n"); - puts(buffer); for (int i = min; i <= max; i++) { if ((numerical == 0 && isnumber(buffer) == 0) || numerical == 1) { printf("%s%d\n", buffer, i); @@ -40,10 +62,19 @@ ninc(FILE *f, int min, int max, int numerical) } } +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" + printf( "ninc - Narthex incrementor %s\n" "By Michael C. Dim. \n\n" "-n Increment numerical lines as well\n" @@ -88,7 +119,13 @@ main(int argc, char * argv[]) } if (min <= max) { - ninc(stdin, min, max, numerical); + FILE * f; + f = save_stdin(stdin); + rewind(f); + print_only(f); + rewind(f); + ninc(f, min, max, numerical); } + exit(EXIT_SUCCESS); } diff --git a/inc/ninc.1 b/inc/ninc.1 index da845f6..89c083b 100644 --- a/inc/ninc.1 +++ b/inc/ninc.1 @@ -6,7 +6,7 @@ ninc \- Narthex incrementor .SH SYNOPSIS cat dictionary.txt | ninc [MIN] [MAX] [OPTIONS] > output.txt .SH DESCRIPTION -ninc reads from standard input and multiplies each line with the difference of max-min, and appends n to each line, where n is increased after every line from min to max inclusive. It prints to standard output. +ninc reads from standard input and, after printing the dictionary as is, it reprints it but multiplies each line with the difference of max-min, and appends n to each line, where n is increased after every line from min to max inclusive. It prints to standard output. .SH OPTIONS -n increment numerical lines diff --git a/leet/nleet.1 b/leet/nleet.1 index 3296d87..a748785 100644 --- a/leet/nleet.1 +++ b/leet/nleet.1 @@ -2,7 +2,7 @@ .TH man 8 "15 Jul 2021" "1.2" "nleet manual page" .SH NAME -ninc \- Narthex leetifier +nleet \- Narthex leetifier .SH SYNOPSIS cat dictionary.txt | nhance [OPTIONS] > output.txt nhance [OPTIONS] dictionary.txt diff --git a/leet/nleet.c b/leet/nleet.c index 6ec0212..e744cae 100644 --- a/leet/nleet.c +++ b/leet/nleet.c @@ -5,12 +5,23 @@ #include /* - * Nhance - Narthex leetifier + * nleet - Narthex leetifier * * By Michael Constantine Dimopoulos * https://mcdim.xyz * License: GNU GPL v3 * + * nleet will iterate over stdin or + * a file and, after printing the + * dictionary as is, it will reprint + * it this time with some characters + * replaced with their leet equiva- + * lents. (hello -> h3ll0) + * + * You are encouraged to edit & + * recompile this file if you want + * to edit the substitution rules. + * */ @@ -84,7 +95,7 @@ die(char * str) static void help(char * exename) { - printf( "Nhance - Narthex leetfier %s\n" + printf( "nleet - Narthex leetfier %s\n" "By Michael C. Dim. \n\n" "-h Print this panel & exit\n" diff --git a/rev/nrev.1 b/rev/nrev.1 index b866fe7..5f070fb 100644 --- a/rev/nrev.1 +++ b/rev/nrev.1 @@ -2,7 +2,7 @@ .TH man 8 "15 Jul 2021" "1.0" "nrev manual page" .SH NAME -Ninc \- Narthex reverser +nrev \- Narthex reverser .SH SYNOPSIS cat dictionary.txt | nhance [OPTIONS] > output.txt nhance [OPTIONS] dictionary.txt diff --git a/rev/nrev.sh b/rev/nrev.sh index 8c3ba81..ac41f68 100755 --- a/rev/nrev.sh +++ b/rev/nrev.sh @@ -1,11 +1,20 @@ #!/bin/sh +# nrev - Narthex reverser +# by Michael Constantine Dimopoulos +# https://mcdim.xyz +# +# nrev iterates over stdin or a file +# and, after reprinting the diction- +# ary, it will reprint it again but +# with each line reversed. + version="1.0" if [ "$1" = "-v" ]; then echo version; exit; elif [ "$1" = "-h" ]; then - printf "Nrev - Narthex reverser ${version} \n"; + printf "nrev - Narthex reverser ${version} \n"; printf "By Michael C. Dim. \n\n"; printf '%s\n' "-h Print this panel & exit"; printf '%s\n\n' "-v Print current version & exit"; diff --git a/wiz/nwiz.sh b/wiz/nwiz.sh index a6a38f4..e7109f4 100755 --- a/wiz/nwiz.sh +++ b/wiz/nwiz.sh @@ -22,6 +22,6 @@ read sn; echo "$sn" >> /tmp/nrthxtmp; echo "Other keywords (separated by space): " read o; echo "$o"| tr " " "\n" >> /tmp/nrthxtmp; -cat /tmp/nrthxtmp | sed '/^$/d' | tr -d ' ' | nhance | ninc 1 30 | nleet > "${n}".txt +cat /tmp/nrthxtmp | sed '/^$/d' | tr -d ' ' | nhance | ncom -b | ninc 1 30 | nleet > "${n}".txt rm /tmp/nrthxtmp echo "[!] Exported at $n.txt"