Skip to content

Commit 0e32baa

Browse files
committed
Generate a 32 char password from the hash
cleaned cli visual and other format
1 parent 9de8230 commit 0e32baa

File tree

9 files changed

+80
-668
lines changed

9 files changed

+80
-668
lines changed

PassCoder2.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<ClCompile Include="External\argon2\thread.c" />
2828
<ClCompile Include="External\Argtable3\argtable3.c" />
2929
<ClCompile Include="External\rlutil\rlutil.c" />
30-
<ClCompile Include="Sources\pc2_chaos.c" />
3130
<ClCompile Include="Sources\pc2_cli.c" />
3231
<ClCompile Include="Sources\pc2_config.c" />
3332
<ClCompile Include="Sources\pc2_core.c" />
@@ -40,7 +39,6 @@
4039
<ClInclude Include="External\argon2\thread.h" />
4140
<ClInclude Include="External\Argtable3\argtable3.h" />
4241
<ClInclude Include="External\rlutil\rlutil.h" />
43-
<ClInclude Include="Sources\pc2_chaos.h" />
4442
<ClInclude Include="Sources\pc2_config.h" />
4543
<ClInclude Include="Sources\pc2_core.h" />
4644
</ItemGroup>

PassCoder2.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
<ClCompile Include="Sources\pc2_config.c">
5252
<Filter>Sources</Filter>
5353
</ClCompile>
54-
<ClCompile Include="Sources\pc2_chaos.c">
55-
<Filter>Sources</Filter>
56-
</ClCompile>
5754
<ClCompile Include="External\rlutil\rlutil.c">
5855
<Filter>External\rlutil</Filter>
5956
</ClCompile>
@@ -83,9 +80,6 @@
8380
<ClInclude Include="Sources\pc2_config.h">
8481
<Filter>Sources</Filter>
8582
</ClInclude>
86-
<ClInclude Include="Sources\pc2_chaos.h">
87-
<Filter>Sources</Filter>
88-
</ClInclude>
8983
<ClInclude Include="External\rlutil\rlutil.h">
9084
<Filter>External\rlutil</Filter>
9185
</ClInclude>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
[![Actions Status](https://github.com/Coldragon/PassCoder2/workflows/Build/badge.svg)](https://github.com/Coldragon/PassCoder2/actions) [![Actions Status](https://img.shields.io/github/v/release/coldragon/PassCoder2.svg)](https://github.com/Coldragon/PassCoder2/releases) [![Actions Status](https://img.shields.io/badge/license-MIT-brightgreen.svg)](./LICENSE.md)
44

55
# PassCoder2
6-
Passcoder2 is a simple C99 crossplatform cli database-less password manager. You just have to remember a passphrase and use a tag to recover your password. The tag can be the website name, your email adresse or anything.
6+
PassCoder2 is a simple C99 crossplatform cli database-less password manager. You just have to remember a passphrase and use a tag to recover your password. The tag can be the website name, your email adress or any other string.
77

88
# How To Use
99
Just run the cli and you'll be prompted to write your passphrase and tag.
1010
There is also some parameters that can be input.
1111
```
12-
usage: PassCoder2.exe [-hv] [<tag>] [-p <passphrase>] [--version]
12+
usage: PassCoder2.exe [-hv] [<tag>] [-p <phrase>] [--version]
1313
1414
<tag> target tag
15-
-p, --pass=<passphrase> private passphrase
15+
-p, --phrase=<phrase> private phrase
1616
-h, --help display this help and exit
1717
-v, --verbose verbose output and exit
1818
--version display version info and exit

Sources/pc2_chaos.c

Lines changed: 0 additions & 612 deletions
This file was deleted.

Sources/pc2_chaos.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

Sources/pc2_cli.c

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,41 @@ pc2_hash_pass_t pc2_argtable_config(int argc, char** argv);
1414
int main(int argc, char ** argv)
1515
{
1616
saveDefaultColor();
17-
pc2_hash_pass_t password = pc2_argtable_config(argc, argv);
17+
pc2_hash_pass_t hash_final = pc2_argtable_config(argc, argv);
1818

19-
if(password.is_empty == 0)
19+
if(hash_final.is_empty == 0)
2020
{
21-
pc2_hash_pass_print(&password);
22-
pc2_hash_pass_clean(&password);
21+
if (pc2_get_verbose())
22+
{
23+
setColor(CYAN);
24+
printf("Hash Password \t: ");
25+
resetColor();
26+
pc2_hash_pass_print(&hash_final);
27+
puts("");
28+
}
29+
setColor(GREEN);
30+
printf("Password : ");
31+
resetColor();
32+
const pc2_password_t password_formated = pc2_password_generate(&hash_final);
33+
for(int j = 0; j < PC2_HASHLEN; j++)
34+
printf("%c", password_formated.array[j]);
35+
pc2_hash_pass_clean(&hash_final);
36+
puts("");
2337
}
24-
2538
pc2_check_run_from_console();
2639
resetColor();
2740
return 0;
2841
}
2942

3043
pc2_hash_pass_t pc2_argtable_config(int argc, char** argv)
3144
{
32-
struct arg_str* passphrase, * tag;
45+
struct arg_str* phrase, * tag;
3346
struct arg_lit* verbose, * help, * version;
3447
struct arg_end* end;
3548
void* argtable[] =
3649
{
3750
tag = arg_strn(NULL, NULL, "<tag>", 0, 1, "target tag"),
38-
passphrase = arg_strn("p", "pass", "<passphrase>", 0, 1, "private passphrase"),
51+
phrase = arg_strn("p", "phrase", "<phrase>", 0, 1, "private phrase"),
3952
help = arg_litn("h", "help", 0, 1, "display this help and exit"),
4053
verbose = arg_litn("v", "verbose", 0, 1, "verbose output and exit"),
4154
version = arg_litn(NULL, "version", 0, 1, "display version info and exit"),
@@ -48,15 +61,15 @@ pc2_hash_pass_t pc2_argtable_config(int argc, char** argv)
4861
// HELP -v
4962
if (help->count > 0)
5063
{
51-
printf("usage: %s", PC2_PROG_EXEC_NAME);
64+
printf("usage: %s%s", PC2_PROG_EXEC_NAME, PC2_OS == PC2_OS_WINDOWS ? ".exe" : "");
5265
arg_print_syntax(stdout, argtable, "\n\n");
5366
arg_print_glossary(stdout, argtable, " %-25s %s\n");
5467
puts("");
5568
}
5669
// VERSION
5770
if (version->count > 0)
5871
{
59-
printf("Version : %s\n", PC2_VERSION);
72+
printf("%s version : %s\n", PC2_PROG_EXEC_NAME, PC2_VERSION);
6073
}
6174
}
6275
else
@@ -71,41 +84,44 @@ pc2_hash_pass_t pc2_argtable_config(int argc, char** argv)
7184
{
7285
printf("Try '");
7386
setColor(GREEN);
74-
printf("%s --help", PC2_PROG_EXEC_NAME);
87+
printf("%s%s --help", PC2_PROG_EXEC_NAME, PC2_OS == PC2_OS_WINDOWS ? "exe" : "");
7588
resetColor();
76-
printf("' for more information.\n");
89+
printf("' for more information.");
7790
}
78-
7991
}
8092
else
8193
{
8294
pc2_set_verbose(verbose->count > 0 ? 1 : 0);
83-
pc2_hash_pass_t hp_passphrase;
95+
pc2_hash_pass_t hp_phrase;
8496
pc2_hash_pass_t hp_tag;
85-
if(passphrase->count == 0)
86-
hp_passphrase = hash_pass_create_from_user_input("Passphrase");
97+
if(phrase->count == 0)
98+
hp_phrase = pc2_hash_pass_create_from_user_input("Phrase");
8799
else
88-
hp_passphrase = hash_pass_create_manually((uint8_t*)passphrase->sval[0]);
89-
pc2_hash_pass_set_salt(&hp_passphrase, PC2_BASE_SALT);
100+
hp_phrase = pc2_hash_pass_create_manually((uint8_t*)phrase->sval[0]);
101+
pc2_hash_pass_set_salt(&hp_phrase, PC2_BASE_SALT);
90102
if (tag->count == 0)
91-
hp_tag = hash_pass_create_from_user_input("Tag");
103+
hp_tag = pc2_hash_pass_create_from_user_input("Tag");
92104
else
93-
hp_tag = hash_pass_create_manually((uint8_t*)tag->sval[0]);
105+
hp_tag = pc2_hash_pass_create_manually((uint8_t*)tag->sval[0]);
94106
pc2_hash_pass_set_salt(&hp_tag, PC2_BASE_SALT);
95107

96-
pc2_hash_pass_t final_hash = pc2_hash_pass_get_final(&hp_passphrase, &hp_tag);
108+
const pc2_hash_pass_t final_hash = pc2_hash_pass_get_final(&hp_phrase, &hp_tag);
97109

98110
if (pc2_get_verbose())
99111
{
100-
puts("Hash 1 :");
101-
pc2_hash_pass_print(&hp_passphrase);
112+
setColor(CYAN);
113+
printf("Hash Phrase \t: ");
114+
resetColor();
115+
pc2_hash_pass_print(&hp_phrase);
102116
puts("");
103-
puts("Hash 2 :");
117+
setColor(CYAN);
118+
printf("Hash Tag \t: ");
119+
resetColor();
104120
pc2_hash_pass_print(&hp_tag);
105121
puts("");
106122
}
107123

108-
pc2_hash_pass_clean(&hp_passphrase);
124+
pc2_hash_pass_clean(&hp_phrase);
109125
pc2_hash_pass_clean(&hp_tag);
110126

111127
arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0]));

Sources/pc2_config.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
#ifndef PC2_CONFIG_H
22
#define PC2_CONFIG_H
33

4+
#define PC2_OS_UNDEFINED 0
5+
#define PC2_OS_WINDOWS 1
6+
#define PC2_OS_LINUX 2
7+
#define PC2_OS_MACOS 3
8+
49
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
510
#define PC2_OS_IS_WINDOWS
11+
#define PC2_OS PC2_OS_WINDOWS
12+
#else
13+
#define PC2_OS PC2_OS_UNDEFINED
614
#endif
715

16+
817
#define PC2_HASHLEN 32
918
#define PC2_SALTLEN PC2_HASHLEN
1019
#define PC2_BASE_SALT "b2TiMYqHl8rRL9foPwAQgKD3k8LsbS19"
1120
#define PC2_ITERAT_COST 4
1221
#define PC2_MEM_COST (1 << 16)
1322
#define PC2_PARRALEL_COST 32
14-
15-
#define PC2_VERSION "0.1"
16-
#define PC2_PROG_EXEC_NAME "PassCoder2.exe"
23+
#define PC2_VERSION "0.3"
24+
#define PC2_PROG_EXEC_NAME "PassCoder2"
1725

1826
void pc2_set_verbose(int p_value);
1927
int pc2_get_verbose();

Sources/pc2_core.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@
1616
#define STRDUP strdup
1717
#endif
1818

19-
pc2_hash_pass_t hash_pass_create_from_user_input(char* field_name)
19+
char symbole[] = PC2_SYMBOLES;
20+
21+
pc2_password_t pc2_password_generate(pc2_hash_pass_t* hp)
22+
{
23+
pc2_password_t final = { 0 };
24+
for (int i = 0; i < PC2_HASHLEN; i += 1)
25+
{
26+
final.array[i] = symbole[hp->output[i] % PC2_SYMBOLES_LEN];
27+
}
28+
return final;
29+
}
30+
31+
pc2_hash_pass_t pc2_hash_pass_create_from_user_input(char* field_name)
2032
{
2133
setColor(GREEN);
2234
printf("%s : ", field_name);
@@ -31,7 +43,7 @@ pc2_hash_pass_t hash_pass_create_from_user_input(char* field_name)
3143
return hp;
3244
}
3345

34-
pc2_hash_pass_t hash_pass_create_manually(uint8_t* r_input)
46+
pc2_hash_pass_t pc2_hash_pass_create_manually(uint8_t* r_input)
3547
{
3648
pc2_hash_pass_t hp = { 0 };
3749
hp.input = (uint8_t*)STRDUP((char*)r_input);
@@ -71,7 +83,7 @@ pc2_hash_pass_t pc2_hash_pass_get_final(pc2_hash_pass_t* r_hp_passphrase, pc2_ha
7183
{
7284
pc2_hash_pass_process(r_hp_passphrase);
7385
pc2_hash_pass_process(r_hp_tag);
74-
pc2_hash_pass_t final_hash = hash_pass_create_manually(r_hp_passphrase->output);
86+
pc2_hash_pass_t final_hash = pc2_hash_pass_create_manually(r_hp_passphrase->output);
7587
pc2_hash_pass_set_salt(&final_hash, r_hp_tag->output);
7688
pc2_hash_pass_process(&final_hash);
7789
return final_hash;
@@ -80,7 +92,6 @@ pc2_hash_pass_t pc2_hash_pass_get_final(pc2_hash_pass_t* r_hp_passphrase, pc2_ha
8092
#if defined(PC2_OS_IS_WINDOWS)
8193
void pc2_check_run_from_console()
8294
{
83-
puts("");
8495
HWND console_wnd = GetConsoleWindow();
8596
DWORD dw_process_id;
8697
GetWindowThreadProcessId(console_wnd, &dw_process_id);

Sources/pc2_core.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
#include "pc2_config.h"
77

8+
#define PC2_SYMBOLES "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&*+,-.:;?^~()"
9+
#define PC2_SYMBOLES_LEN sizeof(PC2_SYMBOLES)
10+
11+
struct pc2_password
12+
{
13+
char array[PC2_HASHLEN];
14+
}; typedef struct pc2_password pc2_password_t;
15+
816
struct pc2_hash_pass
917
{
1018
int is_empty;
@@ -15,8 +23,9 @@ struct pc2_hash_pass
1523

1624
}; typedef struct pc2_hash_pass pc2_hash_pass_t;
1725

18-
pc2_hash_pass_t hash_pass_create_from_user_input(char* field_name);
19-
pc2_hash_pass_t hash_pass_create_manually(uint8_t* r_input);
26+
pc2_password_t pc2_password_generate(pc2_hash_pass_t* hp);
27+
pc2_hash_pass_t pc2_hash_pass_create_from_user_input(char* field_name);
28+
pc2_hash_pass_t pc2_hash_pass_create_manually(uint8_t* r_input);
2029
pc2_hash_pass_t pc2_hash_pass_get_final(pc2_hash_pass_t* r_hp_passphrase, pc2_hash_pass_t* r_hp_tag);
2130
void pc2_hash_pass_set_salt(pc2_hash_pass_t* r_hp, uint8_t* r_salt);
2231
void pc2_hash_pass_print(pc2_hash_pass_t* r_hp);

0 commit comments

Comments
 (0)