@@ -32,40 +32,37 @@ class Menu(QWidget):
32
32
def __init__ (self ):
33
33
super ().__init__ ()
34
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
35
+ self .inputFile = "" # input file holds path to file with password or hash to crack
36
36
self .outputFile = "" # output file will be the file where the passwords are printed
37
37
self .mode = Menu .BRUTE_FORCE # by default will use brute force method
38
38
# file that contains the words for the dictionary attack to run or masks for the masks attack
39
- self .methodInput = ""
39
+ self .methodInput = ""
40
40
self .rules = "" #holds path to the file with rules
41
41
self .appendMask = "" #hold the mask that will be applied to end of brute force
42
42
self .prependMask = "" #hold the mask that will be applied to start of brute force
43
43
# by default we assume we are dealing with plain passwords
44
- self .hashMode = passwordCracker .NO_HASH
45
- self .onlineHashCheck = False
46
44
# make window stay the same size
47
- # testing
48
- self .setUpShortcuts ()
49
45
self .openMenu ()
50
46
51
- #probably remove **
52
- def setUpShortcuts (self ):
53
- # opening file test
54
- openFile = QAction ("&Open File" , self )
55
- openFile .setShortcut ("Ctrl+O" )
56
- openFile .setStatusTip ('Open File' )
57
- openFile .triggered .connect (self .file_open )
58
47
59
- def file_open (self , path = 'Input' ):
48
+ def fileOpen (self , path = 'Input' ):
60
49
fileDialog = QFileDialog ()
61
50
filePath = QFileDialog .getOpenFileName (fileDialog , 'Open File' , path , "Text files (*.txt)" )
62
- print (filePath [0 ])
63
51
try :
64
52
with open (filePath [0 ],"r+" , encoding = "utf-8" ) as file :
65
53
return file .read ().splitlines ()
66
54
except FileNotFoundError :
67
55
print ("ERROR: could not open file" )
68
- return ""
56
+ return ""
57
+
58
+ def fileSelectInput (self , path = 'Input' ):
59
+ if (self .methodInput == "" ):
60
+ self .methodInput = self .fileOpen ("Input/Recommended" )
61
+ if (self .methodInput != "" ):
62
+ pass # change to X icon **
63
+ else :
64
+ self .methodInput = ""
65
+ # change box to back to open icon **
69
66
70
67
def openMenu (self ):
71
68
# self.setStyleSheet(menuCSS)
@@ -102,9 +99,9 @@ def openMenu(self):
102
99
btn .setIconSize (QSize (240 ,35 ))
103
100
btn .setStyleSheet ('QPushButton{border: 0px solid;}' )
104
101
btn .setToolTip ('Open up the input file that the program will use to crack the passwords' )
105
- btn .clicked .connect (lambda :self .file_open ("Input" ))
102
+ btn .clicked .connect (lambda : self .fileSelectInput ("Input" ))
106
103
btn .resize (btn .sizeHint ())
107
- layout .addWidget (btn , 0 , 2 )
104
+ layout .addWidget (btn , 0 , 2 , 1 , 2 )
108
105
109
106
# Togglable options for dictionary attack
110
107
# Check-box to add rules to add to dictionary attack
@@ -122,45 +119,65 @@ def openMenu(self):
122
119
self .maskPrependBox .toggled .connect (self .togglePrependMask )
123
120
layout .addWidget (self .maskPrependBox , 1 , 2 )
124
121
122
+ # validate input for text box
123
+ # self.onlyInt = QIntValidator()
124
+ self .minBoxLabel = QLabel (self )
125
+ self .minBoxLabel .setText ("Min" )
126
+ self .minBoxLabel .setAlignment (Qt .AlignRight )
127
+ layout .addWidget (self .minBoxLabel , 2 , 0 )
128
+
129
+ self .minBox = QSpinBox (self )
130
+ self .minBox .setRange (0 ,10 )
131
+ # self.minBox.setValidator(self.onlyInt)
132
+ layout .addWidget (self .minBox , 2 , 1 )
133
+
134
+ self .maxBoxLabel = QLabel (self )
135
+ self .maxBoxLabel .setText ("Max" )
136
+ self .maxBoxLabel .setAlignment (Qt .AlignRight )
137
+ layout .addWidget (self .maxBoxLabel , 2 , 2 )
138
+
139
+ self .maxBox = QSpinBox (self )
140
+ self .maxBox .setValue (1 )
141
+ self .maxBox .setRange (0 ,10 )
142
+ # self.maxBox.setValidator(self.onlyInt)
143
+ layout .addWidget (self .maxBox , 2 , 3 )
144
+
125
145
self .hashBox = QCheckBox ("Hash mode" )
126
- self .hashBox .toggled .connect (self .toggleHashMode )
127
- layout .addWidget (self .hashBox , 2 , 0 )
146
+ layout .addWidget (self .hashBox , 3 , 0 )
128
147
129
148
self .rainbowBox = QCheckBox ("Rainbow check" )
130
- self .rainbowBox .toggled .connect (self .toggleOnlineHash )
131
- layout .addWidget (self .rainbowBox , 2 , 1 )
149
+ layout .addWidget (self .rainbowBox , 3 , 1 )
132
150
133
151
self .hashDropdown = QComboBox (self )
134
- self .hashDropdown .addItem ("SHA1" )
135
- self .hashDropdown .addItem ("MD5" )
136
- self .hashDropdown .addItem ("bcrypt" )
137
- self .hashDropdown .currentIndexChanged .connect (self .toggleHashMode )
138
- layout .addWidget (self .hashDropdown , 2 , 2 ,1 , 2 )
152
+ self .hashDropdown .addItem ("SHA1" , QVariant (passwordCracker .SHA1 ))
153
+ self .hashDropdown .addItem ("MD5" , QVariant (passwordCracker .MD5 ))
154
+ self .hashDropdown .addItem ("bcrypt" , QVariant (passwordCracker .BCRYPT ))
155
+ layout .addWidget (self .hashDropdown , 3 , 2 , 1 , 2 )
139
156
140
157
# ** USE save file mode instead of open
141
158
self .inputBtn = QPushButton ('' , self )
142
159
self .inputBtn .setIcon (QIcon ('Resources/Images/filepw.png' ))
143
160
self .inputBtn .setIconSize (QSize (240 ,35 ))
144
161
self .inputBtn .setStyleSheet ('QPushButton{border: 0px solid;}' )
145
162
self .inputBtn .setToolTip ('Select file with all the passwords or hashes that you want to crack ' )
146
- self .inputBtn .toggled .connect (self .getInputFile )
147
- layout .addWidget (self .inputBtn , 3 , 1 )
163
+ self .inputBtn .clicked .connect (self .getInputFile )
164
+ layout .addWidget (self .inputBtn , 4 , 0 , 1 , 2 )
148
165
149
166
self .outputBtn = QPushButton ('' , self )
150
167
self .outputBtn .setIcon (QIcon ('Resources/Images/savepw.png' ))
151
168
self .outputBtn .setIconSize (QSize (240 ,35 ))
152
169
self .outputBtn .setStyleSheet ('QPushButton{border: 0px solid;}' )
153
170
self .outputBtn .setToolTip ('Select file that will store the cracked passwords ' )
154
- self .outputBtn .toggled .connect (self .getOutputFile )
155
- layout .addWidget (self .outputBtn , 3 , 2 )
171
+ self .outputBtn .clicked .connect (self .getOutputFile )
172
+ layout .addWidget (self .outputBtn , 4 , 2 , 1 , 2 )
156
173
157
174
self .startBtn = QPushButton ('' , self )
158
175
self .startBtn .setIcon (QIcon ('Resources/Images/crackpw.png' ))
159
- self .startBtn .setIconSize (QSize (240 , 35 ))
176
+ self .startBtn .setIconSize (QSize (260 , 45 ))
160
177
self .startBtn .setStyleSheet ('QPushButton{border: 0px solid;}' )
161
- self .startBtn .toggled .connect (self .startCrack )
178
+ self .startBtn .clicked .connect (self .startCrack )
162
179
self .outputBtn .setToolTip ('Select folder to save password to' )
163
- layout .addWidget (self .startBtn , 4 , 1 , 1 , 2 )
180
+ layout .addWidget (self .startBtn , 5 , 0 , 1 , 4 )
164
181
165
182
# self.setFixedSize(self.size())
166
183
@@ -171,32 +188,88 @@ def selectAttackMode(self):
171
188
self .ruleBox .setVisible (True )
172
189
self .maskAppendBox .setVisible (True )
173
190
self .maskPrependBox .setVisible (True )
191
+ self .minBoxLabel .setVisible (True )
192
+ self .minBox .setVisible (True )
193
+ self .maxBoxLabel .setVisible (True )
194
+ self .maxBox .setVisible (True )
195
+
174
196
if (radiobutton .methodNum == Menu .MASK ):
175
197
self .ruleBox .setVisible (False )
176
198
self .maskAppendBox .setVisible (False )
177
199
self .maskPrependBox .setVisible (False )
200
+ self .minBoxLabel .setVisible (False )
201
+ self .minBox .setVisible (False )
202
+ self .maxBoxLabel .setVisible (False )
203
+ self .maxBox .setVisible (False )
178
204
179
205
def toggleRules (self ):
180
- pass
206
+ if (self .ruleBox .isChecked ()):
207
+ self .rules = self .fileOpen ("Input/Recommended/Rules" )
208
+ if (self .rules == "" ):
209
+ self .ruleBox .setChecked (False )
210
+ else :
211
+ self .rules = ""
212
+
181
213
def toggleAppendMask (self ):
182
- pass
214
+ if (self .maskAppendBox .isChecked ()):
215
+ self .appendMask = self .fileOpen ("Input/Recommended/Mask" )
216
+ if (self .appendMask == "" ):
217
+ self .maskAppendBox .setChecked (False )
218
+ else :
219
+ self .appendMask = ""
183
220
def togglePrependMask (self ):
184
- pass
185
- def toggleHashMode (self ):
186
- pass
187
- def toggleOnlineHash (self ):
188
- pass
221
+ if (self .maskPrependBox .isChecked ()):
222
+ self .prependMask = self .fileOpen ("Input/Recommended/Mask" )
223
+ if (self .prependMask == "" ):
224
+ self .maskPrependBox .setChecked (False )
225
+ else :
226
+ self .prependMask = ""
227
+
228
+ def getHashMode (self ):
229
+ hashMode = 0
230
+ if (self .hashBox .isChecked ()):
231
+ hashMode = self .hashDropdown .currentData ()
232
+ return hashMode
233
+
189
234
def getInputFile (self ):
190
- pass
235
+ fileDialog = QFileDialog ()
236
+ filePath = QFileDialog .getOpenFileName (fileDialog , 'Open File' , 'Input/TargetFile' , "Text files (*.txt)" )
237
+ self .inputFile = filePath [0 ]
238
+
191
239
def getOutputFile (self ):
192
- pass
193
- def startCrack (self ):
194
- pass
240
+ fileDialog = QFileDialog ()
241
+ filePath = QFileDialog .getSaveFileName (fileDialog , 'Open File' , 'Output' , "Text files (*.txt)" )
242
+ self .outputFile = filePath [0 ]
243
+
244
+ def startCrack (self ):
245
+ if (self .inputFile == "" ):
246
+ print ("You need to select input file that contains the files to crack" )
247
+ return
248
+ if (self .outputFile == "" ):
249
+ print ("You must select an output file where the cracked passwords will be saved" )
250
+ return
251
+ if (self .methodInput == "" ):
252
+ print ("You must have an input file for the method" )
253
+ return
254
+ cracker = passwordCracker (self .inputFile , self .outputFile )
255
+ cracker .setVerboseMode (True )
256
+ if (self .mode == Menu .BRUTE_FORCE ):
257
+ cracker .setRuleList (self .rules )
258
+ cracker .setPrependMask (self .prependMask )
259
+ cracker .setAppendMask (self .appendMask )
260
+ cracker .setHashNum (self .getHashMode ())
261
+ if (self .hashBox .isChecked () and self .rainbowBox .isChecked ()):
262
+ pass # use this to run on-line hash check ***
263
+ # Brute force stuff
264
+ cracker .bruteForce (self .methodInput , int (self .minBox .value ()), int (self .maxBox .value ()))
265
+ else :
266
+ cracker .maskAttack (self .methodInput )
267
+ # mask stuff
268
+ print (cracker .endingPrompt ())
269
+
195
270
# Look at different option like input file/output file, rules file and so on
196
271
if __name__ == '__main__' :
197
272
app = QApplication (sys .argv )
198
273
screen = Menu ()
199
274
screen .show ()
200
- sys .exit (app .exec_ ())
201
-
202
-
275
+ sys .exit (app .exec_ ())
0 commit comments