'''
passwordTools.py
pip3 install wxPython scapy
'''

#!/usr/bin/env python
#-*-coding:utf-8-*-
import wx
import random,threading,os
from scapy.all import *

def NumGame():
    x=random.randint(1,100)
    y=0
    z=0
    for i in range(1,10):
        z=i
        dlg=wx.TextEntryDialog(None,"我心里想着一个一百以内的整数你猜是几?")
        if dlg.ShowModal() == wx.ID_OK:
            response=dlg.GetValue()
            try:
                y=int(response)
            except:
                break
            #wx.MessageBox(str(y)+":"+str(x),str(i))
            if y<x:
                wx.MessageBox("太小了")
            elif y>x:
                wx.MessageBox("太大了")
            else:
                break
        else:
            break
    if (y>x or y<x) and z==9:
        wx.MessageBox("错误,已超过输入次数,你输了")
    elif y==x:
        wx.MessageBox("正确,你赢了")
    else:
        wx.MessageBox("输入错误")

def packet_callback(packet):
    if packet[TCP].payload:
        mail_packet=str(packet[TCP].payload)
        #print(mail_packet)
        if "user" in mail_packet.lower() or "pass" in mail_packet.lower()or "login" in mail_packet.lower():
            #print(mail_packet)
            wx.MessageBox(mail_packet,"获取密码")
        
#sniff(filter="tcp port 110 or tcp port 25 or tcp port 143",prn=packet_callback)



def randPass(length=16):
    """生成随机密码"""
    charList = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
	            'n','o','p','q','r','s','t','u','v','w','x','y','z',
	            'A','B','C','D','E','F','G','H','I','J','K','L','M',
	            'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
	            '0','1','2','3','4','5','6','7','8','9','0',
	            '~','!','@','#','$','%','^','&','*','(',')','-','=','+','_']
    try:        
        password = ''.join(random.sample(charList,length))
	     #return(password)
    except:        
        password = ''.join(random.sample(charList,16))
    #print(password)
    return(password)
    
def scanPass(password='love'):
    """暴力破解密码"""
    charList = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
	            'n','o','p','q','r','s','t','u','v','w','x','y','z',
	            'A','B','C','D','E','F','G','H','I','J','K','L','M',
	            'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
	            '0','1','2','3','4','5','6','7','8','9','0',
	            '~','!','@','#','$','%','^','&','*','(',')','-','=','+','_']
    
    string = ''
    for l0 in range(len(charList)):
        string=(charList[l0])
        print(string)
        if password == string:
            print('password is: '+string)
            wx.MessageBox("password is: "+string)
            return(string)
            
    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            string=(charList[l0]+charList[l1])
            print(string)
            if password == string:
                print('password is: '+string)
                wx.MessageBox("password is: "+string)
                return(string)
            
    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                string=(charList[l0]+charList[l1]+charList[l2])
                print(string)
                if password == string:
                    print('password is: '+string)
                    wx.MessageBox("password is: "+string)
                    return(string)
                    
    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                for l3 in range(len(charList)):
                    string=(charList[l0]+charList[l1]+charList[l2]+charList[l3])
                    print(string)
                    if password == string:
                        print('password is: '+string)
                        wx.MessageBox("password is: "+string)
                        return(string)
                        
    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                for l3 in range(len(charList)):
                    for l4 in range(len(charList)):
                        string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4])
                        print(string)
                        if password == string:
                            print('password is: '+string)
                            wx.MessageBox("password is: "+string)
                            return(string)

    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                for l3 in range(len(charList)):
                    for l4 in range(len(charList)):
                        for l5 in range(len(charList)):
                            string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5])
                            print(string)
                            if password == string:
                                print('password is: '+string)
                                wx.MessageBox("password is: "+string)
                                return(string)

    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                for l3 in range(len(charList)):
                    for l4 in range(len(charList)):
                        for l5 in range(len(charList)):
                            for l6 in range(len(charList)):
                                string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6])
                                print(string)
                                if password == string:
                                    print('password is: '+string)
                                    wx.MessageBox("password is: "+string)
                                    return(string)

    for l0 in range(len(charList)):
        for l1 in range(len(charList)):
            for l2 in range(len(charList)):
                for l3 in range(len(charList)):
                    for l4 in range(len(charList)):
                        for l5 in range(len(charList)):
                            for l6 in range(len(charList)):
                                for l7 in range(len(charList)):
                                    string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6]+charList[l7])
                                    print(string)
                                    if password == string:
                                        print('password is: '+string)
                                        wx.MessageBox("password is: "+string)
                                        return(string)                                                                        

    wx.MessageBox("password is: ")
    return(string)

