示例#1
0
    def build_page3(self):
        box = Box(orientation=VERTICAL, spacing=6)
        box.set_border_width(10)

        _row1 = Frame()

        _log_view_textbuffer = m._page3_log_view.get_buffer()
        self._handlers.clear_log_view_buffer(None)

        _end = _log_view_textbuffer.get_end_iter()
        _log_view_textbuffer.create_mark('end', _end, False)

        _scrolled = g.ScrolledWindow()
        _scrolled.set_policy(g.PolicyType.NEVER, g.PolicyType.ALWAYS)
        _scrolled.add(m._page3_log_view)
        _row1.add(_scrolled)

        _row2 = Box()
        m._page3_read_target_btn.connect('clicked',
                                         self._handlers.read_target_file)
        m._page3_clear_btn.connect('clicked',
                                   self._handlers.clear_log_view_buffer)
        m._page3_read_log_btn.connect('clicked', self._handlers.read_log_file)

        _row2.pack_start(m._page3_read_target_btn, True, False, 0)
        _row2.pack_start(m._page3_clear_btn, True, False, 0)
        _row2.pack_start(m._page3_read_log_btn, True, False, 0)

        box.pack_start(_row1, True, True, 5)
        box.pack_end(_row2, False, True, 0)
        return box
示例#2
0
    def _build_page1(self):
        box = Box(orientation=VERTICAL, spacing=6)
        box.set_border_width(10)

        # sqlmap命令语句
        _cmd_area = Frame.new('A.收集选项 的结果显示在这:')

        _cmd_area.add(m._cmd_entry)

        box.pack_start(_cmd_area, False, True, 0)

        # 主构造区
        _notebook = Notebook(m, self._handlers)

        m._page1_misc_purge_ckbtn.connect('toggled', self._show_warn,
                                          '这将抹除所有本地记录!\n确定勾选?')
        m._page1_general_flush_session_ckbtn.connect('toggled',
                                                     self._show_warn,
                                                     '这将清除本地缓存!\n确定勾选?')

        _notebook.add_events(d.EventMask.SCROLL_MASK
                             | d.EventMask.SMOOTH_SCROLL_MASK)
        _notebook.connect('scroll-event', self.scroll_page)

        box.pack_start(_notebook, True, True, 0)

        # 构造与执行
        _exec_area = Box()

        _build_button = btn.new_with_mnemonic('A.收集选项(_A)')
        _build_button.connect('clicked', self._handlers.build_all)
        # 用于改善ui的使用体验
        _unselect_all_btn = btn.new_with_mnemonic('反选所有复选框(_S)')
        _unselect_all_btn.connect('clicked', self.unselect_all_ckbtn)
        _clear_all_entry = btn.new_with_mnemonic('清空所有输入框(_D)')
        _clear_all_entry.connect('clicked', self.clear_all_entry)

        _run_button = btn.new_with_mnemonic('B.开始(_F)')
        _run_button.connect('clicked', self._handlers.run_cmdline)

        _exec_area.pack_start(_build_button, False, True, 0)
        _exec_area.pack_start(_unselect_all_btn, True, False, 0)
        _exec_area.pack_start(_clear_all_entry, True, False, 0)
        _exec_area.pack_end(_run_button, False, True, 0)

        box.pack_end(_exec_area, False, True, 0)
        return box
示例#3
0
    def build_page1(self):
        box = Box(orientation=VERTICAL, spacing=6)
        box.set_border_width(10)
        _ = m._

        # sqlmap命令语句
        _cmd_area = Frame.new(_('A.Options are collected here:'))
        _cmd_area.add(m._cmd_entry)

        # 主构造区
        _notebook = Notebook(m, self._handlers)

        m._general_area_flush_session_ckbtn.connect(
            'toggled', self._show_warn, 'check --flush-session:\n\n'
            'Flush session files for current target?')
        m._misc_area_purge_ckbtn.connect(
            'toggled', self._show_warn, 'check --purge:\n\n'
            'Safely remove all content from sqlmap data directory?')

        _notebook.add_events(d.EventMask.SCROLL_MASK
                             | d.EventMask.SMOOTH_SCROLL_MASK)
        _notebook.connect('scroll-event', self.scroll_page)

        # 构造与执行
        _exec_area = Box()

        _build_button = btn.new_with_mnemonic(_('A.collect(_A)'))
        _build_button.connect('clicked', self._handlers.build_all)

        _unselect_all_btn = btn.new_with_mnemonic(_('unselect(_S)'))
        _unselect_all_btn.connect('clicked', self.unselect_all_ckbtn)
        _clear_all_entry = btn.new_with_mnemonic(_('clear all inputs(_D)'))
        _clear_all_entry.connect('clicked', self.clear_all_entry)

        _run_button = btn.new_with_mnemonic(_('B.run(_F)'))
        _run_button.connect('clicked', self._handlers.run_cmdline)

        _exec_area.pack_start(_build_button, False, True, 0)
        _exec_area.pack_start(_unselect_all_btn, True, False, 0)
        _exec_area.pack_start(_clear_all_entry, True, False, 0)
        _exec_area.pack_end(_run_button, False, True, 0)

        box.pack_start(_cmd_area, False, True, 0)
        box.pack_start(_notebook, True, True, 0)
        box.pack_end(_exec_area, False, True, 0)
        return box
