Skip to content

Commit

Permalink
Merge pull request #66 from FlameOfIgnis/patch-fix-52
Browse files Browse the repository at this point in the history
Fix #52
  • Loading branch information
ignis-sec authored May 21, 2021
2 parents 89402f1 + 21e4500 commit 9b0a66e
Show file tree
Hide file tree
Showing 25 changed files with 395 additions and 445 deletions.
38 changes: 13 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,36 @@
##############################################################################################################

# Compiler
CC := g++
CC := g++
#output directory
BIN := bin
BIN := bin
#include directory
INCLUDE := include
INCLUDE := include
#Libraries
LIB := lib
LIBRARIES :=
LIB := lib
LIBRARIES :=

ifndef PYTHON_VERSION
PYTHON_VERSION := $(shell python3 -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)";) #3.8
endif

PYTHON_VERSION_ :=$(shell python$(PYTHON_VERSION) -c "import sys;t='{v[0]}{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)";) #38
PYTHON_VERSION3 :=$(shell python$(PYTHON_VERSION) -c "import sys;t='{v[0]}.{v[1]}.{v[2]}'.format(v=list(sys.version_info[:3]));sys.stdout.write(t)";) #3.8.s2
##############################################################################################################
##################################### MarkovPassword project options #################################
##############################################################################################################

MP_C_FLAGS := -Wall -Wextra -g
MP_EXEC := Markov
MP_SRC := $(shell find ./MarkovPasswords/src/ -name '*.cpp') $(shell find ./MarkovModel/src/ -name '*.cpp')

#build pattern
$(BIN)/$(MP_EXEC): $(MP_SRC)
$(CC) $(MP_C_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)


PYTHON_VERSION_ :=$(shell python$(PYTHON_VERSION) -c "import sys;t='{v[0]}{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)";) #38
PYTHON_VERSION3 :=$(shell python$(PYTHON_VERSION) -c "import sys;t='{v[0]}.{v[1]}.{v[2]}'.format(v=list(sys.version_info[:3]));sys.stdout.write(t)";) #3.8.s2
##############################################################################################################
##################################### MarkovPassword project options #################################
##############################################################################################################

MP_C_FLAGS := -Wall -Wextra -g
MP_EXEC := Markov
MP_SRC := $(shell find ./MarkovPasswords/src/ -name '*.cpp') $(shell find ./MarkovModel/src/ -name '*.cpp')
MP_SRC := $(shell find ./MarkovPasswords/src/ -name '*.cpp')
MP_INC :=
MP_LIB := -lboost_program_options
MP_INC := $(shell pwd)

#build pattern
$(BIN)/$(MP_EXEC): $(MP_SRC)
$(CC) $(MP_C_FLAGS) -I$(MP_INC) -L$(LIB) $^ -o $@ $(MP_LIB)

$(CC) $(MP_C_FLAGS) -I$(MP_INC) -L$(LIB) $^ -o $@ $(MP_LIB)

##############################################################################################################
##################################### MarkovModel project options #################################
Expand Down Expand Up @@ -77,12 +64,13 @@ $(BIN)/%.cpp.o:%.cpp
##################################### Markopy Options #################################
##############################################################################################################

MPY_SRC := $(shell find MarkovModel/src/ -name '*.cpp') MarkovPasswords/src/markovPasswords.cpp $(shell find Markopy/src/Module/ -name '*.cpp')
MPY_SRC_DIR := Markopy/src/
MPY_SRC := MarkovPasswords/src/markovPasswords.cpp $(shell find Markopy/src/Module/ -name '*.cpp')
MPY_OBJS := $(MPY_SRC:%=$(BIN)/%.o)
MPY_DEPS := $(MPY_OBJS:.o=.d)
MPY_LDFLAGS := -shared -lboost_python$(PYTHON_VERSION_) -lpython$(PYTHON_VERSION)
MPY_C_FLAGS := $(MPY_INC_FLAGS) -MMD -MP -fPIC -I/usr/include/python$(PYTHON_VERSION)
MPY_INC_DIRS := $(shell find $(MPY_SRC_DIR) -type d)
MPY_INC_DIRS := $(shell find $(MPY_SRC_DIR) -type d) $(shell pwd)
MPY_INC_FLAGS := $(addprefix -I,$(MPY_INC_DIRS))
MPY_SO := markopy.so

