Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cppack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
passwords
cppack
Commits
6b13e0ab
Commit
6b13e0ab
authored
Feb 5, 2020
by
Mathieu Valois
Browse files
Options
Downloads
Patches
Plain Diff
Remove useless doc, move some functions and force some other const
parent
8cd16f4a
No related branches found
No related tags found
No related merge requests found
Pipeline
#6334
passed
Feb 6, 2020
Stage: test
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/Statsgen.h
+6
-68
6 additions, 68 deletions
include/Statsgen.h
src/cli/Main.cpp
+19
-1
19 additions, 1 deletion
src/cli/Main.cpp
src/core/Statsgen.cpp
+10
-24
10 additions, 24 deletions
src/core/Statsgen.cpp
with
35 additions
and
93 deletions
include/Statsgen.h
+
6
−
68
View file @
6b13e0ab
...
...
@@ -38,88 +38,24 @@ public:
Statsgen
(){}
Statsgen
(
const
std
::
string
&
name
);
/**
* @brief useful to hide statistics below 1%
* @param hr: 1 to hide, else 0
*/
inline
void
setHiderare
(
const
int
&
hr
)
{
hiderare
=
hr
;
}
int
generate_stats
();
void
print_stats
()
const
;
/**
* @brief Defining the number of best results the user wants to see,
* and so the result should be clearer
* @param t: number of interesting results
*/
inline
void
setHiderare
(
const
int
&
hr
)
{
hiderare
=
hr
;
}
inline
void
setTop
(
const
int
&
t
)
{
top
=
t
;
}
/**
* @brief Defining a regular expression to analyse only
* some interesting passwords
* @param reg: regular expression
*/
inline
void
setRegex
(
const
std
::
string
&
reg
)
{
current_regex
=
reg
;
use_regex
=
true
;
}
/**
* @brief Useful to know if the database uses the format withcount
* @param var: true if database uses the format withcount, else false
*/
inline
void
setWithcount
(
const
bool
&
wc
)
{
withcount
=
wc
;
}
/**
* @brief Filter for the size of the simple masks, can be
* used as an optimisation option
* @param limit: number that limit the size of the simple masks
*/
inline
void
setLimitSimplemask
(
const
int
&
limit
)
{
limitSimplemask
=
limit
;
}
/**
* @brief Filter for the size of the advanced masks, can be
* used as an optimisation option
* @param limit: number that limit the size of the advanced masks
*/
inline
void
setLimitAdvancedmask
(
const
int
&
limit
)
{
limitAdvancedmask
=
limit
;
}
/**
* @brief Number of threads the user wants to use
* @param nb: number of usable threads
*/
inline
void
setNbThread
(
const
int
&
nb
)
{
nbThread
=
nb
;
}
void
configureThread
(
ThreadData
&
td
)
const
;
/**
* @brief Defining all security rules
*/
void
askSecurityRules
();
void
setSecurityRules
(
const
uint
&
length
,
const
uint
&
special
,
const
uint
&
digit
,
const
uint
&
upper
,
const
uint
&
lower
);
/**
* @brief Where to write masks
* @param outfile: the file where to write masks
*/
inline
void
setOutfile
(
const
std
::
string
&
outfile
)
{
outfile_name
=
outfile
;
}
/**
* @brief enable debugging
*/
inline
void
enableDebug
()
{
debug_enabled
=
true
;
}
/**
* @brief Calculate all statistics for a database
* @return 0 if error, 1 if success
*/
int
generate_stats
();
/**
* @brief Print all calculated statistics
*/
void
print_stats
();
inline
int
getNbThreads
()
const
{
return
nbThread
;
}
inline
uint64_t
getNbLines
()
const
{
return
nblines
;
}
inline
uint64_t
getProcessed
()
const
{
return
processed
;
}
...
...
@@ -127,7 +63,6 @@ public:
inline
bool
allFinished
()
const
{
return
finished
;
}
inline
bool
allStarted
()
const
{
return
started
;
}
bool
operator
==
(
const
Statsgen
&
other
)
const
;
void
handle_password
(
const
std
::
string
&
password
,
const
uint64_t
&
nbPasswords
,
ThreadData
&
td
)
const
;
private
:
std
::
string
filename
;
...
...
@@ -157,6 +92,9 @@ private:
uint
finished
=
false
;
// all threads have been started
bool
started
=
false
;
void
handle_password
(
const
std
::
string
&
password
,
const
uint64_t
&
nbPasswords
,
ThreadData
&
td
)
const
;
std
::
pair
<
uint
,
uint
>
get_masks
(
const
std
::
string
&
password
,
PasswordStats
&
c
)
const
;
};
#endif
This diff is collapsed.
Click to expand it.
src/cli/Main.cpp
+
19
−
1
View file @
6b13e0ab
...
...
@@ -61,6 +61,24 @@ void showHelp() {
exit
(
EXIT_SUCCESS
);
}
void
askSecurityRules
(
Statsgen
&
stats
){
uint
length
,
special
,
digit
,
upper
,
lower
;
cout
<<
"Minimal length of a password:"
<<
endl
;
cin
>>
length
;
cout
<<
"Minimum of special characters in a password:"
<<
endl
;
cin
>>
special
;
cout
<<
"Minimum of digits in a password:"
<<
endl
;
cin
>>
digit
;
cout
<<
"Minimum of lower characters in a password:"
<<
endl
;
cin
>>
lower
;
cout
<<
"Minimum of upper characters in a password:"
<<
endl
;
cin
>>
upper
;
stats
.
setSecurityRules
(
length
,
special
,
digit
,
upper
,
lower
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
locale
::
global
(
locale
(
""
));
...
...
@@ -128,7 +146,7 @@ int main(int argc,char* argv[]) {
return
EXIT_FAILURE
;
}
if
(
arg
==
"-s"
||
arg
==
"--security"
){
statsgen
.
askSecurityRules
();
continue
;
askSecurityRules
(
statsgen
);
continue
;
}
else
{
unknownArg
(
argv
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
src/core/Statsgen.cpp
+
10
−
24
View file @
6b13e0ab
...
...
@@ -23,26 +23,6 @@ using namespace std;
Statsgen
::
Statsgen
(
const
std
::
string
&
name
)
:
filename
(
name
){}
void
Statsgen
::
askSecurityRules
()
{
uint
length
,
special
,
digit
,
upper
,
lower
;
cout
<<
"Minimal length of a password:"
<<
endl
;
cin
>>
length
;
cout
<<
"Minimum of special characters in a password:"
<<
endl
;
cin
>>
special
;
cout
<<
"Minimum of digits in a password:"
<<
endl
;
cin
>>
digit
;
cout
<<
"Minimum of lower characters in a password:"
<<
endl
;
cin
>>
lower
;
cout
<<
"Minimum of upper characters in a password:"
<<
endl
;
cin
>>
upper
;
setSecurityRules
(
length
,
special
,
digit
,
upper
,
lower
);
}
void
Statsgen
::
setSecurityRules
(
const
uint
&
length
,
const
uint
&
special
,
const
uint
&
digit
,
const
uint
&
upper
,
const
uint
&
lower
)
{
_sr
=
{
_sr
.
nbSecurePassword
,
length
,
special
,
digit
,
upper
,
lower
};
}
...
...
@@ -109,7 +89,7 @@ int Statsgen::generate_stats() {
return
1
;
}
void
Statsgen
::
print_stats
()
{
void
Statsgen
::
print_stats
()
const
{
int
count
;
float
perc
=
percentage
(
results
.
total_filter
,
results
.
total_counter
);
...
...
@@ -152,7 +132,10 @@ void Statsgen::print_stats() {
if
(
limitSimplemask
>
0
)
{
cout
<<
endl
;
readResult
(
results
.
simplemasks
[
"othermasks"
],
"othermasks"
,
count
,
results
.
total_counter
,
hiderare
);
auto
r
=
results
.
simplemasks
.
find
(
"othermasks"
);
if
(
r
!=
results
.
simplemasks
.
end
()){
readResult
(
r
->
second
,
r
->
first
,
count
,
results
.
total_counter
,
hiderare
);
}
}
...
...
@@ -172,12 +155,15 @@ void Statsgen::print_stats() {
if
(
limitAdvancedmask
>
0
)
{
cout
<<
endl
;
readResult
(
results
.
advancedmasks
[
"othermasks"
],
"othermasks"
,
count
,
results
.
total_counter
,
hiderare
);
auto
r
=
results
.
advancedmasks
.
find
(
"othermasks"
);
if
(
r
!=
results
.
advancedmasks
.
end
()){
readResult
(
r
->
second
,
r
->
first
,
count
,
results
.
total_counter
,
hiderare
);
}
}
}
pair
<
uint
,
uint
>
get_masks
(
const
string
&
password
,
PasswordStats
&
c
){
pair
<
uint
,
uint
>
Statsgen
::
get_masks
(
const
string
&
password
,
PasswordStats
&
c
)
const
{
char
last_simplemask
=
'a'
;
uint
sizeSimpleMask
=
0
;
uint
sizeAdvancedMask
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment