Advertisement
Guest User

Untitled

a guest
Jan 29th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.55 KB | None | 0 0
  1. # main.py
  2. if __name__ == '__main__':
  3.     from lib import GUI as gui
  4.     from lib import Settings
  5.     from lib import Sqlite
  6.     import os
  7.     import PySimpleGUI as Sg
  8.  
  9.     path = os.path.dirname(os.path.realpath(__file__))
  10.     print(path)
  11.     name = 'database'
  12.     db = ''
  13.     loggedin = False
  14.     created = False
  15.     # the currently open case
  16.     active_case = ''
  17.  
  18.  
  19.     def makeCase(number, title, note):
  20.         values = {"number": number, "title": title, "note": note}
  21.         db.set_case(values)
  22.  
  23.     # The layout of the window is created with the 'layout' variable
  24.     layout = [[Sg.Text('At which location would you like to save the TUF database?')],
  25.               [Sg.Input(path), Sg.FolderBrowse()],
  26.               [Sg.T(' ' * 25), Sg.Button('Yes'), Sg.Button('No')]]
  27.     startWindow = Sg.Window('TUF - Turtle Forensics', icon='ICON.ico').Layout(layout)
  28.  
  29.     createCaseWindow2_active = createCaseWindow_active = win4_active = loggedWindow_active = loginWindow_active = False
  30.  
  31.     while True:
  32.         ev1, vals1 = startWindow.Read()
  33.         # If the 'close' button is pushed the program is going to stop with running
  34.         if ev1 is None:
  35.             break
  36.         # If the 'No' button is pushed the program is going to stop with running
  37.         if ev1 == 'No':
  38.             break
  39.         # If the 'Yes' button is pushed the program is going to save the database in the location you've chose
  40.         if ev1 == 'Yes':
  41.             if path != vals1[0]:
  42.                 path = vals1[0]
  43.             db = Sqlite.Sqlite(path, name)
  44.             db.setup_database()
  45.         # If the 'Yes' button is pushed the program is going to activate the 2nd window and hide the previous window.
  46.         if not loginWindow_active and ev1 == 'Yes':
  47.             loginWindow_active = True
  48.             startWindow.Hide()
  49.             # The layout of the window is created with the 'layout' variable
  50.             layout2 = [[Sg. Text('Login as a TUF user or create a new user account.')],
  51.                        [Sg.Text('Username'), Sg.Input()],
  52.                        [Sg.Text('Password'), Sg.Input(password_char='*')],
  53.                        [Sg.Button('Login'), Sg.Button('Create User')]]
  54.             loginWindow = Sg.Window('TUF - Turtle Forensics', size=(400, 300), icon='ICON.ico').Layout(layout2)
  55.  
  56.         if loginWindow_active:
  57.             ev2, vals2 = loginWindow.Read()
  58.  
  59.             if ev2 == "Create User":
  60.                 created = False
  61.                 while created is False:
  62.                     username = vals2[0]
  63.  
  64.                     print("creating")
  65.  
  66.                     if ev2 == 'Create User':
  67.                         values = [vals2[0], vals2[1]]
  68.                         check_created = db.check_exist(username)
  69.  
  70.                         if check_created == vals2[0]:
  71.                             created = True
  72.                             Sg.Popup("This user already exists!")
  73.                             ev2, vals2 = loginWindow.Read()
  74.  
  75.                         else:
  76.                             db.set_user(values)
  77.                             Sg.Popup("The user with the name " + vals2[0] + " has been created!")
  78.                             loggedin = True
  79.                             created = False
  80.                         break
  81.  
  82.                     if ev2 is None:
  83.                         break
  84.             else:
  85.                 while loggedin is False:
  86.                     username = vals2[0]
  87.                     password = vals2[1]
  88.                    
  89.                     if ev2 == 'Login':
  90.                         check_loggedin = db.check_user(username, password)
  91.  
  92.                         if check_loggedin is True:
  93.                             loggedin = True
  94.                             Sg.Popup("You've been logged in successfully! Welcome " + vals2[0] + "!")
  95.                             break
  96.  
  97.                         elif check_loggedin is False:
  98.                             loggedin = False
  99.                             Sg.Popup("This combination of username and password does not exist.")
  100.                             ev2, vals2 = loginWindow.Read()
  101.  
  102.                         else:
  103.                             Sg.Popup("Something went wrong. Try again.")
  104.                             loggedin = False
  105.  
  106.         if not loggedWindow_active and loggedin is True and created is False:
  107.             cases = db.get_cases()
  108.             table = Sg.Table(cases,
  109.                              headings=["case", "case id", "title", "description", "date created"],
  110.                              enable_events=True)
  111.             loggedWindow_active = True
  112.             loginWindow.Hide()
  113.             # The layout of the window is created with the 'layout' variable
  114.             layout3 = [[Sg.T(' ' * 20), Sg.Text('Welcome to Turtle Forensics!')],
  115.                        [Sg.Text('', key='OUTPUT')],
  116.                        [Sg.Text('Would you like to create a new case or open a recent one?')],
  117.                        [table],
  118.                        [Sg.Button('Open Case'), Sg.Button('Create Case')]]
  119.             loggedWindow = Sg.Window('TUF - Turtle Forensics', icon='ICON.ico').Layout(layout3)
  120.  
  121.             while True:
  122.                 if loggedWindow_active:
  123.                     ev3, vals3 = loggedWindow.Read()
  124.  
  125.                     if ev3 == 'clicked':
  126.  
  127.                         Sg.Popup(vals3)
  128.                     if ev3 == 'Open Case':
  129.                         active_case = cases[vals3[0][0]][0]
  130.                         break
  131.  
  132.                     if ev3 is None:
  133.                         break
  134.  
  135.                 if not createCaseWindow_active and ev3 == 'Create Case':
  136.                     createCaseWindow_active = True
  137.                     loggedWindow.Hide()
  138.                     # The layout of the window is created with the 'layout' variable
  139.                     layout4 = [[Sg.Text('Case Number: '), Sg.Input()],
  140.                                [Sg.Text('Case Title:      '), Sg.Input('')],
  141.                                [Sg.Text('Case Note:     '), Sg.Input()],
  142.                                [Sg.Button('Back'), Sg.Button('Save Case')]]
  143.                     createCaseWindow = Sg.Window('Turtle Forensics - Create Case', icon='ICON.ico').Layout(layout4)
  144.  
  145.                     if createCaseWindow_active and loggedin is True:
  146.                         ev4, vals4 = createCaseWindow.Read()
  147.                         if ev4 == 'Save Case':
  148.                             x = ev4, vals4[0]
  149.                             number = x[1]
  150.                             y = ev4, vals4[1]
  151.                             title = y[1]
  152.                             z = ev4, vals4[2]
  153.                             note = z[1]
  154.  
  155.                             makeCase(number, title, note)
  156.                             Sg.Popup('The case: ', title, 'has been made.', icon='ICON.ico')
  157.  
  158.                             createCaseWindow2_active = True
  159.                             createCaseWindow_active = False
  160.                             createCaseWindow.Hide()
  161.                             # The layout of the window is created with the 'layout' variable
  162.                             layout5 = [[Sg.Radio('E01', "Image", key='E01'), Sg.Radio('RAW', "Image", key='RAW')],
  163.                                        [Sg.Text('Image source:    '), Sg.Input(), Sg.FolderBrowse()],
  164.                                        [Sg.Checkbox('Hash Image after Indexing')],
  165.                                        [Sg.Button('Back'), Sg.Button('Save')]]
  166.                             createCaseWindow2 = Sg.Window('Turtle Forensics - Create Case', icon='ICON.ico').Layout(layout5)
  167.  
  168.                     if createCaseWindow2_active:
  169.                         ev5, vals5 = createCaseWindow2.Read()
  170.  
  171.                         if ev5 == 'Save':
  172.                             if vals5['E01']:
  173.                                 print('e01')
  174.                             if vals5['RAW']:
  175.                                 print('raw')
  176.  
  177.                 # case overview
  178.                 if not createCaseWindow2_active and ev3 == 'Open Case' and loggedin is True:
  179.                     case = db.get_case(active_case)
  180.                     loggedWindow.Hide()
  181.                     print(case)
  182.                     layout5 = [[Sg.Radio('E01', "Image", key='e01'), Sg.Radio('RAW', "Image", key='RAW')],
  183.                                [Sg.Text('Image source:    '), Sg.Input(), Sg.FolderBrowse()],
  184.                                [Sg.Checkbox('Hash Image after Indexing')],
  185.                                [Sg.Button('Back'), Sg.Button('Save')]]
  186.                     createCaseWindow2 = Sg.Window('Turtle Forensics - case ' + str(case[2]), icon='ICON.ico').Layout(layout5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement