コード例 #1
0
ファイル: profs.py プロジェクト: waflia/linux_audit
class main_Tab:
    def __init__(self, master, main_path=''):
        self.main_path = main_path
        self.master = master
        self.modules_config = {}  #{module_name : }
        self.modules = {}

        self.fio = ''
        self.org = ''

        #Профили аудита
        self.profiles = {}
        self.current_profile_options = {}

        #Левый фрейм включает данные об аудиторе и о существующих профилях
        leftFrame = ttk.Frame(master)
        self.auditor_Frame = ttk.LabelFrame(leftFrame, text='Данные аудитора')
        self.profiles_Frame = VerticalScrolledFrame(leftFrame,
                                                    text='Профили аудита')

        #Правый фрейм включает редактор текущего профиля и кнопку запуска аудита
        rightFrame = ttk.Frame(master)
        self.current_Frame = ttk.LabelFrame(rightFrame, text='Текущий профиль')
        self.btn_Frame = ttk.Frame(rightFrame)

        #Область данных об аудиторе
        fio_Label = ttk.Label(self.auditor_Frame, text='ФИО')
        self.fio_Entry = ttk.Entry(self.auditor_Frame, font=16, width=30)
        self.fio_Label = ttk.Label(self.auditor_Frame, font=16, width=30)
        org_Label = ttk.Label(self.auditor_Frame, text='Организация')
        self.org_Entry = ttk.Entry(self.auditor_Frame, font=16, width=30)
        self.org_Label = ttk.Label(self.auditor_Frame, font=16, width=30)
        self.fio_OK_btn = ttk.Button(self.auditor_Frame,
                                     text='OK',
                                     width=5,
                                     command=self.accept_auditor)

        fio_Label.grid(row=1, column=0, sticky='new', padx=10)
        self.fio_Entry.grid(row=2, column=0, sticky='nsew', padx=10)
        org_Label.grid(row=3, column=0, sticky='new', padx=10)
        self.org_Entry.grid(row=4, column=0, sticky='nsew', padx=10)
        self.fio_OK_btn.grid(row=5, column=0, sticky='se', padx=10)

        self.profileView = CheckboxTreeview(self.current_Frame)
        self.save_audit_btn = ttk.Button(self.btn_Frame,
                                         text='Сохранить профиль',
                                         command=self.save_btn_click)
        self.run_audit_btn = ttk.Button(self.btn_Frame,
                                        text='Запустить аудит',
                                        command=self.run_audit)

        self.ysb = ttk.Scrollbar(self.current_Frame,
                                 orient='vertical',
                                 command=self.profileView.yview)
        self.profileView.configure(yscroll=self.ysb.set)
        ttk.Style().configure('Vertical.TScrollbar',
                              troughcolor='#f6f4f2',
                              relief=tk.GROOVE)
        ttk.Style().configure('Treeview', background="#ffffff")
        ttk.Style().configure('Frame', background="#f6f4f2")

        #Размещения на фреймах
        leftFrame.pack(side=tk.LEFT, anchor='nw', fill=tk.Y)
        rightFrame.pack(side=tk.LEFT, anchor='nw', expand=1, fill=tk.BOTH)

        self.auditor_Frame.pack(side=tk.TOP,
                                anchor='nw',
                                padx=5,
                                pady=5,
                                fill=tk.X)
        self.profiles_Frame.pack(side=tk.TOP,
                                 anchor='sw',
                                 padx=5,
                                 pady=10,
                                 fill=tk.BOTH,
                                 expand=1)

        self.current_Frame.pack(side=tk.TOP,
                                anchor='nw',
                                padx=5,
                                pady=5,
                                fill=tk.BOTH,
                                expand=1)
        self.btn_Frame.pack(side=tk.TOP, anchor='nw', fill=tk.X)

        self.ysb.pack(side=tk.RIGHT, anchor='n', fill=tk.Y)
        self.profileView.pack(side=tk.TOP, anchor='nw', fill=tk.BOTH, expand=1)
        self.save_audit_btn.pack(side=tk.LEFT, anchor='sw', padx=5, pady=5)
        self.run_audit_btn.pack(side=tk.LEFT,
                                anchor='se',
                                padx=5,
                                pady=5,
                                fill=tk.X,
                                expand=1)

        self.auditor_Frame.grid_rowconfigure(2, minsize=30)
        self.loadProfiles()
        self.profileView.bind("<Button-1>", self.check_uncheck_item, True)

    def run_audit(self):
        for tab_name, tab in self.modules.items():
            tab.run_audit()

    def sync_vars(self):
        for tab_name, tab in self.modules.items():
            if type(self.current_profile_options[tab_name][1]) != type({}):
                i = 0
                for var in tab.vars:
                    var.set(self.current_profile_options[tab_name][1][i])
                    i += 1
            else:
                i = len(tab.vars) - 1
                for second_tab_name, second_tab in self.current_profile_options[
                        tab_name][1].items():
                    for j in range(len(second_tab[1]) - 1, -1, -1):
                        tab.vars[i].set(second_tab[1][j])
                        i -= 1

    def accept_auditor(self):
        if self.fio_OK_btn.cget('text') == 'OK':
            self.fio = self.fio_Entry.get()
            self.org = self.org_Entry.get()

            self.fio_OK_btn.configure(text='Изменить', width=10)

            self.fio_Entry.grid_remove()
            self.org_Entry.grid_remove()

            self.fio_Label.configure(text=self.fio)
            self.org_Label.configure(text=self.org)
            self.fio_Label.grid(row=2, column=0, sticky='nsew', padx=10)
            self.org_Label.grid(row=4, column=0, sticky='nsew', padx=10)
        else:
            self.fio_OK_btn.configure(text='OK', width=5)
            self.fio_Entry.grid()
            self.org_Entry.grid()

            self.fio_Label.grid_remove()
            self.org_Label.grid_remove()

    def loadProfiles(self):
        for child in self.profiles_Frame.interior.winfo_children():
            child.destroy()
        #self.profiles_Frame.pack(side=tk.TOP, anchor='sw', padx=5, pady = 10, fill=tk.BOTH, expand=1)
        try:
            with open(self.main_path + '/profiles.json') as file:
                self.profiles = json.load(file)
        except:
            with open(self.main_path + '/profiles.json', 'w') as file:
                json.dump(self.profiles, file)

        prof_count = len(self.profiles)
        self.var = tk.IntVar()
        for i in range(prof_count):
            tk.Radiobutton(self.profiles_Frame.interior,
                           variable=self.var,
                           value=i,
                           indicator=0,
                           height=3,
                           text=list(self.profiles.keys())[i],
                           selectcolor="#f19572",
                           activebackground="#f19572",
                           command=self.changeCurrentProfile).pack(side=tk.TOP,
                                                                   anchor='nw',
                                                                   fill=tk.X,
                                                                   padx=5,
                                                                   pady=2)

    def dumpProfiles(self):
        with open(self.main_path + '/profiles.json', 'w') as file:
            json.dump(self.profiles, file)

    def changeCurrentProfile(self):
        currentProfileName = list(self.profiles.keys())[self.var.get()]
        self.current_profile_options = copy.deepcopy(
            self.profiles[currentProfileName])
        self.profileView.heading('#0',
                                 text=list(
                                     self.profiles.keys())[self.var.get()],
                                 anchor='w')
        self.initTree()
        self.sync_vars()
        #self.profiles_Label.configure(text=self.var.get())

    def save_btn_click(self):
        self.saveDialog = tk.Toplevel()
        save_frame = ttk.Frame(self.saveDialog)
        self.saveDialog.focus_set()

        width = self.master.winfo_screenwidth() // 5 + 96
        height = self.master.winfo_screenheight() // 5
        dw = (self.master.winfo_screenwidth() - width) // 2
        dh = (self.master.winfo_screenheight() - height) // 2
        self.saveDialog.geometry('{}x{}+{}+{}'.format(width, height, dw, dh))

        self.saveDialog.resizable(False, False)
        self.saveDialog.title('Сохранение профиля')

        # Настройка виджетов в окне ввода пароля
        save_Label = ttk.Label(save_frame, text='Названия профиля')
        self.save_Entry = ttk.Entry(save_frame, font=16)
        save_Btn = ttk.Button(save_frame, text='Сохранить', width=15)

        self.save_Entry.bind('<Return>', self.save_click)
        save_Btn.bind('<Button-1>', self.save_click)

        save_Label.grid(row=1, column=0)
        self.save_Entry.grid(row=2, column=0, padx=10, sticky='nsew')
        save_Btn.grid(row=3, column=0, padx=10, pady=20, sticky='e')

        save_frame.pack(fill=tk.BOTH)
        save_frame.grid_rowconfigure(1, minsize=height // 3)
        save_frame.grid_rowconfigure(2, minsize=30)
        save_frame.grid_columnconfigure(0, minsize=width)
        self.save_Entry.focus_set()

    def save_click(self, event):
        """Функция-обработчик нажатия кнопки """
        profile_name = self.save_Entry.get()
        self.profiles[profile_name] = self.current_profile_options
        self.dumpProfiles()
        self.loadProfiles()
        self.saveDialog.destroy()
        self.initTree()

    def initTree(self):
        if self.current_profile_options == {}:
            self.current_profile_options = dict(
                self.profiles["Профиль по умолчанию"])

        for (key, value) in self.current_profile_options.items():
            if self.modules_config.__contains__(key):
                if not self.profileView.exists(key):
                    self.profileView.insert("", "end", key, text=key)

                self.profileView.change_state(key, value[0])
                value = value[1]

                if type(value) == type("1"):
                    i = 0
                    for func_key in self.modules_config[key][0].keys():
                        func_key = func_key.replace('\n', ' ')

                        if not self.profileView.exists(key + func_key + "_" +
                                                       str(i)):
                            self.profileView.insert(key,
                                                    "end",
                                                    key + func_key + "_" +
                                                    str(i),
                                                    text=func_key)

                        if value[i] == '0':
                            self.profileView.change_state(
                                key + func_key + "_" + str(i), 'unchecked')
                        if value[i] == '1':
                            self.profileView.change_state(
                                key + func_key + "_" + str(i), 'checked')
                        i += 1
                else:
                    j = 0
                    for (second_key, second_value) in dict(value).items():

                        if not self.profileView.exists(second_key):
                            self.profileView.insert(key,
                                                    "end",
                                                    second_key,
                                                    text=second_key)

                        self.profileView.change_state(second_key,
                                                      second_value[0])
                        second_value = second_value[1]

                        if type(value[second_key][1]) == type("1"):
                            i = 0
                            for func_key in self.modules_config[key][0][
                                    j].keys():
                                func_key = func_key.replace('\n', ' ')

                                if not self.profileView.exists(second_key +
                                                               func_key + "_" +
                                                               str(i)):
                                    self.profileView.insert(
                                        second_key,
                                        "end",
                                        second_key + func_key + "_" + str(i),
                                        text=func_key)

                                if value[second_key][1][i] == '0':
                                    self.profileView.change_state(
                                        second_key + func_key + "_" + str(i),
                                        'unchecked')
                                if value[second_key][1][i] == '1':
                                    self.profileView.change_state(
                                        second_key + func_key + "_" + str(i),
                                        'checked')
                                i += 1
                        j += 1

    def check_uncheck_item(self, event):
        x, y, widget = event.x, event.y, event.widget
        elem = widget.identify("element", x, y)
        if "image" in elem:
            # a box was clicked
            item = self.profileView.identify_row(y)
            children = self.profileView.get_children(item)
            parents = []
            parent = widget.parent(item)
            i = 0
            while parent != '':
                parents.append(parent)
                parent = widget.parent(parent)
            if parents and children == ():
                tag = self.profileView.item(parents[-1], "tags")
                self.current_profile_options[parents[-1]][0] = tag[0]
                if len(parents) == 2:
                    tag = self.profileView.item(parents[0], "tags")
                    self.current_profile_options[parents[-1]][1][
                        parents[-2]][0] = tag[0]
                    tag = self.profileView.item(item, "tags")

                    i = int(item.split('_')[1])
                    varL = self.current_profile_options[parents[-1]][1][
                        parents[-2]][1][0:i]
                    varR = self.current_profile_options[parents[-1]][1][
                        parents[-2]][1][i + 1:]

                    if "checked" in tag:
                        self.current_profile_options[parents[-1]][1][
                            parents[-2]][1] = varL + '1' + varR
                    else:
                        self.current_profile_options[parents[-1]][1][
                            parents[-2]][1] = varL + '0' + varR
                else:
                    tag = self.profileView.item(item, "tags")

                    i = int(item.split('_')[1])
                    varL = self.current_profile_options[parents[-1]][1][0:i]
                    varR = self.current_profile_options[parents[-1]][1][i + 1:]

                    if "checked" in tag:
                        self.current_profile_options[
                            parents[-1]][1] = varL + '1' + varR
                    else:
                        self.current_profile_options[
                            parents[-1]][1] = varL + '0' + varR
            else:
                tag = self.profileView.item(item, "tags")
                self.current_profile_options[item][0] = tag[0]
                profile_1 = ''
                for child in self.profileView.get_children(item):
                    children = self.profileView.get_children(child)
                    if children != ():
                        tag = self.profileView.item(child, "tags")
                        self.current_profile_options[item][1][child][0] = tag[
                            0]
                        profile = ''
                        for s_child in self.profileView.get_children(child):
                            tag = self.profileView.item(s_child, "tags")
                            if 'checked' in tag:
                                profile += '1'
                            else:
                                profile += '0'
                        self.current_profile_options[item][1][child][
                            1] = profile
                    else:
                        tag = self.profileView.item(child, "tags")
                        if 'checked' in tag:
                            profile_1 += '1'
                        else:
                            profile_1 += '0'
                        self.current_profile_options[item][1] = profile_1
        self.sync_vars()
コード例 #2
0
class PanelMixin:
    def build_right_materials(self, *args, **kwargs):
        for widget in self.right_mat_tab.winfo_children():
            widget.destroy()

        i = 0
        for mat_loc in self.materials.values():
            for (name, (material, button)) in mat_loc.items():
                # for i, (name, (material, button)), in enumerate(self.materials.items()):
                if button is None:
                    button = tk.Button(
                        master=self.right_mat_tab,
                        text=name,
                        bg=material.color,
                        fg=contrasting_text_color(material.color[1:]),
                        command=self.material_button_generator(material))
                print(self.cbtv.get_checked())
                if name in self.cbtv.get_checked():
                    button.grid(column=i % 3,
                                row=i // 3,
                                pady=self.ICON_PADDING,
                                padx=self.ICON_PADDING)
                else:
                    button.grid_forget()
                i += 1

    def build_bottom_bar(self):
        self.shape_frame = tk.Frame(self.bottom_frame)
        self.shape_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        self.coord_frame = tk.Frame(self.bottom_frame)
        self.coord_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        self.fill_frame = tk.Frame(self.bottom_frame)
        self.fill_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        self.snap_frame = tk.Frame(self.bottom_frame)
        self.snap_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)

        line_button = tk.Button(self.shape_frame, text='Line')
        line_button.config(command=self.shape_func_generator([
            partial(self.paint_2pt_shape_start, shape='line'),
            partial(self.paint_2pt_shape_move, shape='line'),
            partial(self.paint_2pt_shape_end, shape='line')
        ], line_button))
        line_button.grid(row=0, column=0)

        rectangle_button = tk.Button(self.shape_frame, text='Rectangle')
        rectangle_button.config(command=self.shape_func_generator([
            partial(self.paint_2pt_shape_start, shape='rectangle'),
            partial(self.paint_2pt_shape_move, shape='rectangle'),
            partial(self.paint_2pt_shape_end, shape='rectangle')
        ], rectangle_button))
        rectangle_button.grid(row=1, column=0)

        circle_button = tk.Button(self.shape_frame, text='Circle')
        circle_button.config(command=self.shape_func_generator([
            partial(self.paint_2pt_shape_start, shape='circle'),
            partial(self.paint_2pt_shape_move, shape='circle'),
            partial(self.paint_2pt_shape_end, shape='circle')
        ], circle_button))
        circle_button.grid(row=0, column=1)

        ellipse_button = tk.Button(self.shape_frame, text='Ellipse')
        ellipse_button.config(
            command=self.shape_func_generator('ellipse', ellipse_button))
        ellipse_button.grid(row=1, column=1)

        arc_button = tk.Button(self.shape_frame, text='Arc')
        arc_button.config(command=self.shape_func_generator([
            partial(self.paint_3pt_shape_start, shape='arc'),
            partial(self.paint_3pt_shape_move_1st, shape='arc'),
            partial(self.paint_3pt_shape_2nd_pt, shape='arc')
        ], arc_button))
        arc_button.grid(row=0, column=2)

        ellipse_button.config(state=tk.DISABLED)
        arc_button.config(state=tk.DISABLED)

        freehand_button = tk.Button(self.shape_frame, text='Freehand')
        freehand_button.config(command=self.shape_func_generator([
            self.paint_freehand_start, self.paint_freehand_move,
            self.paint_freehand_end
        ], freehand_button))
        freehand_button.grid(row=1, column=2)

        self.shape_buttons = [
            line_button, rectangle_button, circle_button, ellipse_button,
            arc_button, freehand_button
        ]

        ttk.Separator(self.shape_frame,
                      orient=tk.VERTICAL).grid(row=0,
                                               column=3,
                                               rowspan=2,
                                               sticky=tk.N + tk.S)
        self.increase_scaling_factor = tk.Button(self.coord_frame,
                                                 text='Zoom In',
                                                 command=self.zoom_in)
        self.decrease_scaling_factor = tk.Button(self.coord_frame,
                                                 text='Zoom Out',
                                                 command=self.zoom_out)
        self.increase_scaling_factor.grid(row=1, column=0)
        self.decrease_scaling_factor.grid(row=1, column=1)

        # self.scaling_factor_scale = tk.Scale(self.coord_frame, from_=1, to=20, orient=tk.HORIZONTAL, command=self.rebuild_img, repeatinterval=300)
        # self.scaling_factor_scale.set(self.scaling_factor)
        # self.scaling_factor_scale.grid(row=1, column=0, columnspan=2, sticky=tk.E+tk.W)
        ttk.Separator(self.coord_frame,
                      orient=tk.VERTICAL).grid(row=0,
                                               column=2,
                                               rowspan=2,
                                               sticky=tk.N + tk.S)
        show_button = tk.Button(self.snap_frame,
                                text='show',
                                command=self.show_bitmap)
        show_button.pack()
        # delete_button = tk.Button(self.shape_frame, text='Delete')
        # freehand_button.config(command=selection_fro.erasor_bind)
    def show_bitmap(self):
        print(self.bitmap)
        top = tk.Toplevel()
        img = Image.fromarray(self.bitmap)
        img = img.convert('RGB')
        img.show()
        img = ImageTk.PhotoImage(image=img)
        logolbl = tk.Label(top, image=img)
        logolbl.grid()

    def build_left_objects_notebook(self):
        self.left_obj_tab = tk.Frame(self.left_notebook)
        self.left_notebook.add(self.left_obj_tab, text='Objects')

    def build_left_materials_notebook(self):
        self.left_mat_tab = tk.Frame(self.left_notebook)
        self.left_notebook.add(self.left_mat_tab, text='Materials')

    def build_left_materials(self):
        self.cbtv = CheckboxTreeview(master=self.left_mat_tab)
        self.cbtv.pack()
        for cat_name, mat_cat in self.materials.items():
            self.cbtv.insert("", "end", cat_name, text=cat_name)
            for name, (mat, button) in mat_cat.items():
                self.cbtv.insert(cat_name, "end", name, text=name)
                # var = cb
                # check = tk.Checkbutton(master=self.left_mat_tab, text=name, variable=var)
                # check.pack(side=tk.TOP)
        self.cbtv.bind('<<TreeviewSelect>>', self.build_right_materials)

    def build_right_materials_notebook(self):
        self.right_mat_tab = tk.Frame(self.right_notebook)
        self.right_notebook.add(self.right_mat_tab, text='Materials')

        self.build_right_materials()

    def build_right_objects_notebook(self):
        self.right_obj_tab = tk.Frame(self.right_notebook)
        self.right_notebook.add(self.right_obj_tab, text='Objects')
        self.build_right_objects()

    def build_right_objects(self):
        for i, icon in enumerate(glob.glob('../game/data/images/*')):
            col = i % 3
            row = i // 3
            print(row, col)
            img = Image.open(icon)
            img = img.resize((50, 50), Image.ANTIALIAS)
            self.object_icons.append(ImageTk.PhotoImage(img))
            button = tk.Button(self.right_obj_tab,
                               image=self.object_icons[-1],
                               text=icon.split('/')[-1],
                               compound='top')
            # self.buttons.append(button)
            button.grid(row=row,
                        column=col,
                        pady=self.ICON_PADDING,
                        padx=self.ICON_PADDING)

    def undo(self, event):
        print('undo!')
        if self.current_paint_stroke == 0:
            return
        self.current_paint_stroke -= 1
        self.scene_view.delete('stroke_' + str(self.current_paint_stroke))

    def shape_func_generator(self, paint_functions, button):
        def func():
            for b in self.shape_buttons:
                b.config(fg=self.fg_default, bg=self.bg_default)
            button.config(fg=self.active_shape_fg, bg=self.active_shape_bg)
            self.scene_view.bind("<Button-1>", paint_functions[0])
            self.scene_view.bind("<B1-Motion>", paint_functions[1])
            self.scene_view.bind("<ButtonRelease-1>", paint_functions[2])
            self.active_shape_button = button

        return func

    def material_button_generator(self, material):
        def func():
            self.current_material = material
            bg = material.color
            fg = contrasting_text_color(material.color[1:])
            self.active_shape_fg = fg
            self.active_shape_bg = bg
            if self.active_shape_button is not None:
                self.active_shape_button.config(fg=fg, bg=bg)

        return func
