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
21487cbd
You need to sign in or sign up before continuing.
Commit
21487cbd
authored
Feb 3, 2020
by
Mathieu Valois
Browse files
Options
Downloads
Patches
Plain Diff
Iteration over letters is done inside function
parent
ca777cd8
No related branches found
No related tags found
No related merge requests found
Pipeline
#6292
passed
Feb 4, 2020
Stage: test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/Statsgen.h
+2
-11
2 additions, 11 deletions
include/Statsgen.h
src/core/Statsgen.cpp
+58
-65
58 additions, 65 deletions
src/core/Statsgen.cpp
with
60 additions
and
76 deletions
include/Statsgen.h
+
2
−
11
View file @
21487cbd
...
...
@@ -79,8 +79,8 @@ struct thread_data {
bool
use_regex
=
false
;
bool
withcount
=
false
;
int
limitSimplemask
;
int
limitAdvancedmask
;
u
int
limitSimplemask
;
u
int
limitAdvancedmask
;
SecurityRules
sr
;
...
...
@@ -255,15 +255,6 @@ private:
*/
// void analyse_letter(const char & letter, char & last_simplemask, std::string & simplemask_string, std::string & advancedmask_string, Policy & policy, int & sizeAdvancedMask, int & sizeSimpleMask);
/**
* @brief Analyse a password
* @param password: current password
* @param c: container of all useful data of the password
* @param sr: get the actual security rules and count the number of password respecting them
* @param limitAdvancedmask: define the limit for the size of advanced masks
* @param limitSimplemask: define the limit for the size of simple masks
*/
// Container analyze_password(const std::string & password, SecurityRules & sr, const int & limitAdvancedmask, const int & limitSimplemask);
/**
* @brief Update minima and maxima of all general data from analysed passwords
...
...
This diff is collapsed.
Click to expand it.
src/core/Statsgen.cpp
+
58
−
65
View file @
21487cbd
...
...
@@ -242,7 +242,11 @@ void Statsgen::print_stats() {
}
void
analyse_letter
(
const
char
&
letter
,
PasswordStats
&
c
,
char
&
last_simplemask
,
int
&
sizeAdvancedMask
,
int
&
sizeSimpleMask
)
{
pair
<
uint
,
uint
>
get_masks
(
const
string
&
password
,
PasswordStats
&
c
){
char
last_simplemask
=
'a'
;
uint
sizeSimpleMask
=
0
;
uint
sizeAdvancedMask
=
0
;
for
(
wchar_t
letter
:
password
){
sizeAdvancedMask
++
;
if
(
letter
>=
'0'
&&
letter
<=
'9'
)
{
...
...
@@ -283,32 +287,7 @@ void analyse_letter(const char & letter, PasswordStats& c, char & last_simplemas
}
}
}
PasswordStats
analyze_password
(
const
string
&
password
,
SecurityRules
&
sr
,
const
int
&
limitAdvancedmask
,
const
int
&
limitSimplemask
)
{
PasswordStats
c
;
c
.
pass_length
=
password
.
size
();
char
last_simplemask
=
'a'
;
int
sizeAdvancedMask
=
0
;
int
sizeSimpleMask
=
0
;
for
(
wchar_t
letter
:
password
){
analyse_letter
(
letter
,
c
,
last_simplemask
,
sizeAdvancedMask
,
sizeSimpleMask
);
}
if
(
c
.
pol
.
satisfies
(
sr
,
password
.
size
())){
sr
.
nbSecurePassword
++
;
}
if
(
sizeAdvancedMask
>
limitAdvancedmask
)
{
c
.
advancedmask_string
=
"othermasks"
;
}
if
(
sizeSimpleMask
>
limitSimplemask
)
{
c
.
simplemask_string
=
"othermasks"
;
}
return
c
;
return
make_pair
(
sizeSimpleMask
,
sizeAdvancedMask
);
}
void
updateMinMax
(
minMax
&
m
,
const
Policy
&
pol
)
{
...
...
@@ -327,9 +306,23 @@ void handle_password(const string& password, const uint64_t& nbPasswords, thread
if
(
my_data
->
use_regex
&&
!
regex_match
(
password
,
my_data
->
current_regex
)){
return
;
}
PasswordStats
c
=
analyze_password
(
password
,
my_data
->
sr
,
my_data
->
limitAdvancedmask
,
my_data
->
limitSimplemask
);
PasswordStats
c
;
pair
<
uint
,
uint
>
masks
=
get_masks
(
password
,
c
);
if
(
c
.
pol
.
satisfies
(
my_data
->
sr
,
password
.
size
())){
my_data
->
sr
.
nbSecurePassword
++
;
}
if
(
masks
.
first
>
my_data
->
limitSimplemask
)
{
c
.
simplemask_string
=
"othermasks"
;
}
if
(
masks
.
second
>
my_data
->
limitAdvancedmask
)
{
c
.
advancedmask_string
=
"othermasks"
;
}
my_data
->
total_filter
+=
nbPasswords
;
my_data
->
length
[
c
.
pass
_length
]
+=
nbPasswords
;
my_data
->
length
[
pass
word
.
size
()
]
+=
nbPasswords
;
my_data
->
charactersets
[
c
.
pol
]
+=
nbPasswords
;
my_data
->
simplemasks
[
c
.
simplemask_string
]
+=
nbPasswords
;
my_data
->
advancedmasks
[
c
.
advancedmask_string
]
+=
nbPasswords
;
...
...
@@ -399,7 +392,7 @@ uint64_t nbline_file(const string & filename) {
}
// we have not read the whole file
if
(
readfile
.
fail
()
&&
!
readfile
.
eof
()){
cerr
<<
"[ERROR]
"
<<
"
There was an error reading the file at line "
<<
nb
<<
endl
;
cerr
<<
"[ERROR] There was an error reading the file at line "
<<
nb
<<
endl
;
return
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