Expand All @@ -92,7 +80,7 @@ $(BIN)/$(MPY_SO): $(MPY_OBJS)
# Build step for C++ source
$(BIN)/%.cpp.o:%.cpp
mkdir -p $(dir $@)
$(CC) $(MPY_C_FLAGS) -c $< -o $@
$(CC) $(MPY_C_FLAGS) $(MPY_INC_FLAGS) -c $< -o $@

-include $(MPY_DEPS)

Expand Down
7 changes: 3 additions & 4 deletions Markopy/Markopy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<IntDir>$(SolutionDir)$(Platform)\intermediate\Markopy</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -140,7 +141,8 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(pythonLocation)\include;$(PYTHON_PATH)\include;$(BOOST_ROOT);$(SolutionDir)MarkovModel\src\;$(SolutionDir)\MarkovPasswords\src\;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)\MarkovPasswords\src\;$(SolutionDir)MarkovModel\src\;$(pythonLocation)\include;$(PYTHON_PATH)\include;$(BOOST_ROOT);$(SolutionDir)MarkovModel\src\;$(SolutionDir)\MarkovPasswords\src\;</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -152,9 +154,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\MarkovModel\src\edge.cpp" />
<ClCompile Include="..\MarkovModel\src\model.cpp" />
<ClCompile Include="..\MarkovModel\src\node.cpp" />
<ClCompile Include="..\MarkovPasswords\src\markovPasswords.cpp" />
<ClCompile Include="src\Module\markopy.cpp" />
</ItemGroup>
Expand Down
12 changes: 0 additions & 12 deletions Markopy/Markopy.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
<Filter Include="Dependencies">
<UniqueIdentifier>{9fe04840-08b7-4f78-8ae7-6513c3349fd5}</UniqueIdentifier>
</Filter>
<Filter Include="Dependencies\MarkovModel">
<UniqueIdentifier>{e1af0caf-1390-43cd-b7d4-57fe1d3ff9dd}</UniqueIdentifier>
</Filter>
<Filter Include="Dependencies\MarkovPasswords">
<UniqueIdentifier>{ab5a1a08-ca20-48d3-9c82-4fd5e43bb20a}</UniqueIdentifier>
</Filter>
Expand All @@ -33,15 +30,6 @@
<ClCompile Include="src\Module\markopy.cpp">
<Filter>Source Files\Module</Filter>
</ClCompile>
<ClCompile Include="..\MarkovModel\src\edge.cpp">
<Filter>Dependencies\MarkovModel</Filter>
</ClCompile>
<ClCompile Include="..\MarkovModel\src\model.cpp">
<Filter>Dependencies\MarkovModel</Filter>
</ClCompile>
<ClCompile Include="..\MarkovModel\src\node.cpp">
<Filter>Dependencies\MarkovModel</Filter>
</ClCompile>
<ClCompile Include="..\MarkovPasswords\src\markovPasswords.cpp">
<Filter>Dependencies\MarkovPasswords</Filter>
</ClCompile>
Expand Down
3 changes: 0 additions & 3 deletions Markopy/src/Module/markopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

using namespace boost::python;

std::random_device rd;
std::default_random_engine generator(rd());
std::uniform_int_distribution<long long unsigned> distribution(0, 0xffffFFFF);