コード例 #3
0
ファイル: Main.py プロジェクト: akpysec/GUISecurityAudit
def Main():
    window = tkinter.Tk()
    window.title('Security Checker')  # Title
    window.geometry('500x350+450+200')  # Resolution
    window['padx'] = 8
    # window.iconbitmap(default="Appwheel.ico")  # App icon
    title_font = tkfont.Font(family='Arial', size=10,
                             weight="bold")  # Fonts within the App
    label1 = ttk.Label(text="Check the boxes:",
                       font=title_font)  # Writings within the App
    label1.grid(row=0, column=0, sticky="nw", pady=8)

    window.grid_columnconfigure(0, weight=1)
    window.grid_columnconfigure(1, weight=1)
    window.grid_columnconfigure(2, weight=3)
    window.grid_columnconfigure(3, weight=2)
    window.grid_columnconfigure(4, weight=2)
    window.grid_rowconfigure(0, weight=1)
    window.grid_rowconfigure(1, weight=10)
    window.grid_rowconfigure(2, weight=2)
    window.grid_rowconfigure(3, weight=3)
    window.grid_rowconfigure(4, weight=3)

    tree = CheckboxTreeview  # Variable tree equals tree view
    # Edit dictionaries as you like
    # Dict #1
    cisco = {
        1: "enable secret",
        2: "aaa new-model",
        3: "service-password encryption",
        4: "ip ssh version 2",
        5: "motd",
        6: "no logging console",
        7: "no logging monitor",
        8: "vtp password"
    }
    # Dict 2
    smbv1_patch = {
        100: "KB4012598",
        101: "KB4012212",
        102: "KB4012215",
        103: "KB4012213",
        104: "KB4012216",
        105: "KB4012214",
        106: "KB4012217",
        107: "KB4012606",
        108: "KB4013198",
        109: "KB4013429"
    }

    # What should not be present in a configuration files
    should_not_be = [
        "enable password", "snmp-server community public",
        "transport input telnet", "EnableSMB1Protocol              : True"
    ]

    scrollbar1 = ttk.Scrollbar(window, orient="vertical",
                               command=tree.yview)  # Scroll bar
    scrollbar1.grid(row=1, column=6, sticky='nse')

    tree = CheckboxTreeview(yscrollcommand=scrollbar1)
    tree.grid(column=0, columnspan=6, row=1, sticky="news")  # Tree position

    tree.insert("", "end", "1", text="1. CISCO Hardening")
    tree.insert("1", "end", "sub0", text="1.1 Generic configs")
    tree.insert("sub0", "end", cisco[1], text="1.1.1 Password Hash")
    tree.insert("sub0", "end", cisco[3], text="1.1.2 Password Encryption")
    tree.insert("sub0", "end", cisco[2], text="1.1.3 AAA configuration")
    tree.insert("sub0", "end", cisco[4], text="1.1.4 SSH version 2")
    tree.insert("sub0", "end", cisco[5], text="1.1.5 MOTD")
    tree.insert("sub0", "end", cisco[8], text="1.1.6 VTP Password")
    tree.insert("sub0", "end", cisco[6], text="1.1.7 No logging console")
    tree.insert("sub0", "end", cisco[7], text="1.1.8 No logging monitor")

    tree.insert("", "end", "2", text="2. Microsoft SMBv1 Patching Check")
    tree.insert("2",
                "end",
                smbv1_patch[100],
                text="2.1 Windows Vista & Server 2008 (KB4012598)")
    tree.insert("2", "end", "sub10", text="2.2 Windows 7 & Server 2008 R2")
    tree.insert("sub10", "end", smbv1_patch[101], text="2.2 KB4012212")
    tree.insert("sub10", "end", smbv1_patch[102], text="2.3 KB4012215")

    tree.insert("2",
                "end",
                "sub11",
                text="2.4 Windows 8.1 & Server 2012 & 2012 R2")
    tree.insert("sub11", "end", smbv1_patch[103], text="2.4 KB4012213")
    tree.insert("sub11", "end", smbv1_patch[104], text="2.5 KB4012216")
    tree.insert("sub11", "end", smbv1_patch[105], text="2.6 KB4012214")
    tree.insert("sub11", "end", smbv1_patch[106], text="2.7 KB4012217")

    tree.insert("2", "end", "sub12", text="2.8 Windows 10 & Server 2016")
    tree.insert("sub12", "end", smbv1_patch[107], text="2.8 KB4012606")
    tree.insert("sub12", "end", smbv1_patch[108], text="2.7 KB4013198")
    tree.insert("sub12", "end", smbv1_patch[109], text="2.8 KB4013429")

    button2 = ttk.Button(text="Quit", command=sys.exit)  # Close Button
    button2.grid(row=4, column=0, sticky='ws', padx=10,
                 pady=10)  # Close button position

    checked_boxes = list()  # List for appending selected boxes
    lines_in_conf_file = list()  # List for appending the read file
    passed = str('Passed\t\t')
    not_passed = str('Not Passed\t\t')

    def box_select(just):  # Function for appending selected boxes
        checked_boxes.append(tree.get_checked())

    tree.bind('<<TreeviewSelect>>', box_select)

    def file_open():

        if len(tree.get_checked()) > 0:
            readfile = filedialog.askopenfilename(initialdir="/",
                                                  title="Select "
                                                  "configuration"
                                                  " file",
                                                  filetypes=(("txt "
                                                              "files",
                                                              "*.txt *.html"),
                                                             ("all "
                                                              "files", "*.*")))

            try:
                with open(readfile, "r", encoding='utf-8') as opened_file:
                    for i in opened_file:
                        pass
                    encodings = 'utf-8'
            except UnicodeDecodeError:
                encodings = 'utf-16'

            with open(readfile, "r", encoding=encodings) as opened_file:
                for read_line in opened_file:
                    lines_in_conf_file.append(read_line.strip('\n'))
                with open("temp.txt", "a") as conf:  # Opens file --ONCE--
                    for clause in checked_boxes[-1]:  # Loops over selection
                        for line in lines_in_conf_file:  # Loops over conf file
                            if clause in line:  # Checks what equals between loops
                                conf.write("{}".format(passed) + clause +
                                           "\n")  # Writing them into a file
                                break  # Ends IF statement and continues with
                        else:  # a loop on a conf file
                            if clause in should_not_be:  # Checks if selection in not wanted list
                                conf.write(
                                    "{}".format(passed) + clause +
                                    "\n")  # if yes, writes to a file "PASSED"
                            else:
                                conf.write(
                                    "{}".format(not_passed) + clause +
                                    "\n")  # if not, writes to a file "NOT
                                # PASSED"

                checked_configs()

        else:
            pop_up_msg()

    def checked_configs():
        checked = tkinter.Tk()
        # checked.iconbitmap(default="Appwheel.ico")  # App icon
        checked.geometry('650x500+650+300')  # Resolution
        checked.wm_title("Security Checker")

        checked.grid_columnconfigure(0, weight=1)
        checked.grid_columnconfigure(1, weight=1)
        checked.grid_columnconfigure(2, weight=3)
        checked.grid_columnconfigure(3, weight=2)
        checked.grid_columnconfigure(4, weight=2)
        checked.grid_rowconfigure(0, weight=1)
        checked.grid_rowconfigure(1, weight=10)
        checked.grid_rowconfigure(2, weight=2)
        checked.grid_rowconfigure(3, weight=3)
        checked.grid_rowconfigure(4, weight=3)

        label2 = ttk.Label(checked,
                           text='Security check report:',
                           font=title_font)
        label2.grid(row=0, column=0, sticky='ew', padx=10, pady=10)

        button3 = ttk.Button(checked, text="Quit", command=sys.exit)
        button3.grid(row=4, column=0, sticky='ws', padx=10, pady=10)

        def save_report_to_file():
            save_file = filedialog.asksaveasfile(mode='w',
                                                 defaultextension=".txt",
                                                 initialdir="/",
                                                 title="Save "
                                                 "report",
                                                 filetypes=(("txt "
                                                             "files", "*.txt"),
                                                            ("all "
                                                             "files", "*.*")))
            if save_file:
                with open('temp.txt', 'r') as temp_file:
                    for i in temp_file:
                        save_file.write(i)
                    else:
                        return

        button4 = ttk.Button(checked,
                             text="Save to..",
                             command=save_report_to_file)
        button4.grid(row=4, column=5, sticky='es', padx=10, pady=10)

        checked = Text(checked)
        checked.grid(column=0, columnspan=6, row=1, sticky="news")
        checked.insert('1.0', ''.join(open("temp.txt", "r")))

        checked.mainloop()

    def pop_up_msg():
        popup = tkinter.Tk()
        # popup.iconbitmap(default="Appwheel.ico")  # App icon
        popup.wm_title("Security Checker")

        label3 = ttk.Label(
            popup,
            text='Please select at least 1 checkbox to continue',
            font=title_font)
        label3.grid(row=0, column=0, sticky='ew', padx=10, pady=10)

        button5 = ttk.Button(popup, text="Okay", command=popup.destroy)
        button5.grid(row=1, column=0, padx=10, pady=10)

        popup.mainloop()

    button1 = ttk.Button(text="Next", command=file_open)
    button1.grid(row=4, column=5, sticky='es', padx=10,
                 pady=10)  # Open's Browse Button

    window.mainloop()