def findPass(password):
    f=open('password.txt','r')
    for line in f.readlines():
        linetext=line.strip('\r\n')
        #print(linetext,password)
        if linetext == password:
            #wx.MessageBox(linetext+':'+password)
            return(True)
            #print("找到它了,这是一个弱密码")
            break
    f.close()

def testPass(password):
    #wx.MessageBox(str(find),password)
    if len(password)<6: #小于六位
        wx.MessageBox(password,"弱密码")
    elif password.isspace(): #是空格
        wx.MessageBox(password,"弱密码")
    elif password.isdigit(): #纯数字
        wx.MessageBox(password,"弱密码")
    elif password.isalpha(): #纯字母
        wx.MessageBox(password,"弱密码")
    elif password.islower(): #纯小写
        wx.MessageBox(password,"弱密码")
    elif password.isupper(): #纯大写
        wx.MessageBox(password,"弱密码")
    elif findPass(password): #密码字典中存在
        wx.MessageBox(password,"弱密码")
    else:
        wx.MessageBox(password,"强密码")
        return True

def GenKey():
    dlg=wx.TextEntryDialog(None,"请输入密码长度(0-78),超过78将返回默认的16字符密码:")
    if dlg.ShowModal() == wx.ID_OK:
        response=dlg.GetValue()
        password=randPass(int(response))
        wx.MessageBox(password,"结果如下")  
            
def TestKey():
    dlg=wx.TextEntryDialog(None,"请输入密码:")
    if dlg.ShowModal() == wx.ID_OK:
        response=dlg.GetValue()
        password=str(response)
        testPass(password)


def GenTestKey():
    dlg=wx.TextEntryDialog(None,"请输入密码长度,超过78将返回默认的16字符密码:")
    if dlg.ShowModal() == wx.ID_OK:
        response=dlg.GetValue()
        password=randPass(int(response))
        testPass(password)

def EditKey():
    dlg=wx.TextEntryDialog(None,"请输入密码:")
    if dlg.ShowModal() == wx.ID_OK:
        response=dlg.GetValue()
        password=str(response)
        if findPass(password):
            wx.MessageBox(password,"已存在")
        else:
            f=open("password.txt","a")
            f.write(password+"\n")
            wx.MessageBox("密码维护成功","弱密码")
            f.close

