Advertisement
Guest User

Untitled

a guest
Aug 16th, 2015
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.19 KB | None | 0 0
  1. #!/usr/bin/python
  2. import wx
  3. import datetime
  4.  
  5. def genSeed(t1):
  6.     dt = t1 - datetime.datetime(1601, 1, 1, 0, 0, 0)
  7.     t = dt.days*864000000000 + dt.seconds*10000000 + dt.microseconds*10
  8.  
  9.     tA = (t/2**32 + 0xFE624E21)
  10.     tB = (t%2**32 + 0x2AC18000) % (1<<32)
  11.  
  12.     if tA >= (1<<32):
  13.         tA += 1
  14.         tA %= 1<<32
  15.  
  16.     r = (tA % 0x989680) * (2**32)
  17.     r = ((r + tB) / 0x989680) % (2**31)
  18.     return r
  19.  
  20.  
  21. def monthDays(month,year):
  22.     if month in [11, 4, 6, 9]:
  23.         return 30
  24.     if month in [1, 3, 5, 7, 8, 10, 12]:
  25.         return 31
  26.     if year % 4 == 0 and year % 100 != 0:
  27.         return 29
  28.     if year % 400 == 0:
  29.         return 29
  30.     return 28
  31.  
  32.  
  33. def prettyBytes(size):
  34.     for x in ['B','KB','MB','GB']:
  35.         if size < 1024.0:
  36.             return "%3.1f %s" % (size, x)
  37.         size /= 1024.0
  38.  
  39.  
  40. def prettySeconds(time):
  41.     for x in [[60.,'sec.'],[60.,'min.'],[24.,'hours'],[365.,'days']]:
  42.         if time < x[0]:
  43.             return "%3.1f %s" % (time, x[1])
  44.         time /= x[0]
  45.  
  46.  
  47.  
  48. class MainFrame(wx.Frame):
  49.  
  50.     def __init__(self, *args, **kwargs):
  51.         super(MainFrame, self).__init__(*args, **kwargs)
  52.         self.InitUI()
  53.  
  54.  
  55.     def InitUI(self):
  56.         self.panel = wx.Panel(self,-1)
  57.  
  58.         #Window
  59.         self.sb = self.CreateStatusBar(style=0)
  60.         self.sb.SetStatusText("  v1.0 - 10.03.2013  |  alexaltea123@gmail.com")
  61.         self.sb.SetForegroundColour(wx.RED)
  62.         self.SetWindowStyle(wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.CAPTION | wx.CLIP_CHILDREN | wx.SYSTEM_MENU)
  63.         self.SetSize((460, 460))
  64.         self.SetTitle('TP-Link Routers: Seed Generator')
  65.  
  66.         #Static
  67.         months = ['January', 'February', 'March', 'April', 'May', 'June',
  68.                   'July', 'August', 'September', 'October', 'November', 'December']
  69.  
  70.         #Frame: Select Method
  71.         self.method1 = wx.RadioButton(self.panel, label='Method 1: Get seeds between two dates.', pos=(20, 15), style=wx.RB_GROUP)
  72.         self.method2 = wx.RadioButton(self.panel, label='Method 2: Get seeds before or after a certain date.', pos=(20, 135))
  73.         wx.StaticBox(self.panel, pos=(30,34), size=(396,80))
  74.         wx.StaticBox(self.panel, pos=(30,154), size=(396,80))
  75.  
  76.         #Frame: Method 1
  77.         wx.StaticText(self.panel, label="Start date:", pos=(50, 50+4))
  78.         wx.StaticText(self.panel, label="End date:", pos=(50, 82+2))
  79.         self.year1  = wx.SpinCtrl(self.panel, pos=(160, 50), size=(60, -1))
  80.         self.year2  = wx.SpinCtrl(self.panel, pos=(160, 82), size=(60, -1))
  81.         self.month1 = wx.ComboBox(self.panel, pos=(230, 50), size=(120,-1), choices=months, style=wx.CB_READONLY)
  82.         self.month2 = wx.ComboBox(self.panel, pos=(230, 82), size=(120,-1), choices=months, style=wx.CB_READONLY)
  83.         self.day1 = wx.SpinCtrl(self.panel, pos=(360, 50), size=(50,-1))
  84.         self.day2 = wx.SpinCtrl(self.panel, pos=(360, 82), size=(50,-1))
  85.  
  86.         timenow = datetime.datetime.utcnow()
  87.         self.year1.SetRange(1601, timenow.year)
  88.         self.year2.SetRange(1601, timenow.year)
  89.         self.year1.SetValue(2010)
  90.         self.year2.SetValue(timenow.year)
  91.  
  92.         self.month1.SetValue('January')
  93.         self.month2.SetValue(months[timenow.month-1])
  94.         self.day1.SetValue(1)
  95.         self.day2.SetValue(timenow.day)
  96.  
  97.         #Frame: Method 2
  98.         wx.StaticText(self.panel, label="Select date:", pos=(50,170+4))
  99.         wx.StaticText(self.panel, label="Margin of error:", pos=(50,202+4))
  100.         wx.StaticText(self.panel, label="day(s)", pos=(230,202+4))
  101.         self.year3  = wx.SpinCtrl(self.panel, pos=(160, 170), size=(60, -1))
  102.         self.month3 = wx.ComboBox(self.panel, pos=(230, 170), size=(120,-1), choices=months, style=wx.CB_READONLY)
  103.         self.day3 = wx.SpinCtrl(self.panel, pos=(360, 170), size=(50,-1))
  104.         self.dday = wx.SpinCtrl(self.panel, pos=(160, 202), size=(60,-1))
  105.  
  106.         self.year3.SetRange(1601, timenow.year)
  107.         self.year3.SetValue(timenow.year)
  108.         self.month3.SetValue(months[timenow.month-1])
  109.         self.day3.SetValue(timenow.day)
  110.         self.dday.SetRange(1, 65535)
  111.  
  112.         #Frame: Events
  113.         self.method1.Bind(wx.EVT_RADIOBUTTON, self.updateSeeds)
  114.         self.method2.Bind(wx.EVT_RADIOBUTTON, self.updateSeeds)
  115.         self.year1.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  116.         self.year2.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  117.         self.year3.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  118.         self.year1.Bind(wx.EVT_SPINCTRL, lambda e: self.updateDayRange(1))
  119.         self.year2.Bind(wx.EVT_SPINCTRL, lambda e: self.updateDayRange(2))
  120.         self.year3.Bind(wx.EVT_SPINCTRL, lambda e: self.updateDayRange(3))
  121.         self.month1.Bind(wx.EVT_COMBOBOX, self.updateSeeds)
  122.         self.month2.Bind(wx.EVT_COMBOBOX, self.updateSeeds)
  123.         self.month3.Bind(wx.EVT_COMBOBOX, self.updateSeeds)
  124.         self.month1.Bind(wx.EVT_COMBOBOX, lambda e: self.updateDayRange(1))
  125.         self.month2.Bind(wx.EVT_COMBOBOX, lambda e: self.updateDayRange(2))
  126.         self.month3.Bind(wx.EVT_COMBOBOX, lambda e: self.updateDayRange(3))
  127.         self.day1.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  128.         self.day2.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  129.         self.day3.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  130.         self.dday.Bind(wx.EVT_SPINCTRL, self.updateSeeds)
  131.  
  132.         #Frame: Results
  133.         wx.StaticText(self.panel, label="Initial seed:", pos=(30,260+4))
  134.         wx.StaticText(self.panel, label="Final seed:", pos=(30,290+4))
  135.         self.seedAhex = wx.StaticText(self.panel, label=" ", pos=(240,260+4))
  136.         self.seedBhex = wx.StaticText(self.panel, label=" ", pos=(240,290+4))
  137.         self.seedA = wx.TextCtrl(self.panel, pos=(120, 260), size=(100,-1), style=wx.TE_READONLY)
  138.         self.seedB = wx.TextCtrl(self.panel, pos=(120, 290), size=(100,-1), style=wx.TE_READONLY)
  139.  
  140.         #Frame: Info
  141.         self.infoA = wx.StaticText(self.panel, label=" ", pos=(30,340+2))
  142.         self.infoB = wx.StaticText(self.panel, label=" ", pos=(30,365+2))
  143.         self.infoC = wx.StaticText(self.panel, label=" ", pos=(30,390+2))
  144.  
  145.         #Frame: Calls
  146.         self.updateSeeds(0)
  147.         self.updateDayRange(1)
  148.         self.updateDayRange(2)
  149.         self.updateDayRange(3)
  150.  
  151.         self.Show(True)
  152.  
  153.  
  154.     def updateSeeds(self, e):
  155.         months = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6,
  156.                   'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}
  157.         #Using Method 1
  158.         if self.method1.GetValue():
  159.             timeA = datetime.datetime(
  160.                 self.year1.GetValue(),
  161.                 months[self.month1.GetValue()],
  162.                 self.day1.GetValue(),
  163.                 0,0,0)
  164.             timeB = datetime.datetime(
  165.                 self.year2.GetValue(),
  166.                 months[self.month2.GetValue()],
  167.                 self.day2.GetValue(),
  168.                 0,0,0)
  169.             seedA = genSeed(timeA)
  170.             seedB = genSeed(timeB)
  171.             if seedA > seedB:
  172.                 seedA, seedB = seedB, seedA
  173.             if seedA == seedB:
  174.                 seedB += 24*60*60
  175.  
  176.         #Using Method 2
  177.         if self.method2.GetValue():
  178.             time = datetime.datetime(
  179.                 self.year3.GetValue(),
  180.                 months[self.month3.GetValue()],
  181.                 self.day3.GetValue(),
  182.                 0,0,0)
  183.             dtime = datetime.timedelta(
  184.                 days=self.dday.GetValue()
  185.                 )
  186.             seedA = genSeed(time-dtime)
  187.             seedB = genSeed(time+dtime)
  188.  
  189.         self.seedA.SetValue(str(seedA))
  190.         self.seedB.SetValue(str(seedB))
  191.         self.seedAhex.SetLabel("Hex: " + hex(seedA)[2:].upper().replace('L',''))
  192.         self.seedBhex.SetLabel("Hex: " + hex(seedB)[2:].upper().replace('L',''))
  193.  
  194.         infoB = prettyBytes(11*(seedB-seedA+1))
  195.         infoB += " (WPA/WPA2) or "
  196.         infoB += prettyBytes(14*(seedB-seedA+1))
  197.         infoB += " (WEP)"
  198.  
  199.         infoC = prettySeconds((seedB-seedA+1)/20000)
  200.         infoC += " (GPU) or "
  201.         infoC += prettySeconds((seedB-seedA+1)/2000)
  202.         infoC += " (CPU)"
  203.  
  204.         self.infoA.SetLabel("Total seeds/passwords:    "+str(seedB-seedA+1))
  205.         self.infoB.SetLabel("Size of dictionary:             "+infoB)
  206.         self.infoC.SetLabel("Est. time of cracking:       "+infoC)
  207.  
  208.  
  209.  
  210.     def updateDayRange(self, dayID):
  211.         months = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6,
  212.                   'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}
  213.         if dayID == 1:
  214.             year = self.year1.GetValue()
  215.             month = months[self.month1.GetValue()]
  216.             self.day1.SetRange(1, monthDays(month,year))
  217.         if dayID == 2:
  218.             year = self.year2.GetValue()
  219.             month = months[self.month2.GetValue()]
  220.             self.day2.SetRange(1, monthDays(month,year))
  221.         if dayID == 3:
  222.             year = self.year3.GetValue()
  223.             month = months[self.month3.GetValue()]
  224.             self.day3.SetRange(1, monthDays(month,year))
  225.         self.updateSeeds(0)
  226.  
  227.  
  228.  
  229. def init(self):
  230.     ex = wx.App(0)
  231.     MainWindow = MainFrame(None)
  232.     ex.MainLoop()
  233.     return 0
  234.  
  235. if __name__ == '__main__':
  236.     init(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement