#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 5.4
#  in conjunction with Tcl version 8.6
#    Oct 06, 2020 12:31:08 PM IST  platform: Windows NT

import sys

try:
    import Tkinter as tk
except ImportError:
    import tkinter as tk

try:
    import ttk
    py3 = False
except ImportError:
    import tkinter.ttk as ttk
    py3 = True

import index_support
import vulnerability_detector
def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root
    root = tk.Tk()
    top = Toplevel1 (root)
    index_support.init(root, top)
    root.mainloop()

w = None
def create_Toplevel1(rt, *args, **kwargs):
    '''Starting point when module is imported by another module.
       Correct form of call: 'create_Toplevel1(root, *args, **kwargs)' .'''
    global w, w_win, root
    #rt = root
    root = rt
    w = tk.Toplevel (root)
    top = Toplevel1 (w)
    index_support.init(w, top, *args, **kwargs)
    return (w, top)

def destroy_Toplevel1():
    global w
    w.destroy()
    w = None

class Toplevel1:
    def sql_injection_verify(self):
        self.sql_injection_scroll.delete("1.0",tk.END)
        vulnerability_detector.scan_sql_injection(self.Entry1.get(),self)
    def xss_verify(self):
        self.xss_detection_scroll.delete("1.0",tk.END)
        vulnerability_detector.scan_xss(self.Entry1.get(),self)
    def logger_verify(self):
        self.logger_scroll.delete("1.0",tk.END)
        vulnerability_detector.logger(self)
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("1124x705+-56+32")
        top.minsize(140, 1)
        top.maxsize(1924, 1057)
        top.resizable(1, 1)
        top.title("New Toplevel")
        top.configure(background="#9ab3f5")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.Label1 = tk.Label(top)
        self.Label1.place(relx=-0.051, rely=0.014, height=92, width=1172)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#7579e7")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font="-family {Comic Sans MS} -size 24 -weight bold -slant roman -underline 0 -overstrike 0")
        self.Label1.configure(foreground="#ffffff")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''W3AF''')

        self.Label2 = tk.Label(top)
        self.Label2.place(relx=0.417, rely=0.199, height=26, width=207)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(anchor='w')
        self.Label2.configure(background="#9ab3f5")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font="-family {Comic Sans MS} -size 16 -weight bold -slant roman -underline 0 -overstrike 0")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Enter the website URL:''')

        self.sql_injection = tk.Button(top,command=self.sql_injection_verify)
        self.sql_injection.place(relx=0.109, rely=0.357, height=51, width=242)
        self.sql_injection.configure(activebackground="#ececec")
        self.sql_injection.configure(activeforeground="#000000")
        self.sql_injection.configure(background="#a3d8f4")
        self.sql_injection.configure(disabledforeground="#a3a3a3")
        self.sql_injection.configure(font="-family {Comic Sans MS} -size 12 -weight bold -slant roman -underline 0 -overstrike 0")
        self.sql_injection.configure(foreground="#000000")
        self.sql_injection.configure(highlightbackground="#d9d9d9")
        self.sql_injection.configure(highlightcolor="black")
        self.sql_injection.configure(pady="0")
        self.sql_injection.configure(text='''SQL Injection detection''')

        self.Entry1 = tk.Entry(top)
        self.Entry1.place(relx=0.256, rely=0.27,height=32, relwidth=0.813)
        self.Entry1.configure(background="white")
        self.Entry1.configure(disabledforeground="#a3a3a3")
        self.Entry1.configure(font="TkFixedFont")
        self.Entry1.configure(foreground="#000000")
        self.Entry1.configure(highlightbackground="#d9d9d9")
        self.Entry1.configure(highlightcolor="black")
        self.Entry1.configure(insertbackground="black")
        self.Entry1.configure(selectbackground="blue")
        self.Entry1.configure(selectforeground="white")

        self.xss_detection = tk.Button(top,command=self.xss_verify)
        self.xss_detection.place(relx=0.417, rely=0.355, height=51, width=244)
        self.xss_detection.configure(activebackground="#ececec")
        self.xss_detection.configure(activeforeground="#000000")
        self.xss_detection.configure(background="#a3d8f4")
        self.xss_detection.configure(disabledforeground="#a3a3a3")
        self.xss_detection.configure(font="-family {Comic Sans MS} -size 12 -weight bold -slant roman -underline 0 -overstrike 0")
        self.xss_detection.configure(foreground="#000000")
        self.xss_detection.configure(highlightbackground="#d9d9d9")
        self.xss_detection.configure(highlightcolor="black")
        self.xss_detection.configure(pady="0")
        self.xss_detection.configure(text='''XSS detection''')

        self.logs = tk.Button(top,command=self.logger_verify)
        self.logs.place(relx=0.732, rely=0.355, height=51, width=244)
        self.logs.configure(activebackground="#ececec")
        self.logs.configure(activeforeground="#000000")
        self.logs.configure(background="#a3d8f4")
        self.logs.configure(disabledforeground="#a3a3a3")
        self.logs.configure(font="-family {Comic Sans MS} -size 12 -weight bold -slant roman -underline 0 -overstrike 0")
        self.logs.configure(foreground="#000000")
        self.logs.configure(highlightbackground="#d9d9d9")
        self.logs.configure(highlightcolor="black")
        self.logs.configure(pady="0")
        self.logs.configure(text='''Logger''')

        self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
        top.configure(menu = self.menubar)

        self.sql_injection_scroll = ScrolledText(top)
        self.sql_injection_scroll.place(relx=0.044, rely=0.44, relheight=0.454
                , relwidth=0.285)
        self.sql_injection_scroll.configure(background="white")
        self.sql_injection_scroll.configure(font="TkTextFont")
        self.sql_injection_scroll.configure(foreground="black")
        self.sql_injection_scroll.configure(highlightbackground="#d9d9d9")
        self.sql_injection_scroll.configure(highlightcolor="black")
        self.sql_injection_scroll.configure(insertbackground="black")
        self.sql_injection_scroll.configure(insertborderwidth="3")
        self.sql_injection_scroll.configure(selectbackground="blue")
        self.sql_injection_scroll.configure(selectforeground="white")
        self.sql_injection_scroll.configure(wrap="none")

        self.xss_detection_scroll = ScrolledText(top)
        self.xss_detection_scroll.place(relx=0.366, rely=0.44, relheight=0.452
                , relwidth=0.287)
        self.xss_detection_scroll.configure(background="white")
        self.xss_detection_scroll.configure(font="TkTextFont")
        self.xss_detection_scroll.configure(foreground="black")
        self.xss_detection_scroll.configure(highlightbackground="#d9d9d9")
        self.xss_detection_scroll.configure(highlightcolor="black")
        self.xss_detection_scroll.configure(insertbackground="black")
        self.xss_detection_scroll.configure(insertborderwidth="3")
        self.xss_detection_scroll.configure(selectbackground="blue")
        self.xss_detection_scroll.configure(selectforeground="white")
        self.xss_detection_scroll.configure(wrap="none")

        self.logger_scroll = ScrolledText(top)
        self.logger_scroll.place(relx=0.688, rely=0.44, relheight=0.454
                , relwidth=0.285)
        self.logger_scroll.configure(background="white")
        self.logger_scroll.configure(font="TkTextFont")
        self.logger_scroll.configure(foreground="black")
        self.logger_scroll.configure(highlightbackground="#d9d9d9")
        self.logger_scroll.configure(highlightcolor="black")
        self.logger_scroll.configure(insertbackground="black")
        self.logger_scroll.configure(insertborderwidth="3")
        self.logger_scroll.configure(selectbackground="blue")
        self.logger_scroll.configure(selectforeground="white")
        self.logger_scroll.configure(wrap="none")