class Frame1(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(800,600))

        self.panel=wx.Panel(self)
        self.panel.SetBackgroundColour('white')
        self.menuBar=wx.MenuBar()
        self.menu1=wx.Menu()
        self.NumberGameMenuItem=self.menu1.Append(wx.NewId(),"猜数字游戏")
        self.menuBar.Append(self.menu1,"游戏")
        self.menu2=wx.Menu()
        self.GenKeyMenuItem=self.menu2.Append(wx.NewId(),"生成密码")
        self.TestKeyMenuItem=self.menu2.Append(wx.NewId(),"测试密码")
        self.GenTestKeyMenuItem=self.menu2.Append(wx.NewId(),"生成并测试密码")
        self.menu2.AppendSeparator()
        self.EditKeyMenuItem=self.menu2.Append(wx.NewId(),"维护密码字典")
        self.menuBar.Append(self.menu2,"密码工具")
        self.menu3=wx.Menu()
        self.FindKeyMenuItem=self.menu3.Append(wx.NewId(),"密码暴力破解")
        self.menuBar.Append(self.menu3,"密码暴力破解")
        self.menu4=wx.Menu()        
        self.HelpMenuItem=self.menu4.Append(wx.NewId(),"帮助")
        self.AboutMenuItem=self.menu4.Append(wx.NewId(),"关于")
        self.menuBar.Append(self.menu4,"帮助")
        self.menu5=wx.Menu()
        self.Close_menuItem=self.menu5.Append(wx.NewId(),"返回")
        self.menuBar.Append(self.menu5,"退出")
        self.SetMenuBar(self.menuBar)
        

        self.GenKeyButton=wx.Button(self.panel,-1,'生成密码',size=(150,50))
        self.TestKeyButton=wx.Button(self.panel,-1,'密码测试',size=(150,50))
        self.GenTestButton=wx.Button(self.panel,-1,'生成密码并测试',size=(150,50))
        self.CloseButton=wx.Button(self.panel,-1,'返回',size=(150,50))
        
        text='''
      信息安全是一个新兴学科,在以往的密码安全意识教育课程当中,主要以历史事件,密码原理来引入课程,讲解一些
密码算法,课程比较抽象学生难以直观的操作和理解。我们编写一个密码演示程序,让学生可以直接动手操作进行体验,
提高学习的互动性趣味性和直观性,让学生能够在操作和体验当中提高兴趣理解其中的道理。
      在密码的使用过程中,我们给出一个密码经常是弱密码,这样的密码有一定的规律可以比较容易记忆。但是使用弱密
码,很容易就可以对你的密码进行破解。所以我们要编写一个密码工具程序,对给出的密码进行测试,确定这个密码是不
是弱密码,是不是可以使用。并且我们给出的程序功能,需要自动生成强密码,并对密码进行测试确定不是弱密码。
      在远程和本地监控Windows系统下用户操作行为的过程中,经常需要记录计算机键盘的输入和屏幕的输出。键盘记录
是最古老的黑客技术之一,至今仍在不同的层面广泛使用,攻击者使用它是因为它能有效的捕获所需的敏感信息,如账号
密码和聊天记录等。
      大部分渗透测试框架和恶意软件都具有截取远程目标屏幕的能力,他能捕获打开的图片、播放的视频帧和其他一些敏
感信息,这些信息一般能由数据抓包或键盘记录来获取。
'''
        self.lable=wx.StaticText(self.panel,label=text,pos=(0,50))

        self.Bind(wx.EVT_BUTTON,self.OnGenKey,self.GenKeyButton)
        self.Bind(wx.EVT_BUTTON,self.OnTestKey,self.TestKeyButton)
        self.Bind(wx.EVT_BUTTON,self.OnGenTestKey,self.GenTestButton)
        self.Bind(wx.EVT_BUTTON,self.OnClose,self.CloseButton)
        
        self.Bind(wx.EVT_MENU,self.OnNumberGame,self.NumberGameMenuItem)
        self.Bind(wx.EVT_MENU,self.OnGenKey,self.GenKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnTestKey,self.TestKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnGenTestKey,self.GenTestKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnEditKey,self.EditKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnFindKey,self.FindKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnHelp,self.HelpMenuItem)
        self.Bind(wx.EVT_MENU,self.OnAbout,self.AboutMenuItem)
        self.Bind(wx.EVT_MENU,self.OnClose,self.Close_menuItem)

        self.mainSizer=wx.BoxSizer(wx.VERTICAL)
        self.btSizer=wx.BoxSizer(wx.HORIZONTAL)
        self.btSizer.Add(self.GenKeyButton,wx.EXPAND|wx.BOTTOM)
        self.btSizer.Add(self.TestKeyButton,wx.EXPAND|wx.BOTTOM)
        self.btSizer.Add(self.GenTestButton,wx.EXPAND|wx.BOTTOM)
        self.btSizer.Add(self.CloseButton,wx.EXPAND|wx.BOTTOM)        
        self.mainSizer.Add(self.btSizer,0,wx.EXPAND|wx.BOTTOM)
        self.panel.SetSizer(self.mainSizer)
        self.statusBar=self.CreateStatusBar()

    def OnNumberGame(self,event):
        NumGame()

    def OnGenKey(self,event):
        GenKey()  
                
    def OnTestKey(self,event):
        TestKey()
        
    def OnGenTestKey(self,event):
        GenTestKey()

    def OnEditKey(self,event):
        EditKey()        

    def OnFindKey(self,event):
        #wx.MessageBox("侦测邮箱密码,确认后请 稍侯......")
        #sniff(filter="tcp port 110 or tcp port 25 or tcp port 143",prn=packet_callback,timeout=10)
        #newPassword=raw_input('input you password pleas:')
        #password=genPass(newPassword)
        dlg=wx.TextEntryDialog(None,"请输入八位以内需要破解的密码:")
        if dlg.ShowModal() == wx.ID_OK:
            response=dlg.GetValue()
            password=str(response)
            #scanPass(password)        

        """暴力破解密码"""
        charList = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
	                'n','o','p','q','r','s','t','u','v','w','x','y','z',
	                'A','B','C','D','E','F','G','H','I','J','K','L','M',
	                'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
	                '0','1','2','3','4','5','6','7','8','9','0',
	                '~','!','@','#','$','%','^','&','*','(',')','-','=','+','_']
    
        string = ''
        for l0 in range(len(charList)):
            string=(charList[l0])
            #print(string)
            #self.lable.SetLabel(string)
            #self.statusBar.SetStatusText(string, 0)
            if password == string:
                print('password is: '+string)
                wx.MessageBox("password is: "+string)
                return(string)
            
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                string=(charList[l0]+charList[l1])
                #print(string)
                #self.lable.SetLabel(string)
                #self.statusBar.SetStatusText(string, 0)
                if password == string:
                    print('password is: '+string)
                    wx.MessageBox("password is: "+string)
                    return(string)
            
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    string=(charList[l0]+charList[l1]+charList[l2])
                    #print(string)
                    #self.lable.SetLabel(string)
                    #self.statusBar.SetStatusText(string, 0)
                    if password == string:
                        print('password is: '+string)
                        wx.MessageBox("password is: "+string)
                        return(string)
                    
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        string=(charList[l0]+charList[l1]+charList[l2]+charList[l3])
                        #print(string)
                        #self.lable.SetLabel(string)
                        #self.statusBar.SetStatusText(string, 0)
                        if password == string:
                            print('password is: '+string)
                            wx.MessageBox("password is: "+string)
                            return(string)
                        
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4])
                            #print(string)
                            #self.lable.SetLabel(string)
                            #self.statusBar.SetStatusText(string, 0)
                            if password == string:
                                print('password is: '+string)
                                wx.MessageBox("password is: "+string)
                                return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5])
                                #print(string)
                                #self.lable.SetLabel(string)
                                #self.statusBar.SetStatusText(string, 0)
                                if password == string:
                                    print('password is: '+string)
                                    wx.MessageBox("password is: "+string)
                                    return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                for l6 in range(len(charList)):
                                    string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6])
                                    #print(string)
                                    #self.lable.SetLabel(string)
                                    #self.statusBar.SetStatusText(string, 0)
                                    if password == string:
                                        print('password is: '+string)
                                        wx.MessageBox("password is: "+string)
                                        return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                for l6 in range(len(charList)):
                                    for l7 in range(len(charList)):
                                        string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6]+charList[l7])
                                        #print(string)
                                        #self.lable.SetLabel(string)
                                        #self.statusBar.SetStatusText(string, 0)
                                        if password == string:
                                            print('password is: '+string)
                                            wx.MessageBox("password is: "+string)
                                            return(string)                                                                        

        wx.MessageBox("password is: ")
        return(string)            
                   
        #self.statusBar.SetStatusText(u"密码:"+word, 0)
        #self.lable.SetLabel("密码:"+word)

    def OnHelp(self,event):
        frame2=Frame2(self,-1,'帮助')
        frame2.Center()
        frame2.Show(True)

    def OnAbout(self,event):
        wx.MessageBox("密码工具软件  作者:郑瑞国")

    def OnClose(self,event):
         self.Close()

