class GraphFrame(Frame): def __init__(self, parent, paned_window, **kwargs): Frame.__init__(self, paned_window) self.parent = parent self.df_column_frame = ScrolledFrame(self, vertflex='expand') self.graph_frame = ScrolledFrame(self, horizflex='expand', vertflex='expand') self.plot_figure = kwargs['plot'] if 'plot' in kwargs else None self.plot_title = kwargs['plot_title'] if 'plot_title' in kwargs else 'Line Plot' self.y_label = kwargs['y_label'] if 'y_label' in kwargs else 'y' self.df = kwargs['df'] if 'df' in kwargs else DataFrame() # If the dataframe wasn't passed in, then create an empty dataframe plot_selected_avg = ModelRunnerPlots.get_avg_plot(self.plot_title, self.y_label, self.df, None) self.plot_figure = plot_selected_avg self.graph_canvas = FigureCanvasTkAgg(plot_selected_avg, master=self.graph_frame.interior()) self.col_list = list() for col in self.df.columns: if col != 'year' and 'Average' not in col: col_var = IntVar() col_var.set(0) col_checkbox = Checkbutton(self.df_column_frame.interior(), text=col, variable=col_var, command=self.on_col_check) self.col_list.append([col_var, col_checkbox, col]) avg_dataframe, dataframe = ModelRunnerPlots.find_avg_dataframe(self.df) for col in avg_dataframe.columns: if col != 'year': col_var = IntVar() col_var.set(0) col_checkbox = Checkbutton(self.df_column_frame.interior(), text=col, variable=col_var, command=self.on_col_check) self.col_list.append([col_var, col_checkbox, col]) self.log_filename_frame = Frame(self) self.log_label = Label(self.log_filename_frame, text='Logfile: ' + kwargs['log_filename']) if 'log_filename' in kwargs else None self.button_frame = Frame(self) self.close_button = Button(self.button_frame, text='Close', command=self.on_close) self.save_button = Button(self.button_frame, text='Save', command=self.on_save) def set_grid(self): #print 'Resizing graph frame' #self.grid(padx=4, pady=4) self.pack(padx=4, pady=4, expand=True, fill=Tkinter.BOTH) #self.rowconfigure(0, minsize=600) #self.columnconfigure(0, minsize=100) #self.columnconfigure(1, minsize=600) self.columnconfigure(0, weight=1) self.columnconfigure(1, weight=5) self.rowconfigure(0, weight=1) self.df_column_frame.grid(row=0, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) #self.df_column_frame.pack(side=Tkinter.LEFT, expand=True, fill=Tkinter.BOTH) row_index = 0 for col in self.col_list: checkButton = col[1] checkButton.grid(sticky=Tkinter.E + Tkinter.W) row_index += 1 self.graph_frame.grid(row=0, column=1, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) #self.graph_frame.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.BOTH) try: self.graph_canvas.get_tk_widget().grid(row=0, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) #self.graph_canvas.get_tk_widget().pack(expand=True, fill=Tkinter.BOTH) except AttributeError: pass self.log_filename_frame.grid(row=1, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) if self.log_label != None: self.log_label.pack(side=Tkinter.LEFT) self.button_frame.grid(row=1, column=1, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) #self.button_frame.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X) self.close_button.pack(side=Tkinter.RIGHT) self.save_button.pack(side=Tkinter.RIGHT) def unset_grid(self): self.pack_forget() self.df_column_frame.grid_forget() self.graph_frame.grid_forget() try: self.graph_canvas.get_tk_widget().grid_forget() except AttributeError: pass self.log_filename_frame.grid_forget() if self.log_label != None: self.log_label.pack_forget() self.button_frame.grid_forget() self.close_button.pack_forget() self.save_button.pack_forget() def on_col_check(self): # Based upon what is checked, a new plot should be created value_vars = list() for col in self.col_list: if col[0].get() == 1: #print col[2] + ' is checked' value_vars.append(col[2]) else: pass #print col[2] + ' is not checked' plot_selected = ModelRunnerPlots.create_line_plot(self.plot_title, self.y_label, self.df, None, value_vars=value_vars) #if len(value_vars) == 0: #plot_selected = ModelRunnerPlots.get_avg_plot(self.plot_title, self.y_label, self.df, None) plt.close(self.plot_figure) try: self.graph_canvas.get_tk_widget().grid_remove() self.graph_canvas = FigureCanvasTkAgg(plot_selected, master=self.graph_frame.interior()) self.graph_canvas.get_tk_widget().grid(row=0, column=1, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W) except AttributeError: pass self.plot_figure = plot_selected def on_close(self): if self.parent != None: self.parent.on_close() def on_save(self): if self.plot_figure != None: filename = tkFileDialog.asksaveasfilename() if filename != None and len(filename) > 0: dotIndex = filename.rindex('.') # Enforce the 'png' file extension filename = filename[0:dotIndex+1] + 'png' self.plot_figure.savefig(filename, format='png')
class guiDemo3(Frame): def __init__(self,parent): Frame.__init__(self,parent) self.parent = parent self.dict = {} #temporary self.initUI() #start up the main menu def initUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.mainMenuLabel= Label(self, text="Main Menu") self.mainMenuLabel.pack(side=TOP,padx=5, pady=5) self.singleModeButton= Button(self, text="Single Computer Mode", command=self.unpackInitUI_LoadSingleComputerMode) self.singleModeButton.pack(side=TOP, padx=5, pady=5) self.networkModeButton= Button(self, text="Networking Mode", command=self.unpackInitUI_LoadNetworkMode) self.networkModeButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in initUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of initUI//////////////////////////// def unpackInitUI_LoadSingleComputerMode(self): self.closeButton.pack_forget() self.mainMenuLabel.pack_forget() self.singleModeButton.pack_forget() self.networkModeButton.pack_forget() self.singleModeUI() def unpackInitUI_LoadNetworkMode(self): self.closeButton.pack_forget() self.mainMenuLabel.pack_forget() self.singleModeButton.pack_forget() self.networkModeButton.pack_forget() self.networkModeUI() def unpackSingleModeUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.initUI() def unpackSingleModeUI_LoadSingleDictionaryUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.dictionaryCrackingMethodUI(0) def unpackSingleModeUI_LoadSingleBruteForceUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodUI(0) def unpackSingleModeUI_LoadSingleRainbowTableUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodUI(0) def singleModeUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackSingleModeUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.singleModeLabel= Label(self, text="Single Computer Mode") self.singleModeLabel.pack(side=TOP, padx=5, pady=5) self.selectCrackingMethodLabel= Label(self, text="Select Your Cracking Method") self.selectCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryCrackingMethodButton= Button(self, text="Dictionary", command=self.unpackSingleModeUI_LoadSingleDictionaryUI) self.dictionaryCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.bruteForceCrackingMethodButton= Button(self, text="Brute-Force (default)", command=self.unpackSingleModeUI_LoadSingleBruteForceUI) self.bruteForceCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.rainbowTableCrackingMethodButton= Button(self, text="Rainbow Table", command=self.unpackSingleModeUI_LoadSingleRainbowTableUI) self.rainbowTableCrackingMethodButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in singleModeUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #End of single mode def unpackNetworkModeUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.initUI() def networkModeUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkModeUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkModeLabel= Label(self, text="Network Mode: Server/Client Selection Screen") self.networkModeLabel.pack(side=TOP, padx=5, pady=5) self.selectNetworkModuleLabel= Label(self, text="Select Server or Client") self.selectNetworkModuleLabel.pack(side=TOP, padx=5, pady=5) self.serverModuleButton= Button(self, text="I am the Server", command= self.unpackNetworkModeUI_LoadNetworkServerUI) self.serverModuleButton.pack(side=TOP, padx=5, pady=5) self.clientModuleButton= Button(self, text="I am a Client", command= self.unpackNetworkModeUI_LoadNetworkClientUI) self.clientModuleButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkModeUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of networkModeUI def unpackNetworkModeUI_LoadNetworkServerUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.networkServerUI() def unpackNetworkModeUI_LoadNetworkClientUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.networkClientUI() def unpackNetworkClientUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkClientLabel.pack_forget() self.insertServerIPLabel.pack_forget() self.insertServerIPTextfield.pack_forget() self.startClientButton.pack_forget() self.initUI() def networkClientUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkClientUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkClientLabel= Label(self, text="Network Client") self.networkClientLabel.pack(side=TOP, padx=5, pady=5) self.insertServerIPLabel= Label(self, text="Enter in the Server's IP:") self.insertServerIPLabel.pack(side=TOP, padx=5, pady=5) self.insertServerIPTextfield= Entry(self, bd=5) self.insertServerIPTextfield.pack(side=TOP, padx=5, pady=5) #TODO allow right click for pasting into box self.startClientButton= Button(self, text="Start Client", command=lambda: self.startClient(str(self.insertServerIPTextfield.get()))) self.startClientButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkClientUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of networkclient UI def startClient(self,inputIP): try: if(len(inputIP) < 1): showwarning("Network Client Start Warning: NO IP","No IP address has been entered!") else: self.networkClient= Process(target=Client, args=(inputIP,)) self.networkClient.start() self.networkClientStatusUI() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in startClient definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def networkClientStatusUI(self): self.networkClientStatusWindow= Tk() self.networkClientStatusWindow.geometry("640x480") self.networkClientStatusWindow.title("Network Client Status Window") self.networkClientStatusWindow.style = Style() self.networkClientStatusWindow.style.theme_use("default") self.networkClientStatusWindow.pack(fill=BOTH, expand=1) #TODO throws an attribute error on 'pack', thus nothing is drawn to the screen, fix this self.CloseButton= Button(self, text="Close Status Window", command=lambda: closeStatusWindow()) self.CloseButton.pack(side=BOTTOM, padx=5, pady=5) def closeStatusWindow(self): self.networkClientStatusWindow.destroy() def unpackNetworkServerUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.initUI() def networkServerUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkServerUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkServerLabel= Label(self, text="Network Server") self.networkServerLabel.pack(side=TOP, padx=5, pady=5) self.selectCrackingMethodLabel= Label(self, text="Select Your Cracking Method") self.selectCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryCrackingMethodButton= Button(self, text="Dictionary", command=self.unpackNetworkServerUI_LoadNetworkDictionaryUI) self.dictionaryCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.bruteForceCrackingMethodButton= Button(self, text="Brute-Force (default)", command=self.unpackNetwrokServerUI_LoadNetworkBruteForceUI) self.bruteForceCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.rainbowTableCrackingMethodButton= Button(self, text="Rainbow Table", command=self.unpackNetworkServerUI_LoadNetworkRainbowTableUI) self.rainbowTableCrackingMethodButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkServerUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of networkServerUI def unpackNetworkServerUI_LoadNetworkDictionaryUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.dictionaryCrackingMethodUI(1) def unpackNetwrokServerUI_LoadNetworkBruteForceUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodUI(1) def unpackNetworkServerUI_LoadNetworkRainbowTableUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodUI(1) def unpackDictionaryCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.dictionaryCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.dictionaryFileLocationLabel.pack_forget() self.selectedDictionaryFileLabel.pack_forget() self.selectDictionaryFileButton.pack_forget() self.inputHashTextFieldLabel.pack_forget() self.inputHashTextField.pack_forget() self.selectAlgorithmLabel.pack_forget() self.md5RadioButton.pack_forget() self.sha1RadioButton.pack_forget() self.sha224RadioButton.pack_forget() self.sha256RadioButton.pack_forget() self.sha512RadioButton.pack_forget() self.startDictionaryCrackButton.pack_forget() self.initUI() def dictionaryCrackingMethodUI(self,mode): #mode is either 1 (network) or 0 (single) currentMode= "ERROR: Mode not selected" #initialize variable self.selectedDictionaryFile= "" selectedAlgorithm= "MD5" #set to md5 as the default inputHash= StringVar() inputHash.set("") try: if(mode == 0): currentMode= "Single" elif(mode == 1): currentMode= "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackDictionaryCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.dictionaryCrackingMethodLabel= Label(self, text="Dictionary Cracking Method") self.dictionaryCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel = Label(self,text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryFileLocationLabel= Label(self, text="Dictionary File to be used:") self.dictionaryFileLocationLabel.pack(side=TOP, padx=5, pady=5) self.selectedDictionaryFileLabel= Label(self, text=str(self.selectedDictionaryFile)) self.selectedDictionaryFileLabel.pack(side=TOP, padx=5, pady=5) self.selectDictionaryFileButton= Button(self, text="Select Dictionary File", textvariable= str(self.selectedDictionaryFile), command=self.selectFileWindow) # self.selectDictionaryFileButton.pack(side=TOP, padx=5, pady=5) #TODO modify the dictionary file so that when a file is selected, that filepath is passed onto server #TODO check for dictionary file existance before handling (and file extensions for windows) #TODO insert option to crack a file of hashes (pass file to the server/single) #TODO check for file existance before handling (and file extensions for windows) self.inputHashTextFieldLabel= Label(self, text="The hash to be cracked:") self.inputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.inputHashTextField= Entry(self, bd=5, textvariable= inputHash) self.inputHashTextField.pack(side=TOP, padx=5, pady=5) self.selectAlgorithmLabel = Label(self, text="Select the Cracking Algorithm:") self.selectAlgorithmLabel.pack(side=TOP, padx=5, pady=5) self.md5RadioButton= Radiobutton(self, text="MD5 (default)", variable= selectedAlgorithm, value="MD5" ) self.md5RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha1RadioButton= Radiobutton(self, text="SHA 1", variable= selectedAlgorithm, value="SHA 1") self.sha1RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha224RadioButton= Radiobutton(self, text="SHA 224", variable= selectedAlgorithm, value="SHA 224") self.sha224RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha256RadioButton= Radiobutton(self, text="SHA 256", variable= selectedAlgorithm, value="SHA 256") self.sha256RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha512RadioButton= Radiobutton(self, text="SHA 512", variable= selectedAlgorithm, value="SHA 512") self.sha512RadioButton.pack(side=LEFT, padx=5, pady=5) #TODO display result in a noneditable text view if(currentMode is 'Single'): self.dict = {'cracking method': "dic", 'file name': str(self.selectedDictionaryFileLabel.cget("text")), 'algorithm': selectedAlgorithm, 'hash': str(inputHash.get()), 'single':"True"} print "selectedDictionaryFileLabel text="+str(self.selectedDictionaryFileLabel.cget("text")) self.startDictionaryCrackButton= Button(self, text="Start Dictionary Crack (Single Mode)", command=lambda: self.startNetworkServer(self.dict)) self.startDictionaryCrackButton.pack(side=BOTTOM, padx=5, pady=5) elif(currentMode is 'Network'): print "GUI DEBUG: Inside elif(currentMode is 'Network)" if(len(str(self.inputHashTextField)) < 1): showwarning("Empty hash text field", "The hash text field is empty") else: print "GUI DEBUG: '"+str(self.inputHashTextField.get())+"'" self.dict = {'cracking method': "dic", 'file name': str(self.selectedDictionaryFile), 'algorithm': selectedAlgorithm, 'hash': str(inputHash.get())} self.startDictionaryCrackButton= Button(self, text="Start Dictionary Crack (Network Mode)", command=lambda: self.startNetworkServer(self.dict)) self.startDictionaryCrackButton.pack(side=BOTTOM, padx=5, pady=5) else: raise Exception("GUI ERROR: Invalid currentMode in startDictionaryCrackButton: '"+str(currentMode)+"'") except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in dictionaryCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of dictionary cracking methodUI def setDictHash(self,newHash): print "GUI DEBUG: hash is: '"+str(newHash)+"'" self.dict['hash']= str(newHash) def startNetworkServer(self, crackingMethod): print "GUI DEBUG: hash is: '"+str(crackingMethod['hash'])+"'" self.networkServer= Process(target=Server, args=(crackingMethod,)) self.networkServer.start() #TODO idea: create a server is running window, with the stats def unpackBruteForceCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.inputHashTextFieldLabel.pack_forget() self.inputHashTextField.pack_forget() self.bruteForceCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.startBruteForceCrackButton.pack_forget() self.algorithmSelectionLabel.pack_forget() self.algorithmOptionMenu.pack_forget() self.alphabetSelectionLabel.pack_forget() self.alphabetOptionMenu.pack_forget() self.minKeyLengthLabel.pack_forget() self.minKeyLengthTextField.pack_forget() self.maxKeyLengthLabel.pack_forget() self.maxKeyLengthTextField.pack_forget() self.outputHashTextFieldLabel.pack_forget() self.outputHashTextField.pack_forget() self.initUI() def bruteForceCrackingMethodUI(self, mode): #mode is either 1 (network) or 0 (single) currentMode= None selectedAlgorithm= StringVar() selectedAlgorithm.set("MD5") selectedAlphabet= StringVar() selectedAlphabet.set("All") minKeyLength= IntVar() minKeyLength.set(5) maxKeyLength= IntVar() maxKeyLength.set(15) inputHash= StringVar() inputHash.set("") try: if(mode==0): currentMode= "Single" elif(mode ==1): currentMode= "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackBruteForceCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.bruteForceCrackingMethodLabel = Label(self, text="Brute-Force Cracking Method") self.bruteForceCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel= Label(self, text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) self.algorithmSelectionLabel= Label(self, text="Select which algorithm you want to use:") self.algorithmSelectionLabel.pack(side=TOP, padx=5, pady=5) self.algorithmOptionMenu= OptionMenu(self, selectedAlgorithm, "MD5", "SHA 1", "SHA 224", "SHA 256", "SHA 512") self.algorithmOptionMenu.pack(side=TOP, padx=5, pady=5) self.alphabetSelectionLabel= Label(self, text="Select which alphabet you want to use:") self.alphabetSelectionLabel.pack(side=TOP, padx=5, pady=5) self.alphabetOptionMenu= OptionMenu(self, selectedAlphabet, "All", "ASCII_Uppercase", "ASCII_Lowercase", "Digits", "Special_Symbols") self.alphabetOptionMenu.pack(side=TOP, padx=5, pady=5) self.minKeyLengthLabel= Label(self, text="Select the minimum key length: (Default is 5)") self.minKeyLengthLabel.pack(side=TOP, padx=5, pady=5) self.minKeyLengthTextField= Entry(self, bd=5, textvariable= minKeyLength) self.minKeyLengthTextField.pack(side=TOP, padx=5, pady=5) self.maxKeyLengthLabel= Label(self, text="Select the maximum key length: (Default is 15)") self.maxKeyLengthLabel.pack(side=TOP, padx=5, pady=5) self.maxKeyLengthTextField= Entry(self, bd=5, textvariable= maxKeyLength) self.maxKeyLengthTextField.pack(side=TOP, padx=5, pady=5) #TODO add support for combination of alphabets #TODO insert option to hash a file of hashes (pass the file to server/single) #TODO check for file existance before handling (and file extensions for windows) self.inputHashTextFieldLabel= Label(self, text="The hash to be cracked:") self.inputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.inputHashTextField= Entry(self, bd=5, textvariable= inputHash) self.inputHashTextField.pack(side=TOP, padx=5, pady=5) #TODO display results is a copiable textview if(currentMode is 'Single'): self.dict = {'cracking method': "bf", 'hash': str(inputHash.get()), 'algorithm':str(selectedAlgorithm.get()), 'alphabet':str(selectedAlphabet.get()), 'min key length':int(minKeyLength.get()), 'max key length':int(maxKeyLength.get()), 'single':"True"} self.startBruteForceCrackButton= Button(self, text="Start Brute-Force Crack (Single Mode)", command=lambda: self.startNetworkServer(self.dict)) self.startBruteForceCrackButton.pack(side=BOTTOM, padx=5, pady=5) elif(currentMode is 'Network'): # print "GUI DEBUG: Inside elif(currentMode is 'Network)" #if(len(str(inputHash.get())) < 1): # showwarning("Empty hash text field", "The hash text field is empty") #else: print "GUI DEBUG: '"+str(self.inputHashTextField.get())+"'" self.dict = {'cracking method': "bf", 'hash': str(inputHash.get()), 'algorithm':str(selectedAlgorithm.get()), 'alphabet':str(selectedAlphabet.get()), 'min key length':int(minKeyLength.get()), 'max key length':int(maxKeyLength.get())} self.startBruteForceCrackButton= Button(self, text="Start Brute-Force Crack (Network Mode)", command=lambda: self.startNetworkServer(self.dict)) self.startBruteForceCrackButton.pack(side=BOTTOM, padx=5, pady=5) else: raise Exception("ERROR: Invalid mode parameter in Brute-Force CrackingUI: '"+str(mode)+"'") #This will display the results, could set to show up after the program is run. self.outputHashTextFieldLabel= Label(self, text="Results") self.outputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.outputHashTextField= Entry(self, bd=5) self.outputHashTextField.insert(0, "Test") self.outputHashTextField.pack(side=TOP,padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in bruteForceCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of brute force cracking UI def unpackRainbowTableCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.rainbowTableCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.initUI() def rainbowTableCrackingMethodUI(self, mode): #mode is either 1 (network) or 0 (single) currentMode= None try: if(mode == 0): currentMode = "Single" elif(mode == 1): currentMode = "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackRainbowTableCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.rainbowTableCrackingMethodLabel= Label(self, text="Rainbow Table Cracking Method") self.rainbowTableCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel= Label(self,text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) #TODO insert Rainbow table settings here except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in rainbowTableCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of rainbow table cracking UI def selectFileWindow(self): filename= "" filename= askopenfilename() #remove the file extension # modifiedFileName= self.removeFileNameExtension(filename) print "Modified fileName= '"+str(filename)+"'" self.selectedDictionaryFileLabel.config(text=str(filename)) self.selectedDictionaryFile= str(self.selectedDictionaryFileLabel.cget("text")) ''' def removeFileNameExtension(self, inputFileName): outboundFileName= "" lastForwardSlashPos=0 for i in range(0, len(inputFileName)): if(inputFileName[i] == "."): break elif(inputFileName[i] == "/"): lastForwardSlashPos= i outboundFileName+= inputFileName[i] else: outboundFileName+= inputFileName[i] print "FileName after extension is removed: '"+str(outboundFileName)+"'" pathlessFileName= self.removeAbsoluteFilePath(outboundFileName, lastForwardSlashPos) print "FileName after absolute filepath was removed: '"+str(pathlessFileName)+"'" return pathlessFileName def removeAbsoluteFilePath(self, inboundFilePath, lastForwardSlashPos): relativeFilePath= "" for i in range(lastForwardSlashPos+1, len(inboundFilePath)): if(inboundFilePath[i] is not None): relativeFilePath+= inboundFilePath[i] else: break return relativeFilePath ''' def confirmExit(self): result= askyesno('Exit Confirmation', 'Are you sure you want to quit this application? \n (WARNING: All server, client, and single computer processes will be terminated!!)') if result == True: self.onExit() #if no is selected, then the window just closes def onExit(self): # self.networkServer.join() try: self.networkServer.terminate() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in onExit terminate networkserver process Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #self.networkClient.join() try: self.networkClient.terminate() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in onExit terminate networkclient process Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" self.parent.destroy()
class guiMainMenu(Frame): def __init__(self,parent): Frame.__init__(self,parent) self.parent= parent self.initUI() def initUI(self): try: self.parent.title("Main Menu") self.style = Style() self.style.theme_use("default") menuBar = Menu(self.parent) self.parent.config(menu=menuBar) fileMenu = Menu(menuBar) fileMenu.add_command(label="Exit", command=self.onExit) menuBar.add_cascade(label="File", menu=fileMenu) fileMenu.add_command(label="Settings") menuBar.add_cascade(label="Edit", menu=fileMenu) fileMenu.add_command(label="GUI Interface") fileMenu.add_command(label="Command Line Interface") menuBar.add_cascade(label="View", menu=fileMenu) self.pack(fill=BOTH, expand=1) self.closeButton= Button(self,text="Close", command=self.onExit) self.closeButton.pack(side=RIGHT, padx=5, pady=5) self.singleButton= Button(self, text="Single Computer") self.singleButton.pack(side=TOP, padx=5,pady=5) self.networkButton= Button(self, text="Network Mode", command=self.unpack_initUI_andLoadNetwork) self.networkButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in initUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpack_initUI_andLoadNetwork(self): self.closeButton.pack_forget() self.singleButton.pack_forget() self.networkButton.pack_forget() self.networkUI() def onExit(self): self.quit() def networkUI(self): try: self.parent.title("Network Mode") self.style= Style() self.style.theme_use("default") #load new buttons self.backToMMButton= Button(self, text="Back to Main Menu", command=self.unpack_networkUI_andLoadMM) self.backToMMButton.pack(side=RIGHT, padx=5, pady=5) self.runServerButton= Button(self, text="Run Server", command=self.startServer) self.runServerButton.pack(side=TOP, padx=5, pady=5) self.runClientButton= Button(self, text="Run Client", command=self.promptForIP_startClient) self.runClientButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpack_networkUI_andLoadMM(self): self.backToMMButton.pack_forget() self.runServerButton.pack_forget() self.runClientButton.pack_forget() self.initUI() def startServer(self): #starts the network server try: self.networkServer = Process(target=Server) self.networkServer.start() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in startServer definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def startClient(self, inputIP): try: self.networkClient = Process(target=Client, args=(inputIP,)) self.networkClient.start() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in startClient definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def promptForIP_startClient(self): #use when ready inputIPLabel= Label(self, text="Server's IP:") inputIP= Entry(self, bd=5) inputIPLabel.pack(side=TOP, padx=5, pady=5) inputIP.pack(side=TOP, padx=5, pady=5) self.startClient(inputIP)
class guiDemo3(Frame): def __init__(self,parent): Frame.__init__(self,parent) self.parent = parent self.initUI() #start up the main menu def initUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.mainMenuLabel= Label(self, text="Main Menu") self.mainMenuLabel.pack(side=TOP,padx=5, pady=5) self.singleModeButton= Button(self, text="Single Computer Mode", command=self.unpackInitUI_LoadSingleComputerMode) self.singleModeButton.pack(side=TOP, padx=5, pady=5) self.networkModeButton= Button(self, text="Networking Mode", command=self.unpackInitUI_LoadNetworkMode) self.networkModeButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in initUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" #end of initUI//////////////////////////// def unpackInitUI_LoadSingleComputerMode(self): self.closeButton.pack_forget() self.mainMenuLabel.pack_forget() self.singleModeButton.pack_forget() self.networkModeButton.pack_forget() self.singleModeUI() def unpackInitUI_LoadNetworkMode(self): self.closeButton.pack_forget() self.mainMenuLabel.pack_forget() self.singleModeButton.pack_forget() self.networkModeButton.pack_forget() self.networkModeUI() def unpackSingleModeUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.initUI() def unpackSingleModeUI_LoadSingleDictionaryUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.dictionaryCrackingMethodUI(0) def unpackSingleModeUI_LoadSingleBruteForceUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodUI(0) def unpackSingleModeUI_LoadSingleRainbowTableUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.singleModeLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodUI(0) def singleModeUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackSingleModeUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.singleModeLabel= Label(self, text="Single Computer Mode") self.singleModeLabel.pack(side=TOP, padx=5, pady=5) self.selectCrackingMethodLabel= Label(self, text="Select Your Cracking Method") self.selectCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryCrackingMethodButton= Button(self, text="Dictionary", command=self.unpackSingleModeUI_LoadSingleDictionaryUI) self.dictionaryCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.bruteForceCrackingMethodButton= Button(self, text="Brute-Force (default)", command=self.unpackSingleModeUI_LoadSingleBruteForceUI) self.bruteForceCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.rainbowTableCrackingMethodButton= Button(self, text="Rainbow Table", command=self.unpackSingleModeUI_LoadSingleRainbowTableUI) self.rainbowTableCrackingMethodButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in singleModeUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackNetworkModeUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.initUI() def networkModeUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkModeUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkModeLabel= Label(self, text="Network Mode: Server/Client Selection Screen") self.networkModeLabel.pack(side=TOP, padx=5, pady=5) self.selectNetworkModuleLabel= Label(self, text="Select Server or Client") self.selectNetworkModuleLabel.pack(side=TOP, padx=5, pady=5) self.serverModuleButton= Button(self, text="I am the Server", command= self.unpackNetworkModeUI_LoadNetworkServerUI) self.serverModuleButton.pack(side=TOP, padx=5, pady=5) self.clientModuleButton= Button(self, text="I am a Client", command= self.unpackNetworkModeUI_LoadNetworkClientUI) self.clientModuleButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkModeUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackNetworkModeUI_LoadNetworkServerUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.networkServerUI() def unpackNetworkModeUI_LoadNetworkClientUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkModeLabel.pack_forget() self.selectNetworkModuleLabel.pack_forget() self.serverModuleButton.pack_forget() self.clientModuleButton.pack_forget() self.networkClientUI() def unpackNetworkClientUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkClientLabel.pack_forget() self.insertServerIPLabel.pack_forget() self.insertServerIPTextfield.pack_forget() self.startClientButton.pack_forget() self.initUI() def networkClientUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkClientUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkClientLabel= Label(self, text="Network Client") self.networkClientLabel.pack(side=TOP, padx=5, pady=5) self.insertServerIPLabel= Label(self, text="Enter in the Server's IP:") self.insertServerIPLabel.pack(side=TOP, padx=5, pady=5) self.insertServerIPTextfield= Entry(self, bd=5) self.insertServerIPTextfield.pack(side=TOP, padx=5, pady=5) self.startClientButton= Button(self, text="Start Client", command=lambda:self.startClient(str(self.insertServerIPTextfield))) self.startClientButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkClientUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def startClient(self,inputIP): try: if(len(inputIP) < 1): showwarning("Network Client Start Warning: NO IP","No IP address has been entered!") else: self.networkClient= Process(target=Client, args=(inputIP,)) self.networkClient.start() except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in startClient definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackNetworkServerUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.initUI() def networkServerUI(self): try: self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkServerUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.networkServerLabel= Label(self, text="Network Server") self.networkServerLabel.pack(side=TOP, padx=5, pady=5) self.selectCrackingMethodLabel= Label(self, text="Select Your Cracking Method") self.selectCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryCrackingMethodButton= Button(self, text="Dictionary", command=self.unpackNetworkServerUI_LoadNetworkDictionaryUI) self.dictionaryCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.bruteForceCrackingMethodButton= Button(self, text="Brute-Force (default)", command=self.unpackNetwrokServerUI_LoadNetworkBruteForceUI) self.bruteForceCrackingMethodButton.pack(side=TOP, padx=5, pady=5) self.rainbowTableCrackingMethodButton= Button(self, text="Rainbow Table", command=self.unpackNetworkServerUI_LoadNetworkRainbowTableUI) self.rainbowTableCrackingMethodButton.pack(side=TOP, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in networkServerUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackNetworkServerUI_LoadNetworkDictionaryUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.dictionaryCrackingMethodUI(1) def unpackNetwrokServerUI_LoadNetworkBruteForceUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodUI(1) def unpackNetworkServerUI_LoadNetworkRainbowTableUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.networkServerLabel.pack_forget() self.selectCrackingMethodLabel.pack_forget() self.dictionaryCrackingMethodButton.pack_forget() self.bruteForceCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodButton.pack_forget() self.rainbowTableCrackingMethodUI(1) def unpackDictionaryCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.dictionaryCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.dictionaryFileLocationLabel.pack_forget() self.selectedDictionaryFileLabel.pack_forget() self.selectDictionaryFileButton.pack_forget() self.inputHashTextFieldLabel.pack_forget() self.inputHashTextField.pack_forget() self.selectAlgorithmLabel.pack_forget() self.md5RadioButton.pack_forget() self.sha1RadioButton.pack_forget() self.sha224RadioButton.pack_forget() self.sha256RadioButton.pack_forget() self.sha512RadioButton.pack_forget() self.startDictionaryCrackButton.pack_forget() self.initUI() def dictionaryCrackingMethodUI(self,mode): #mode is either 1 (network) or 0 (single) currentMode= "ERROR: Mode not selected" #initialize variable selectedDictionaryFile= "No Dictionary file has been selected" selectedAlgorithm= "MD5" #set to md5 as the default try: if(mode == 0): currentMode= "Single" elif(mode == 1): currentMode= "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackDictionaryCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) if(currentMode is 'Single'): self.startDictionaryCrackButton= Button(self, text="Start Dictionary Crack (Single Mode)") self.startDictionaryCrackButton.pack(side=BOTTOM, padx=5, pady=5) #TODO create call method to start the dictionary crack elif(currentMode is 'Network'): self.startDictionaryCrackButton= Button(self, text="Start Dictionary Crack (Network Mode)") self.startDictionaryCrackButton.pack(side=BOTTOM, padx=5, pady=5) #TODO create call method to start the dictionary crack else: raise Exception("GUI ERROR: Invalid currentMode in startDictionaryCrackButton: '"+str(currentMode)+"'") self.dictionaryCrackingMethodLabel= Label(self, text="Dictionary Cracking Method") self.dictionaryCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel = Label(self,text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) self.dictionaryFileLocationLabel= Label(self, text="Dictionary File to be used:") self.dictionaryFileLocationLabel.pack(side=TOP, padx=5, pady=5) self.selectedDictionaryFileLabel= Label(self, text=str(selectedDictionaryFile)) self.selectedDictionaryFileLabel.pack(side=TOP, padx=5, pady=5) self.selectDictionaryFileButton= Button(self, text="Select Dictionary File", command=self.selectFileWindow) self.selectDictionaryFileButton.pack(side=TOP, padx=5, pady=5) self.inputHashTextFieldLabel= Label(self, text="The hash to be cracked:") self.inputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.inputHashTextField= Entry(self, bd=5) self.inputHashTextField.pack(side=TOP, padx=5, pady=5) self.selectAlgorithmLabel = Label(self, text="Select the Cracking Algorithm:") self.selectAlgorithmLabel.pack(side=TOP, padx=5, pady=5) self.md5RadioButton= Radiobutton(self, text="MD5 (default)", variable= selectedAlgorithm, value="MD5" ) self.md5RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha1RadioButton= Radiobutton(self, text="SHA 1", variable= selectedAlgorithm, value="SHA 1") self.sha1RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha224RadioButton= Radiobutton(self, text="SHA 224", variable= selectedAlgorithm, value="SHA 224") self.sha224RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha256RadioButton= Radiobutton(self, text="SHA 256", variable= selectedAlgorithm, value="SHA 256") self.sha256RadioButton.pack(side=LEFT, padx=5, pady=5) self.sha512RadioButton= Radiobutton(self, text="SHA 512", variable= selectedAlgorithm, value="SHA 512") self.sha512RadioButton.pack(side=LEFT, padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in dictionaryCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackBruteForceCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.inputHashTextFieldLabel.pack_forget() self.inputHashTextField.pack_forget() self.bruteForceCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.startBruteForceCrackButton.pack_forget() self.outputHashTextFieldLabel.pack_forget() self.outputHashTextField.pack_forget() self.initUI() def bruteForceCrackingMethodUI(self, mode): #mode is either 1 (network) or 0 (single) currentMode= None try: if(mode==0): currentMode= "Single" elif(mode ==1): currentMode= "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackBruteForceCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) if(currentMode is 'Single'): self.startBruteForceCrackButton= Button(self, text="Start Brute-Force Crack (Single Mode)") self.startBruteForceCrackButton.pack(side=BOTTOM, padx=5, pady=5) #TODO create call method to start the brute force crack elif(currentMode is 'Network'): self.startBruteForceCrackButton= Button(self, text="Start Brute-Force Crack (Network Mode)") self.startBruteForceCrackButton.pack(side=BOTTOM, padx=5, pady=5) #TODO create call method to start the brute force crack else: raise Exception ("GUI ERROR: Invalid currentMode in startBruteForceCrackButton: '"+str(currentMode)+"'") self.bruteForceCrackingMethodLabel = Label(self, text="Brute-Force Cracking Method") self.bruteForceCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel= Label(self, text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) self.inputHashTextFieldLabel= Label(self, text="The hash to be cracked:") self.inputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.inputHashTextField= Entry(self, bd=5) self.inputHashTextField.pack(side=TOP, padx=5, pady=5) #self.selectAlgorithmLabel = Label(self, text="Select the Cracking Algorithm:") #self.selectAlgorithmLabel.pack(side=TOP, padx=5, pady=5) #self.md5RadioButton= Radiobutton(self, text="MD5 (default)", value="MD5" ) #self.md5RadioButton.pack(side=LEFT, padx=5, pady=5) #self.sha1RadioButton= Radiobutton(self, text="SHA 1", value="SHA 1") #self.sha1RadioButton.pack(side=LEFT, padx=5, pady=5) #self.sha224RadioButton= Radiobutton(self, text="SHA 224", value="SHA 224") #self.sha224RadioButton.pack(side=LEFT, padx=5, pady=5) #self.sha256RadioButton= Radiobutton(self, text="SHA 256", value="SHA 256") #self.sha256RadioButton.pack(side=LEFT, padx=5, pady=5) #self.sha512RadioButton= Radiobutton(self, text="SHA 512", value="SHA 512") #self.sha512RadioButton.pack(side=LEFT, padx=5, pady=5) #self.selectAlgorithm = #This will display the results, could set to show up after the program is run. self.outputHashTextFieldLabel= Label(self, text="Results") self.outputHashTextFieldLabel.pack(side=TOP, padx=5, pady=5) self.outputHashTextField= Entry(self, bd=5) self.outputHashTextField.insert(0, "Test") #This will disable modification but you cant hightlight and copy it. #self.outputHashTextField.config(state='disabled') self.outputHashTextField.pack(side=TOP,padx=5, pady=5) except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in bruteForceCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def unpackRainbowTableCrackingMethodUI_LoadInitUI(self): self.closeButton.pack_forget() self.returnToInitUIButton.pack_forget() self.rainbowTableCrackingMethodLabel.pack_forget() self.currentModeLabel.pack_forget() self.initUI() def rainbowTableCrackingMethodUI(self, mode): #mode is either 1 (network) or 0 (single) currentMode= None try: if(mode == 0): currentMode = "Single" elif(mode == 1): currentMode = "Network" else: raise Exception("ERROR: Invalid mode parameter: '"+str(mode)+"'") self.parent.title("Mighty Cracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #load buttons and labels self.closeButton= Button(self, text="Close Program", command=self.confirmExit) self.closeButton.pack(side=BOTTOM, padx=5, pady=5) self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackRainbowTableCrackingMethodUI_LoadInitUI) self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5) self.rainbowTableCrackingMethodLabel= Label(self, text="Rainbow Table Cracking Method") self.rainbowTableCrackingMethodLabel.pack(side=TOP, padx=5, pady=5) self.currentModeLabel= Label(self,text="Current Mode: "+str(currentMode)) self.currentModeLabel.pack(side=TOP, padx=5, pady=5) #TODO insert Rainbow table settings here except Exception as inst: print "=============================================================================================" print "GUI ERROR: An exception was thrown in rainbowTableCrackingMethodUI definition Try block" #the exception instance print type(inst) #srguments stored in .args print inst.args #_str_ allows args tto be printed directly print inst print "=============================================================================================" def selectFileWindow(self): filename= "" filename= askopenfilename() self.selectedDictionaryFileLabel.config(text=str(filename)) def confirmExit(self): result= askyesno('Exit Confirmation', 'Are you sure you want to quit this application? \n (WARNING: All server, client, and single computer processes will be terminated!!)') if result == True: self.onExit() #if no is selected, then the window just closes def onExit(self): self.quit()