Example #1
0
    def _log_view_insert(self, file_path):
        '''
    file_path: pathlib.Path
               sqlmap库中dataToOutFile默认utf8写入
    '''
        m = self.m
        try:
            with file_path.open(encoding='utf8') as _f:
                _line_list_tmp = _f.readlines()
                if _line_list_tmp:
                    for _line_tmp in _line_list_tmp:
                        m._page3_log_view.write(_line_tmp)
                else:
                    m._page3_log_view.write('%s: 空文件' % file_path)
        except EnvironmentError as e:
            m._page3_log_view.write(str(e))
        finally:
            m._page3_log_view.write(
                time.strftime('\n%Y-%m-%d %R:%S: ', time.localtime()))
            # win下, strftime方法无法处理unicode, py的bug, 到此时还没修复
            m._page3_log_view.write('----------我是分割线----------\n', )

            m._page3_log_view.SetFocus()
            _mark = m._page3_log_view.GetInsertionPoint()
            wx.CallAfter(m._page3_log_view.ShowPosition, _mark)
Example #2
0
    def _task_view_append(self, output):
        _task_view = self.m._page4_task_view

        _task_view.write('%s\n' % output)

        _task_view.SetFocus()
        _mark = _task_view.GetInsertionPoint()
        wx.CallAfter(_task_view.ShowPosition, _mark)
Example #3
0
  def _set_manual_view(self, view, isClick):
    '''
    不用多线程能行嘛? 想要获得输出结果就一定会有阻塞的可能!
    https://www.jianshu.com/p/11090e197648
    https://wiki.gnome.org/Projects/PyGObject/Threading
    needle注: 操作的共享对象有两个: _get_sqlmap_path_btn, view
              原则一样, 所有对共用对象的操作都要用CallAfter
              这样写是不是很丑?
              另外, 如果没运行完, 主线程就退出了, 会卡住哦, 属于正常
    '''
    if isClick:
      wx.CallAfter(self._get_sqlmap_path_btn.Disable)
      wx.CallAfter(view.SetValue, '')

    byte_coding = 'utf8' if IS_POSIX else 'gbk'

    # _manual_hh = '/home/needle/bin/output_interval.sh'
    # win下的sqlmap -hh有Enter阻塞
    _manual_hh = 'echo y|%s -hh' % self._handlers.get_sqlmap_path()
    try:
      _subp = Popen(_manual_hh, stdout=PIPE, stderr=STDOUT, shell = True)

      for _an_bytes_line_tmp in iter(_subp.stdout.readline, b''):
        wx.CallAfter(view.write,
                     _an_bytes_line_tmp.decode(byte_coding))

      _subp.wait()
      _subp.stdout.close()
    except FileNotFoundError as e:
      wx.CallAfter(view.write, str(e))
    except Exception as e:
      print(e)  # 如果主线程结束太快, 会: AssertionError: No wx.App created yet
    finally:
      wx.CallAfter(self._get_sqlmap_path_btn.Enable)

    if isClick:
      # 用gtk时, 如果view不在屏幕上可见, ShowPosition会报错
      wx.CallAfter(view.ShowPosition, 0)
      wx.CallAfter(self._get_sqlmap_path_btn.SetFocus)
Example #4
0
 def onCloseByAccel(self, event):
   '''
   https://stackoverflow.com/questions/49454737/how-can-i-exit-out-of-a-wxpython-application-cleanly
   '''
   # print('by accelerator.')
   wx.CallAfter(self.Close)