class Frame2(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(800,600))

        self.panel=wx.Panel(self)
        self.panel.SetBackgroundColour('white')
                        
        #self.button1=wx.Button(self.panel,-1,'猜数字游戏',size=(150,50))
        #self.button2=wx.Button(self.panel,-1,'密码工具',size=(150,50))
        #self.button3=wx.Button(self.panel,-1,'密码暴力破解',size=(150,50))
        #self.button4=wx.Button(self.panel,-1,'关闭',size=(150,50))
        
        text='''
      信息安全是一个新兴学科,在以往的密码安全意识教育课程当中,主要以历史事件,密码原理来引入课程,讲解一些
密码算法,课程比较抽象学生难以直观的操作和理解。我们编写一个密码演示程序,让学生可以直接动手操作进行体验,
提高学习的互动性趣味性和直观性,让学生能够在操作和体验当中提高兴趣理解其中的道理。
      在密码的使用过程中,我们给出一个密码经常是弱密码,这样的密码有一定的规律可以比较容易记忆。但是使用弱密
码,很容易就可以对你的密码进行破解。所以我们要编写一个密码工具程序,对给出的密码进行测试,确定这个密码是不
是弱密码,是不是可以使用。并且我们给出的程序功能,需要自动生成强密码,并对密码进行测试确定不是弱密码。
      在远程和本地监控Windows系统下用户操作行为的过程中,经常需要记录计算机键盘的输入和屏幕的输出。键盘记录
是最古老的黑客技术之一,至今仍在不同的层面广泛使用,攻击者使用它是因为它能有效的捕获所需的敏感信息,如账号
密码和聊天记录等。
      大部分渗透测试框架和恶意软件都具有截取远程目标屏幕的能力,他能捕获打开的图片、播放的视频帧和其他一些敏
感信息,这些信息一般能由数据抓包或键盘记录来获取。
'''
        self.lable=wx.StaticText(self.panel,label=text,pos=(0,50))
        #font=wx.Font(18,wx.DECORATIVE,wx.ITALIC,wx.NORMAL)
        #self.lable.SetFont(font)
        #self.lable.SetLabelText('abcdefg')
    
