Compare commits
8 Commits
master
...
PythonBran
Author | SHA1 | Date |
---|---|---|
Matthieu DUVAL | f64a148b5d | 8 years ago |
Matthieu DUVAL | 109ed57adc | 8 years ago |
Matthieu DUVAL | e06f39baae | 8 years ago |
Matthieu DUVAL | 732477d016 | 8 years ago |
Matthieu DUVAL | 9ffbeb2e47 | 8 years ago |
Matthieu DUVAL | bca161e5ec | 8 years ago |
Matthieu DUVAL | 42d349e215 | 8 years ago |
Matthieu DUVAL | 000f32b239 | 8 years ago |
@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class APPLICATION_CONSTANTS():
|
||||||
|
NAME = "RizzleHash"
|
||||||
|
VERSION = "0.7 - rc1"
|
||||||
|
YEAR = "2015"
|
||||||
|
AUTHORS = "Matthieu DUVAL, Rudy DUCHE"
|
||||||
|
|
||||||
|
class LAN_CONSTANTS():
|
||||||
|
class MESSAGE_KEY(Enum):
|
||||||
|
NB_CORE_CLIENT = "nbCoreClient" #peramètre passé dans la requette doit etre suivit du nombre de coeur aloué pour le calcul
|
||||||
|
NB_CORE_TOTAL = "nbCoreTotal"
|
||||||
|
INDEX_CORE_MIN = "indexCoreMin"
|
||||||
|
CRYPTED_PASSWORD = "cryptedPassword"
|
||||||
|
ENCRYPTION_KEY = "encryptionKey"
|
||||||
|
HASH_METHOD = "hashMethode"
|
||||||
|
PASSWORD_MAX_LENGTH = "passwordMaxLength"
|
||||||
|
MESSAGE_TYPE = "type"
|
||||||
|
RETURN_STATE = "returnState"
|
||||||
|
NB_WORDS = "nbWords"
|
||||||
|
PROCESS_TIME = "processTime"
|
||||||
|
WORD = "word"
|
||||||
|
LOCAL_THREAD_NAME = "threadName"
|
||||||
|
|
||||||
|
class MESSAGE_VALUE(Enum) :
|
||||||
|
TYPE_INFO = "info"
|
||||||
|
TYPE_CONFIG = "config"
|
||||||
|
TYPE_ERROR = "error"
|
||||||
|
TYPE_RESULT = "result"
|
||||||
|
TYPE_DEFAULT = "default"
|
||||||
|
STATE_OK = "OK"
|
||||||
|
STATE_KO = "KO"
|
||||||
|
|
||||||
|
class MESSAGE_SPECIAL_CHAR(Enum) :
|
||||||
|
SEPARATOR = ','
|
||||||
|
ASIGNATOR = ':'
|
||||||
|
SAME_VALUE_SEPRATOR = ';'
|
||||||
|
|
||||||
|
class PROCESS_CONSTANTS():
|
||||||
|
class MESSAGE_RETURN_TYPE(Enum):
|
||||||
|
PERFS = 1
|
||||||
|
RETURN = 0
|
||||||
|
|
||||||
|
class PARAMS_CONSTANTS():
|
||||||
|
class LONG_PARAMS(Enum):
|
||||||
|
VERBOSE = "--verbose"
|
||||||
|
HELP = "--help"
|
||||||
|
MODE = "--mode"
|
||||||
|
HASH = "--hash"
|
||||||
|
ENCRYPTION_KEY = "--key"
|
||||||
|
PORT = "--port"
|
||||||
|
SERVER_IP = "--ip"
|
||||||
|
ROLE = "--role"
|
||||||
|
SECRET_PARAM = "--cd"
|
||||||
|
CORE = "--core"
|
||||||
|
MAX_LENGTH = "--length"
|
||||||
|
|
||||||
|
class SHORT_PARAMS(Enum):
|
||||||
|
VERBOSE = "-v"
|
||||||
|
HELP = "-h"
|
||||||
|
MODE = "-m"
|
||||||
|
ENCRYPTION_KEY = "-k"
|
||||||
|
PORT = "-p"
|
||||||
|
SERVER_IP = "-s"
|
||||||
|
ROLE = "-r"
|
||||||
|
CORE = "-c"
|
||||||
|
MAX_LENGTH = "-l"
|
||||||
|
|
||||||
|
class PARAMS_VALUE(Enum):
|
||||||
|
MODE_LOCAL = "local"
|
||||||
|
MODE_LAN = "lan"
|
||||||
|
ROLE_CLIENT = "client"
|
||||||
|
ROLE_SERVER = "server"
|
||||||
|
|
||||||
|
class ANSWER_STATES():
|
||||||
|
class MESSAGE_STATE(Enum):
|
||||||
|
STATE_OK = "OK"
|
||||||
|
STATE_KO = "KO"
|
||||||
|
|
||||||
|
class HASH_METHODS():
|
||||||
|
class HASH_METHOD(Enum):
|
||||||
|
HASH_MD5 = "md5"
|
||||||
|
HASH_SHA1 = "sha1"
|
||||||
|
HASH_SHA224 = "sha224"
|
||||||
|
HASH_SHA256 = "sha256"
|
||||||
|
HASH_SHA384 = "sha384"
|
||||||
|
HASH_SHA512 = "sha512"
|
||||||
|
HASH_NONE = "None"
|
@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
||||||
|
class CryptPass():
|
||||||
|
def __init__(self):
|
||||||
|
self.passwordNonCrypte = ""
|
||||||
|
self.key = ""
|
||||||
|
self.typeCryptage = ""
|
||||||
|
self.passwordCrypte = ""
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getHash(self, passwordNonCrypteWithKey, typeCryptage):
|
||||||
|
self.passwordCrypte = ""
|
||||||
|
passwordNonCrypteWithKey = passwordNonCrypteWithKey.encode()
|
||||||
|
if typeCryptage == "md5":
|
||||||
|
passwordCrypte = hashlib.md5(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha1":
|
||||||
|
passwordCrypte = hashlib.sha1(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha224":
|
||||||
|
passwordCrypte = hashlib.sha224(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha256":
|
||||||
|
passwordCrypte = hashlib.sha256(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha384":
|
||||||
|
passwordCrypte = hashlib.sha384(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha512":
|
||||||
|
passwordCrypte = hashlib.sha512(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
else:
|
||||||
|
print(" Error : " + typeCryptage + " hash methode not suported")
|
||||||
|
print(" We support : md5, sha1, sha224, sha256, sha384, sha512")
|
||||||
|
print()
|
||||||
|
sys.exit()
|
||||||
|
self.passwordCrypte = passwordCrypte
|
||||||
|
return self.passwordCrypte
|
||||||
|
|
||||||
|
|
||||||
|
#si le fichier est lancé seul
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
app = CryptPass()
|
||||||
|
print()
|
||||||
|
print(app.getHash(sys.argv[1],sys.argv[2]))
|
||||||
|
print()
|
||||||
|
sys.exit()
|
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import ctypes
|
||||||
|
import time
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
|
class EasterEgg():
|
||||||
|
def openTray(self):
|
||||||
|
if platform.system() == 'Linux':
|
||||||
|
os.system("eject -r")
|
||||||
|
os.system("eject -t cdrom")
|
||||||
|
else:
|
||||||
|
ctypes.windll.winmm.mciSendStringW("set cdaudio door open", None, 0, None)
|
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import random
|
||||||
|
|
||||||
|
from BF_Constants import *
|
||||||
|
|
||||||
|
tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ")
|
||||||
|
|
||||||
|
class Encryption():
|
||||||
|
def __init__(self):
|
||||||
|
self.passwordNonCrypte = ""
|
||||||
|
self.key = ""
|
||||||
|
self.typeCryptage = ""
|
||||||
|
self.passwordCrypte = ""
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getRandKey(self, keySize):
|
||||||
|
keyRand = ""
|
||||||
|
i = 0
|
||||||
|
while i < keySize:
|
||||||
|
keyRand = keyRand + round(randrange(0, len(tabChar)),0)
|
||||||
|
return keyRand
|
||||||
|
|
||||||
|
def md5(self, string):
|
||||||
|
return hashlib.md5(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def sha1(self, string):
|
||||||
|
return hashlib.sha1(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def sha224(self, string):
|
||||||
|
return hashlib.sha224(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def sha384(self, string):
|
||||||
|
return hashlib.sha384(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def sha256(self, string):
|
||||||
|
return hashlib.sha256(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def sha512(self, string):
|
||||||
|
return hashlib.sha512(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def none(self, string):
|
||||||
|
return string
|
||||||
|
|
||||||
|
def hashForLambda(self, functionLambda, string):
|
||||||
|
return functionLambda(string)
|
||||||
|
|
||||||
|
|
||||||
|
#si le fichier est lancé seul
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
sys.exit()
|
@ -0,0 +1,291 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of Foobar.
|
||||||
|
|
||||||
|
# Foobar is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Foobar is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Foobar. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import locale
|
||||||
|
from datetime import datetime
|
||||||
|
import time
|
||||||
|
import BF_Utils
|
||||||
|
from BF_Constants import *
|
||||||
|
|
||||||
|
class GUI():
|
||||||
|
def __init__(self):
|
||||||
|
self.guiStartTime = str(datetime.now().time().strftime("%H:%M:%S"))
|
||||||
|
self.guiTime=time.time()
|
||||||
|
self.appName = APPLICATION_CONSTANTS.NAME+ " V" +APPLICATION_CONSTANTS.VERSION
|
||||||
|
self.headerLines = self.prepareHeader()
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareHeader(self):
|
||||||
|
lines = list()
|
||||||
|
info = list()
|
||||||
|
lenGui = len(self.appName)
|
||||||
|
info.append("System family : " + str(platform.system()))
|
||||||
|
info.append("System release : " + str(platform.release()))
|
||||||
|
info.append("Processor Core : " + str(os.cpu_count()))
|
||||||
|
info.append("App Started at : "+self.guiStartTime)
|
||||||
|
for value in info:
|
||||||
|
if len(value) > lenGui:
|
||||||
|
lenGui = len(value)
|
||||||
|
|
||||||
|
lines.append(self.separationLineCreator("+","+","-",lenGui+2))
|
||||||
|
lines.append(self.centredLine("| "," |"," ",self.appName,lenGui))
|
||||||
|
lines.append(self.separationLineCreator("+","+","-",lenGui+2))
|
||||||
|
|
||||||
|
for content in info:
|
||||||
|
lines.append(str(self.leftAlignLine("| "," |"," ",content,lenGui)))
|
||||||
|
|
||||||
|
lines.append(self.separationLineCreator("+","+","-",lenGui+2))
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def separationLineCreator(self,leftBorder,rightBorder,separator,lenGui):
|
||||||
|
listSeparationLine = list()
|
||||||
|
listSeparationLine.append(leftBorder)
|
||||||
|
for i in range (0, lenGui):
|
||||||
|
listSeparationLine.append(separator)
|
||||||
|
listSeparationLine.append(rightBorder)
|
||||||
|
separationLine = "".join(listSeparationLine)
|
||||||
|
return separationLine
|
||||||
|
|
||||||
|
def centredLine(self,leftBorder,rightBorder,offsetChar,value,lenGui):
|
||||||
|
lenSpace = (lenGui - len(value))/2
|
||||||
|
if lenSpace.is_integer():
|
||||||
|
lenSpaceLeft = int(lenSpace)
|
||||||
|
lenSpaceRight = int(lenSpace)
|
||||||
|
else :
|
||||||
|
lenSpaceLeft = round(lenSpace)
|
||||||
|
if( round(lenSpace) < lenSpace ):
|
||||||
|
lenSpaceRight = round(lenSpace)+ 1
|
||||||
|
else:
|
||||||
|
lenSpaceRight = round(lenSpace)- 1
|
||||||
|
|
||||||
|
listSpaceLeft = list()
|
||||||
|
for i in range(0,lenSpaceLeft):
|
||||||
|
listSpaceLeft.append(offsetChar)
|
||||||
|
|
||||||
|
listSpaceRight = list()
|
||||||
|
for i in range(0,lenSpaceRight):
|
||||||
|
listSpaceRight.append(offsetChar)
|
||||||
|
|
||||||
|
centeredLine = leftBorder+"".join(listSpaceLeft) + value + "".join(listSpaceRight)+rightBorder
|
||||||
|
return centeredLine
|
||||||
|
|
||||||
|
def tableLine(self,offsetChar,value1,value2,lenMaxValue1):
|
||||||
|
tableLine = ""
|
||||||
|
listSpaceSeparator = list()
|
||||||
|
for i in range(0,lenMaxValue1 - len(value1)):
|
||||||
|
listSpaceSeparator.append(offsetChar)
|
||||||
|
|
||||||
|
tableLine = value1+"".join(listSpaceSeparator)+value2
|
||||||
|
return tableLine
|
||||||
|
|
||||||
|
def leftAlignLine(self,leftBorder,rightBorder,offsetChar,value,lenGui):
|
||||||
|
lenSpaceRight = lenGui - len(value)
|
||||||
|
listSpaceRight = list()
|
||||||
|
for i in range(0,lenSpaceRight):
|
||||||
|
listSpaceRight.append(offsetChar)
|
||||||
|
|
||||||
|
leftAlignLine = leftBorder+value+"".join(listSpaceRight)+rightBorder
|
||||||
|
return leftAlignLine
|
||||||
|
|
||||||
|
def clearScreen(self):
|
||||||
|
if platform.system() == 'Linux':
|
||||||
|
os.system('clear')
|
||||||
|
else:
|
||||||
|
os.system('cls')
|
||||||
|
|
||||||
|
def setLocale(self):
|
||||||
|
if platform.system() == 'Linux':
|
||||||
|
locale.setlocale(locale.LC_ALL, 'french')
|
||||||
|
else:
|
||||||
|
locale.setlocale(locale.LC_ALL, 'french_france')
|
||||||
|
|
||||||
|
def displayHeader(self):
|
||||||
|
self.clearScreen()
|
||||||
|
for line in self.headerLines:
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
def displayProcessPerfs(self, host, processName, WordsSeconds, curentWord):
|
||||||
|
self.setLocale()
|
||||||
|
WordsSeconds = locale.format('%d', WordsSeconds, grouping=True)
|
||||||
|
print("Host : " + host )
|
||||||
|
print("\t"+ processName+" : " + '{:>10}'.format(WordsSeconds) + " Word/s \tCurrent word: " + curentWord)
|
||||||
|
return
|
||||||
|
|
||||||
|
def displayProcessPerfsList(self, host, processName, WordsSeconds, curentWord):
|
||||||
|
self.setLocale()
|
||||||
|
print("Host : " + host )
|
||||||
|
for i in range(0,len(processName)):
|
||||||
|
WordsSeconds[i] = locale.format('%d', WordsSeconds[i], grouping=True)
|
||||||
|
print("\t"+ processName[i]+" : " + '{:>10}'.format(WordsSeconds[i]) + " Word/s \tCurrent word: " + curentWord[i])
|
||||||
|
return
|
||||||
|
|
||||||
|
def displayTotalPerfs(self, host,WordsSeconds):
|
||||||
|
self.setLocale()
|
||||||
|
WordsSeconds = locale.format('%d', WordsSeconds, grouping=True)
|
||||||
|
print("Word Per Second : " +'{:>10}'.format(WordsSeconds)+ " Word/s")
|
||||||
|
|
||||||
|
def displayError(self, host,errorCode, errorMessage):
|
||||||
|
print("Error at : " + host)
|
||||||
|
print("\t"+errorCode + " : " + errorMessage)
|
||||||
|
|
||||||
|
def displayMessage(self,host,message):
|
||||||
|
print("From " + host + ": " + message )
|
||||||
|
|
||||||
|
def displayResult(self,value,timeSeconds):
|
||||||
|
if(time.time() - timeSeconds) > 60 :
|
||||||
|
seconds = time.time() - timeSeconds
|
||||||
|
d,h,m,s = self.formatTime(seconds)
|
||||||
|
|
||||||
|
if d != 0:
|
||||||
|
print("Found ! : " + value +" in " + "%d:%02d:%02d:%02d" % (d,h, m, s))
|
||||||
|
elif h != 0 :
|
||||||
|
print("Found ! : " + value +" in " + "%d:%02d:%02d" % (h, m, s))
|
||||||
|
else:
|
||||||
|
print("Found ! : " + value +" in " + "%d:%02d" % (m, s))
|
||||||
|
else:
|
||||||
|
print("Found ! : " + value +" in " + str(round(time.time() - timeSeconds,2)) + " second")
|
||||||
|
return
|
||||||
|
|
||||||
|
def displayCopyright(self):
|
||||||
|
lines = list()
|
||||||
|
info = list()
|
||||||
|
lenGui = 0
|
||||||
|
info.append("")
|
||||||
|
info.append(APPLICATION_CONSTANTS.NAME + " Copyright © " + APPLICATION_CONSTANTS.YEAR + " " + APPLICATION_CONSTANTS.AUTHORS)
|
||||||
|
info.append("This program comes with ABSOLUTELY NO WARRANTY")#; for details type `show w'.")
|
||||||
|
info.append("This is free software, and you are welcome to redistribute it")
|
||||||
|
info.append("under certain conditions. Please read the COPYING and README")#; type `show c' for details.")
|
||||||
|
info.append("")
|
||||||
|
for value in info:
|
||||||
|
if len(value) > lenGui:
|
||||||
|
lenGui = len(value)
|
||||||
|
|
||||||
|
lines.append(self.separationLineCreator("*","*","*",lenGui+2))
|
||||||
|
for content in info:
|
||||||
|
lines.append(str(self.leftAlignLine("* "," *"," ",content,lenGui)))
|
||||||
|
|
||||||
|
lines.append(self.separationLineCreator("*","*","*",lenGui+2))
|
||||||
|
|
||||||
|
self.clearScreen()
|
||||||
|
for line in lines:
|
||||||
|
print(line)
|
||||||
|
print()
|
||||||
|
input("press any key to continue...")
|
||||||
|
|
||||||
|
def formatTime(self,seconds):
|
||||||
|
m, s = divmod(seconds, 60)
|
||||||
|
h, m = divmod(m, 60)
|
||||||
|
d ,h = divmod(h, 24)
|
||||||
|
return d,h,m,s
|
||||||
|
|
||||||
|
def displayShortHelp(self):
|
||||||
|
print()
|
||||||
|
print("Usage : " )
|
||||||
|
leftTab = list()
|
||||||
|
leftTab.append("\t"+PARAMS_CONSTANTS.LONG_PARAMS.HELP.value+", "+ PARAMS_CONSTANTS.SHORT_PARAMS.HELP.value)
|
||||||
|
leftTab.append("\t"+PARAMS_CONSTANTS.LONG_PARAMS.HASH.value+"=[passwordSearch]")
|
||||||
|
leftTab.append("\t"+PARAMS_CONSTANTS.LONG_PARAMS.VERBOSE.value+", "+ PARAMS_CONSTANTS.SHORT_PARAMS.VERBOSE.value)
|
||||||
|
leftTab.append("\t"+PARAMS_CONSTANTS.LONG_PARAMS.MODE.value+", " +PARAMS_CONSTANTS.SHORT_PARAMS.MODE.value)
|
||||||
|
|
||||||
|
rightTab = list()
|
||||||
|
rightTab.append("Display help message")
|
||||||
|
rightTab.append("Set hash to search")
|
||||||
|
rightTab.append("Set verbose mode")
|
||||||
|
rightTab.append("Set application mode")
|
||||||
|
|
||||||
|
|
||||||
|
maxLenLeft = 0
|
||||||
|
for value in leftTab:
|
||||||
|
if len(value) > maxLenLeft:
|
||||||
|
maxLenLeft = len(value)
|
||||||
|
|
||||||
|
for i in range(0,len(leftTab)):
|
||||||
|
print(self.tableLine(" ",leftTab[i],rightTab[i],maxLenLeft+4))
|
||||||
|
print()
|
||||||
|
|
||||||
|
def displayFullHelp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def displayVersion(self):
|
||||||
|
print()
|
||||||
|
print(APPLICATION_CONSTANTS.NAME + " version " + APPLICATION_CONSTANTS.VERSION)
|
||||||
|
|
||||||
|
def getStringInputValue(self,question):
|
||||||
|
print()
|
||||||
|
return input(question +" ")
|
||||||
|
|
||||||
|
def getIntInputValue(self,question):
|
||||||
|
print()
|
||||||
|
userChoice = input(question +" ")
|
||||||
|
if not BF_Utils.is_int(userChoice):
|
||||||
|
self.displayHeader()
|
||||||
|
print()
|
||||||
|
self.displayError("localhost","EntryError","Input is not a Number !")
|
||||||
|
userChoice = self.getIntInputValue(question)
|
||||||
|
return int(userChoice)
|
||||||
|
|
||||||
|
def createMenu(self,title,entryList,margin):
|
||||||
|
print()
|
||||||
|
print(title)
|
||||||
|
print()
|
||||||
|
for i in range(0,len(entryList)):
|
||||||
|
print(margin+ str(i + 1) + " - " + entryList[i])
|
||||||
|
print()
|
||||||
|
userChoice = input()
|
||||||
|
if BF_Utils.is_int(userChoice):
|
||||||
|
if not (int(userChoice)> 0 and int(userChoice) <= len(entryList)):
|
||||||
|
self.displayHeader()
|
||||||
|
print()
|
||||||
|
self.displayError("localhost","EntryError","Choice not in the list !")
|
||||||
|
userChoice = self.displayMenu(title,entryList,margin)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.displayHeader()
|
||||||
|
print()
|
||||||
|
self.displayError("localhost","EntryError","Input is not a Number !")
|
||||||
|
userChoice = self.displayMenu(title,entryList,margin)
|
||||||
|
return int(userChoice)
|
||||||
|
|
||||||
|
def createMenuValue(self,title,entryList,margin):
|
||||||
|
print()
|
||||||
|
print(title)
|
||||||
|
print()
|
||||||
|
for i in range(0,len(entryList)):
|
||||||
|
print(margin+ str(i + 1) + " - " + entryList[i])
|
||||||
|
print()
|
||||||
|
userChoice = input()
|
||||||
|
if BF_Utils.is_int(userChoice):
|
||||||
|
if not (int(userChoice)> 0 and int(userChoice) <= len(entryList)):
|
||||||
|
self.displayHeader()
|
||||||
|
print()
|
||||||
|
self.displayError("localhost","EntryError","Choice not in the list !")
|
||||||
|
userChoice = self.displayMenu(title,entryList,margin)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.displayHeader()
|
||||||
|
print()
|
||||||
|
self.displayError("localhost","EntryError","Input is not a Number !")
|
||||||
|
userChoice = self.displayMenu(title,entryList,margin)
|
||||||
|
return entryList[int(userChoice) - 1]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of Foobar.
|
||||||
|
|
||||||
|
# Foobar is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Foobar is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Foobar. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import socketserver
|
||||||
|
from threading import Thread
|
||||||
|
import signal
|
||||||
|
|
||||||
|
from BF_Constants import *
|
||||||
|
from BF_EasterEgg import *
|
||||||
|
import BF_Utils
|
||||||
|
FOUND = False
|
||||||
|
|
||||||
|
class InterfaceServerHandler(socketserver.BaseRequestHandler):
|
||||||
|
def handle(self):
|
||||||
|
self.messageType = LAN_CONSTANTS.MESSAGE_VALUE.TYPE_DEFAULT.value
|
||||||
|
self.messageState = LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value
|
||||||
|
self.data = self.request.recv(1024).strip()
|
||||||
|
self.traitementResponse(self.data.decode('utf-8'),self.client_address[0])
|
||||||
|
|
||||||
|
if self.messageType == LAN_CONSTANTS.MESSAGE_VALUE.TYPE_RESULT.value:
|
||||||
|
if self.messageState == LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value:
|
||||||
|
#self.request.sendall(bytes(BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_KEY.RETURN_STATE.value,LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value,False),"utf-8"))
|
||||||
|
|
||||||
|
global FOUND
|
||||||
|
FOUND = True
|
||||||
|
easterEgg = EasterEgg()
|
||||||
|
easterEgg.openTray()
|
||||||
|
self.finish()
|
||||||
|
|
||||||
|
|
||||||
|
def traitementResponse(self,param,clientAdress):
|
||||||
|
errorMessage = list()
|
||||||
|
errorCode = list()
|
||||||
|
argvArray = param.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value)
|
||||||
|
for object in argvArray:
|
||||||
|
key,value = BF_Utils.getValueWithKey(object)
|
||||||
|
if key == LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value:
|
||||||
|
self.messageType = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.RETURN_STATE.value :
|
||||||
|
self.messageState = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.WORD.value :
|
||||||
|
self.word = value
|
||||||
|
|
||||||
|
class InterfaceServer(Thread):
|
||||||
|
def __init__(self,port):
|
||||||
|
Thread.__init__(self)
|
||||||
|
self.port = port
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
server = socketserver.TCPServer(('', self.port), InterfaceServerHandler)
|
||||||
|
while not FOUND:
|
||||||
|
server.handle_request()
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from threding import Thread,queue
|
||||||
|
|
||||||
|
class DisplayThread(Threadin.thread):
|
||||||
|
def __init__(self,queue)
|
||||||
|
super.__init__()
|
||||||
|
self.queue = queue
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pass
|
@ -0,0 +1,347 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
|
||||||
|
from multiprocessing import Queue
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import socketserver
|
||||||
|
|
||||||
|
from BF_ProcessBruteForce import *
|
||||||
|
from BF_MultyStationClient import *
|
||||||
|
from BF_MultyStationServer import *
|
||||||
|
from BF_InterfaceServer import *
|
||||||
|
from BF_GUI import *
|
||||||
|
from BF_Constants import *
|
||||||
|
from BF_Utils import *
|
||||||
|
from BF_Encryption import *
|
||||||
|
|
||||||
|
class App():
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
# le Gui gerre l'affichage
|
||||||
|
self.GUI = GUI()
|
||||||
|
#self.GUI.displayHeader()
|
||||||
|
|
||||||
|
#mode de fonctionement
|
||||||
|
self.local = False
|
||||||
|
self.server = False
|
||||||
|
self.client = False
|
||||||
|
|
||||||
|
#verbose
|
||||||
|
self.verbose = False
|
||||||
|
|
||||||
|
#parametre client mode
|
||||||
|
self.serverIP = ""
|
||||||
|
self.serverPort = 0
|
||||||
|
|
||||||
|
#parametre porcess
|
||||||
|
self.password = ""
|
||||||
|
self.encryptionKey = ""
|
||||||
|
self.hashMethod=""
|
||||||
|
self.maxLength = 0
|
||||||
|
self.firstProcessIndex = 0
|
||||||
|
self.nbProcess = 0
|
||||||
|
self.nbTotalProcess = 0
|
||||||
|
|
||||||
|
## La liste contenant nos object Processe
|
||||||
|
self.processes = list()
|
||||||
|
self.queue = multiprocessing.Queue()
|
||||||
|
self.infoQueue = multiprocessing.Queue()
|
||||||
|
self.found = False
|
||||||
|
self.appTime = time.time()
|
||||||
|
|
||||||
|
def initProcess(self):
|
||||||
|
if(self.nbProcess > os.cpu_count()):
|
||||||
|
self.GUI.displayError("localhost","Ressources", "Too many process allowed for your computer")
|
||||||
|
sys.exit()
|
||||||
|
for i in range(self.firstProcessIndex, self.firstProcessIndex+self.nbProcess):
|
||||||
|
p=ProcessBruteForce(self.queue, i,self.nbTotalProcess , self.password, self.encryptionKey, self.maxLength, self.verbose, self.hashMethod)
|
||||||
|
self.processes.append(p)
|
||||||
|
|
||||||
|
def menu(self):
|
||||||
|
# Mode selection
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
entry = list()
|
||||||
|
entry.append("local Mode")
|
||||||
|
entry.append("lan Mode")
|
||||||
|
choice = self.GUI.createMenu("What 's your mode ?",entry,"\t")
|
||||||
|
if(choice == 1):
|
||||||
|
self.local=True
|
||||||
|
else:
|
||||||
|
self.local = False
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
entry = list()
|
||||||
|
entry.append("server")
|
||||||
|
entry.append("client")
|
||||||
|
choice = self.GUI.createMenu("What 's your role ?",entry,"\t")
|
||||||
|
if(choice == 1):
|
||||||
|
self.server=True
|
||||||
|
else:
|
||||||
|
self.client=True
|
||||||
|
#Verbose mode
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
entry = list()
|
||||||
|
entry.append("True")
|
||||||
|
entry.append("False")
|
||||||
|
choice = self.GUI.createMenu("Display Stats",entry,"\t")
|
||||||
|
if(choice == 1):
|
||||||
|
self.verbose=True
|
||||||
|
else:
|
||||||
|
self.verbose=False
|
||||||
|
|
||||||
|
#get server's IP address and port if client mode
|
||||||
|
if self.client:
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.serverIP = self.GUI.getStringInputValue("What's the IP server address ?")
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.serverPort = self.GUI.getIntInputValue("What's the server port ?")
|
||||||
|
|
||||||
|
if self.server:
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.serverPort = self.GUI.getIntInputValue("What's the server port ?")
|
||||||
|
#Get number of core
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.nbProcess = self.GUI.getIntInputValue("How many core want you allowed?")
|
||||||
|
|
||||||
|
if not self.client:
|
||||||
|
#Get max size of password
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.maxLength = self.GUI.getIntInputValue("What 's the max size of password do you want to search?")
|
||||||
|
|
||||||
|
#Get password
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.password = self.GUI.getStringInputValue("What's your hash ?")
|
||||||
|
|
||||||
|
#Get EncryptionKey
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
self.encryptionKey = self.GUI.getStringInputValue("What's your encryption key ? (if you know it)")
|
||||||
|
|
||||||
|
#Get hashMethod
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
entry = list()
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_MD5.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_SHA1.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_SHA224.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_SHA256.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_SHA384.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_SHA512.value)
|
||||||
|
entry.append(HASH_METHODS.HASH_METHOD.HASH_NONE.value)
|
||||||
|
choiceValue = self.GUI.createMenuValue("Choose a Hash Method",entry,"\t")
|
||||||
|
self.hashMethod = choiceValue
|
||||||
|
|
||||||
|
#Clear screen
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if self.local :
|
||||||
|
self.localMode()
|
||||||
|
else:
|
||||||
|
if self.server:
|
||||||
|
self.serverMode()
|
||||||
|
else:
|
||||||
|
self.client = True
|
||||||
|
self.clientMode()
|
||||||
|
|
||||||
|
def clientMode(self):
|
||||||
|
self.GUI.displayHeader()
|
||||||
|
client = MultyStationClient(self.serverIP, self.serverPort)
|
||||||
|
client.configToServer(str(self.nbProcess))
|
||||||
|
serverAnswer = client.receive()
|
||||||
|
key, value = BF_Utils.getValueWithKey(serverAnswer)
|
||||||
|
print(key)
|
||||||
|
if key == ANSWER_STATES.MESSAGE_STATE.STATE_KO.value:
|
||||||
|
print(value)
|
||||||
|
else:
|
||||||
|
#mise en attente de la range
|
||||||
|
self.GUI.displayMessage(self.serverIP,"Mise en attente de la range")
|
||||||
|
value = client.listen()
|
||||||
|
self.nbTotalProcess, self.firstProcessIndex, self.password, self.encryptionKey, self.maxLength, self.hashMethod = client.initParamProcessing(value)
|
||||||
|
self.initProcess()
|
||||||
|
self.executeProcess()
|
||||||
|
sys.exit()
|
||||||
|
return
|
||||||
|
|
||||||
|
def serverMode(self):
|
||||||
|
server = MultyStationServer('',self.serverPort,self.nbProcess,self.password,'1234',self.maxLength,self.hashMethod)
|
||||||
|
server.connect()
|
||||||
|
server.run()
|
||||||
|
sys.exit()
|
||||||
|
return
|
||||||
|
|
||||||
|
def localMode(self):
|
||||||
|
self.firstProcessIndex = 0
|
||||||
|
self.nbTotalProcess = self.nbProcess
|
||||||
|
self.initProcess()
|
||||||
|
self.appTime = time.time()
|
||||||
|
self.executeProcess()
|
||||||
|
|
||||||
|
def initialisation(self):
|
||||||
|
self.GUI.displayCopyright()
|
||||||
|
if not self.gestionParams():
|
||||||
|
self.menu()
|
||||||
|
|
||||||
|
def gestionParams(self):
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
for argv in sys.argv:
|
||||||
|
if PARAMS_CONSTANTS.LONG_PARAMS.HELP.value == argv or PARAMS_CONSTANTS.SHORT_PARAMS.HELP.value == argv:
|
||||||
|
self.GUI.displayShortHelp()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.HASH.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.password = "".join(str.split(argv,clefParam + "="))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.MODE.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.MODE.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
mode = "".join(str.split(argv,clefParam + "="))
|
||||||
|
if mode == PARAMS_CONSTANTS.PARAMS_VALUE.MODE_LOCAL.value:
|
||||||
|
self.local = True
|
||||||
|
elif mode == PARAMS_CONSTANTS.PARAMS_VALUE.MODE_LAN.value:
|
||||||
|
self.local = False
|
||||||
|
else:
|
||||||
|
self.GUI.displayError("127.0.0.1","PARAMETERS","Attribut for " + clefParam + " no reconize : "+ mode)
|
||||||
|
self.GUI.displayShortHelp()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.ROLE.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.ROLE.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
mode = "".join(str.split(argv,clefParam + "="))
|
||||||
|
if mode == PARAMS_CONSTANTS.PARAMS_VALUE.ROLE_CLIENT.value:
|
||||||
|
self.client = True
|
||||||
|
self.server = False
|
||||||
|
elif mode == PARAMS_CONSTANTS.PARAMS_VALUE.ROLE_SERVER.value:
|
||||||
|
self.client = False
|
||||||
|
self.server = True
|
||||||
|
else:
|
||||||
|
self.GUI.displayError("127.0.0.1","PARAMETERS","Attribut for " + clefParam + " no reconize : "+ mode)
|
||||||
|
self.GUI.displayShortHelp()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.ENCRYPTION_KEY.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.ENCRYPTION_KEY.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.encryptionKey = "".join(str.split(argv,clefParam + "="))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.SERVER_IP.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.SERVER_IP.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.serverIP = "".join(str.split(argv,clefParam + "="))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.PORT.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.PORT.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.serverPort = int("".join(str.split(argv,clefParam + "=")))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.CORE.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.CORE.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.nbProcess = int("".join(str.split(argv,clefParam + "=")))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.MAX_LENGTH.value in argv or PARAMS_CONSTANTS.SHORT_PARAMS.MAX_LENGTH.value in argv:
|
||||||
|
clefParam = "".join(str.split(argv,"=")[0])
|
||||||
|
self.maxLength = int("".join(str.split(argv,clefParam + "=")))
|
||||||
|
|
||||||
|
elif PARAMS_CONSTANTS.LONG_PARAMS.VERBOSE.value == argv or PARAMS_CONSTANTS.SHORT_PARAMS.VERBOSE.value == argv:
|
||||||
|
self.verbose = True
|
||||||
|
|
||||||
|
elif argv == sys.argv[0]:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.GUI.displayError("127.0.0.1","PARAMETERS","Unknown command \t" + argv)
|
||||||
|
self.GUI.displayShortHelp()
|
||||||
|
sys.exit()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def executeProcess(self):
|
||||||
|
self.appTime = time.time()
|
||||||
|
for proc in self.processes:
|
||||||
|
proc.start()
|
||||||
|
|
||||||
|
procAlive=True
|
||||||
|
totalMotParSecondes = 0
|
||||||
|
if self.client:
|
||||||
|
self.serverInterface = InterfaceServer(self.serverPort +1)
|
||||||
|
self.serverInterface.start()
|
||||||
|
|
||||||
|
while procAlive:
|
||||||
|
totalMotParSecondes =0
|
||||||
|
procAlive =False
|
||||||
|
processTime = list()
|
||||||
|
words = list()
|
||||||
|
wordsSeconds = list()
|
||||||
|
currentWords = list()
|
||||||
|
porcessName = list()
|
||||||
|
if self.client:
|
||||||
|
if not self.serverInterface.is_alive():
|
||||||
|
for proc in self.processes:
|
||||||
|
proc.terminate()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
for proc in self.processes:
|
||||||
|
#proc.join()
|
||||||
|
resultat = self.queue.get()
|
||||||
|
if resultat[0]== PROCESS_CONSTANTS.MESSAGE_RETURN_TYPE.RETURN.value :
|
||||||
|
if self.client :
|
||||||
|
if resultat[1] == True :
|
||||||
|
sock = MultyStationClient(self.serverIP, self.serverPort)
|
||||||
|
sock.resultToServer(resultat[2])
|
||||||
|
self.GUI.displayResult(resultat[2],self.appTime)
|
||||||
|
for proc in self.processes:
|
||||||
|
proc.terminate()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
else :
|
||||||
|
if resultat[1] == True :
|
||||||
|
self.GUI.displayResult(resultat[2],self.appTime)
|
||||||
|
for proc in self.processes:
|
||||||
|
proc.terminate()
|
||||||
|
sys.exit()
|
||||||
|
elif resultat[0] == PROCESS_CONSTANTS.MESSAGE_RETURN_TYPE.PERFS.value :
|
||||||
|
words.append(resultat[1])
|
||||||
|
processTime.append(resultat[2])
|
||||||
|
currentWords.append(resultat[3])
|
||||||
|
porcessName.append(resultat[4])
|
||||||
|
wordsSeconds.append(round(resultat[1]/resultat[2]))
|
||||||
|
totalMotParSecondes = totalMotParSecondes + round(resultat[1]/resultat[2])
|
||||||
|
else:
|
||||||
|
self.GUI.displayError('localhost','useCase',str(resultat[0]) +" non traité")
|
||||||
|
|
||||||
|
#on verifie qu'il y a encore des process en cours (il n'y a pas de do while en python
|
||||||
|
if proc.is_alive():
|
||||||
|
procAlive =True
|
||||||
|
if self.verbose:
|
||||||
|
if self.client :
|
||||||
|
sock = MultyStationClient(self.serverIP, self.serverPort)
|
||||||
|
sock.infoToServerList(words,processTime,currentWords,porcessName)
|
||||||
|
else :
|
||||||
|
self.GUI.displayProcessPerfsList('localhost',porcessName,wordsSeconds,currentWords)
|
||||||
|
self.GUI.displayTotalPerfs('localhost',totalMotParSecondes)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
#si le fichier est lancé seul
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
application = App()
|
||||||
|
application.initialisation()
|
||||||
|
application.run()
|
||||||
|
sys.exit()
|
@ -0,0 +1,141 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import BF_Utils
|
||||||
|
from BF_Constants import *
|
||||||
|
|
||||||
|
|
||||||
|
class MultyStationClient:
|
||||||
|
def __init__(self, serverAdress, serveurPort):
|
||||||
|
super().__init__()
|
||||||
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
self.serverAdress = serverAdress
|
||||||
|
self.serveurPort = serveurPort
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
self.sock.connect((self.serverAdress, self.serveurPort))
|
||||||
|
|
||||||
|
def listen(self):
|
||||||
|
newSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
newSocket.bind(('',self.serveurPort + 1))
|
||||||
|
newSocket.listen(1)
|
||||||
|
|
||||||
|
chunks = []
|
||||||
|
bytes_recd = 0
|
||||||
|
#newSocket.connect(('', self.serveurPort + 1))
|
||||||
|
while bytes_recd < 5:
|
||||||
|
conn, addr = newSocket.accept()
|
||||||
|
#print("test addr: "+ str(addr))
|
||||||
|
chunk = conn.recv(min(2048 - bytes_recd, 2048))
|
||||||
|
#if chunk == b'':
|
||||||
|
# raise RuntimeError("socket connection broken")
|
||||||
|
chunks.append(chunk)
|
||||||
|
bytes_recd = bytes_recd + len(chunk)
|
||||||
|
data = b''.join(chunks).decode("UTF-8")
|
||||||
|
conn.sendall(bytes(data,"UTF-8"))
|
||||||
|
if data:
|
||||||
|
break
|
||||||
|
return data
|
||||||
|
|
||||||
|
def initParamProcessing(self, param):
|
||||||
|
errorMessage = list()
|
||||||
|
errorCode = list()
|
||||||
|
argvArray = param.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value)
|
||||||
|
for object in argvArray:
|
||||||
|
key, value = BF_Utils.getValueWithKey(object)
|
||||||
|
if key == LAN_CONSTANTS.MESSAGE_KEY.NB_CORE_TOTAL.value:
|
||||||
|
nbCoreTotal = int(value)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.INDEX_CORE_MIN.value:
|
||||||
|
indexCoreMin = int(value)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.CRYPTED_PASSWORD.value:
|
||||||
|
cryptedPassword = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.ENCRYPTION_KEY.value:
|
||||||
|
encryptionKey = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.PASSWORD_MAX_LENGTH.value:
|
||||||
|
passwordMaxLength = int(value)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.HASH_METHOD.value:
|
||||||
|
hashMethod = value
|
||||||
|
|
||||||
|
return nbCoreTotal, indexCoreMin, cryptedPassword, encryptionKey, passwordMaxLength,hashMethod
|
||||||
|
|
||||||
|
def send(self, msg):
|
||||||
|
totalsent = 0
|
||||||
|
while totalsent < 5:
|
||||||
|
sent = self.sock.send(msg[totalsent:])
|
||||||
|
if sent == 0:
|
||||||
|
raise RuntimeError("socket connection broken")
|
||||||
|
totalsent = totalsent + sent
|
||||||
|
sent = sent +1
|
||||||
|
|
||||||
|
def configToServer(self,nbProcess):
|
||||||
|
self.connect()
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_CONFIG.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.NB_CORE_CLIENT.value,nbProcess,False)
|
||||||
|
self.send(bytes(msg,"utf-8"))
|
||||||
|
|
||||||
|
def infoToServer(self,nbWord,processTime,word,threadName):
|
||||||
|
self.connect()
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_INFO.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.NB_WORDS.value,nbWord,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.PROCESS_TIME.value,processTime,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.WORD.value,word,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.LOCAL_THREAD_NAME.value,threadName,False)
|
||||||
|
self.send(bytes(msg,"utf-8"))
|
||||||
|
|
||||||
|
def infoToServerList(self,nbWord,processTime,word,threadName):
|
||||||
|
self.connect()
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_INFO.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessageList(LAN_CONSTANTS.MESSAGE_KEY.NB_WORDS.value,nbWord,True)
|
||||||
|
msg = msg + BF_Utils.createMessageList(LAN_CONSTANTS.MESSAGE_KEY.PROCESS_TIME.value,processTime,True)
|
||||||
|
msg = msg + BF_Utils.createMessageList(LAN_CONSTANTS.MESSAGE_KEY.WORD.value,word,True)
|
||||||
|
msg = msg + BF_Utils.createMessageList(LAN_CONSTANTS.MESSAGE_KEY.LOCAL_THREAD_NAME.value,threadName,False)
|
||||||
|
self.send(bytes(msg,"utf-8"))
|
||||||
|
|
||||||
|
#time.sleep(0.1)
|
||||||
|
#self.receive()
|
||||||
|
|
||||||
|
def resultToServer(self,word):
|
||||||
|
self.connect()
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_RESULT.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.RETURN_STATE.value,LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.WORD.value,word,False)
|
||||||
|
self.send(bytes(msg,"utf-8"))
|
||||||
|
|
||||||
|
def receive(self):
|
||||||
|
chunks = []
|
||||||
|
bytes_recd = 0
|
||||||
|
while bytes_recd < 5:
|
||||||
|
chunk = self.sock.recv(min(2048 - bytes_recd, 2048))
|
||||||
|
#if chunk == b'':
|
||||||
|
# raise RuntimeError("socket connection broken")
|
||||||
|
chunks.append(chunk)
|
||||||
|
bytes_recd = bytes_recd + len(chunk)
|
||||||
|
return b''.join(chunks).decode("UTF-8")
|
||||||
|
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
client = MultyStationClient('127.0.0.1',2323)
|
||||||
|
client.connect()
|
||||||
|
client.send(bytes('nbCore:4','UTF-8'))
|
||||||
|
print(client.receive())
|
||||||
|
|
||||||
|
sys.exit()
|
@ -0,0 +1,282 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import socketserver
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import signal
|
||||||
|
import BF_Utils
|
||||||
|
from BF_Constants import *
|
||||||
|
from BF_GUI import *
|
||||||
|
|
||||||
|
COEUR_CONNECTE = 0
|
||||||
|
IP_CONNECTE = list()
|
||||||
|
CLIENT = list()
|
||||||
|
NB_COEUR = 0
|
||||||
|
PASSWORD_FOUND = ""
|
||||||
|
FOUND = False
|
||||||
|
|
||||||
|
class MultyStationServerHandler(socketserver.BaseRequestHandler):
|
||||||
|
"""
|
||||||
|
The RequestHandler class for our server.
|
||||||
|
|
||||||
|
It is instantiated once per connection to the server, and must
|
||||||
|
override the handle() method to implement communication to the
|
||||||
|
client.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, request, client_address, server):
|
||||||
|
self.request = request
|
||||||
|
self.client_address = client_address
|
||||||
|
self.server = server
|
||||||
|
self.setup()
|
||||||
|
self.coreClient = 0
|
||||||
|
self.client = list()
|
||||||
|
self.GUI = GUI()
|
||||||
|
self.messageType = LAN_CONSTANTS.MESSAGE_VALUE.TYPE_DEFAULT.value
|
||||||
|
|
||||||
|
global COEUR_CONNECTE
|
||||||
|
global CLIENT
|
||||||
|
try:
|
||||||
|
self.handle()
|
||||||
|
COEUR_CONNECTE = COEUR_CONNECTE + self.coreClient
|
||||||
|
CLIENT = CLIENT + self.client
|
||||||
|
finally:
|
||||||
|
self.finish()
|
||||||
|
|
||||||
|
def handle(self):
|
||||||
|
# self.request is the TCP socket connected to the client
|
||||||
|
self.data = self.request.recv(1024).strip()
|
||||||
|
#self.GUI.displayMessage("".join(self.client_address[0]),self.data.decode('utf-8'))
|
||||||
|
|
||||||
|
errorCode, errorMessage = self.traitementResponse(self.data.decode('utf-8'),self.client_address[0])
|
||||||
|
if self.messageType == LAN_CONSTANTS.MESSAGE_VALUE.TYPE_CONFIG.value:
|
||||||
|
self.sendResponse(errorCode, errorMessage)
|
||||||
|
elif self.messageType == LAN_CONSTANTS.MESSAGE_VALUE.TYPE_INFO.value:
|
||||||
|
self.managmentInfo(self.data.decode('utf-8'),"".join(self.client_address[0]))
|
||||||
|
elif self.messageType == LAN_CONSTANTS.MESSAGE_VALUE.TYPE_RESULT.value:
|
||||||
|
if self.messageState == LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value:
|
||||||
|
#print(self.data.decode('utf-8'))
|
||||||
|
global FOUND
|
||||||
|
FOUND = True
|
||||||
|
#self.finish()
|
||||||
|
return
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finish(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def managmentInfo(self,data,clientAdress):
|
||||||
|
argvArray = data.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value)
|
||||||
|
processName = list()
|
||||||
|
WordsSeconds = list()
|
||||||
|
curentWord = list()
|
||||||
|
processTime = list()
|
||||||
|
nbWord = list()
|
||||||
|
for object in argvArray:
|
||||||
|
key,value = BF_Utils.getValueWithKey(object)
|
||||||
|
if LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SAME_VALUE_SEPRATOR.value in value:
|
||||||
|
|
||||||
|
contentList = value.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SAME_VALUE_SEPRATOR.value)
|
||||||
|
if key == LAN_CONSTANTS.MESSAGE_KEY.LOCAL_THREAD_NAME.value :
|
||||||
|
for content in contentList:
|
||||||
|
processName.append(content)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.WORD.value:
|
||||||
|
for content in contentList:
|
||||||
|
curentWord.append(content)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.PROCESS_TIME.value:
|
||||||
|
for content in contentList:
|
||||||
|
processTime.append(float(content))
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.NB_WORDS.value:
|
||||||
|
for content in contentList:
|
||||||
|
nbWord.append(int(content))
|
||||||
|
|
||||||
|
for i in range(0,len(nbWord)):
|
||||||
|
WordsSeconds.append(round(nbWord[i]/processTime[i]))
|
||||||
|
self.GUI.displayProcessPerfsList( clientAdress, processName, WordsSeconds, curentWord)
|
||||||
|
"""else:
|
||||||
|
if key == LAN_CONSTANTS.MESSAGE_KEY.LOCAL_THREAD_NAME.value :
|
||||||
|
processName = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.WORD.value:
|
||||||
|
curentWord = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.PROCESS_TIME.value:
|
||||||
|
processTime = float(value)
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.NB_WORDS.value:
|
||||||
|
nbWord = int(value)
|
||||||
|
WordsSeconds = round(nbWord/processTime)
|
||||||
|
self.GUI.displayProcessPerfs( clientAdress, processName, WordsSeconds, curentWord)"""
|
||||||
|
|
||||||
|
|
||||||
|
def sendResponse(self, errorCode, errorMessage):
|
||||||
|
message = list()
|
||||||
|
for i in range(0,len(errorCode)):
|
||||||
|
if not i == (len(errorCode) -1):
|
||||||
|
message.append(errorCode[i]+':'+errorMessage[i]+',')
|
||||||
|
else:
|
||||||
|
message.append(errorCode[i]+':'+errorMessage[i])
|
||||||
|
self.request.sendall(bytes("".join(message),'utf-8'))
|
||||||
|
|
||||||
|
|
||||||
|
def traitementResponse(self,param,clientAdress):
|
||||||
|
errorMessage = list()
|
||||||
|
errorCode = list()
|
||||||
|
argvArray = param.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value)
|
||||||
|
for object in argvArray:
|
||||||
|
key,value = BF_Utils.getValueWithKey(object)
|
||||||
|
if key == LAN_CONSTANTS.MESSAGE_KEY.NB_CORE_CLIENT.value :
|
||||||
|
code, message = self.coreProcessing(value,clientAdress)
|
||||||
|
errorCode = errorCode + code
|
||||||
|
errorMessage = errorMessage + message
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value:
|
||||||
|
self.messageType = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.RETURN_STATE.value:
|
||||||
|
self.messageState = value
|
||||||
|
elif key == LAN_CONSTANTS.MESSAGE_KEY.WORD.value:
|
||||||
|
global PASSWORD_FOUND
|
||||||
|
PASSWORD_FOUND = value
|
||||||
|
else:
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_KO.value)
|
||||||
|
errorMessage.append('protocol key not recognize')
|
||||||
|
return errorCode,errorMessage
|
||||||
|
|
||||||
|
def coreProcessing(self,value,clientAdress):
|
||||||
|
global IP_CONNECTE
|
||||||
|
|
||||||
|
errorMessage = list()
|
||||||
|
errorCode = list()
|
||||||
|
if BF_Utils.is_int(value):
|
||||||
|
if clientAdress not in IP_CONNECTE:
|
||||||
|
coeurClient = int(value)
|
||||||
|
if coeurClient > 0:
|
||||||
|
if coeurClient <= NB_COEUR:
|
||||||
|
self.coreClient = coeurClient
|
||||||
|
IP_CONNECTE.append(clientAdress)
|
||||||
|
self.client.append((clientAdress,coeurClient))
|
||||||
|
errorMessage.append("core added")
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_OK.value)
|
||||||
|
else:
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_KO.value)
|
||||||
|
errorMessage.append("Please insert " + str(NB_COEUR - self.coreClient)+ " core max")
|
||||||
|
else:
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_KO.value)
|
||||||
|
errorMessage.append("Please insert at least 1 core")
|
||||||
|
else:
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_KO.value)
|
||||||
|
errorMessage.append("client already conected")
|
||||||
|
else:
|
||||||
|
errorCode.append(ANSWER_STATES.MESSAGE_STATE.STATE_KO.value)
|
||||||
|
errorMessage.append("Value is not integer")
|
||||||
|
|
||||||
|
return errorCode,errorMessage
|
||||||
|
|
||||||
|
|
||||||
|
class MultyStationServer():
|
||||||
|
def __init__(self,host,port,nbCoeur,password,key,passwordLength,hashMethod):
|
||||||
|
global NB_COEUR
|
||||||
|
self.nbCoeur=nbCoeur
|
||||||
|
NB_COEUR = nbCoeur
|
||||||
|
self.serverTime = time.time()
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.coreConnected = 0
|
||||||
|
self.password = password
|
||||||
|
self.passwordLength = passwordLength
|
||||||
|
self.hashMethod=hashMethod
|
||||||
|
self.key = key
|
||||||
|
self.GUI = GUI()
|
||||||
|
signal.signal(signal.SIGINT, self.signal_handler)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def signal_handler(self, signal, frame):
|
||||||
|
self.serverHandler.shutdown()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
self.serverHandler = socketserver.TCPServer((self.host, self.port ), MultyStationServerHandler)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
global IP_CONNECTE
|
||||||
|
global FOUND
|
||||||
|
if NB_COEUR < 1:
|
||||||
|
self.GUI.displayError("127.0.0.1","INIT","too low processor core")
|
||||||
|
sys.exit()
|
||||||
|
while COEUR_CONNECTE < NB_COEUR:
|
||||||
|
self.serverHandler.handle_request()
|
||||||
|
|
||||||
|
self.GUI.displayMessage(IP_CONNECTE[len(IP_CONNECTE) -1],str(COEUR_CONNECTE) +"/" +str(NB_COEUR))
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
indexCore = 0
|
||||||
|
for pc in CLIENT:
|
||||||
|
#print("ip : " + pc[0] + "\t Nombre de core offert : " + str(pc[1]))
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
sock.connect((pc[0],self.port+1))
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_CONFIG.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.NB_CORE_TOTAL.value, str(self.nbCoeur),True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.INDEX_CORE_MIN.value, str(indexCore),True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.CRYPTED_PASSWORD.value, str(self.password),True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.ENCRYPTION_KEY.value, str(self.key),True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.HASH_METHOD.value, str(self.hashMethod),True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.PASSWORD_MAX_LENGTH.value, str(self.passwordLength),False)
|
||||||
|
#self.GUI.displayMessage("127.0.0.1","Message envoyé : "+msg)
|
||||||
|
sock.send(bytes(msg,"UTF-8"))
|
||||||
|
indexCore = indexCore +pc[1]
|
||||||
|
sock.recv(min(2048, 2048))
|
||||||
|
sock.close()
|
||||||
|
|
||||||
|
self.serverTime = time.time()
|
||||||
|
self.GUI.displayMessage("SERVER","Start ! ")
|
||||||
|
global FOUND
|
||||||
|
while not FOUND:
|
||||||
|
self.serverHandler.handle_request()
|
||||||
|
|
||||||
|
self.GUI.displayMessage("SERVER","Found ! ")
|
||||||
|
self.GUI.displayResult(PASSWORD_FOUND,self.serverTime )
|
||||||
|
|
||||||
|
for pc in CLIENT:
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
sock.connect((pc[0],self.port+1))
|
||||||
|
msg = BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.MESSAGE_TYPE.value,LAN_CONSTANTS.MESSAGE_VALUE.TYPE_RESULT.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.RETURN_STATE.value,LAN_CONSTANTS.MESSAGE_VALUE.STATE_OK.value,True)
|
||||||
|
msg = msg + BF_Utils.createMessage(LAN_CONSTANTS.MESSAGE_KEY.WORD.value,PASSWORD_FOUND,False)
|
||||||
|
sock.send(bytes(msg,"utf-8"))
|
||||||
|
sock.recv(min(2048, 2048))
|
||||||
|
sock.close()
|
||||||
|
|
||||||
|
for pc in range(0,len(CLIENT)-1):
|
||||||
|
self.serverHandler.handle_request()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
HOST = ''
|
||||||
|
PORT = 2323
|
||||||
|
nbCoeur = 8
|
||||||
|
server = MultyStationServer(HOST,PORT,nbCoeur,"azert","",6)
|
||||||
|
server.connect()
|
||||||
|
server.run()
|
||||||
|
sys.exit()
|
||||||
|
|
@ -0,0 +1,125 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
from BF_Encryption import *
|
||||||
|
|
||||||
|
tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
||||||
|
class ProcessBruteForce(multiprocessing.Process):
|
||||||
|
def __init__(self,queue, idx, nbInstence,hash, clef, limite, verbose, hashMethode):
|
||||||
|
super().__init__()
|
||||||
|
self.queue = queue
|
||||||
|
self.idx = idx
|
||||||
|
self.nbInstence = nbInstence
|
||||||
|
|
||||||
|
#la queue contien 3 valeur :int useCase = 0, boolean found, list passTrouve
|
||||||
|
#la queue contien 5 valeur :int useCase = 1, nbMots, time secondes , list motEnCours nom du thread
|
||||||
|
#useCase = 0, on remonte les information contenant le mot Trouvé ou non
|
||||||
|
#useCase = 1, on remonte des information sur les performances
|
||||||
|
#gestion du temps
|
||||||
|
self.nbMot = 0
|
||||||
|
self.procTime = time.time()
|
||||||
|
self.verbose = verbose
|
||||||
|
self.hashMethodeFunction = self.getFunctionHash(hashMethode)
|
||||||
|
self.hash = hash
|
||||||
|
if(clef != None):
|
||||||
|
self.keySet = True
|
||||||
|
else:
|
||||||
|
self.keySet = False
|
||||||
|
|
||||||
|
self.clef = clef
|
||||||
|
self.limite = limite
|
||||||
|
self.password = ''
|
||||||
|
self.isFound = False
|
||||||
|
|
||||||
|
self.encryptionObject = Encryption()
|
||||||
|
return
|
||||||
|
|
||||||
|
def getFunctionHash(self, hashMethode):
|
||||||
|
|
||||||
|
function = None
|
||||||
|
cryptClass = Encryption()
|
||||||
|
|
||||||
|
if hashMethode == HASH_METHODS.HASH_METHOD.HASH_MD5.value:
|
||||||
|
function = (cryptClass.md5)
|
||||||
|
elif hashMethode == HASH_METHODS.HASH_METHOD.HASH_SHA1.value:
|
||||||
|
function = (cryptClass.sha1)
|
||||||
|
elif hashMethode == HASH_METHODS.HASH_METHOD.HASH_SHA224.value:
|
||||||
|
function = (cryptClass.sha224)
|
||||||
|
elif hashMethode == HASH_METHODS.HASH_METHOD.HASH_SHA256.value:
|
||||||
|
function = (cryptClass.sha256)
|
||||||
|
elif hashMethode == HASH_METHODS.HASH_METHOD.HASH_SHA384.value:
|
||||||
|
function = (cryptClass.sha384)
|
||||||
|
elif hashMethode == HASH_METHODS.HASH_METHOD.HASH_SHA512.value:
|
||||||
|
function = (cryptClass.sha512)
|
||||||
|
else:
|
||||||
|
function = (cryptClass.none)
|
||||||
|
return (function)
|
||||||
|
|
||||||
|
def testSpeed(self):
|
||||||
|
self.nbMot = self.nbMot+1
|
||||||
|
if (time.time() - self.procTime) > 5 :
|
||||||
|
self.queue.put([1,self.nbMot,time.time() - self.procTime, "".join(self.password),multiprocessing.current_process().name])
|
||||||
|
self.nbMot = 0
|
||||||
|
self.procTime = time.time()
|
||||||
|
|
||||||
|
def md5(self,string):
|
||||||
|
return hashlib.md5(string.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.bruteForce(self.hash)
|
||||||
|
|
||||||
|
def recursiveFunction(self,characters, size , isLast):
|
||||||
|
self.testSpeed()
|
||||||
|
if size == 0:
|
||||||
|
yield []
|
||||||
|
|
||||||
|
elif not isLast:
|
||||||
|
for i in range(len(characters)):
|
||||||
|
for j in self.recursiveFunction(characters[:i] + characters[i:], size - 1,False):
|
||||||
|
yield [characters[i]] + j
|
||||||
|
else:
|
||||||
|
indexMin = round((len(characters)/self.nbInstence)*self.idx)
|
||||||
|
indexMax = round(indexMin + (len(characters)/self.nbInstence))
|
||||||
|
if( self.idx == self.nbInstence - 1 ):
|
||||||
|
indexMax = len(tabChar)
|
||||||
|
for i in range(indexMin,indexMax):
|
||||||
|
for j in self.recursiveFunction(characters[:i] + characters[i:], size - 1,False):
|
||||||
|
yield [characters[i]] + j
|
||||||
|
|
||||||
|
def bruteForce(self,hash):
|
||||||
|
workRange = range(0,self.limite)
|
||||||
|
stringBuilder = ''
|
||||||
|
encryptWord = Encryption()
|
||||||
|
for length in workRange:
|
||||||
|
for i in self.recursiveFunction(tabChar, length,True):
|
||||||
|
self.password = stringBuilder + ''.join(i)
|
||||||
|
if encryptWord.hashForLambda(self.hashMethodeFunction,self.password) == hash:
|
||||||
|
self.queue.put([0,True, self.password])
|
||||||
|
return
|
||||||
|
|
||||||
|
self.queue.put([0,False, self.password])
|
||||||
|
#si le fichier est lancé seul
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
sys.exit()
|
@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/python3.4
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
||||||
|
|
||||||
|
# This file is part of RizzleHash.
|
||||||
|
|
||||||
|
# RizzleHash is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# RizzleHash is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
from BF_Constants import *
|
||||||
|
|
||||||
|
def is_int(stringInteger):
|
||||||
|
try:
|
||||||
|
int(stringInteger)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def is_float(stringFloat):
|
||||||
|
try:
|
||||||
|
float(stringFloat)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def getValueWithKey(value):
|
||||||
|
value = str(value)
|
||||||
|
argvArray = value.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value)
|
||||||
|
for argv in argvArray:
|
||||||
|
key = argv.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.ASIGNATOR.value)
|
||||||
|
key = key[0]
|
||||||
|
value = argv.split(LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.ASIGNATOR.value)
|
||||||
|
value = value[1]
|
||||||
|
return key, value
|
||||||
|
|
||||||
|
def createMessage(key,value,isNotLast):
|
||||||
|
value = str(value)
|
||||||
|
message = key + LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.ASIGNATOR.value + value
|
||||||
|
if isNotLast:
|
||||||
|
message = message + LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value
|
||||||
|
return message
|
||||||
|
|
||||||
|
def createMessageList(key,content,isNotLast):
|
||||||
|
message = key + LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.ASIGNATOR.value
|
||||||
|
for i in range(0,len(content)):
|
||||||
|
message = message + str(content[i])
|
||||||
|
if i < len(content) -1:
|
||||||
|
message = message + LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SAME_VALUE_SEPRATOR.value
|
||||||
|
if isNotLast:
|
||||||
|
message = message + LAN_CONSTANTS.MESSAGE_SPECIAL_CHAR.SEPARATOR.value
|
||||||
|
return message
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.6)
|
|
||||||
project(rizzlehash)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
|
|
||||||
set(SOURCE_FILES
|
|
||||||
include/CPUID.h
|
|
||||||
include/RH_Constants.h
|
|
||||||
include/RH_Encryption.h
|
|
||||||
include/RH_GUI.h
|
|
||||||
include/RH_ProcessBruteForce.h
|
|
||||||
include/RH_Utils.h
|
|
||||||
src/RH_Constants.cpp
|
|
||||||
src/RH_Encryption.cpp
|
|
||||||
src/RH_GUI.cpp
|
|
||||||
src/RH_ProcessBruteForce.cpp
|
|
||||||
src/RH_Utils.cpp
|
|
||||||
RH_Main.cpp
|
|
||||||
COPYING
|
|
||||||
README.md
|
|
||||||
)
|
|
||||||
#Ajout de openssl
|
|
||||||
find_package(OpenSSL REQUIRED)
|
|
||||||
if(OPENSSL_FOUND)
|
|
||||||
message(STATUS "OpenSSL_INCLUDE_DIRS: ${OPENSSL_INCLUDE_DIR}")
|
|
||||||
message(STATUS "OpenSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
|
|
||||||
message(STATUS "OpenSSL_VERSION: ${OPENSSL_VERSION}")
|
|
||||||
include_directories(${Ssl_INCLUDE_DIRS})
|
|
||||||
link_libraries(${OPENSSL_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#Ajout de pthread
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
link_libraries(${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
#find_package(Crypto REQUIRED)
|
|
||||||
|
|
||||||
|
|
||||||
add_executable(rizzlehash ${SOURCE_FILES})
|
|
@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <thread>
|
|
||||||
#include <queue>
|
|
||||||
#include <time.h>
|
|
||||||
#include <mutex>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "include/RH_GUI.h"
|
|
||||||
#include "include/RH_ProcessBruteForce.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char ** argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
mutex mtx;
|
|
||||||
|
|
||||||
GUI gui = GUI();
|
|
||||||
gui.displayCopyright();
|
|
||||||
gui.displayHeader();
|
|
||||||
//gui.displayShortHelp();
|
|
||||||
|
|
||||||
uint16_t nombreChoisi = 4;
|
|
||||||
|
|
||||||
queue<ProcessBruteForce::statReturn> q[nombreChoisi];
|
|
||||||
ProcessBruteForce bfArray[nombreChoisi];
|
|
||||||
thread threadArray[nombreChoisi];
|
|
||||||
|
|
||||||
for(int it = 0; it< nombreChoisi; it++)
|
|
||||||
{
|
|
||||||
bfArray[it].init(&q[it],it,nombreChoisi,"dc5fc7f9897dfa3eff22a1905ea70277","",10,true,"md5");
|
|
||||||
threadArray[it] = thread(bfArray[it]);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool done = false;
|
|
||||||
uint16_t nbLignes = 0;
|
|
||||||
while(!done)
|
|
||||||
{
|
|
||||||
for(int it = 0; it< nombreChoisi; it++)
|
|
||||||
{
|
|
||||||
if(!q[it].empty())
|
|
||||||
{
|
|
||||||
if(nbLignes > 12)
|
|
||||||
{
|
|
||||||
nbLignes = 0;
|
|
||||||
gui.displayHeader();
|
|
||||||
}
|
|
||||||
nbLignes++;
|
|
||||||
|
|
||||||
ProcessBruteForce::statReturn sr = q[it].back();
|
|
||||||
uint32_t wordSecond = sr.totalWords / sr.nbSecond;
|
|
||||||
gui.displayProcessPerfs("localhost",sr.currentProcessName,wordSecond,sr.currentWord);
|
|
||||||
q[it].pop();
|
|
||||||
if(sr.isFound){
|
|
||||||
done = sr.isFound;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usleep(2);// permert d'eviter de surcharger un coeur pour rien
|
|
||||||
|
|
||||||
}
|
|
||||||
for(int it = 0; it< nombreChoisi; it++)
|
|
||||||
{
|
|
||||||
threadArray[it].detach();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -0,0 +1,39 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import hashlib
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
||||||
|
class CryptPass():
|
||||||
|
def __init__(self):
|
||||||
|
self.passwordNonCrypte = ""
|
||||||
|
self.key = ""
|
||||||
|
self.typeCryptage = ""
|
||||||
|
self.passwordCrypte = ""
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getHash(self, passwordNonCrypteWithKey, typeCryptage):
|
||||||
|
self.passwordCrypte = ""
|
||||||
|
passwordNonCrypteWithKey = passwordNonCrypteWithKey.encode()
|
||||||
|
if typeCryptage == "md5":
|
||||||
|
passwordCrypte = hashlib.md5(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha1":
|
||||||
|
passwordCrypte = hashlib.sha1(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha224":
|
||||||
|
passwordCrypte = hashlib.sha224(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha256":
|
||||||
|
passwordCrypte = hashlib.sha256(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha384":
|
||||||
|
passwordCrypte = hashlib.sha384(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
elif typeCryptage == "sha512":
|
||||||
|
passwordCrypte = hashlib.sha512(passwordNonCrypteWithKey).hexdigest()
|
||||||
|
self.passwordCrypte = passwordCrypte
|
||||||
|
return self.passwordCrypte
|
||||||
|
|
||||||
|
|
||||||
|
#si le fichier est lancé seul
|
||||||
|
if __name__ == '__main__' :
|
||||||
|
app = CryptPass()
|
||||||
|
print(app.getHash(sys.argv[1],"md5"))
|
||||||
|
sys.exit()
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CPUID_H_INCLUDED
|
|
||||||
#define CPUID_H_INCLUDED
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cpuid.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
//#include <w32api.h>
|
|
||||||
|
|
||||||
class CPUID{
|
|
||||||
uint32_t regs[4];
|
|
||||||
public:
|
|
||||||
explicit CPUID(unsigned eax , unsigned ecx)
|
|
||||||
{
|
|
||||||
asm volatile ("cpuid":"=a"(regs[0]),
|
|
||||||
"=b"(regs[1]),
|
|
||||||
"=c"(regs[2]),
|
|
||||||
"=d"(regs[3]):
|
|
||||||
"a"(eax),"c"(ecx));
|
|
||||||
}
|
|
||||||
const uint32_t &EAX() const {return regs[0];}
|
|
||||||
const uint32_t &EBX() const {return regs[1];}
|
|
||||||
const uint32_t &ECX() const {return regs[2];}
|
|
||||||
const uint32_t &EDX() const {return regs[3];}
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif // CPUID_H_INCLUDED
|
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RH_CONSTANTS_H
|
|
||||||
#define RH_CONSTANTS_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include "CPUID.h"
|
|
||||||
//#include <w32api.h>
|
|
||||||
using namespace std;
|
|
||||||
class RH_Constants
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
RH_Constants();
|
|
||||||
static list<char> trimProcName(int32_t * value, int taille);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static string getOSName();
|
|
||||||
static string getOSFamily();
|
|
||||||
static int getNumberOfCore();
|
|
||||||
static string getProcessorVendor();
|
|
||||||
static string getProcessorName();
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace PARAMS_CONSTANTS
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace LONG_PARAMS
|
|
||||||
{
|
|
||||||
const string VERBOSE = "--verbose";
|
|
||||||
const string HELP = "--help";
|
|
||||||
const string MODE = "--mode";
|
|
||||||
const string HASH = "--hash";
|
|
||||||
const string ENCRYPTION_KEY = "--key";
|
|
||||||
const string PORT = "--port";
|
|
||||||
const string SERVER_IP = "--ip";
|
|
||||||
const string ROLE = "--role";
|
|
||||||
const string SECRET_PARAM = "--cd";
|
|
||||||
const string CORE = "--core";
|
|
||||||
const string MAX_LENGTH = "--length";
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace SHORT_PARAMS
|
|
||||||
{
|
|
||||||
const string VERBOSE = "-v";
|
|
||||||
const string HELP = "-h";
|
|
||||||
const string MODE = "-m";
|
|
||||||
const string ENCRYPTION_KEY = "-k";
|
|
||||||
const string PORT = "-p";
|
|
||||||
const string SERVER_IP = "-s";
|
|
||||||
const string ROLE = "-r";
|
|
||||||
const string CORE = "-c";
|
|
||||||
const string MAX_LENGTH = "-l";
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace PARAMS_VALUE
|
|
||||||
{
|
|
||||||
const string MODE_LOCAL = "local";
|
|
||||||
const string MODE_LAN = "lan";
|
|
||||||
const string ROLE_CLIENT = "client";
|
|
||||||
const string ROLE_SERVER = "server";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const string APPLICATION_NAME("RizzleHash V0.8 - rc1");
|
|
||||||
static const string APPLICATION_YEAR("2015");
|
|
||||||
static const string APPLICATION_AUTHORS("Matthieu DUVAL,Rudy DUCHE");
|
|
||||||
static const string OS(RH_Constants::getOSName());
|
|
||||||
static const int NB_CORE(RH_Constants::getNumberOfCore());
|
|
||||||
static const string PROCESSOR_VENDOR(RH_Constants::getProcessorVendor());
|
|
||||||
static const string PROCESSOR_NAME(RH_Constants::getProcessorName());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // RH_CONSTANTS_H
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef RH_ENCRYPTION_H
|
|
||||||
#define RH_ENCRYPTION_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <functional>
|
|
||||||
#include <openssl/sha.h>
|
|
||||||
#include <openssl/md5.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class RH_Encryption
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RH_Encryption();
|
|
||||||
static function<string (string)> getFunctionHashLambda(string hashMethode);
|
|
||||||
//static function<string (string)> hashForLambda(function<string(string)> functionLambda, string value);
|
|
||||||
virtual ~RH_Encryption();
|
|
||||||
protected:
|
|
||||||
private:
|
|
||||||
static function<string (string)> none();
|
|
||||||
static function<string (string)> md5();
|
|
||||||
static function<string (string)> sha1();
|
|
||||||
static function<string (string)> sha224();
|
|
||||||
static function<string (string)> sha384();
|
|
||||||
static function<string (string)> sha256();
|
|
||||||
static function<string (string)> sha512();
|
|
||||||
static string bytesArrayToStrinctString(uint8_t, unsigned char*);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RH_ENCRYPTION_H
|
|
@ -1,14 +0,0 @@
|
|||||||
#ifndef RH_UTILS_H
|
|
||||||
#define RH_UTILS_H
|
|
||||||
|
|
||||||
|
|
||||||
class RH_Utils
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RH_Utils();
|
|
||||||
virtual ~RH_Utils();
|
|
||||||
protected:
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RH_UTILS_H
|
|
@ -1,175 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
#include "../include/RH_Constants.h"
|
|
||||||
|
|
||||||
RH_Constants::RH_Constants()
|
|
||||||
{
|
|
||||||
//applicationName = "RizzleHash V0.8 - rc1";
|
|
||||||
}
|
|
||||||
|
|
||||||
string RH_Constants::getOSName()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return "Windows 32-bit";
|
|
||||||
#elif _WIN64
|
|
||||||
return "Windows 64 bit";
|
|
||||||
#elif __APPLE__ ||__MACH__
|
|
||||||
return "degage connard!";
|
|
||||||
#elif __linux__
|
|
||||||
return "Linux";
|
|
||||||
#elif __FreeBSD__
|
|
||||||
return "FreeBSD";
|
|
||||||
#elif __unix || __unix__
|
|
||||||
return "Unix";
|
|
||||||
#else
|
|
||||||
return "Unknown";
|
|
||||||
#endif // _WIN32
|
|
||||||
}
|
|
||||||
|
|
||||||
int RH_Constants::getNumberOfCore()
|
|
||||||
{
|
|
||||||
CPUID *cpuID = new CPUID(0x0B,0x01);
|
|
||||||
int nbCore = cpuID->EBX();
|
|
||||||
nbCore = nbCore & 0x0000FFFF;
|
|
||||||
|
|
||||||
delete cpuID;
|
|
||||||
return nbCore;
|
|
||||||
}
|
|
||||||
|
|
||||||
string RH_Constants::getProcessorVendor()
|
|
||||||
{
|
|
||||||
CPUID *cpuID = new CPUID(0x00,0x00);
|
|
||||||
string vendor;
|
|
||||||
vendor += string((const char*)&cpuID->EBX(),4);
|
|
||||||
vendor += string((const char*)&cpuID->EDX(),4);
|
|
||||||
vendor += string((const char*)&cpuID->ECX(),4);
|
|
||||||
delete cpuID;
|
|
||||||
return vendor;
|
|
||||||
}
|
|
||||||
|
|
||||||
string RH_Constants::getProcessorName()
|
|
||||||
{
|
|
||||||
CPUID *cpuID = new CPUID(0x80000000,0x00);
|
|
||||||
string name;
|
|
||||||
if( cpuID->EAX() >= 0x80000004)
|
|
||||||
{
|
|
||||||
cpuID = new CPUID(0x80000002,0x00);
|
|
||||||
int32_t value[12];
|
|
||||||
value[0] = cpuID->EAX();
|
|
||||||
value[1] = cpuID->EBX();
|
|
||||||
value[2] = cpuID->ECX();
|
|
||||||
value[3] = cpuID->EDX();
|
|
||||||
|
|
||||||
cpuID = new CPUID(0x80000003,0x00);
|
|
||||||
value[4] = cpuID->EAX();
|
|
||||||
value[5] = cpuID->EBX();
|
|
||||||
value[6] = cpuID->ECX();
|
|
||||||
value[7] = cpuID->EDX();
|
|
||||||
|
|
||||||
cpuID = new CPUID(0x80000004,0x00);
|
|
||||||
value[8] = cpuID->EAX();
|
|
||||||
value[9] = cpuID->EBX();
|
|
||||||
value[10] = cpuID->ECX();
|
|
||||||
value[11] = cpuID->EDX();
|
|
||||||
|
|
||||||
int taille = 0;
|
|
||||||
bool eosFound = false;
|
|
||||||
for( unsigned int i = 0; i< sizeof(value) ; i++)
|
|
||||||
{
|
|
||||||
char bytes[] ={0x00,0x00,0x00,0x00};
|
|
||||||
bytes[0] = value[i] &0x000000FF;
|
|
||||||
bytes[1] = (value[i] >> 8 )&0x000000FF;
|
|
||||||
bytes[2] = (value[i] >> 16)&0x000000FF;
|
|
||||||
bytes[3] = (value[i] >> 24)&0x000000FF;
|
|
||||||
for(unsigned int j=0;j< sizeof(bytes);j++)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(bytes[j] == 0x00)
|
|
||||||
{
|
|
||||||
eosFound = true;
|
|
||||||
}
|
|
||||||
if(!eosFound) //si on a trouvé le caractère de fin de chaine,
|
|
||||||
//on arrete d'augmenter le taille de la chaine
|
|
||||||
{
|
|
||||||
taille++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Suppression des espace en double
|
|
||||||
*/
|
|
||||||
list<char> bytes = trimProcName(value,taille);
|
|
||||||
char value2[bytes.size()];
|
|
||||||
for (list<char>::iterator i = bytes.begin(); i != bytes.end(); i++)
|
|
||||||
{
|
|
||||||
value2[distance(bytes.begin(),i)] = *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
//name = string((const char*)&value,taille);
|
|
||||||
name = string((const char*)&value2,bytes.size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
name = "not supported";
|
|
||||||
}
|
|
||||||
//name = "not supported";
|
|
||||||
delete cpuID;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
list<char> RH_Constants::trimProcName(int32_t * value, int taille)
|
|
||||||
{
|
|
||||||
list<char> bytes;
|
|
||||||
int j = 0;
|
|
||||||
for( unsigned int i = 0; i< 48; i++)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* partie 1
|
|
||||||
*/
|
|
||||||
if( j==0 && (value[i] &0x000000FF) != 0x20)//on suprime le première espace
|
|
||||||
{
|
|
||||||
bytes.push_back(value[i] &0x000000FF);
|
|
||||||
}
|
|
||||||
if(i >0 && j < taille &&!((((value[i-1] >> 24 )&0x000000FF) == 0x20)&& ((value[i] &0x000000FF) == 0x20)))
|
|
||||||
{
|
|
||||||
bytes.push_back(value[i] &0x000000FF);
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
|
|
||||||
if(j < taille && !(((value[i] &0x000000FF) == 0x20) && ((value[i]>> 8) &0x000000FF) == 0x20))
|
|
||||||
{
|
|
||||||
bytes.push_back((value[i] >> 8 )&0x000000FF);
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
|
|
||||||
if(j < taille && !((((value[i] >> 8)&0x000000FF) == 0x20) && ((value[i]>> 16) &0x000000FF) == 0x20))
|
|
||||||
{
|
|
||||||
bytes.push_back((value[i] >> 16 )&0x000000FF);
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
|
|
||||||
if(j < taille && !((((value[i] >> 16)&0x000000FF) == 0x20) && ((value[i]>> 24) &0x000000FF) == 0x20))
|
|
||||||
{
|
|
||||||
bytes.push_back((value[i] >> 24 )&0x000000FF);
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
return bytes;
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
#include "../include/RH_Encryption.h"
|
|
||||||
|
|
||||||
RH_Encryption::RH_Encryption(){
|
|
||||||
//ctor
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::md5(){
|
|
||||||
function<string (string)> methode = [] (string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
MD5_CTX md5;
|
|
||||||
MD5_Init(&md5);
|
|
||||||
MD5_Update(&md5,(const unsigned char*)stringValue, value.length());
|
|
||||||
unsigned char buffer[MD5_DIGEST_LENGTH];
|
|
||||||
MD5_Final(buffer, &md5);
|
|
||||||
return bytesArrayToStrinctString(MD5_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
return methode;
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::sha1(){
|
|
||||||
return [](string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
unsigned char buffer[SHA_DIGEST_LENGTH];
|
|
||||||
SHA(stringValue,value.length(),buffer);
|
|
||||||
return bytesArrayToStrinctString(SHA_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::sha224(){
|
|
||||||
return [](string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
unsigned char buffer[SHA224_DIGEST_LENGTH];
|
|
||||||
SHA224(stringValue,value.length(),buffer);
|
|
||||||
return bytesArrayToStrinctString(SHA224_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::sha384(){
|
|
||||||
return [](string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
unsigned char buffer[SHA384_DIGEST_LENGTH];
|
|
||||||
SHA384(stringValue,value.length(),buffer);
|
|
||||||
return bytesArrayToStrinctString(SHA384_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::sha256(){
|
|
||||||
return [](string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
unsigned char buffer[SHA256_DIGEST_LENGTH];
|
|
||||||
SHA256(stringValue,value.length(),buffer);
|
|
||||||
return bytesArrayToStrinctString(SHA256_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::sha512( ){
|
|
||||||
return [](string value){
|
|
||||||
const unsigned char* stringValue = (unsigned char *) value.c_str();
|
|
||||||
unsigned char buffer[SHA512_DIGEST_LENGTH];
|
|
||||||
SHA256(stringValue,value.length(),buffer);
|
|
||||||
return bytesArrayToStrinctString(SHA512_DIGEST_LENGTH,buffer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string (string)> RH_Encryption::none(){
|
|
||||||
return [](string value){
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function<string(string)> RH_Encryption::getFunctionHashLambda(string hashMethode) {
|
|
||||||
function<string(string)> resultMethode;
|
|
||||||
|
|
||||||
if (hashMethode == "md5") resultMethode = md5();
|
|
||||||
else if(hashMethode == "sha1") resultMethode = sha1();
|
|
||||||
else if(hashMethode == "sha224") resultMethode = sha224();
|
|
||||||
else if(hashMethode == "sha384") resultMethode = sha384();
|
|
||||||
else if(hashMethode == "sha256") resultMethode = sha256();
|
|
||||||
else if(hashMethode == "sha512") resultMethode = sha512();
|
|
||||||
else resultMethode = none();
|
|
||||||
|
|
||||||
return resultMethode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*function<string (string)> RH_Encryption::hashForLambda(function<string(string)> functionLambda, string value){
|
|
||||||
return functionLambda(value);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
string RH_Encryption::bytesArrayToStrinctString(uint8_t lenght, unsigned char * bytes) {
|
|
||||||
char resString[2];
|
|
||||||
string result;
|
|
||||||
for (uint8_t i = 0; i < lenght; i++){
|
|
||||||
sprintf(resString,"%02x", bytes[i]);
|
|
||||||
result.append(resString);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RH_Encryption::~RH_Encryption(){
|
|
||||||
//dtor
|
|
||||||
}
|
|
@ -1,288 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../include/RH_GUI.h"
|
|
||||||
|
|
||||||
GUI::GUI()
|
|
||||||
{
|
|
||||||
this->guiTime = time(NULL);
|
|
||||||
this->headerLines = this->prepareHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
GUI::~GUI()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayHeader()
|
|
||||||
{
|
|
||||||
this->clearScreen();
|
|
||||||
for(list<string>::iterator i = this->headerLines.begin(); i != this->headerLines.end(); i++)
|
|
||||||
{
|
|
||||||
cout << *i << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayProcessPerfs(string host, string processName, int WordsSeconds, string currentWord)
|
|
||||||
{
|
|
||||||
// Ce bloc devrat disparaitre
|
|
||||||
stringstream ss;
|
|
||||||
ss.imbue(locale(""));
|
|
||||||
ss << fixed << WordsSeconds;
|
|
||||||
//cout << "Host: " << host << endl;
|
|
||||||
cout << "\t" << processName << ": \t" << ss.str() << "/s\tcurrentWord: [ " << currentWord << " ]" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayProcessPerfsList(string host, list<string> processName, list<int>WordsSeconds, list<string> currentWord)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayTotalPerfs(string host,int WordsSeconds)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayError(string host,string errorCode,string errorMessage)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayMessage(string host,string message)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayResult(string value,time_t secondes)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayCopyright()
|
|
||||||
{
|
|
||||||
list<string> lines;
|
|
||||||
list<string> info;
|
|
||||||
int lenGui = 0;
|
|
||||||
info.push_back("");
|
|
||||||
info.push_back(APPLICATION_NAME + " Copyright (c) " + APPLICATION_YEAR + " " + APPLICATION_AUTHORS);
|
|
||||||
info.push_back("This program comes with ABSOLUTELY NO WARRANTY");//#; for details type `show w'.")
|
|
||||||
info.push_back("This is free software, and you are welcome to redistribute it");
|
|
||||||
info.push_back("under certain conditions. Please read the COPYING and README");//; type `show c' for details.");
|
|
||||||
info.push_back("");
|
|
||||||
|
|
||||||
for(list<string>::iterator i = info.begin(); i != info.end(); i++)
|
|
||||||
{
|
|
||||||
if ((*i).size() > lenGui)
|
|
||||||
{
|
|
||||||
lenGui = (*i).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
lines.push_back(this->separationLineCreator("*","*","*",lenGui+2));
|
|
||||||
for (list<string>::iterator i = info.begin(); i != info.end(); i++)
|
|
||||||
{
|
|
||||||
lines.push_back(this->leftAlignLine("* "," *"," ",lenGui,*i));
|
|
||||||
}
|
|
||||||
lines.push_back(this->separationLineCreator("*","*","*",lenGui+2));
|
|
||||||
this->clearScreen();
|
|
||||||
for (list<string>::iterator i = lines.begin(); i != lines.end(); i++)
|
|
||||||
{
|
|
||||||
cout << *i << endl;
|
|
||||||
}
|
|
||||||
cout << endl << "press any key to continue..." << endl;
|
|
||||||
cin.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayShortHelp()
|
|
||||||
{
|
|
||||||
cout << endl;
|
|
||||||
cout << "Usage : " << endl;
|
|
||||||
list<string> leftTab;
|
|
||||||
list<string> rightTab;
|
|
||||||
|
|
||||||
leftTab.push_back("\t"+PARAMS_CONSTANTS::LONG_PARAMS::HELP +", "+ PARAMS_CONSTANTS::SHORT_PARAMS::HELP);
|
|
||||||
leftTab.push_back("\t"+PARAMS_CONSTANTS::LONG_PARAMS::HASH+"=[passwordSearch]");
|
|
||||||
leftTab.push_back("\t"+PARAMS_CONSTANTS::LONG_PARAMS::VERBOSE+", "+PARAMS_CONSTANTS::SHORT_PARAMS::VERBOSE);
|
|
||||||
leftTab.push_back("\t"+PARAMS_CONSTANTS::LONG_PARAMS::MODE+", " +PARAMS_CONSTANTS::SHORT_PARAMS::MODE);
|
|
||||||
|
|
||||||
rightTab.push_back("Display help message");
|
|
||||||
rightTab.push_back("Set hash to search");
|
|
||||||
rightTab.push_back("Set verbose mode");
|
|
||||||
rightTab.push_back("Set application mode");
|
|
||||||
|
|
||||||
|
|
||||||
int maxLenLeft = 0;
|
|
||||||
for (list<string>::iterator i = leftTab.begin(); i != leftTab.end(); i++)
|
|
||||||
{
|
|
||||||
if((*i).length() > maxLenLeft)
|
|
||||||
{
|
|
||||||
maxLenLeft = (*i).size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list<string>::iterator j = rightTab.begin();
|
|
||||||
|
|
||||||
for (list<string>::iterator i = leftTab.begin(); i != leftTab.end(); i++)
|
|
||||||
{
|
|
||||||
cout << this->tableLine(*i,*j," ",maxLenLeft+1) << endl;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayFullHelp()
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::displayVersion()
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GUI::getInputInt(string question)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::getInputString(string question)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GUI::displayMenuInt(string title,list<string> entryList, string margin)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::displayMenuString(string title,list<string> entryList, string margin)
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::clearScreen()
|
|
||||||
{
|
|
||||||
#if defined(__unix__) || defined(__unix) || defined(unix) || defined(__linux__)
|
|
||||||
system("clear");
|
|
||||||
#else
|
|
||||||
system("cls");
|
|
||||||
#endif // defined
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::setLocale()
|
|
||||||
{
|
|
||||||
cout << "Not yet implemented " << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
list<string> GUI::prepareHeader()
|
|
||||||
{
|
|
||||||
const int INFO_SIZE = 4;
|
|
||||||
const int LINES_SIZE = 8;
|
|
||||||
list<string> info;
|
|
||||||
list<string> lines;
|
|
||||||
int lenGui = APPLICATION_NAME.size();
|
|
||||||
|
|
||||||
// on convertis le in en string
|
|
||||||
stringstream ss;
|
|
||||||
ss << NB_CORE;
|
|
||||||
string nbCore = ss.str();
|
|
||||||
|
|
||||||
struct tm * timeinfo;
|
|
||||||
timeinfo = localtime(&this->guiTime);
|
|
||||||
//strftime(buffer,80,"%I:%M",timeinfo)
|
|
||||||
//string time = string(asctime(timeinfo));
|
|
||||||
//trim(time);
|
|
||||||
string date = to_string(timeinfo->tm_mday) + "/" +to_string(timeinfo->tm_mon) +"/" + to_string(timeinfo->tm_year+1900);
|
|
||||||
string hour = to_string(timeinfo->tm_hour) + ":" +to_string(timeinfo->tm_min) +":" + to_string(timeinfo->tm_sec);
|
|
||||||
info.push_back("System family : " + OS );
|
|
||||||
info.push_back("Processor vendor: " + PROCESSOR_VENDOR);
|
|
||||||
info.push_back("Processor name : " + PROCESSOR_NAME);
|
|
||||||
info.push_back("Number of core : " + nbCore);
|
|
||||||
info.push_back("App started at : " + date + " " + hour);
|
|
||||||
|
|
||||||
for(list<string>::iterator i = info.begin(); i!=info.end();i++) {
|
|
||||||
if((*i).size() > lenGui) {
|
|
||||||
lenGui = (*i).size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lines.push_back(this->separationLineCreator("+", "+","-", lenGui+2));
|
|
||||||
lines.push_back(this->centredLine("| "," |"," ",lenGui,APPLICATION_NAME));
|
|
||||||
lines.push_back(this->separationLineCreator("+", "+","-", lenGui+2));
|
|
||||||
for(list<string>::iterator i = info.begin(); i!=info.end();i++)
|
|
||||||
{
|
|
||||||
lines.push_back(this->leftAlignLine("| "," |"," ",lenGui,*i));
|
|
||||||
}
|
|
||||||
lines.push_back(this->separationLineCreator("+", "+","-", lenGui+2));
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::separationLineCreator(string leftBroder, string rightBorder, string separator, int lenGui)
|
|
||||||
{
|
|
||||||
string separationLine = leftBroder;
|
|
||||||
for(int i=0;i<lenGui;i++) {
|
|
||||||
separationLine += separator;
|
|
||||||
}
|
|
||||||
separationLine += rightBorder;
|
|
||||||
return separationLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::centredLine(string leftBroder, string rightBorder, string offsetChar, int lenGui,string value)
|
|
||||||
{
|
|
||||||
int lenSpace = (lenGui -value.size())/2;
|
|
||||||
int reste = (lenGui -value.size())%2;
|
|
||||||
int lenSpaceLeft = lenSpace;
|
|
||||||
int lenSpaceRight = lenSpace + reste;
|
|
||||||
string spaceLeft;
|
|
||||||
string spaceRight;
|
|
||||||
for(int i = 0; i< lenSpaceLeft; i++) {
|
|
||||||
spaceLeft += offsetChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i< lenSpaceRight; i++) {
|
|
||||||
spaceRight += offsetChar;
|
|
||||||
}
|
|
||||||
string centeredLine = leftBroder + spaceLeft + value + spaceRight + rightBorder;
|
|
||||||
return centeredLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::tableLine(string value1, string value2, string offsetChar, int lenMaxValue)
|
|
||||||
{
|
|
||||||
string tableLine = "";
|
|
||||||
string spaceSeparator = "";
|
|
||||||
for(int i=0;i<lenMaxValue - value1.length();i++) {
|
|
||||||
spaceSeparator += offsetChar;
|
|
||||||
}
|
|
||||||
tableLine = value1 + spaceSeparator + value2;
|
|
||||||
return tableLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GUI::leftAlignLine(string leftBroder, string rightBorder, string offsetChar, int lenGui,string value)
|
|
||||||
{
|
|
||||||
int lenSpaceRight = lenGui - value.size();
|
|
||||||
string spaceRight ="";
|
|
||||||
for( int i=0;i<lenSpaceRight;i++) {
|
|
||||||
spaceRight += offsetChar;
|
|
||||||
}
|
|
||||||
string leftAlignLine = leftBroder + value + spaceRight + rightBorder;
|
|
||||||
return leftAlignLine;
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2015 Matthieu DUVAL, Rudy DUCHE
|
|
||||||
*
|
|
||||||
* This file is part of RizzleHash.
|
|
||||||
*
|
|
||||||
* RizzleHash is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RizzleHash is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RizzleHash. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../include/RH_ProcessBruteForce.h"
|
|
||||||
|
|
||||||
ProcessBruteForce::ProcessBruteForce()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessBruteForce::ProcessBruteForce(queue<statReturn> * q,int idx,int nbInstence,string hashString,string clef,uint32_t limite,bool verbose,string hashMethode)
|
|
||||||
{
|
|
||||||
this->init(q,idx,nbInstence,hashString,clef,limite,verbose,hashMethode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessBruteForce::init(queue<statReturn> * q,int idx,int nbInstence,string hashString,string clef,uint32_t limite,bool verbose,string hashMethode)
|
|
||||||
{
|
|
||||||
this->q = q;
|
|
||||||
this->idx = idx;
|
|
||||||
this->nbInstence = nbInstence;
|
|
||||||
this->hashString = hashString;
|
|
||||||
this->hashMethodeFunction = RH_Encryption::getFunctionHashLambda(hashMethode);
|
|
||||||
this->clef = clef;
|
|
||||||
this->limite = limite;
|
|
||||||
this->verbose = verbose;
|
|
||||||
this->nbWord = 0;
|
|
||||||
|
|
||||||
|
|
||||||
this->indexMin = (sizeof(this->tabChar)/this->nbInstence)*this->idx;
|
|
||||||
this->indexMax = indexMin + (sizeof(this->tabChar)/this->nbInstence);
|
|
||||||
if(this->idx == this->nbInstence - 1 )
|
|
||||||
{
|
|
||||||
this->indexMax = sizeof(tabChar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessBruteForce::operator()()
|
|
||||||
{
|
|
||||||
this->clock = time(NULL);// on initialise la clock locale
|
|
||||||
this->bruteForce();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessBruteForce::bruteForce()
|
|
||||||
{
|
|
||||||
this->password = new char[this->limite+1];
|
|
||||||
this->password[0] = '\0';
|
|
||||||
for(uint32_t i=0;i < this->limite;i++) {
|
|
||||||
this->password[i+1] = '\0';
|
|
||||||
this->recursiveFunction(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Here we create and test if the word is equal to our
|
|
||||||
*
|
|
||||||
* @param index
|
|
||||||
*/
|
|
||||||
void ProcessBruteForce::recursiveFunction(uint32_t index)
|
|
||||||
{
|
|
||||||
if(index > 0){
|
|
||||||
for(uint32_t i =0; i<sizeof(this->tabChar); i++){
|
|
||||||
this->password[index] = this->tabChar[i];
|
|
||||||
recursiveFunction(index - 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(index == 0){
|
|
||||||
for(uint32_t i = this->indexMin; i< this->indexMax; i++){
|
|
||||||
this->password[index] = this->tabChar[i];
|
|
||||||
string currentWord(this->password);
|
|
||||||
string testWord = this->hashMethodeFunction(currentWord);
|
|
||||||
if(this->hashString == testWord){
|
|
||||||
cout << "found :" << currentWord << endl;
|
|
||||||
this->isFound = true;
|
|
||||||
}
|
|
||||||
testSpeed(currentWord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function used to get speed off the bf process
|
|
||||||
*/
|
|
||||||
void ProcessBruteForce::testSpeed(string currentWord)
|
|
||||||
{
|
|
||||||
if(this->verbose)
|
|
||||||
{
|
|
||||||
time_t now = time(NULL);
|
|
||||||
this->nbWord++;
|
|
||||||
if(now - this->clock > 5)
|
|
||||||
{
|
|
||||||
statReturn stats;
|
|
||||||
stats.isFound=this->isFound;
|
|
||||||
stats.currentWord = currentWord;
|
|
||||||
stats.currentProcessName = string("Process " + to_string(this->idx+1));
|
|
||||||
stats.nbSecond = now - this->clock;
|
|
||||||
stats.totalWords = this->nbWord;
|
|
||||||
this->q->push(stats);
|
|
||||||
this->clock = time(NULL);
|
|
||||||
this->nbWord = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessBruteForce::~ProcessBruteForce()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#include "../include/RH_Utils.h"
|
|
||||||
|
|
||||||
RH_Utils::RH_Utils()
|
|
||||||
{
|
|
||||||
//ctor
|
|
||||||
}
|
|
||||||
|
|
||||||
RH_Utils::~RH_Utils()
|
|
||||||
{
|
|
||||||
//dtor
|
|
||||||
}
|
|
Loading…
Reference in new issue