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
9f9d463f
Commit
9f9d463f
authored
Feb 5, 2020
by
Mathieu Valois
Browse files
Options
Downloads
Patches
Plain Diff
Remove stdin support
parent
5e467db9
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/Statsgen.h
+0
-1
0 additions, 1 deletion
include/Statsgen.h
include/ThreadData.h
+0
-2
0 additions, 2 deletions
include/ThreadData.h
src/cli/Main.cpp
+0
-1
0 additions, 1 deletion
src/cli/Main.cpp
src/core/Statsgen.cpp
+6
-47
6 additions, 47 deletions
src/core/Statsgen.cpp
with
6 additions
and
51 deletions
include/Statsgen.h
+
0
−
1
View file @
9f9d463f
...
...
@@ -163,7 +163,6 @@ private:
int
limitAdvancedmask
=
12
;
// Limit the size of Advanced Mask
uint
nbThread
=
1
;
// Number of usable threads, default 1
std
::
string
outfile_name
;
// File where to write masks
bool
is_stdin
=
false
;
// If filename is stdin
bool
debug_enabled
=
false
;
// Enable debug output
...
...
This diff is collapsed.
Click to expand it.
include/ThreadData.h
+
0
−
2
View file @
9f9d463f
...
...
@@ -3,7 +3,6 @@
#include
<string>
#include
<unordered_map>
#include
<queue>
#include
<climits>
#include
<regex>
...
...
@@ -44,7 +43,6 @@ struct ThreadData {
StringOccurrence
simplemasks
;
StringOccurrence
advancedmasks
;
StringOccurrence
charactersets
;
std
::
queue
<
std
::
string
>
password_queue
;
minMax
minMaxValue
;
...
...
This diff is collapsed.
Click to expand it.
src/cli/Main.cpp
+
0
−
1
View file @
9f9d463f
...
...
@@ -35,7 +35,6 @@ void showHelp() {
"Usage: stats FILENAME [OPTIONS]"
,
"To be sure the database's format can be read, please use this command before:"
,
" iconv -f ISO-8859-1 -t UTF-8 databaseInput.txt -o databaseOutput.txt"
,
"Use '-' for FILENAME to read from stdin"
,
"Options:"
,
" --help, -h Show this help message"
,
" --withcount, -w Mendatory if the input database has the following format : [number of occurence] [password]"
,
...
...
This diff is collapsed.
Click to expand it.
src/core/Statsgen.cpp
+
6
−
47
View file @
9f9d463f
...
...
@@ -21,12 +21,7 @@
#include
"Utils.h"
using
namespace
std
;
Statsgen
::
Statsgen
(
const
std
::
string
&
name
)
:
filename
(
name
){
if
(
name
==
"-"
){
is_stdin
=
true
;
cerr
<<
"[WARNING]"
<<
" reading from stdin enabled, loading the whole list in memory"
<<
endl
;
}
}
Statsgen
::
Statsgen
(
const
std
::
string
&
name
)
:
filename
(
name
){}
void
Statsgen
::
askSecurityRules
()
{
...
...
@@ -66,26 +61,14 @@ int Statsgen::generate_stats() {
finished
=
0
;
started
=
false
;
uint64_t
nbline
=
0
;
if
(
!
is_stdin
){
nbline
=
nbline_file
(
filename
);
if
(
!
nbline
){
// error reading the file
cerr
<<
"[ERROR] Empty file or not existing file"
<<
endl
;
return
0
;
}
}
pthread_t
threads
[
MAX_THREADS
];
// split stdin into nbThread files on disk
if
(
is_stdin
){
string
line
;
nbline
=
0
;
while
(
cin
>>
line
){
td
[
nbline
%
nbThread
].
password_queue
.
push
(
line
);
nbline
++
;
}
}
for
(
uint
i
=
0
;
i
<
nbThread
;
i
++
)
{
td
[
i
].
thread_id
=
i
+
1
;
configureThread
(
td
[
i
]);
...
...
@@ -102,15 +85,7 @@ int Statsgen::generate_stats() {
cerr
<<
"[DEBUG] "
<<
"Thread "
<<
td
[
i
].
thread_id
<<
" analyse : "
<<
td
[
i
].
lineBegin
<<
" --> "
<<
td
[
i
].
lineEnd
<<
endl
;
}
int
rc
;
// We use std::queue if input is from stdin
if
(
is_stdin
)
{
rc
=
pthread_create
(
&
threads
[
i
],
NULL
,
generate_stats_thread_queue
,
(
void
*
)
&
td
[
i
]
);
}
// Else we split the file in nbThread threads
else
{
rc
=
pthread_create
(
&
threads
[
i
],
NULL
,
generate_stats_thread
,
(
void
*
)
&
td
[
i
]
);
}
int
rc
=
pthread_create
(
&
threads
[
i
],
NULL
,
generate_stats_thread
,
(
void
*
)
&
td
[
i
]
);
if
(
rc
)
{
cerr
<<
"[ERROR] unable to create thread,"
<<
rc
<<
endl
;
...
...
@@ -286,22 +261,6 @@ void handle_password(const string& password, const uint64_t& nbPasswords, Thread
my_data
->
minMaxValue
.
updateMinMax
(
c
.
pol
);
}
void
*
generate_stats_thread_queue
(
void
*
threadarg
)
{
ThreadData
*
my_data
=
(
ThreadData
*
)
threadarg
;
string
line
;
uint64_t
nbline
=
0
;
while
(
!
my_data
->
password_queue
.
empty
())
{
++
nbline
;
line
=
my_data
->
password_queue
.
front
();
my_data
->
password_queue
.
pop
();
if
(
line
.
size
()
==
0
){
continue
;
}
handle_password
(
line
,
1
,
my_data
);
}
pthread_exit
(
NULL
);
}
void
*
generate_stats_thread
(
void
*
threadarg
)
{
ThreadData
*
my_data
=
(
ThreadData
*
)
threadarg
;
...
...
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