Make "clearscreen" more reasonable and configurable

This commit is contained in:
Long Le 2017-04-08 13:36:24 +07:00
parent 5458dd5ba8
commit 847a926b04
3 changed files with 10 additions and 1 deletions

View File

@ -35,6 +35,7 @@ OPTIONS = {
"autosave" : ("on", "auto saving peda session, e.g: on|off"),
"payload" : ("peda-payload-#FILENAME#.txt", "target file to save output of payload command"),
"context" : ("register,code,stack", "context display setting, e.g: register, code, stack, all"),
"clearscr" : ("on", "clear screen for each context display"),
"verbose" : ("off", "show detail execution of commands, e.g: on|off"),
"debug" : ("off", "show detail error of peda commands, e.g: on|off"),
"_teefd" : ("", "internal use only for tracelog/crashlog writing")

View File

@ -147,6 +147,10 @@ def blue(text, attrib=None):
"""Wrapper for colorize(text, 'blue')"""
return colorize(text, "blue", attrib)
def clearscreen():
"""Clear terminal screen"""
sys.stdout.write("\x1b[2J\x1b[H")
class message(object):
"""
Generic pretty printer with redirection.

View File

@ -4271,7 +4271,7 @@ class PEDACmd(object):
pc = peda.getreg("pc")
# display register info
msg("\033[2J\033[0;0H [%s]" % "registers".center(78, "-"), "blue")
msg("[%s]" % "registers".center(78, "-"), "blue")
self.xinfo("register")
return
@ -4392,6 +4392,10 @@ class PEDACmd(object):
if not self._is_running():
return
clearscr = config.Option.get("clearscr")
if clearscr == "on":
clearscreen()
status = peda.get_status()
# display registers
if "reg" in opt or "register" in opt: