Skip to content

Commit

Permalink
finished basic graphical portion
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarif123456 committed Dec 4, 2019
1 parent 1b2a24f commit b5e3729
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 78 deletions.
1 change: 0 additions & 1 deletion Input/passwod1.txt

This file was deleted.

3 changes: 0 additions & 3 deletions Input/password2.txt

This file was deleted.

9 changes: 0 additions & 9 deletions Input/passwords.txt

This file was deleted.

4 changes: 0 additions & 4 deletions Input/rule.txt

This file was deleted.

3 changes: 0 additions & 3 deletions Output/o1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
password
password
crack
3 changes: 1 addition & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



3 changes: 2 additions & 1 deletion RuleApplyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

169 changes: 121 additions & 48 deletions graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -122,45 +119,65 @@ 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)
self.inputBtn.setIcon(QIcon('Resources/Images/filepw.png'))
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())

Expand All @@ -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_())
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ 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")
if(mode == 4):
# 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
Expand Down
11 changes: 7 additions & 4 deletions passwordCracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit b5e3729

Please sign in to comment.