Skip to content

Commit b9e6590

Browse files
committed
created basic outline for program GUI
1 parent 44bcecc commit b9e6590

File tree

2 files changed

+95
-56
lines changed

2 files changed

+95
-56
lines changed

graphics.py

+89-43
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ class Menu(QWidget):
3131

3232
def __init__(self):
3333
super().__init__()
34+
# set up all the default variable to be used in password cracker
35+
self.inputFile = "" # input file holds path to file with password or ash to crack
36+
self.outputFile = "" # output file will be the file where the passwords are printed
37+
self.mode = Menu.BRUTE_FORCE # by default will use brute force method
38+
# file that contains the words for the dictionary attack to run or masks for the masks attack
39+
self.methodInput= ""
40+
self.rules = "" #holds path to the file with rules
41+
self.appendMask = "" #hold the mask that will be applied to end of brute force
42+
self.prependMask = "" #hold the mask that will be applied to start of brute force
43+
# by default we assume we are dealing with plain passwords
44+
self.hashMode = passwordCracker.NO_HASH
45+
self.onlineHashCheck = False
46+
# testing
3447
self.setUpShortcuts()
3548
self.openMenu()
3649

@@ -51,9 +64,10 @@ def file_open(self, path = 'Input'):
5164
return file.read().splitlines()
5265
except FileNotFoundError:
5366
print("ERROR: could not open file")
67+
return ""
5468

5569
def openMenu(self):
56-
self.setStyleSheet(menuCSS)
70+
# self.setStyleSheet(menuCSS)
5771
# set up window
5872
self.setGeometry(300, 200, 300, 600)
5973
self.setWindowTitle('Password Cracker')
@@ -66,18 +80,14 @@ def openMenu(self):
6680
# set one group for all password methods
6781
methodGroup = QButtonGroup()
6882
#brute force option
69-
radiobutton = QRadioButton("Brute-force or dictionary attack")
83+
radiobutton = QRadioButton("Brute-force attack")
84+
radiobutton.setToolTip('Select to do either brute-force or dictionary attack!')
7085
radiobutton.setChecked(True)
7186
radiobutton.methodNum = Menu.BRUTE_FORCE
7287
methodGroup.addButton(radiobutton, 0)
7388
radiobutton.toggled.connect(self.selectAttackMode)
7489
layout.addWidget(radiobutton, 0, 0)
7590

76-
# Check-box to add option to add to dictionary attack
77-
self.optionBox = QCheckBox("Customize Attack attack")
78-
self.optionBox.toggled.connect(self.toggleMenu)
79-
layout.addWidget(self.optionBox , 1, 0)
80-
8191
#mask option
8292
radiobutton = QRadioButton("Mask attack")
8393
radiobutton.methodNum = Menu.MASK
@@ -94,51 +104,87 @@ def openMenu(self):
94104
btn.resize(btn.sizeHint())
95105
layout.addWidget(btn, 0, 4)
96106

97-
# Create togglable menu -> Nest layout in frame because you can control when to show and when to hide
98-
# frame = QFrame()
99-
# bruteForceMenu = QGridLayout()
100-
101-
bruteForceGroup = QButtonGroup()
102-
# Option to apply rules
103-
self.ruleMenu = QRadioButton("Add Rules")
104-
# self.ruleMenu.setProperty('Hide', False)
105-
# btn.setObjectName('ShowMe')
106-
self.ruleMenu.optionNum = Menu.USE_RULE
107-
bruteForceGroup.addButton(self.ruleMenu, 1)
108-
self.ruleMenu.toggled.connect(self.selectBruteforceOption)
109-
self.ruleMenu.setVisible(False)
110-
layout.addWidget(self.ruleMenu, 2, 0)
111-
112-
#store hidden layout in frame
113-
# frame.setLayout(bruteForceMenu)
107+
# Togglable options for dictionary attack
108+
# Check-box to add rules to add to dictionary attack
109+
self.ruleBox = QCheckBox("Add Rules")
110+
self.ruleBox.toggled.connect(self.toggleRules)
111+
layout.addWidget(self.ruleBox , 1, 0)
112+
113+
# Check-box to append a mask to add to dictionary attack
114+
self.maskAppendBox = QCheckBox("Append Mask")
115+
self.maskAppendBox.toggled.connect(self.toggleAppendMask)
116+
layout.addWidget(self.maskAppendBox , 1, 2)
117+
118+
# Check-box to append a mask to add to dictionary attack
119+
self.maskPrependBox = QCheckBox("Prepend Mask")
120+
self.maskPrependBox.toggled.connect(self.togglePrependMask)
121+
layout.addWidget(self.maskPrependBox , 1, 3)
122+
123+
self.hashBox = QCheckBox("Hash mode")
124+
self.hashBox.toggled.connect(self.toggleHashMode)
125+
layout.addWidget(self.hashBox , 2, 0)
126+
127+
self.rainbowBox = QCheckBox("Rainbow check")
128+
self.rainbowBox.toggled.connect(self.toggleOnlineHash)
129+
layout.addWidget(self.rainbowBox , 2, 1)
130+
131+
self.hashDropdown = QComboBox(self)
132+
self.hashDropdown.addItem("SHA1")
133+
self.hashDropdown.addItem("MD5")
134+
self.hashDropdown.addItem("bcrypt")
135+
self.hashDropdown.currentIndexChanged.connect(self.toggleHashMode)
136+
layout.addWidget(self.hashDropdown , 2, 2,1 , 2)
114137