示例#4
0
    def build_page2(self):
        '''
    用subprocess不可实现与sqlmap的交互!
    不管是多线程, 同步还是异步, 都不行, 只能使用pty
    '''
        box = Box(orientation=VERTICAL, spacing=6)
        box.set_border_width(10)

        _row1 = Box(spacing=6)
        m._page2_respwan_btn.connect('clicked',
                                     self._handlers.respawn_terminal)
        m._page2_right_btn.connect("button-press-event", self.on_right_click)
        # can not disable
        # m._page2_right_btn.set_sensitive(False)
        self._build_page2_context()

        _row1.pack_start(m._page2_respwan_btn, False, True, 0)
        _row1.pack_start(m._page2_right_btn, False, True, 0)

        _row2 = Frame()
        # equals: _pty = m._page2_terminal.pty_new_sync(Vte.PtyFlags.DEFAULT)
        _pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT)
        m._page2_terminal.set_pty(_pty)
        m._page2_terminal.connect('key_press_event', self.on_clipboard_by_key)
        m._page2_terminal.connect("button-press-event", self.on_right_click,
                                  m._page2_right_btn)

        # https://stackoverflow.com/questions/55105447/virtual-python-shell-with-vte-pty-spawn-async
        # https://gtk-d.dpldocs.info/vte.Pty.Pty.spawnAsync.html
        # API手册上的该方法签名有问题, 与实际的对不上
        # 最后一个参数为回调函数, 是必填项
        _pty.spawn_async(str(Path.home()), [self._handlers.shell], None,
                         GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None, -1,
                         None, lambda pty, task: None)

        _scrolled = g.ScrolledWindow()
        _scrolled.set_policy(g.PolicyType.NEVER, g.PolicyType.ALWAYS)
        _scrolled.add(m._page2_terminal)
        _row2.add(_scrolled)

        box.pack_start(_row1, False, True, 5)
        box.pack_end(_row2, True, True, 0)
        return box
示例#5
0
    def _build_page2(self):
        '''
    用subprocess不可实现与sqlap的交互!
    不管是多线程, 同步还是异步, 都不行, 只能使用pty
    '''
        box = Box(orientation=VERTICAL, spacing=6)
        box.set_border_width(10)

        _row1 = Box(spacing=6)
        # m._page2_cmdline_str_label.set_alignment(0, 0.5)    # 怎么没有垂直居中?
        m._page2_respwan_btn.connect('clicked',
                                     self._handlers.respawn_terminal)

        # _row1.pack_start(m._page2_cmdline_str_label, True, True, 0)
        _row1.pack_start(m._page2_respwan_btn, False, True, 0)

        _row2 = Frame()
        # 等价于_pty = m._page2_terminal.pty_new_sync(Vte.PtyFlags.DEFAULT)
        _pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT)
        m._page2_terminal.set_pty(_pty)

        # https://stackoverflow.com/questions/55105447/virtual-python-shell-with-vte-pty-spawn-async
        # https://gtk-d.dpldocs.info/vte.Pty.Pty.spawnAsync.html
        # API手册上的该方法签名有问题, 与实际的对不上
        # 最后一个参数为回调函数, 是必填项
        _pty.spawn_async(str(Path.home()), [self._handlers.shell], None,
                         GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None, -1,
                         None, lambda pty, task: None)

        _scrolled = g.ScrolledWindow()
        _scrolled.set_policy(g.PolicyType.NEVER, g.PolicyType.ALWAYS)
        _scrolled.add(m._page2_terminal)
        _row2.add(_scrolled)

        box.pack_start(_row1, False, True, 5)
        box.pack_end(_row2, True, True, 0)
        return box