BOOST_PYTHON_MODULE(markopy)
{
Expand Down
9 changes: 3 additions & 6 deletions MarkovModel/MarkovModel.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Model|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\Release\</OutDir>
<IntDir>$(Platform)\Release\</IntDir>
<IntDir>$(SolutionDir)$(Platform)\intermediate\MarkovModel\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Lib Model|x64'">
<LinkIncremental>false</LinkIncremental>
Expand Down Expand Up @@ -204,7 +204,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);cudart.lib</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<CudaLink>
<LinkOut>$(IntDir)$(TargetName).device-link.obj</LinkOut>
Expand All @@ -221,6 +221,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)MarkovModel\src</AdditionalIncludeDirectories>
<LanguageStandard>Default</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -243,11 +244,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\dllmain.cpp" />
<ClCompile Include="src\MarkovModel.h" />
<ClCompile Include="src\model.cpp" />
<ClCompile Include="src\node.cpp" />
<ClCompile Include="src\pch.cpp" />
<ClCompile Include="src\edge.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
12 changes: 0 additions & 12 deletions MarkovModel/MarkovModel.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,5 @@
<ClCompile Include="src\pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\node.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\model.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\edge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\MarkovModel.h">
<Filter>Header Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
13 changes: 0 additions & 13 deletions MarkovModel/src/MarkovModel.h

This file was deleted.

4 changes: 0 additions & 4 deletions MarkovModel/src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
#include "model.h"
#include <iostream>

// dllmain.cpp : Defines the entry point for the DLL application.
//std::random_device rd;
//std::default_random_engine generator(rd());
//std::uniform_int_distribution<long long unsigned> distribution(0, 0xffffFFFF);

#ifdef _WIN32
__declspec(dllexport) void dll_loadtest() {
Expand Down
57 changes: 0 additions & 57 deletions MarkovModel/src/edge.cpp

This file was deleted.

56 changes: 55 additions & 1 deletion MarkovModel/src/edge.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <cstdint>

#include <cstddef>

namespace Markov {

Expand Down Expand Up @@ -69,3 +69,57 @@ namespace Markov {

};

//default constructor of edge
template <typename NodeStorageType>
Markov::Edge<NodeStorageType>::Edge() {
this->_left = NULL;
this->_right = NULL;
this->_weight = 0;
}
//constructor of edge
template <typename NodeStorageType>
Markov::Edge<NodeStorageType>::Edge(Markov::Node<NodeStorageType>* _left, Markov::Node<NodeStorageType>* _right) {
this->_left = _left;
this->_right = _right;
this->_weight = 0;
}
//to AdjustEdge the edges by the edge with its offset
template <typename NodeStorageType>
void Markov::Edge<NodeStorageType>::AdjustEdge(uint64_t offset) {
this->_weight += offset;
this->LeftNode()->UpdateTotalVerticeWeight(offset);
}
//to TraverseNode the node
template <typename NodeStorageType>
Markov::Node<NodeStorageType>* Markov::Edge<NodeStorageType>::TraverseNode() {
if (this->RightNode()->NodeValue() == 0xff) //terminator node
return NULL;
return _right;
}
//to set the LeftNode of the node
template <typename NodeStorageType>
void Markov::Edge<NodeStorageType>::SetLeftEdge(Markov::Node<NodeStorageType>* n) {
this->_left = n;
}
//to set the RightNode of the node
template <typename NodeStorageType>
void Markov::Edge<NodeStorageType>::SetRightEdge(Markov::Node<NodeStorageType>* n) {
this->_right = n;
}
//to get the EdgeWeight of the node
template <typename NodeStorageType>
uint64_t Markov::Edge<NodeStorageType>::EdgeWeight() {
return this->_weight;
}
//to get the LeftNode of the node
template <typename NodeStorageType>
Markov::Node<NodeStorageType>* Markov::Edge<NodeStorageType>::LeftNode() {
return this->_left;
}
//to get the RightNode of the node
template <typename NodeStorageType>
Markov::Node<NodeStorageType>* Markov::Edge<NodeStorageType>::RightNode() {
return this->_right;
}


Loading

0 comments on commit 9b0a66e

Please sign in to comment.