Show console output from sqlmap
(self, configFile)
| 553 | self._show_console(configFile) |
| 554 | |
| 555 | def _show_console(self, configFile): |
| 556 | """Show console output from sqlmap""" |
| 557 | height, width = self.stdscr.getmaxyx() |
| 558 | |
| 559 | # Create console window |
| 560 | console_win = curses.newwin(height - 4, width - 4, 2, 2) |
| 561 | console_win.box() |
| 562 | console_win.attron(curses.color_pair(2)) |
| 563 | console_win.addstr(0, 2, " sqlmap Console - Press Q to close ") |
| 564 | console_win.attroff(curses.color_pair(2)) |
| 565 | console_win.refresh() |
| 566 | |
| 567 | # Create output area |
| 568 | output_win = console_win.derwin(height - 8, width - 8, 2, 2) |
| 569 | output_win.scrollok(True) |
| 570 | output_win.idlok(True) |
| 571 | |
| 572 | # Start sqlmap process |
| 573 | try: |
| 574 | process = subprocess.Popen( |
| 575 | [sys.executable or "python", os.path.join(paths.SQLMAP_ROOT_PATH, "sqlmap.py"), "-c", configFile], |
| 576 | shell=False, |
| 577 | stdout=subprocess.PIPE, |
| 578 | stderr=subprocess.STDOUT, |
| 579 | stdin=subprocess.PIPE, |
| 580 | bufsize=1, |
| 581 | close_fds=not IS_WIN |
| 582 | ) |
| 583 | |
| 584 | if not IS_WIN: |
| 585 | # Make it non-blocking |
| 586 | import fcntl |
| 587 | flags = fcntl.fcntl(process.stdout, fcntl.F_GETFL) |
| 588 | fcntl.fcntl(process.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) |
| 589 | |
| 590 | output_win.nodelay(True) |
| 591 | console_win.nodelay(True) |
| 592 | |
| 593 | lines = [] |
| 594 | current_line = "" |
| 595 | |
| 596 | while True: |
| 597 | # Check for user input |
| 598 | try: |
| 599 | key = console_win.getch() |
| 600 | if key in (ord('q'), ord('Q')): |
| 601 | # Kill process |
| 602 | process.terminate() |
| 603 | break |
| 604 | elif key == curses.KEY_ENTER or key == 10: |
| 605 | # Send newline to process |
| 606 | if process.poll() is None: |
| 607 | try: |
| 608 | process.stdin.write(b'\n') |
| 609 | process.stdin.flush() |
| 610 | except: |
| 611 | pass |
| 612 | except: |
no test coverage detected