示例#6
0
    def build_page4(self):
        box = Box(orientation=VERTICAL)
        box.set_border_width(10)

        _row1 = Box(spacing=6)
        _row1.pack_start(m._page4_api_server_label, False, True, 0)
        _row1.pack_start(m._page4_api_server_entry, True, True, 0)
        _row1.pack_start(m._page4_admin_token_label, False, True, 0)
        _row1.pack_start(m._page4_admin_token_entry, True, True, 0)

        _row2 = Box(spacing=6)
        _arrow_down = g.Image.new_from_icon_name('pan-down-symbolic', 1)
        m._page4_admin_list_btn.set_image(_arrow_down)
        m._page4_admin_list_btn.set_image_position(g.PositionType.RIGHT)
        m._page4_admin_list_btn.set_always_show_image(True)

        m._page4_task_new_btn.connect('clicked', self._handlers.api.task_new)
        m._page4_admin_list_btn.connect('clicked',
                                        self._handlers.api.admin_list)
        m._page4_admin_flush_btn.connect('clicked',
                                         self._handlers.api.admin_flush)
        m._page4_clear_task_view_btn.connect(
            'clicked', self._handlers.clear_task_view_buffer)

        _row2.pack_start(m._page4_task_new_btn, False, True, 0)
        _row2.pack_start(m._page4_admin_list_btn, False, True, 0)
        _row2.pack_start(m._page4_admin_flush_btn, False, True, 0)
        _row2.pack_start(m._page4_clear_task_view_btn, False, True, 0)
        _row2.pack_end(m._page4_password_entry, False, True, 0)
        _row2.pack_end(m._page4_password_label, False, True, 0)
        _row2.pack_end(m._page4_username_entry, False, True, 0)
        _row2.pack_end(m._page4_username_label, False, True, 0)

        _row3 = Frame()
        _paned = g.Paned()

        self._api_admin_list_rows = g.ListBox.new()
        self._api_admin_list_rows.set_selection_mode(g.SelectionMode.NONE)

        _lscrolled = g.ScrolledWindow()
        _lscrolled.set_size_request(400, -1)
        _lscrolled.set_policy(g.PolicyType.NEVER, g.PolicyType.ALWAYS)
        _lscrolled.add(self._api_admin_list_rows)

        _rbox = Box(orientation=VERTICAL)
        _page4_option_set_view_tip = label(
            label='check optiondict.py of sqlmap about options.',
            halign=g.Align.START)
        _option_set_view_textbuffer = m._page4_option_set_view.get_buffer()
        _options_example = ("{\n"
                            "  'url': 'http://www.site.com/vuln.php?id=1',\n"
                            "  'level': 1, 'risk': 1,\n\n"
                            "}\n")
        _option_set_view_textbuffer.set_text(
            _options_example, len(_options_example.encode('utf8')))
        # 貌似scrollwindow要直接包含textview,
        # 不然一直回车后, 页面不会向上滚
        _option_set_scrolled = g.ScrolledWindow()
        _option_set_scrolled.set_size_request(400, -1)
        _option_set_scrolled.set_policy(g.PolicyType.NEVER,
                                        g.PolicyType.ALWAYS)
        _option_set_scrolled.add(m._page4_option_set_view)

        _rbox.pack_start(m._page4_option_get_entry, False, True, 2)
        _rbox.pack_start(_page4_option_set_view_tip, False, True, 2)
        _rbox.pack_start(_option_set_scrolled, True, True, 2)

        # Warning: don't edit pack1(), pack2() again, otherwise it becomes strange.
        _paned.pack1(_lscrolled, False, False)
        _paned.pack2(_rbox, False, True)
        _row3.add(_paned)

        _row4 = Frame()

        _task_view_textbuffer = m._page4_task_view.get_buffer()
        _end = _task_view_textbuffer.get_end_iter()
        _task_view_textbuffer.create_mark('end', _end, False)
        self._handlers.api.task_view_append('response result:')

        _scrolled = g.ScrolledWindow()
        _scrolled.set_policy(g.PolicyType.NEVER, g.PolicyType.ALWAYS)
        _scrolled.add(m._page4_task_view)

        _row4.add(_scrolled)

        box.pack_start(_row1, False, True, 5)
        box.pack_start(_row2, False, True, 5)
        box.pack_start(_row3, True, True, 5)
        box.pack_start(_row4, True, True, 5)
        return box