# The following code is added to facilitate the Scrolled widgets you specified.
class AutoScroll(object):
    '''Configure the scrollbars for a widget.'''
    def __init__(self, master):
        #  Rozen. Added the try-except clauses so that this class
        #  could be used for scrolled entry widget for which vertical
        #  scrolling is not supported. 5/7/14.
        try:
            vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
        except:
            pass
        hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
        try:
            self.configure(yscrollcommand=self._autoscroll(vsb))
        except:
            pass
        self.configure(xscrollcommand=self._autoscroll(hsb))
        self.grid(column=0, row=0, sticky='nsew')
        try:
            vsb.grid(column=1, row=0, sticky='ns')
        except:
            pass
        hsb.grid(column=0, row=1, sticky='ew')
        master.grid_columnconfigure(0, weight=1)
        master.grid_rowconfigure(0, weight=1)
        # Copy geometry methods of master  (taken from ScrolledText.py)
        if py3:
            methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \
                  | tk.Place.__dict__.keys()
        else:
            methods = tk.Pack.__dict__.keys() + tk.Grid.__dict__.keys() \
                  + tk.Place.__dict__.keys()
        for meth in methods:
            if meth[0] != '_' and meth not in ('config', 'configure'):
                setattr(self, meth, getattr(master, meth))

    @staticmethod
    def _autoscroll(sbar):
        '''Hide and show scrollbar as needed.'''
        def wrapped(first, last):
            first, last = float(first), float(last)
            if first <= 0 and last >= 1:
                sbar.grid_remove()
            else:
                sbar.grid()
            sbar.set(first, last)
        return wrapped

    def __str__(self):
        return str(self.master)

