Skip to content

Commit a1252d8

Browse files
committed
Compliance with colon in operation, using :\t
- Replaced every occurence in peda.py and lib/utils.py - context_code, traceinst and tracecall working
1 parent f07976d commit a1252d8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lib/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,19 @@ def format_disasm_code(code, nearby=None):
514514
color = colorcodes[c]
515515
if c == "call":
516516
for f in VULN_FUNCTIONS:
517-
if f in line.split(":", 1)[1]:
517+
if f in line.split(":\t", 1)[-1]:
518518
style = "bold, underline"
519519
color = "red"
520520
break
521521
break
522522

523-
prefix = line.split(":")[0]
523+
prefix = line.split(":\t")[0]
524524
addr = re.search("(0x[^\s]*)", prefix)
525525
if addr:
526526
addr = to_int(addr.group(1))
527527
else:
528528
addr = -1
529-
line = line.split(":", 1)[1]
529+
line = "\t" + line.split(":\t", 1)[-1]
530530
if addr < target:
531531
style = "dark"
532532
elif addr == target:

peda.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def parse_and_eval(self, exp):
152152
if not out:
153153
return None
154154
else:
155-
return out.split(":")[1].strip()
155+
return out.split(":\t")[-1].strip()
156156

157157
else:
158158
out = self.execute_redirect("print %s" % exp)
@@ -1213,7 +1213,7 @@ def eval_target(self, inst):
12131213

12141214
target = None
12151215
inst = inst.strip()
1216-
opcode = inst.split(":")[1].split()[0]
1216+
opcode = inst.split(":\t")[-1].split()[0]
12171217
# this regex includes x86_64 RIP relateive address reference
12181218
p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*(0x[^ ]*)")
12191219
m = p.search(inst)
@@ -1250,7 +1250,7 @@ def testjump(self, inst=None):
12501250
if not inst:
12511251
return None
12521252

1253-
opcode = inst.split(":")[1].split()[0]
1253+
opcode = inst.split(":\t")[-1].split()[0]
12541254
next_addr = self.eval_target(inst)
12551255
if next_addr is None:
12561256
next_addr = 0
@@ -1634,7 +1634,7 @@ def readmem(self, address, size):
16341634
out = self.execute_redirect("x/%dbx 0x%x" % (size, address))
16351635
if out:
16361636
for line in out.splitlines():
1637-
bytes = line.split(":")[1].split()
1637+
bytes = line.split(":\t")[-1].split()
16381638
mem += "".join([chr(int(c, 0)) for c in bytes])
16391639

16401640
return mem
@@ -2005,7 +2005,7 @@ def examine_mem_value(self, value):
20052005
def examine_data(value, bits=32):
20062006
out = self.execute_redirect("x/%sx 0x%x" % ("g" if bits == 64 else "w", value))
20072007
if out:
2008-
v = out.split(":")[1].strip()
2008+
v = out.split(":\t")[-1].strip()
20092009
if is_printable(int2hexstr(to_int(v), bits/8)):
20102010
out = self.execute_redirect("x/s 0x%x" % value)
20112011
return out
@@ -3985,14 +3985,14 @@ def tracecall(self, *arg):
39853985
matched = False
39863986
for fn in fnames:
39873987
fn = fn.strip()
3988-
if re.search(fn, code.split(":")[1]):
3988+
if re.search(fn, code.split(":\t")[-1]):
39893989
matched = True
39903990
break
39913991
else:
39923992
matched = True
39933993
for fn in fnames:
39943994
fn = fn.strip()
3995-
if re.search(fn, code.split(":")[1]):
3995+
if re.search(fn, code.split(":\t")[-1]):
39963996
matched = False
39973997
break
39983998

@@ -4067,7 +4067,7 @@ def traceinst(self, *arg):
40674067

40684068
# special case for JUMP inst
40694069
prev_code = ""
4070-
if re.search("j[^m]", code.split(":")[1].split()[0]):
4070+
if re.search("j[^m]", code.split(":\t")[-1].split()[0]):
40714071
prev_insts = peda.prev_inst(peda.getreg("pc"))
40724072
if prev_insts:
40734073
prev_code = "0x%x:%s" % prev_insts[0]
@@ -4076,7 +4076,7 @@ def traceinst(self, *arg):
40764076
text = "%s%s%s" % (" "*(prev_depth-1), " dep:%02d " % (prev_depth-1), code.strip())
40774077
msg(text, teefd=logfd)
40784078

4079-
if re.search("call", code.split(":")[1].split()[0]):
4079+
if re.search("call", code.split(":\t")[-1].split()[0]):
40804080
args = peda.get_function_args()
40814081
if args:
40824082
for (i, a) in enumerate(args):
@@ -4148,7 +4148,7 @@ def profile(self, *arg):
41484148
break
41494149
if peda.is_address(pc, binmap):
41504150
for k in keyword:
4151-
if k in code.split(":")[1]:
4151+
if k in code.split(":\t")[-1]:
41524152
code = code.strip("=>").strip()
41534153
stats.setdefault(code, 0)
41544154
stats[code] += 1
@@ -4213,7 +4213,7 @@ def context_code(self, *arg):
42134213
msg(text)
42144214
if inst: # valid $PC
42154215
text = ""
4216-
opcode = inst.split(":")[-1].split()[0]
4216+
opcode = inst.split(":\t")[-1].split()[0]
42174217
# stopped at function call
42184218
if "call" in opcode:
42194219
text += peda.disassemble_around(pc, count)

0 commit comments

Comments
 (0)