| #!/usr/bin/env python |
| # |
| # encrypt_n_crack_gui.py |
| # Front-end gui for encrypt_n_crack_engine |
| # |
| # Copyright (C) 2010 shadytyrant@gmail.com |
| # |
| # This program is free software: you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation, either version 3 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| #-------------------------------------------- |
| |
| import wx |
| import os |
| import encrypt_n_crack_engine as Hash |
| |
| class EncryptNCrack(wx.Frame): |
| |
| def __init__(self, *args, **kwds): |
| kwds["style"] = wx.DEFAULT_FRAME_STYLE |
| wx.Frame.__init__(self, *args, **kwds) |
| |
| self.notebook_1 = wx.Notebook(self, -1, style=0) |
| self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1) |
| self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1) |
| |
| self.label_1 = wx.StaticText(self.notebook_1_pane_1, -1, "Text to encrypt") |
| self.txtToEncrypt = wx.TextCtrl(self.notebook_1_pane_1, -1, "") |
| |
| self.label_2 = wx.StaticText(self.notebook_1_pane_1, -1, "Encrypted text") |
| self.txtToDisplay = wx.TextCtrl(self.notebook_1_pane_1, -1, "", style=wx.TE_READONLY) |
| |
| self.rdoEncryptMd5 = wx.RadioButton(self.notebook_1_pane_1, -1, "MD5") |
| self.rdoEncryptSha1 = wx.RadioButton(self.notebook_1_pane_1, -1, "SHA1") |
| self.rdoEncryptBase64 = wx.RadioButton(self.notebook_1_pane_1, -1, "BASE64") |
| |
| self.btnEncrypt = wx.Button(self.notebook_1_pane_1, -1, "Encrypt") |
| |
| self.label_3 = wx.StaticText(self.notebook_1_pane_2, -1, "Encrypted text to crack") |
| self.txtToCrack = wx.TextCtrl(self.notebook_1_pane_2, -1, "") |
| |
| self.label_5 = wx.StaticText(self.notebook_1_pane_2, -1, "Path to wordlist") |
| self.txtPathToWordlist = wx.TextCtrl(self.notebook_1_pane_2, -1, "") |
| self.btnPickWordlist = wx.Button(self.notebook_1_pane_2, -1, "Pick Wordlist") |
| |
| self.label_4 = wx.StaticText(self.notebook_1_pane_2, -1, "Crack status") |
| self.txtToDisplayStatus = wx.TextCtrl(self.notebook_1_pane_2, -1, "") |
| |
| self.rdoCrackMd5 = wx.RadioButton(self.notebook_1_pane_2, -1, "MD5") |
| self.rdoCrackSha1 = wx.RadioButton(self.notebook_1_pane_2, -1, "SHA1") |
| self.rdoCrackBase64 = wx.RadioButton(self.notebook_1_pane_2, -1, "BASE64") |
| |
| self.btnCrack = wx.Button(self.notebook_1_pane_2, -1, "Crack") |
| |
| self.__set_properties() |
| self.__do_layout() |
| self.__bind_events() |
| |
| |
| def __set_properties(self): |
| self.SetTitle("Encrypt N Crack") |
| self.SetSize((421, 307)) |
| self.txtPathToWordlist.SetMinSize((300, 27)) |
| self.txtPathToWordlist.SetValue("wordlist.txt") |
| |
| |
| def __do_layout(self): |
| sizer_1 = wx.BoxSizer(wx.HORIZONTAL) |
| sizer_4 = wx.BoxSizer(wx.VERTICAL) |
| sizer_5 = wx.BoxSizer(wx.HORIZONTAL) |
| sizer_6 = wx.BoxSizer(wx.HORIZONTAL) |
| sizer_2 = wx.BoxSizer(wx.VERTICAL) |
| sizer_3 = wx.BoxSizer(wx.HORIZONTAL) |
| |
| sizer_2.Add(self.label_1, 0, wx.ALL, 3) |
| sizer_2.Add(self.txtToEncrypt, 0, wx.ALL|wx.EXPAND, 3) |
| sizer_2.Add(self.label_2, 0, wx.ALL, 3) |
| sizer_2.Add(self.txtToDisplay, 0, wx.ALL|wx.EXPAND, 3) |
| sizer_3.Add(self.rdoEncryptMd5, 0, wx.ALL, 3) |
| sizer_3.Add(self.rdoEncryptSha1, 0, wx.ALL, 3) |
| sizer_3.Add(self.rdoEncryptBase64, 0, wx.ALL, 3) |
| sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) |
| sizer_2.Add(self.btnEncrypt, 0, wx.ALL|wx.EXPAND, 3) |
| |
| self.notebook_1_pane_1.SetSizer(sizer_2) |
| |
| sizer_4.Add(self.label_3, 0, wx.ALL, 3) |
| sizer_4.Add(self.txtToCrack, 0, wx.ALL|wx.EXPAND, 3) |
| sizer_4.Add(self.label_5, 0, wx.ALL, 3) |
| sizer_6.Add(self.txtPathToWordlist, 0, wx.ALL, 3) |
| sizer_6.Add(self.btnPickWordlist, 0, wx.ALL|wx.ALIGN_RIGHT, 3) |
| sizer_4.Add(sizer_6, 1, wx.EXPAND, 0) |
| sizer_4.Add(self.label_4, 0, wx.ALL, 3) |
| sizer_4.Add(self.txtToDisplayStatus, 0, wx.ALL|wx.EXPAND, 3) |
| sizer_5.Add(self.rdoCrackMd5, 0, wx.ALL, 3) |
| sizer_5.Add(self.rdoCrackSha1, 0, wx.ALL, 3) |
| sizer_5.Add(self.rdoCrackBase64, 0, wx.ALL, 3) |
| sizer_4.Add(sizer_5, 1, wx.EXPAND, 0) |
| sizer_4.Add(self.btnCrack, 0, wx.ALL|wx.EXPAND, 3) |
| |
| self.notebook_1_pane_2.SetSizer(sizer_4) |
| self.notebook_1.AddPage(self.notebook_1_pane_1, "Encrypt") |
| self.notebook_1.AddPage(self.notebook_1_pane_2, "Crack") |
| sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0) |
| |
| self.SetSizer(sizer_1) |
| self.Layout() |
| self.Centre() |
| self.SetSize((421, 307)) |
| |
| |
| def __bind_events(self): |
| self.Bind(wx.EVT_BUTTON, self.OnButtonEncryptClick, self.btnEncrypt) |
| self.Bind(wx.EVT_BUTTON, self.OnButtonPickWordlistClick, self.btnPickWordlist) |
| self.Bind(wx.EVT_BUTTON, self.OnButtonCrackClick, self.btnCrack) |
| |
| |
| def OnButtonEncryptClick(self, event): |
| if self.rdoEncryptMd5.GetValue() == True: |
| encrypt = Hash.Encrypt() |
| word = self.txtToEncrypt.GetValue() |
| hash = encrypt.Md5(word) |
| self.txtToDisplay.SetValue(hash) |
| |
| elif self.rdoEncryptSha1.GetValue() == True: |
| encrypt = Hash.Encrypt() |
| word = self.txtToEncrypt.GetValue() |
| hash = encrypt.Sha1(word) |
| self.txtToDisplay.SetValue(hash) |
| |
| else: |
| encrypt = Hash.Encrypt() |
| word = self.txtToEncrypt.GetValue() |
| hash = encrypt.Base64(word) |
| self.txtToDisplay.SetValue(hash) |
| |
| def OnButtonCrackClick(self, event): |
| if self.rdoCrackMd5.GetValue() == True: |
| crack = Hash.Crack() |
| hash = self.txtToCrack.GetValue() |
| |
| check = crack.CheckMd5(hash) |
| |
| if check == False: |
| messageBox = wx.MessageBox('Please enter a valid md5 hash!', 'Error', wx.OK | wx.ICON_ERROR) |
| app.MainLoop() |
| else: |
| words = crack.LoadWordlist(self.txtPathToWordlist.GetValue()) |
| |
| if words == False: |
| messageBox = wx.MessageBox('Please pick a valid wordlist!', 'Error', wx.OK | wx.ICON_ERROR) |
| app.MainLoop() |
| else: |
| answer = crack.Md5(words, hash) |
| |
| if answer == False: |
| messageBox = wx.MessageBox('Could not crack hash!', 'Error', wx.OK | wx.ICON_EXCLAMATION) |
| self.txtToDisplayStatus.SetValue('Could not crack hash') |
| app.MainLoop() |
| else: |
| self.txtToDisplayStatus.SetValue(answer) |
| elif self.rdoCrackSha1.GetValue() == True: |
| crack = Hash.Crack() |
| hash = self.txtToCrack.GetValue() |
| |
| check = crack.CheckSha1(hash) |
| |
| if check == False: |
| messageBox = wx.MessageBox('Please enter a valid sha1 hash!', 'Error', wx.OK | wx.ICON_ERROR) |
| app.MainLoop() |
| else: |
| words = crack.LoadWordlist(self.txtPathToWordlist.GetValue()) |
| |
| if words == False: |
| messageBox = wx.MessageBox('Please pick a valid wordlist!', 'Error', wx.OK | wx.ICON_ERROR) |
| app.MainLoop() |
| else: |
| answer = crack.Sha1(words, hash) |
| |
| if answer == False: |
| messageBox = wx.MessageBox('Could not crack hash!', 'Error', wx.OK | wx.ICON_EXCLAMATION) |
| self.txtToDisplayStatus.SetValue('Could not crack hash') |
| app.MainLoop() |
| else: |
| self.txtToDisplayStatus.SetValue(answer) |
| else: |
| crack = Hash.Crack() |
| hash = self.txtToCrack.GetValue() |
| |
| words = crack.LoadWordlist(self.txtPathToWordlist.GetValue()) |
| |
| if words == False: |
| messageBox = wx.MessageBox('Please pick a valid wordlist!', 'Error', wx.OK | wx.ICON_ERROR) |
| app.MainLoop() |
| else: |
| answer = crack.Base64(words, hash) |
| |
| if answer == False: |
| messageBox = wx.MessageBox('Could not crack hash!', 'Error', wx.OK | wx.ICON_EXCLAMATION) |
| self.txtToDisplayStatus.SetValue('Could not crack hash') |
| app.MainLoop() |
| else: |
| self.txtToDisplayStatus.SetValue(answer) |
| |
| |
| def OnButtonPickWordlistClick(self, event): |
| # Open file dialog and set path string in text box |
| dlg = wx.FileDialog(self, message="Find a wordlist...", defaultDir=os.getcwd(), defaultFile="", style=wx.OPEN) |
| wildcard = "All files (*.*)|*.*" |
| dlg.SetWildcard(wildcard) |
| |
| if dlg.ShowModal() == wx.ID_OK: |
| filename = dlg.GetPath() |
| self.txtPathToWordlist.SetValue(filename) |
| dlg.Destroy() |