def _create_container(func):
    '''Creates a ttk Frame with a given master, and use this new frame to
    place the scrollbars and the widget.'''
    def wrapped(cls, master, **kw):
        container = ttk.Frame(master)
        container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
        container.bind('<Leave>', lambda e: _unbound_to_mousewheel(e, container))
        return func(cls, container, **kw)
    return wrapped

class ScrolledText(AutoScroll, tk.Text):
    '''A standard Tkinter Text widget with scrollbars that will
    automatically show/hide as needed.'''
    @_create_container
    def __init__(self, master, **kw):
        tk.Text.__init__(self, master, **kw)
        AutoScroll.__init__(self, master)

import platform
def _bound_to_mousewheel(event, widget):
    child = widget.winfo_children()[0]
    if platform.system() == 'Windows' or platform.system() == 'Darwin':
        child.bind_all('<MouseWheel>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Shift-MouseWheel>', lambda e: _on_shiftmouse(e, child))
    else:
        child.bind_all('<Button-4>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Button-5>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Shift-Button-4>', lambda e: _on_shiftmouse(e, child))
        child.bind_all('<Shift-Button-5>', lambda e: _on_shiftmouse(e, child))

def _unbound_to_mousewheel(event, widget):
    if platform.system() == 'Windows' or platform.system() == 'Darwin':
        widget.unbind_all('<MouseWheel>')
        widget.unbind_all('<Shift-MouseWheel>')
    else:
        widget.unbind_all('<Button-4>')
        widget.unbind_all('<Button-5>')
        widget.unbind_all('<Shift-Button-4>')
        widget.unbind_all('<Shift-Button-5>')

def _on_mousewheel(event, widget):
    if platform.system() == 'Windows':
        widget.yview_scroll(-1*int(event.delta/120),'units')
    elif platform.system() == 'Darwin':
        widget.yview_scroll(-1*int(event.delta),'units')
    else:
        if event.num == 4:
            widget.yview_scroll(-1, 'units')
        elif event.num == 5:
            widget.yview_scroll(1, 'units')

def _on_shiftmouse(event, widget):
    if platform.system() == 'Windows':
        widget.xview_scroll(-1*int(event.delta/120), 'units')
    elif platform.system() == 'Darwin':
        widget.xview_scroll(-1*int(event.delta), 'units')
    else:
        if event.num == 4:
            widget.xview_scroll(-1, 'units')
        elif event.num == 5:
            widget.xview_scroll(1, 'units')

if __name__ == '__main__':
    vp_start_gui()