class Frame(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(800,600))

        self.panel=wx.Panel(self)
        self.panel.SetBackgroundColour('white')
        self.menuBar=wx.MenuBar()
        self.menu1=wx.Menu()
        self.NumberGameMenuItem=self.menu1.Append(wx.NewId(),"猜数字游戏")
        self.menuBar.Append(self.menu1,"游戏")
        self.menu2=wx.Menu()
        self.GenKeyMenuItem=self.menu2.Append(wx.NewId(),"生成密码")
        self.TestKeyMenuItem=self.menu2.Append(wx.NewId(),"测试密码")
        self.GenTestKeyMenuItem=self.menu2.Append(wx.NewId(),"生成并测试密码")
        self.menu2.AppendSeparator()
        self.EditKeyMenuItem=self.menu2.Append(wx.NewId(),"维护密码字典")
        self.menuBar.Append(self.menu2,"密码工具")
        self.menu3=wx.Menu()
        self.FindKeyMenuItem=self.menu3.Append(wx.NewId(),"密码暴力破解")
        self.menuBar.Append(self.menu3,"密码暴力破解")
        self.menu4=wx.Menu()        
        self.HelpMenuItem=self.menu4.Append(wx.NewId(),"帮助")
        self.AboutMenuItem=self.menu4.Append(wx.NewId(),"关于")
        self.menuBar.Append(self.menu4,"帮助")
        self.menu5=wx.Menu()
        self.CloseMenuItem=self.menu5.Append(wx.NewId(),"关闭")
        self.menuBar.Append(self.menu5,"退出")
        self.SetMenuBar(self.menuBar)
        
        self.button1=wx.Button(self.panel,-1,'猜数字游戏',size=(150,50))
        self.button2=wx.Button(self.panel,-1,'密码工具',size=(150,50))
        self.button3=wx.Button(self.panel,-1,'密码暴力破解',size=(150,50))
        self.button4=wx.Button(self.panel,-1,'关闭',size=(150,50))
        
        text='''
      信息安全是一个新兴学科,在以往的密码安全意识教育课程当中,主要以历史事件,密码原理来引入课程,讲解一些
密码算法,课程比较抽象学生难以直观的操作和理解。我们编写一个密码演示程序,让学生可以直接动手操作进行体验,
提高学习的互动性趣味性和直观性,让学生能够在操作和体验当中提高兴趣理解其中的道理。
      在密码的使用过程中,我们给出一个密码经常是弱密码,这样的密码有一定的规律可以比较容易记忆。但是使用弱密
码,很容易就可以对你的密码进行破解。所以我们要编写一个密码工具程序,对给出的密码进行测试,确定这个密码是不
是弱密码,是不是可以使用。并且我们给出的程序功能,需要自动生成强密码,并对密码进行测试确定不是弱密码。
      在远程和本地监控Windows系统下用户操作行为的过程中,经常需要记录计算机键盘的输入和屏幕的输出。键盘记录
是最古老的黑客技术之一,至今仍在不同的层面广泛使用,攻击者使用它是因为它能有效的捕获所需的敏感信息,如账号
密码和聊天记录等。
      大部分渗透测试框架和恶意软件都具有截取远程目标屏幕的能力,他能捕获打开的图片、播放的视频帧和其他一些敏
感信息,这些信息一般能由数据抓包或键盘记录来获取。

'''
        self.lable=wx.StaticText(self.panel,label=text,pos=(0,50))
        #font=wx.Font(18,wx.DECORATIVE,wx.ITALIC,wx.NORMAL)
        #self.lable.SetFont(font)

        self.Bind(wx.EVT_BUTTON,self.OnNumGame,self.button1)
        self.Bind(wx.EVT_BUTTON,self.OnButton2,self.button2)
        self.Bind(wx.EVT_BUTTON,self.OnFindKey,self.button3)
        self.Bind(wx.EVT_BUTTON,self.OnClose,self.button4)

        self.Bind(wx.EVT_MENU,self.OnNumGame,self.NumberGameMenuItem)
        self.Bind(wx.EVT_MENU,self.OnGenKey,self.GenKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnTestKey,self.TestKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnGenTestKey,self.GenTestKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnEditKey,self.EditKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnFindKey,self.FindKeyMenuItem)
        self.Bind(wx.EVT_MENU,self.OnHelp,self.HelpMenuItem)
        self.Bind(wx.EVT_MENU,self.OnAbout,self.AboutMenuItem)
        self.Bind(wx.EVT_MENU,self.OnClose,self.CloseMenuItem)


        self.mainSizer=wx.BoxSizer(wx.VERTICAL)
        self.btSizer=wx.BoxSizer(wx.HORIZONTAL)
        self.btSizer.Add(self.button1,wx.EXPAND)
        self.btSizer.Add(self.button2,wx.EXPAND)
        self.btSizer.Add(self.button3,wx.EXPAND)
        self.btSizer.Add(self.button4,wx.EXPAND)
        self.mainSizer.Add(self.btSizer,0,wx.EXPAND|wx.BOTTOM)
        self.panel.SetSizer(self.mainSizer)
        self.statusBar=self.CreateStatusBar()
        self.statusBar.SetStatusText(u"密码工具", 0)

    def OnNumGame(self,event):
        NumGame()

    def OnGenKey(self,event):
        GenKey()  
                
    def OnTestKey(self,event):
        TestKey()
        
    def OnGenTestKey(self,event):
        GenTestKey()
        
    def OnEditKey(self,event):
        EditKey()
                                                     
    def OnButton2(self,event):
        frame1=Frame1(self,-1,'密码工具')
        frame1.Center()
        frame1.Show(True)

    def OnFindKey(self,event):
        #wx.MessageBox("侦测邮箱密码,确认后请 稍侯......")
        #sniff(filter="tcp port 110 or tcp port 25 or tcp port 143",prn=packet_callback,timeout=10)
        #newPassword=raw_input('input you password pleas:')
        #password=genPass(newPassword)        
        dlg=wx.TextEntryDialog(None,"请输入八位以内需要破解的密码:")
        if dlg.ShowModal() == wx.ID_OK:
            response=dlg.GetValue()
            password=str(response)
            #word=scanPass(password)
            
        """暴力破解密码"""
        charList = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
	                'n','o','p','q','r','s','t','u','v','w','x','y','z',
	                'A','B','C','D','E','F','G','H','I','J','K','L','M',
	                'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
	                '0','1','2','3','4','5','6','7','8','9','0',
	                '~','!','@','#','$','%','^','&','*','(',')','-','=','+','_']
    
        string = ''
        for l0 in range(len(charList)):
            string=(charList[l0])
            print(string)
            #self.lable.SetLabel(string)
            #self.statusBar.SetStatusText(string, 0)
            if password == string:
                print('password is: '+string)
                wx.MessageBox("password is: "+string)
                return(string)
            
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                string=(charList[l0]+charList[l1])
                print(string)
                #self.lable.SetLabel(string)
                #self.statusBar.SetStatusText(string, 0)
                if password == string:
                    print('password is: '+string)
                    wx.MessageBox("password is: "+string)
                    return(string)
            
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    string=(charList[l0]+charList[l1]+charList[l2])
                    print(string)
                    #self.lable.SetLabel(string)
                    #self.statusBar.SetStatusText(string, 0)
                    if password == string:
                        print('password is: '+string)
                        wx.MessageBox("password is: "+string)
                        return(string)
                    
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        string=(charList[l0]+charList[l1]+charList[l2]+charList[l3])
                        print(string)
                        #self.lable.SetLabel(string)
                        #self.statusBar.SetStatusText(string, 0)
                        if password == string:
                            print('password is: '+string)
                            wx.MessageBox("password is: "+string)
                            return(string)
                        
        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4])
                            print(string)
                            #self.lable.SetLabel(string)
                            #self.statusBar.SetStatusText(string, 0)
                            if password == string:
                                print('password is: '+string)
                                wx.MessageBox("password is: "+string)
                                return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5])
                                print(string)
                                #self.lable.SetLabel(string)
                                #self.statusBar.SetStatusText(string, 0)
                                if password == string:
                                    print('password is: '+string)
                                    wx.MessageBox("password is: "+string)
                                    return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                for l6 in range(len(charList)):
                                    string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6])
                                    print(string)
                                    #self.lable.SetLabel(string)
                                    #self.statusBar.SetStatusText(string, 0)
                                    if password == string:
                                        print('password is: '+string)
                                        wx.MessageBox("password is: "+string)
                                        return(string)

        for l0 in range(len(charList)):
            for l1 in range(len(charList)):
                for l2 in range(len(charList)):
                    for l3 in range(len(charList)):
                        for l4 in range(len(charList)):
                            for l5 in range(len(charList)):
                                for l6 in range(len(charList)):
                                    for l7 in range(len(charList)):
                                        string=(charList[l0]+charList[l1]+charList[l2]+charList[l3]+charList[l4]+charList[l5]+charList[l6]+charList[l7])
                                        print(string)
                                        #self.lable.SetLabel(string)
                                        #self.statusBar.SetStatusText(string, 0)
                                        if password == string:
                                            print('password is: '+string)
                                            wx.MessageBox("password is: "+string)
                                            return(string)                                                                        

        wx.MessageBox("password is: ")
        return(string)            
                   
        #self.statusBar.SetStatusText(u"密码:"+word, 0)
        #self.lable.SetLabel("密码:"+word)
            
            
    def OnHelp(self,event):
        frame2=Frame2(self,-1,'帮助')
        frame2.Center()
        frame2.Show(True)

    def OnAbout(self,event):
        wx.MessageBox("密码工具软件  作者:郑瑞国")
    
    def OnClose(self,event):
         self.Close()
        
class App(wx.App):
    def OnInit(self):
        self.frame=Frame(None,-1,'密码生成与测试工具')
        self.frame.Center()
        self.frame.Show(True)
        self.SetTopWindow(self.frame)
        return True
              
#newPassword=raw_input('input you password pleas:')
#password=genPass(newPassword)

if __name__ == "__main__":        
    app=App()
    app.MainLoop()