Skip to content

Commit 2520e61

Browse files
committed
Updated everything
1 parent 1169968 commit 2520e61

File tree

13 files changed

+159
-38
lines changed

13 files changed

+159
-38
lines changed

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,37 @@
33

44
CC=gcc
55

6-
#all: inc/nin.c enhance/nhan.c leet/nleet.c rev/nrev.sh
6+
#all: inc/nin.c enhance/nhan.c leet/nleet.c com/ncom.c rev/nrev.sh
77
# $(CC) enhance/nhan.c -o nhance
88
# $(CC) inc/nin.c -o ninc
99
# $(CC) leet/nleet.c -o nleet
10+
# $(CC) com/ncom.c -o ncom
1011

11-
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
12+
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
1213
$(CC) enhance/nhan.c -o nhance
1314
$(CC) inc/nin.c -o ninc
1415
$(CC) leet/nleet.c -o nleet
16+
$(CC) com/ncom.c -o ncom
1517
sudo mv nhance /bin
1618
sudo mv ninc /bin
1719
sudo mv nleet /bin
18-
sudo mv rev/nrev.sh /bin/nrev
19-
sudo mv wiz/nwiz.sh /bin/nwiz
20+
sudo mv ncom /bin
21+
sudo cp rev/nrev.sh /bin/nrev
22+
sudo cp wiz/nwiz.sh /bin/nwiz
2023
mkdir -p /var/lib/narthex/
2124
cp wiz/elder.txt /var/lib/narthex/
2225
sudo cp enhance/nhance.1 /usr/share/man/man1
2326
sudo cp inc/ninc.1 /usr/share/man/man1
2427
sudo cp leet/nleet.1 /usr/share/man/man1
28+
sudo cp com/ncom.1 /usr/share/man/man1
2529
sudo cp rev/nrev.1 /usr/share/man/man1
2630
sudo mandb
2731

28-
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
32+
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
2933
rm /bin/ninc /usr/share/man/man1/ninc.1
3034
rm /bin/nhance /usr/share/man/man1/nhance.1
3135
rm /bin/nleet /usr/share/man/man1/nleet.1
3236
rm /bin/nrev /usr/share/man/man1/nrev.1
37+
rm /bin/ncom /usr/share/man/man1/ncom.1
3338
rm /bin/nwiz
34-
rm -r $${HOME}/.config/narthex/
39+
rm -r /var/lib/narthex/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
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!
33

44
## The tools
5-
+ nchanc - A capitalization tool that appends the results to the bottom of the dictionary (stdout).
5+
+ nchance - A capitalization tool that appends the results to the bottom of the dictionary (stdout).
66
+ ninc - A incrementation tool that multiplies alphabetical lines and appends an n++ at the end of each line.
77
+ ncom - A combination tool that creates different combinations between the existing lines of the dictionary.
88
+ nrev - A reversing tool, that appends the reserved versions of the lines at the end of the dictionary.

com/ncom.1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.\" Manpage for ncom
2+
3+
.TH man 8 "26 Jul 2021" "1.0" "ncom manual page"
4+
.SH NAME
5+
ncom \- Narthex combinator
6+
.SH SYNOPSIS
7+
cat dictionary.txt | ncom [OPTIONS] > output.txt
8+
.SH DESCRIPTION
9+
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.
10+
11+
.SH OPTIONS
12+
-d use dot separator
13+
14+
-u use underscore separator
15+
16+
-m use hyphen separator
17+
18+
-n exclude numerical bases, so if the base is '2002' and the part to be appended is 'word', the operation will not be executed.
19+
20+
-b do not operate when the base is the same with the appended part
21+
22+
-v print version and exit
23+
24+
-h print help panel and exit
25+
26+
.SH AUTHOR
27+
Michael Constantine Dimopoulos <mk@mcdim.xyz>
28+
29+
https://mcdim.xyz
30+
31+
.SH LICENSE
32+
GNU Public License 3.0 (GPL-3.0)

com/ncom.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@
55
#include <ctype.h>
66

77
/*
8-
* Ncom - Narthex combinator (?)
8+
* ncom - Narthex combinator (?)
99
*
1010
* By Michael Constantine Dimopoulos
1111
* https://mcdim.xyz <mk@mcdim.xyz>
1212
* License: GNU GPL v3
1313
*
14-
* Currently under development
15-
* :)
14+
* ncom iterates over stdin and after
15+
* printing the dictionary as is, it will
16+
* print it again but will also append
17+
* every line of stdin to each iteration
18+
* creating, that way, a list of combi-
19+
* nations (pairs) of the lines.
20+
*
21+
* By default, it will append when the
22+
* base is the same as the appended part
23+
* (i.e wordword), but that can be
24+
* switched off with the -b flag. It
25+
* can also use other separators, such
26+
* as a hyphen or a dot, all with their
27+
* own flags.
1628
*
1729
*/
1830

@@ -27,7 +39,6 @@ save_stdin(FILE *f)
2739
while(fgets(buffer, sizeof(buffer), f) != NULL) {
2840
fprintf(f2, "%s", buffer);
2941
}
30-
fclose(f);
3142
return f2;
3243
}
3344

