diff --git a/Input/passwod1.txt b/Input/passwod1.txt deleted file mode 100755 index 0dbcce6..0000000 --- a/Input/passwod1.txt +++ /dev/null @@ -1 +0,0 @@ -Iwanttobreakthispassword1456 \ No newline at end of file diff --git a/Input/password2.txt b/Input/password2.txt deleted file mode 100755 index 4ef0131..0000000 --- a/Input/password2.txt +++ /dev/null @@ -1,3 +0,0 @@ -$2y$12$q2x0KrVh1HIZ92ISzvUO5.4zx5lbMkJ/Lm5PMCPyXo6/GBX32ipSe -$2y$10$/G8YE2OoSNh3Gp472Xt99.D1RdxMb9TazQv8aKi6swvlx1CGFBARK -$2y$10$GgHXTqVmWBVUulC01ISu6em01jcrU3THxBBS4NhQodytuTxc6sM0u diff --git a/Input/passwords.txt b/Input/passwords.txt deleted file mode 100755 index ef2efda..0000000 --- a/Input/passwords.txt +++ /dev/null @@ -1,9 +0,0 @@ -aaA! -fcS# -sdA2 -gdS~ -aa -alphaMega -alphaM -alphaAndMega -nnL$ \ No newline at end of file diff --git a/Input/rule.txt b/Input/rule.txt deleted file mode 100755 index ee2d52d..0000000 --- a/Input/rule.txt +++ /dev/null @@ -1,4 +0,0 @@ -lMX428 -rMr6 -uMl4 -lMuX084 \ No newline at end of file diff --git a/Output/o1.txt b/Output/o1.txt index f1a74c2..e69de29 100755 --- a/Output/o1.txt +++ b/Output/o1.txt @@ -1,3 +0,0 @@ -password -password -crack diff --git a/Readme.md b/Readme.md index 2af3617..4ff1c88 100755 --- a/Readme.md +++ b/Readme.md @@ -89,9 +89,8 @@ SHA-2 NIST MD-5 -BCrypt must use Tara's method and talk about challenger protocol --> use custom challenge to create custom rainbowList - +ClERAYa4 diff --git a/RuleApplyer.py b/RuleApplyer.py index dec60d0..41ec7e4 100755 --- a/RuleApplyer.py +++ b/RuleApplyer.py @@ -304,4 +304,5 @@ def prependMemory(curString : str) -> str: "z": 2, # second argument is how many times first character will be duplicated "Z": 2, # second argument is how many times last character will be duplicated "X": 4, # Insert substring of length M starting from position N of word saved to memory at position I -} \ No newline at end of file +} + diff --git a/graphics.py b/graphics.py index b008a24..84d3b34 100755 --- a/graphics.py +++ b/graphics.py @@ -32,40 +32,37 @@ class Menu(QWidget): def __init__(self): super().__init__() # set up all the default variable to be used in password cracker - self.inputFile = "" # input file holds path to file with password or ash to crack + self.inputFile = "" # input file holds path to file with password or hash to crack self.outputFile = "" # output file will be the file where the passwords are printed self.mode = Menu.BRUTE_FORCE # by default will use brute force method # file that contains the words for the dictionary attack to run or masks for the masks attack - self.methodInput= "" + self.methodInput = "" self.rules = "" #holds path to the file with rules self.appendMask = "" #hold the mask that will be applied to end of brute force self.prependMask = "" #hold the mask that will be applied to start of brute force # by default we assume we are dealing with plain passwords - self.hashMode = passwordCracker.NO_HASH - self.onlineHashCheck = False # make window stay the same size - # testing - self.setUpShortcuts() self.openMenu() - #probably remove ** - def setUpShortcuts(self): - # opening file test - openFile = QAction("&Open File", self) - openFile.setShortcut("Ctrl+O") - openFile.setStatusTip('Open File') - openFile.triggered.connect(self.file_open) - def file_open(self, path = 'Input'): + def fileOpen(self, path = 'Input'): fileDialog = QFileDialog() filePath = QFileDialog.getOpenFileName(fileDialog, 'Open File', path, "Text files (*.txt)") - print(filePath[0]) try: with open(filePath[0],"r+", encoding="utf-8") as file: return file.read().splitlines() except FileNotFoundError: print("ERROR: could not open file") - return "" + return "" + + def fileSelectInput(self, path = 'Input'): + if(self.methodInput == ""): + self.methodInput = self.fileOpen("Input/Recommended") + if(self.methodInput != ""): + pass # change to X icon ** + else: + self.methodInput = "" + # change box to back to open icon ** def openMenu(self): # self.setStyleSheet(menuCSS) @@ -102,9 +99,9 @@ def openMenu(self): btn.setIconSize(QSize(240,35)) btn.setStyleSheet('QPushButton{border: 0px solid;}') btn.setToolTip('Open up the input file that the program will use to crack the passwords') - btn.clicked.connect(lambda:self.file_open("Input")) + btn.clicked.connect(lambda: self.fileSelectInput("Input")) btn.resize(btn.sizeHint()) - layout.addWidget(btn, 0, 2) + layout.addWidget(btn, 0, 2,1,2) # Togglable options for dictionary attack # Check-box to add rules to add to dictionary attack @@ -122,20 +119,40 @@ def openMenu(self): self.maskPrependBox.toggled.connect(self.togglePrependMask) layout.addWidget(self.maskPrependBox , 1, 2) + # validate input for text box + # self.onlyInt = QIntValidator() + self.minBoxLabel = QLabel(self) + self.minBoxLabel.setText("Min") + self.minBoxLabel.setAlignment(Qt.AlignRight) + layout.addWidget(self.minBoxLabel, 2, 0) + + self.minBox = QSpinBox(self) + self.minBox.setRange(0,10) + # self.minBox.setValidator(self.onlyInt) + layout.addWidget(self.minBox , 2, 1) + + self.maxBoxLabel = QLabel(self) + self.maxBoxLabel.setText("Max") + self.maxBoxLabel.setAlignment(Qt.AlignRight) + layout.addWidget(self.maxBoxLabel, 2, 2) + + self.maxBox = QSpinBox(self) + self.maxBox.setValue(1) + self.maxBox.setRange(0,10) + # self.maxBox.setValidator(self.onlyInt) + layout.addWidget(self.maxBox , 2, 3) + self.hashBox = QCheckBox("Hash mode") - self.hashBox.toggled.connect(self.toggleHashMode) - layout.addWidget(self.hashBox , 2, 0) + layout.addWidget(self.hashBox , 3, 0) self.rainbowBox = QCheckBox("Rainbow check") - self.rainbowBox.toggled.connect(self.toggleOnlineHash) - layout.addWidget(self.rainbowBox , 2, 1) + layout.addWidget(self.rainbowBox , 3, 1) self.hashDropdown = QComboBox(self) - self.hashDropdown.addItem("SHA1") - self.hashDropdown.addItem("MD5") - self.hashDropdown.addItem("bcrypt") - self.hashDropdown.currentIndexChanged.connect(self.toggleHashMode) - layout.addWidget(self.hashDropdown , 2, 2,1 , 2) + self.hashDropdown.addItem("SHA1", QVariant(passwordCracker.SHA1)) + self.hashDropdown.addItem("MD5", QVariant(passwordCracker.MD5)) + self.hashDropdown.addItem("bcrypt", QVariant(passwordCracker.BCRYPT)) + layout.addWidget(self.hashDropdown , 3, 2, 1, 2) # ** USE save file mode instead of open self.inputBtn = QPushButton('', self) @@ -143,24 +160,24 @@ def openMenu(self): self.inputBtn.setIconSize(QSize(240,35)) self.inputBtn.setStyleSheet('QPushButton{border: 0px solid;}') self.inputBtn.setToolTip('Select file with all the passwords or hashes that you want to crack ') - self.inputBtn.toggled.connect(self.getInputFile) - layout.addWidget(self.inputBtn , 3, 1) + self.inputBtn.clicked.connect(self.getInputFile) + layout.addWidget(self.inputBtn, 4, 0, 1, 2) self.outputBtn = QPushButton('', self) self.outputBtn.setIcon(QIcon('Resources/Images/savepw.png')) self.outputBtn.setIconSize(QSize(240,35)) self.outputBtn.setStyleSheet('QPushButton{border: 0px solid;}') self.outputBtn.setToolTip('Select file that will store the cracked passwords ') - self.outputBtn.toggled.connect(self.getOutputFile) - layout.addWidget(self.outputBtn , 3, 2) + self.outputBtn.clicked.connect(self.getOutputFile) + layout.addWidget(self.outputBtn, 4, 2, 1, 2) self.startBtn = QPushButton('', self) self.startBtn.setIcon(QIcon('Resources/Images/crackpw.png')) - self.startBtn.setIconSize(QSize(240,35)) + self.startBtn.setIconSize(QSize(260,45)) self.startBtn.setStyleSheet('QPushButton{border: 0px solid;}') - self.startBtn.toggled.connect(self.startCrack) + self.startBtn.clicked.connect(self.startCrack) self.outputBtn.setToolTip('Select folder to save password to') - layout.addWidget(self.startBtn , 4, 1, 1, 2) + layout.addWidget(self.startBtn , 5, 0, 1, 4) # self.setFixedSize(self.size()) @@ -171,32 +188,88 @@ def selectAttackMode(self): self.ruleBox.setVisible(True) self.maskAppendBox.setVisible(True) self.maskPrependBox.setVisible(True) + self.minBoxLabel.setVisible(True) + self.minBox.setVisible(True) + self.maxBoxLabel.setVisible(True) + self.maxBox.setVisible(True) + if(radiobutton.methodNum == Menu.MASK): self.ruleBox.setVisible(False) self.maskAppendBox.setVisible(False) self.maskPrependBox.setVisible(False) + self.minBoxLabel.setVisible(False) + self.minBox.setVisible(False) + self.maxBoxLabel.setVisible(False) + self.maxBox.setVisible(False) def toggleRules(self): - pass + if(self.ruleBox.isChecked()): + self.rules = self.fileOpen("Input/Recommended/Rules") + if(self.rules == ""): + self.ruleBox.setChecked(False) + else: + self.rules = "" + def toggleAppendMask(self): - pass + if(self.maskAppendBox.isChecked()): + self.appendMask = self.fileOpen("Input/Recommended/Mask") + if(self.appendMask == ""): + self.maskAppendBox.setChecked(False) + else: + self.appendMask = "" def togglePrependMask(self): - pass - def toggleHashMode(self): - pass - def toggleOnlineHash(self): - pass + if(self.maskPrependBox.isChecked()): + self.prependMask = self.fileOpen("Input/Recommended/Mask") + if(self.prependMask == ""): + self.maskPrependBox.setChecked(False) + else: + self.prependMask = "" + + def getHashMode(self): + hashMode = 0 + if(self.hashBox.isChecked()): + hashMode = self.hashDropdown.currentData() + return hashMode + def getInputFile(self): - pass + fileDialog = QFileDialog() + filePath = QFileDialog.getOpenFileName(fileDialog, 'Open File', 'Input/TargetFile', "Text files (*.txt)") + self.inputFile = filePath[0] + def getOutputFile(self): - pass - def startCrack(self): - pass + fileDialog = QFileDialog() + filePath= QFileDialog.getSaveFileName(fileDialog, 'Open File', 'Output', "Text files (*.txt)") + self.outputFile = filePath[0] + + def startCrack(self): + if(self.inputFile == ""): + print("You need to select input file that contains the files to crack") + return + if(self.outputFile == ""): + print("You must select an output file where the cracked passwords will be saved") + return + if(self.methodInput == "" ): + print("You must have an input file for the method") + return + cracker = passwordCracker(self.inputFile, self.outputFile) + cracker.setVerboseMode(True) + if(self.mode == Menu.BRUTE_FORCE): + cracker.setRuleList(self.rules) + cracker.setPrependMask(self.prependMask) + cracker.setAppendMask(self.appendMask) + cracker.setHashNum(self.getHashMode()) + if(self.hashBox.isChecked() and self.rainbowBox.isChecked()): + pass # use this to run on-line hash check *** + # Brute force stuff + cracker.bruteForce(self.methodInput , int(self.minBox.value()), int(self.maxBox.value())) + else: + cracker.maskAttack(self.methodInput) + # mask stuff + print(cracker.endingPrompt()) + # Look at different option like input file/output file, rules file and so on if __name__ == '__main__': app = QApplication(sys.argv) screen = Menu() screen.show() - sys.exit(app.exec_()) - - + sys.exit(app.exec_()) \ No newline at end of file diff --git a/main.py b/main.py index 3a0275f..06ea641 100755 --- a/main.py +++ b/main.py @@ -43,13 +43,13 @@ def passwordCrackingMenu(): # 3. Mask attack # 4. Rule-based with dictionary # 5. Combination''')) - mode = 2 + mode = 5 cracker.setVerboseMode(True) if(mode == 1): # get key space from file or one of the pre selected cracker.bruteForce("456789", 0,4) if(mode == 2): - cracker.setHashNum(passwordCracker.BCRYPT) + # cracker.setHashNum(passwordCracker.BCRYPT) cracker.bruteForce(['password','crack'], 0,2) if(mode == 3): cracker.maskAttack("?d?d?d?d") @@ -57,7 +57,7 @@ def passwordCrackingMenu(): # get rule File using Tkinter with open("Input/rule.txt","r+", encoding="utf-8") as ruleFile: cracker.setRuleList(ruleFile.read().splitlines()) - cracker.bruteForce(['p','prat', 'p@ssW0rd'], 0,3) + cracker.bruteForce([ 'p@ssW0rd'], 0,1) if(mode == 5 ): cracker.setPrependMask("?d?d?d?d") # get rule File using Tkinter diff --git a/passwordCracker.py b/passwordCracker.py index bec01f4..c922bb1 100755 --- a/passwordCracker.py +++ b/passwordCracker.py @@ -16,6 +16,7 @@ class passwordCracker: SHA1 = 1 MD5 = 2 BCRYPT = 3 + def __init__(self, inputPasswordFile : str, oFile : str): # I would try and catch error here but I want the program to crash if the input, output file are not set incorrectly self.passwordList = getFileInfo(inputPasswordFile) @@ -57,9 +58,9 @@ def checkMask(self,plainTextPassword) -> bool: if(len(self.appendMask) == 0 and len(self.prependMask) == 0): return False if(len(self.appendMask) != 0): # apply mask to end - self.maskAttack(self.appendMask, "", plainTextPassword) + self.maskAttack(self.appendMask, plainTextPassword) if (len(self.prependMask) != 0 ): - self.maskAttack(self.prependMask, plainTextPassword) + self.maskAttack(self.prependMask, "", plainTextPassword) return True def ruleAttack(self, keyspace, min_length = 0, max_length = 1) -> bool: @@ -70,7 +71,10 @@ def ruleAttack(self, keyspace, min_length = 0, max_length = 1) -> bool: if 0 == len(self.passwordList): return True return False - + def endingPrompt(self) -> str: + if 0 == len(self.passwordList): + return "All passwords cracked!" + return "Finished cracker. Could not find all passwords:(" def passwordCheck(self, plainTextPassword): possiblePassword = self.getWord(plainTextPassword) for password in self.passwordList: @@ -81,7 +85,6 @@ def passwordCheck(self, plainTextPassword): self.outputFile.write(plainTextPassword+"\n") self.passwordList.remove(password) if 0 == len(self.passwordList): - print("All passwords cracked!") return True return False # for some hashes we can't just straight compare passwords