Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cyan, purple, black, white (colorize functions to customize the peda) #148

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions lib/.gdb_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
b main
r
exit
q
22 changes: 19 additions & 3 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ def blue(text, attrib=None):
"""Wrapper for colorize(text, 'blue')"""
return colorize(text, "blue", attrib)

def cyan(text, attrib=None):
"""Wrapper for colorize(text, 'cyan')"""
return colorize(text, "cyan", attrib)

def purple(text, attrib=None):
"""Wrapper for colorize(text, 'purple')"""
return colorize(text, "purple", attrib)

def black(text, attrib=None):
"""Wrapper for colorize(text, 'black')"""
return colorize(text, "black", attrib)

def white(text, attrib=None):
"""Wrapper for colorize(text, 'white')"""
return colorize(text, "white", attrib)

def clearscreen():
"""Clear terminal screen"""
sys.stdout.write("\x1b[2J\x1b[H")
Expand Down Expand Up @@ -446,9 +462,9 @@ def check_badchars(data, chars=None):
def format_address(addr, type):
"""Colorize an address"""
colorcodes = {
"data": "blue",
"code": "red",
"rodata": "green",
"data": "cyan",
"code": "purple",
"rodata": "red",
"value": None
}
return colorize(addr, colorcodes[type])
Expand Down
26 changes: 13 additions & 13 deletions peda.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import config
from nasm import *

if sys.version_info.major is 3:
if sys.version_info.major == 3:
from urllib.request import urlopen
from urllib.parse import urlencode
pyversion = 3
Expand Down Expand Up @@ -4250,7 +4250,7 @@ def context_register(self, *arg):

pc = peda.getreg("pc")
# display register info
msg("[%s]" % "registers".center(78, "-"), "blue")
msg("[%s]" % "registers".center(78, "-"), "yellow")
self.xinfo("register")

return
Expand All @@ -4276,7 +4276,7 @@ def context_code(self, *arg):
else:
inst = None

text = blue("[%s]" % "code".center(78, "-"))
text = yellow("[%s]" % "code".center(78, "-"))
msg(text)
if inst: # valid $PC
text = ""
Expand Down Expand Up @@ -4337,7 +4337,7 @@ def context_stack(self, *arg):
if not self._is_running():
return

text = blue("[%s]" % "stack".center(78, "-"))
text = yellow("[%s]" % "stack".center(78, "-"))
msg(text)
sp = peda.getreg("sp")
if peda.is_address(sp):
Expand Down Expand Up @@ -4387,8 +4387,8 @@ def context(self, *arg):
# display stack content, forced in case SIGSEGV
if "stack" in opt or "SIGSEGV" in status:
self.context_stack(count)
msg("[%s]" % ("-"*78), "blue")
msg("Legend: %s, %s, %s, value" % (red("code"), blue("data"), green("rodata")))
msg("[%s]" % ("-"*78), "yellow")
msg("Legend: %s, %s, %s, value" % (cyan("code"), purple("data"), red("rodata")))

# display stopped reason
if "SIG" in status:
Expand Down Expand Up @@ -5789,9 +5789,9 @@ def list_shellcode():
while True:
for os in oslist:
msg('%s %s'%(yellow('[+]'),green(os)))
if pyversion is 2:
if pyversion == 2:
os = input('%s'%blue('os:'))
if pyversion is 3:
if pyversion == 3:
os = input('%s'%blue('os:'))
if os in oslist: #check if os exist
break
Expand All @@ -5800,9 +5800,9 @@ def list_shellcode():
while True:
for job in joblist:
msg('%s %s'%(yellow('[+]'),green(job)))
if pyversion is 2:
if pyversion == 2:
job = raw_input('%s'%blue('job:'))
if pyversion is 3:
if pyversion == 3:
job = input('%s'%blue('job:'))
if job != '':
break
Expand All @@ -5811,9 +5811,9 @@ def list_shellcode():
while True:
for encode in encodelist:
msg('%s %s'%(yellow('[+]'),green(encode)))
if pyversion is 2:
if pyversion == 2:
encode = raw_input('%s'%blue('encode:'))
if pyversion is 3:
if pyversion == 3:
encode = input('%s'%blue('encode:'))
if encode != '':
break
Expand Down Expand Up @@ -6151,7 +6151,7 @@ def sigint_handler(signal, frame):
peda.execute("set confirm off")
peda.execute("set verbose off")
peda.execute("set output-radix 0x10")
peda.execute("set prompt \001%s\002" % red("\002gdb-peda$ \001")) # custom prompt
peda.execute("set prompt \001%s\002" % yellow("\002gdb-redhung$ \001")) # custom prompt
peda.execute("set height 0") # disable paging
peda.execute("set history expansion on")
peda.execute("set history save on") # enable history saving
Expand Down