138+
# ** USE save file mode instead of open
139+
self.inputBtn = QPushButton('', self)
140+
self.inputBtn.setIcon(QIcon('Resources/Images/open.png'))
141+
self.inputBtn.setIconSize(QSize(24,24))
142+
self.inputBtn.setToolTip('Select file with all the passwords or hashes that you want to crack ')
143+
self.inputBtn.toggled.connect(self.getInputFile)
144+
layout.addWidget(self.inputBtn , 3, 1)
145+
146+
self.outputBtn = QPushButton('', self)
147+
self.outputBtn.setIcon(QIcon('Resources/Images/open.png'))
148+
self.outputBtn.setIconSize(QSize(24,24))
149+
self.outputBtn.setToolTip('Select file that will store the cracked passwords ')
150+
self.outputBtn.toggled.connect(self.getOutputFile)
151+
layout.addWidget(self.outputBtn , 3, 2)
152+
153+
self.startBtn = QPushButton('Crack passwords!', self)
154+
self.startBtn.toggled.connect(self.startCrack)
155+
self.outputBtn.setToolTip('Press to start cracking passwords!')
156+
layout.addWidget(self.startBtn , 4, 1, 1, 2)
115157

116-
# self.addWidget(frame) # add to bruteForce menu to main window
117-
# frame.hide()
118-
# frame.show()
119-
120-
#testing **
158+
121159
def selectAttackMode(self):
122160
radiobutton = self.sender()
123161
if radiobutton.isChecked():
124162
if(radiobutton.methodNum == Menu.BRUTE_FORCE):
125-
self.optionBox.setVisible(True)
163+
self.ruleBox.setVisible(True)
164+
self.maskAppendBox.setVisible(True)
165+
self.maskPrependBox.setVisible(True)
126166
if(radiobutton.methodNum == Menu.MASK):
127-
self.optionBox.setVisible(False)
167+
self.ruleBox.setVisible(False)
168+
self.maskAppendBox.setVisible(False)
169+
self.maskPrependBox.setVisible(False)
128170

129-
130-
def toggleMenu(self):
131-
# for every box
132-
if(self.optionBox.isChecked()):
133-
# self.ruleMenu.setProperty('Hide', True)
134-
self.ruleMenu.setVisible(True)
135-
else:
136-
self.ruleMenu.setVisible(False)
137-
# self.ruleMenu.setProperty('Hide', False)
138-
# self.ruleMenu.setStyle(self.ruleMenu.style())
139-
def selectBruteforceOption(self):
140-
# use dictionary attack with proper option applied
171+
def toggleRules(self):
172+
pass
173+
def toggleAppendMask(self):
174+
pass
175+
def togglePrependMask(self):
176+
pass
177+
def toggleHashMode(self):
178+
pass
179+
def toggleOnlineHash(self):
180+
pass
181+
def getInputFile(self):
182+
pass
183+
def getOutputFile(self):
184+
pass
185+
def startCrack(self):
141186
pass
187+
# Look at different option like input file/output file, rules file and so on
142188
if __name__ == '__main__':
143189
app = QApplication(sys.argv)
144190
screen = Menu()

passwordCracker.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ def getFileInfo(filePath : str):
99
file = open(filePath,"r+", encoding="utf-8")
1010
return file.read().splitlines()
1111

12-
def makeOutputFile(filePath : str):
13-
file = open(filePath,"w+", encoding="utf-8")
14-
return file
1512

1613
class passwordCracker:
1714
#static variable for the different types of hashes
18-
NOHASH = 0
15+
NO_HASH = 0
1916
SHA1 = 1
2017
MD5 = 2
2118
BCRYPT = 3
2219
def __init__(self, inputPasswordFile : str, oFile : str):
2320
# I would try and catch error here but I want the program to crash if the input, output file are not set incorrectly
2421
self.passwordList = getFileInfo(inputPasswordFile)
25-
self.outputFile = makeOutputFile(oFile)
26-
self.hashNumber = 0 #default is to use plain-text
22+
self.outputFile = open(oFile,"w+", encoding="utf-8")
23+
self.hashNumber = passwordCracker.NO_HASH #default is to use plain-text
2724
self.verbose = False #default is singular attacks so we don't need to verbose the attempts
2825
self.appendMask = []
2926
self.prependMask = []
@@ -94,9 +91,9 @@ def comparePassword(self, possiblePassword, password) -> bool:
9491
return bcrypt.checkpw(possiblePassword.encode('utf-8'), password.encode('utf-8'))
9592
except ValueError as e:
9693
print("Not in BCRYPT form")
97-
return False
98-
94+
return False
9995
return possiblePassword == password
96+
10097
# straight brute force with no rules
10198
def normalBruteForce(self, keyspace, min_length = 0, max_length = 1) -> bool: #return if finished
10299
for i in range( min_length ,max_length ):
@@ -197,8 +194,4 @@ def ruleEnhancer(self, ruleString : str, wordList : list) -> list:
197194
if(self.passwordCheck(plainTextPassword)):
198195
return True
199196

200-
wordList = nextWordList
201-
202-
203-
204-
197+
wordList = nextWordList

0 commit comments

Comments
 (0)