Markopy
Utilizing Markov Models for brute forcing attacks
|
Abstract representation of a markov model. More...
Public Member Functions | |
def | Import (str filename) |
def | Export (str filename) |
def | Train (str dataset, str seperator, int threads) |
def | Generate (int count, str wordlist, int minlen, int maxlen, int threads) |
std::ifstream * | OpenDatasetFile (const char *filename) |
Open dataset file and return the ifstream pointer. More... | |
void | Train (const char *datasetFileName, char delimiter, int threads) |
Train the model with the dataset file. More... | |
std::ofstream * | Save (const char *filename) |
Export model to file. More... | |
void | Generate (unsigned long int n, const char *wordlistFileName, int minLen=6, int maxLen=12, int threads=20) |
Call Markov::Model::RandomWalk n times, and collect output. More... | |
void | Buff (const char *str, double multiplier, bool bDontAdjustSelfLoops=true, bool bDontAdjustExtendedLoops=false) |
Buff expression of some characters in the model. More... | |
char * | RandomWalk (Markov::Random::RandomEngine *randomEngine, int minSetting, int maxSetting, char *buffer) |
Do a random walk on this model. More... | |
void | AdjustEdge (const char *payload, long int occurrence) |
Adjust the model with a single string. More... | |
bool | Import (std::ifstream *) |
Import a file to construct the model. More... | |
bool | Import (const char *filename) |
Open a file to import with filename, and call bool Model::Import with std::ifstream. More... | |
bool | Export (std::ofstream *) |
Export a file of the model. More... | |
bool | Export (const char *filename) |
Open a file to export with filename, and call bool Model::Export with std::ofstream. More... | |
Node< char > * | StarterNode () |
Return starter Node. More... | |
std::vector< Edge< char > * > * | Edges () |
Return a vector of all the edges in the model. More... | |
std::map< char, Node< char > * > * | Nodes () |
Return starter Node. More... | |
void | OptimizeEdgeOrder () |
Sort edges of all nodes in the model ordered by edge weights. More... | |
Private Member Functions | |
void | TrainThread (Markov::API::Concurrency::ThreadSharedListHandler *listhandler, char delimiter) |
A single thread invoked by the Train function. More... | |
void | GenerateThread (std::mutex *outputLock, unsigned long int n, std::ofstream *wordlist, int minLen, int maxLen) |
A single thread invoked by the Generate function. More... | |
Private Attributes | |
std::ifstream * | datasetFile |
std::ofstream * | modelSavefile |
Dataset file input of our system More... | |
std::ofstream * | outputFile |
File to save model of our system More... | |
std::map< char, Node< char > * > | nodes |
Map LeftNode is the Nodes NodeValue Map RightNode is the node pointer. More... | |
Node< char > * | starterNode |
Starter Node of this model. More... | |
std::vector< Edge< char > * > | edges |
A list of all edges in this model. More... | |
Abstract representation of a markov model.
To help with the python-cpp gateway documentation.
|
inherited |
Adjust the model with a single string.
Start from the starter node, and for each character, AdjustEdge the edge EdgeWeight from current node to the next, until NULL character is reached.
Then, update the edge EdgeWeight from current node, to the terminator node.
This function is used for training purposes, as it can be used for adjusting the model with each line of the corpus file.
Example Use: Create an empty model and train it with string: "testdata"
string | - String that is passed from the training, and will be used to AdjustEdge the model with |
occurrence | - Occurrence of this string. |
Definition at line 109 of file model.h.
|
inherited |
Buff expression of some characters in the model.
str | A string containing all the characters to be buffed |
multiplier | A constant value to buff the nodes with. |
bDontAdjustSelfEdges | Do not adjust weights if target node is same as source node |
bDontAdjustExtendedLoops | Do not adjust if both source and target nodes are in first parameter |
Definition at line 153 of file markovPasswords.cpp.
References Markov::Edge< NodeStorageType >::AdjustEdge(), Markov::Node< storageType >::Edges(), Markov::Edge< NodeStorageType >::EdgeWeight(), Markov::Model< NodeStorageType >::Nodes(), and Markov::Model< NodeStorageType >::OptimizeEdgeOrder().
Referenced by main().
|
inlineinherited |
|
inherited |
Open a file to export with filename, and call bool Model::Export with std::ofstream.
Example Use: Export file to filename
Definition at line 166 of file model.h.
|
inherited |
Export a file of the model.
File contains a list of edges. Format is: Left_repr;EdgeWeight;right_repr. For more information on the format, check out the project wiki or github readme.
Iterate over this vertices, and their edges, and write them to file.
Example Use: Export file to ofstream
Definition at line 155 of file model.h.
def Python.Markopy.MarkovModel.Export | ( | str | filename | ) |
def Python.Markopy.MarkovModel.Generate | ( | int | count, |
str | wordlist, | ||
int | minlen, | ||
int | maxlen, | ||
int | threads | ||
) |
Definition at line 34 of file mm.py.
Referenced by Python.Markopy.MarkovPasswordsCLI._generate().
|
inherited |
Call Markov::Model::RandomWalk n times, and collect output.
Generate from model and write results to a file. a much more performance-optimized method. FastRandomWalk will reduce the runtime by %96.5 on average.
n | - Number of passwords to generate. |
wordlistFileName | - Filename to write to |
minLen | - Minimum password length to generate |
maxLen | - Maximum password length to generate |
threads | - number of OS threads to spawn |
Definition at line 118 of file markovPasswords.cpp.
References Markov::API::MarkovPasswords::GenerateThread().
Referenced by Markov::Markopy::BOOST_PYTHON_MODULE(), and Markov::GUI::Generate::generation().
|
privateinherited |
A single thread invoked by the Generate function.
DEPRECATED: See Markov::API::MatrixModel::FastRandomWalkThread for more information. This has been replaced with a much more performance-optimized method. FastRandomWalk will reduce the runtime by %96.5 on average.
outputLock | - shared mutex lock to lock during output operation. Prevents race condition on write. |
n | number of lines to be generated by this thread |
wordlist | wordlistfile |
minLen | - Minimum password length to generate |
maxLen | - Maximum password length to generate |
Definition at line 140 of file markovPasswords.cpp.
References Markov::Model< NodeStorageType >::RandomWalk().
Referenced by Markov::API::MarkovPasswords::Generate().
|
inherited |
Open a file to import with filename, and call bool Model::Import with std::ifstream.
Example Use: Import a file with filename
Definition at line 137 of file model.h.
|
inherited |
Import a file to construct the model.
File contains a list of edges. For more info on the file format, check out the wiki and github readme pages. Format is: Left_repr;EdgeWeight;right_repr
Iterate over this list, and construct nodes and edges accordingly.
Example Use: Import a file from ifstream
Definition at line 126 of file model.h.
def Python.Markopy.MarkovModel.Import | ( | str | filename | ) |
|
inlineinherited |
|
inherited |
Open dataset file and return the ifstream pointer.
filename | - Filename to open |
Definition at line 51 of file markovPasswords.cpp.
References Markov::Model< NodeStorageType >::Import().
|
inherited |
|
inherited |
Do a random walk on this model.
Start from the starter node, on each node, invoke RandomNext using the random engine on current node, until terminator node is reached. If terminator node is reached before minimum length criateria is reached, ignore the last selection and re-invoke randomNext
If maximum length criteria is reached but final node is not, cut off the generation and proceed to the final node. This function takes Markov::Random::RandomEngine as a parameter to generate pseudo random numbers from
This library is shipped with two random engines, Marsaglia and Mersenne. While mersenne output is higher in entropy, most use cases don't really need super high entropy output, so Markov::Random::Marsaglia is preferable for better performance.
This function WILL NOT reallocate buffer. Make sure no out of bound writes are happening via maximum length criteria.
Example Use: Generate 10 lines, with 5 to 10 characters, and print the output. Use Marsaglia
randomEngine | Random Engine to use for the random walks. For examples, see Markov::Random::Mersenne and Markov::Random::Marsaglia |
minSetting | Minimum number of characters to generate |
maxSetting | Maximum number of character to generate |
buffer | buffer to write the result to |
Definition at line 86 of file model.h.
|
inherited |
Export model to file.
filename | - Export filename. |
Definition at line 106 of file markovPasswords.cpp.
References Markov::Model< NodeStorageType >::Export().
|
inlineinherited |
|
inherited |
Train the model with the dataset file.
datasetFileName | - Ifstream* to the dataset. If null, use class member |
delimiter | - a character, same as the delimiter in dataset content |
threads | - number of OS threads to spawn |
Definition at line 65 of file markovPasswords.cpp.
References intHandler(), Markov::API::Concurrency::ThreadSharedListHandler::ThreadSharedListHandler(), and Markov::API::MarkovPasswords::TrainThread().
Referenced by Markov::Markopy::BOOST_PYTHON_MODULE(), Markov::GUI::Generate::train(), Markov::GUI::Train::train(), and Markov::API::ModelMatrix::Train().
def Python.Markopy.MarkovModel.Train | ( | str | dataset, |
str | seperator, | ||
int | threads | ||
) |
|
privateinherited |
A single thread invoked by the Train function.
listhandler | - Listhandler class to read corpus from |
delimiter | - a character, same as the delimiter in dataset content |
Definition at line 85 of file markovPasswords.cpp.
References Markov::Model< NodeStorageType >::AdjustEdge(), keepRunning, and Markov::API::Concurrency::ThreadSharedListHandler::next().
Referenced by Markov::API::MarkovPasswords::Train().
|
privateinherited |
Definition at line 123 of file markovPasswords.h.
|
privateinherited |
|
privateinherited |
Dataset file input of our system
Definition at line 124 of file markovPasswords.h.
|
privateinherited |
|
privateinherited |
File to save model of our system
Definition at line 125 of file markovPasswords.h.
|
privateinherited |