@@ -42,7 +53,7 @@ isnumber(char * str)
4253
}
4354

4455
static void
45-
com(FILE *f2, FILE *f3, int d, int u, int m, int n)
56+
com(FILE *f2, FILE *f3, int d, int u, int m, int n, int b)
4657
{
4758
char buffer[BUFFER_SIZE];
4859
char buffer2[BUFFER_SIZE];
@@ -51,10 +62,12 @@ com(FILE *f2, FILE *f3, int d, int u, int m, int n)
5162
while (fgets(buffer2, sizeof(buffer2), f3) != NULL) {
5263
strtok(buffer2, "\n");
5364
if ((n == 0 && isnumber(buffer) == 0) || n == 1) {
54-
printf("%s%s\n", buffer, buffer2);
55-
if (d == 1) printf("%s%s%s\n", buffer, ".", buffer2);
56-
if (m == 1) printf("%s%s%s\n", buffer, "-", buffer2);
57-
if (u == 1) printf("%s%s%s\n", buffer, "-", buffer2);
65+
if ((b == 1 && strcmp(buffer,buffer2) != 0) || b == 0) {
66+
printf("%s%s\n", buffer, buffer2);
67+
if (d == 1) printf("%s%s%s\n", buffer, ".", buffer2);
68+
if (m == 1) printf("%s%s%s\n", buffer, "-", buffer2);
69+
if (u == 1) printf("%s%s%s\n", buffer, "-", buffer2);
70+
}
5871
}
5972
}
6073
rewind(f3);
@@ -73,13 +86,14 @@ print_only(FILE *f)
7386
static void
7487
help(char * exename)
7588
{
76-
printf( "Ninc - Narthex incrementor %s\n"
89+
printf( "ncom - Narthex combinator %s\n"
7790
"By Michael C. Dim. <mk@mcdim.xyz>\n\n"
7891

7992
"-d Use dot separator\n"
8093
"-u Use underscore separator\n"
8194
"-m Use hyphen separator\n"
8295
"-n Exclude numerical bases\n"
96+
"-b Exclude base-appended\n"
8397
"-h Print this panel & exit\n"
8498
"-v Print current version & exit\n\n"
8599

@@ -98,14 +112,14 @@ die(char * str)
98112
void
99113
main(int argc, char * argv[])
100114
{
101-
int d=0, u=0, m=0, n=1;
115+
int d=0, u=0, m=0, b=0, n=1;
102116
char *cvalue = NULL;
103117
int index;
104118
int c;
105119

106120
opterr = 0;
107121

108-
while ( (c = getopt (argc, argv, "dumnvhh:")) != -1 )
122+
while ( (c = getopt(argc, argv, "dumnvbhh:")) != -1 )
109123
switch (c) {
110124
case 'v':
111125
die(VERSION);
@@ -123,10 +137,15 @@ main(int argc, char * argv[])
123137
case 'n':
124138
n=1;
125139
break;
140+
case 'b':
141+
b=1;
142+
break;
126143
case '?':
127-
fprintf (stderr, "Unknown option `\\x%x'.\n", optopt);
128-
exit(EXIT_FAILURE);
144+
/*fprintf (stderr, "Unknown option `%c`\n", c);
145+
exit(EXIT_FAILURE);*/
146+
break;
129147
}
148+
130149
FILE * f2, * f3;
131150
f2 = save_stdin(stdin);
132151
rewind(f2);
@@ -136,7 +155,7 @@ main(int argc, char * argv[])
136155
print_only(f2);
137156
rewind(f2);
138157
rewind(f3);
139-
com(f2, f3, d, u, m, n);
158+
com(f2, f3, d, u, m, n, b);
140159

141160
fclose(f2);
142161

enhance/nhan.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
#include <string.h>
66

77
/*
8-
* Nhance - Narthex enhancer
8+
* nhance - Narthex enhancer
99
*
1010
* By Michael Constantine Dimopoulos
1111
* https://mcdim.xyz <mk@mcdim.xyz>
1212
* License: GNU GPL v3
13-
*
13+
*
14+
* nhance iterates over stdin and,
15+
* after printing the dictionary as
16+
* is, it will reprint it this time
17+
* with the first letter capitalized.
18+
* It can also append full capitali-
19+
* zations at the end of the dictio-
20+
* nary with the -f flag.
21+
*
1422
*/
1523

1624

@@ -76,7 +84,7 @@ die(char * str)
7684
static void
7785
help(char * exename)
7886
{
79-
printf( "Nhance - Narthex enhancer %s\n"
87+
printf( "nhance - Narthex enhancer %s\n"
8088
"By Michael C. Dim. <mk@mcdim.xyz>\n\n"
8189

8290
"-f Append full capitalization\n"

enhance/nhance.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
.TH man 8 "15 Jul 2021" "1.2" "nhance manual page"
44
.SH NAME
5-
Ninc \- Narthex enhancer
5+
ninc \- Narthex enhancer
66
.SH SYNOPSIS
77
cat dictionary.txt | nhance [OPTIONS] > output.txt
88
nhance [OPTIONS] dictionary.txt
99
.SH DESCRIPTION
1010
nhance reads from standard input or a file and appends to it the lines capitalized. It prints to standard output.
1111

1212
.SH OPTIONS
13-
-f Append full capitalizations as well
13+
-f append full capitalizations as well
1414

1515
-v print version and exit
1616

inc/nin.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,40 @@
44
#include <ctype.h>
55

66
/*
7-
* Ninc - Narthex incrementor
7+
* ninc - Narthex incrementor
88
*
99
* By Michael Constantine Dimopoulos
1010
* https://mcdim.xyz <mk@mcdim.xyz>
1111
* License: GNU GPL v3
1212
*
13+
* ninc will iterate over stdin and
14+
* after printing the dictionary as
15+
* is, it will reprint it but will
16+
* also multiply each line with the
17+
* difference of max-min, and will
18+
* append n to each line, where n is
19+
* increased after every line from
20+
* min to max inclusive. (I know, I
21+
* know. Just try to use it and it
22+
* will make more sense).
23+
*
1324
*/
1425

1526
#define VERSION "v1.0"
1627
#define BUFFER_SIZE 256
1728

29+
FILE *
30+
save_stdin(FILE *f)
31+
{
32+
FILE *f2 = tmpfile();
33+
char buffer[BUFFER_SIZE];
34+
while(fgets(buffer, sizeof(buffer), f) != NULL) {
35+
fprintf(f2, "%s", buffer);
36+
}
37+
fclose(f);
38+
return f2;
39+
}
40+
1841
static int
1942
isnumber(char * str)
2043
{
@@ -31,7 +54,6 @@ ninc(FILE *f, int min, int max, int numerical)
3154
char buffer[BUFFER_SIZE];
3255
while (fgets(buffer, sizeof(buffer), f) != NULL) {
3356
strtok(buffer, "\n");
34-
puts(buffer);
3557
for (int i = min; i <= max; i++) {
3658
if ((numerical == 0 && isnumber(buffer) == 0) || numerical == 1) {
3759
printf("%s%d\n", buffer, i);
@@ -40,10 +62,19 @@ ninc(FILE *f, int min, int max, int numerical)
4062
}
4163
}
4264

65+
void
66+
print_only(FILE *f)
67+
{
68+
char buffer[BUFFER_SIZE];
69+
while(fgets(buffer, sizeof(buffer), f) != NULL) {
70+
printf("%s",buffer);
71+
}
72+
}
73+
4374
static void
4475
help(char * exename)
4576
{
46-
printf( "Ninc - Narthex incrementor %s\n"
77+
printf( "ninc - Narthex incrementor %s\n"
4778
"By Michael C. Dim. <mk@mcdim.xyz>\n\n"
4879

4980
"-n Increment numerical lines as well\n"
@@ -88,7 +119,13 @@ main(int argc, char * argv[])
88119
}
89120

90121
if (min <= max) {
91-
ninc(stdin, min, max, numerical);
122+
FILE * f;
123+
f = save_stdin(stdin);
124+
rewind(f);
125+
print_only(f);
126+
rewind(f);
127+
ninc(f, min, max, numerical);
92128
}
129+
93130
exit(EXIT_SUCCESS);
94131
}

inc/ninc.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ninc \- Narthex incrementor
66
.SH SYNOPSIS
77
cat dictionary.txt | ninc [MIN] [MAX] [OPTIONS] > output.txt
88
.SH DESCRIPTION
9-
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.
9+
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.
1010

1111
.SH OPTIONS
1212
-n increment numerical lines

leet/nleet.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.TH man 8 "15 Jul 2021" "1.2" "nleet manual page"
44
.SH NAME
5-
ninc \- Narthex leetifier
5+
nleet \- Narthex leetifier
66
.SH SYNOPSIS
77
cat dictionary.txt | nhance [OPTIONS] > output.txt
88
nhance [OPTIONS] dictionary.txt

leet/nleet.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@
55
#include <string.h>
66

77
/*
8-
* Nhance - Narthex leetifier
8+
* nleet - Narthex leetifier
99
*
1010
* By Michael Constantine Dimopoulos
1111
* https://mcdim.xyz <mk@mcdim.xyz>
1212
* License: GNU GPL v3
1313
*
14+
* nleet will iterate over stdin or
15+
* a file and, after printing the
16+
* dictionary as is, it will reprint
17+
* it this time with some characters
18+
* replaced with their leet equiva-
19+
* lents. (hello -> h3ll0)
20+
*
21+
* You are encouraged to edit &
22+
* recompile this file if you want
23+
* to edit the substitution rules.
24+
*
1425
*/
1526

1627

@@ -84,7 +95,7 @@ die(char * str)
8495
static void
8596
help(char * exename)
8697
{
87-
printf( "Nhance - Narthex leetfier %s\n"
98+
printf( "nleet - Narthex leetfier %s\n"
8899
"By Michael C. Dim. <mk@mcdim.xyz>\n\n"
89100

90101
"-h Print this panel & exit\n"

0 commit comments

Comments
 (0)