Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions peda-arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def format_shellcode(self, buf, arch='arm'):

shellcode = []
# ' 0: e49df004 pop {pc} ; (ldr pc, [sp], #4)'
pattern = re.compile("\s*([0-9a-f]+):\s*([0-9a-f]+)(.+)")
pattern = re.compile(r"\s*([0-9a-f]+):\s*([0-9a-f]+)(.+)")

# matches = pattern.findall(asmcode)
for line in asmcode.splitlines():
Expand Down Expand Up @@ -252,7 +252,7 @@ def _get_function_args_32(self, code, argc=None):

if argc is None:
# deal with regs
p = re.compile(":\s*(\S+)\s*(\w+),")
p = re.compile(r":\s*(\S+)\s*(\w+),")
matches = p.findall(code)
m = [r for (_, r) in matches]

Expand Down Expand Up @@ -502,7 +502,7 @@ def _testjump(self, inst=None):
return None

# inst='=> 0x8b84 <_start+40>:\tblxeq.n\t0xa3bc <__libc_start_main>'
match = re.match('.*:\s+(b[l|x]{0,2})(\S{0}|\S{2})(\.w|\.n)?\s+', inst)
match = re.match(r'.*:\s+(b[l|x]{0,2})(\S{0}|\S{2})(\.w|\.n)?\s+', inst)
next_addr = self.peda.eval_target(inst)
if next_addr is None:
next_addr = 0
Expand Down Expand Up @@ -567,7 +567,7 @@ def _testjump_cb(self, inst=None):
return None

# inst='=> 0xaf130bd4:\tcbz\tr0, 0xaf130be4'
match = re.match('.*:\s+cb(n?z)?\s+(\S+),\s*(\S+)', inst)
match = re.match(r'.*:\s+cb(n?z)?\s+(\S+),\s*(\S+)', inst)
if not match:
return None
cond, r, next_addr = match.groups()
Expand Down
12 changes: 6 additions & 6 deletions peda-intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def nasm2shellcode(asmcode):
return ""

shellcode = []
pattern = re.compile("([0-9A-F]{8})\s*([^\s]*)\s*(.*)")
pattern = re.compile(r"([0-9A-F]{8})\s*([^\s]*)\s*(.*)")

# matches = pattern.findall(asmcode)
for line in asmcode.splitlines():
Expand Down Expand Up @@ -263,7 +263,7 @@ def _get_function_args_32(self, code, argc=None):
"""
if not argc:
argc = 0
p = re.compile(".*mov.*\[esp(.*)\],")
p = re.compile(r".*mov.*\[esp(.*)\],")
matches = p.findall(code)
if matches:
l = len(matches)
Expand Down Expand Up @@ -297,7 +297,7 @@ def _get_function_args_64(self, code, argc=None):
arg_order = ["rdi", "rsi", "rdx", "rcx", "r8", "r9"]

if not argc:
p = re.compile(":\s*([^ ]*)\s*(.*),")
p = re.compile(r":\s*([^ ]*)\s*(.*),")
matches = p.findall(code)
regs = [r for (_, r) in matches]
p = re.compile("di|si|dx|cx|r8|r9")
Expand Down Expand Up @@ -559,7 +559,7 @@ def traceinst(self, *arg):
prev_depth = self.peda.backtrace_depth(peda.getreg("sp"))
logfd = open(logname, "w")

p = re.compile(".*?:\s*[^ ]*\s*([^,]*),(.*)")
p = re.compile(r".*?:\s*[^ ]*\s*([^,]*),(.*)")
while count:
result = self.peda.stepuntil(",".join(instlist), mapname, prev_depth)
if result is None:
Expand All @@ -571,7 +571,7 @@ def traceinst(self, *arg):

# special case for JUMP inst
prev_code = ""
if re.search("j[^m]", code.split(":\t")[-1].split()[0]):
if re.search(r"j[^m]", code.split(":\t")[-1].split()[0]):
prev_insts = self.peda.prev_inst(peda.getpc())
if prev_insts:
prev_code = "0x%x:%s" % prev_insts[0]
Expand All @@ -580,7 +580,7 @@ def traceinst(self, *arg):
text = "%s%s%s" % (" " * (prev_depth - 1), " dep:%02d " % (prev_depth - 1), code.strip())
msg(text, teefd=logfd)

if re.search("call", code.split(":\t")[-1].split()[0]):
if re.search(r"call", code.split(":\t")[-1].split()[0]):
args = self.peda.get_function_args()
if args:
for (i, a) in enumerate(args):
Expand Down
6 changes: 3 additions & 3 deletions peda/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ def examine_data(value, bits=32):
if start <= value < end:
if type == "code":
out = self.get_disasm(value)
p = re.compile(".*?0x[^ ]*?\s(.*)")
p = re.compile(r".*?0x[^ ]*?\s(.*)")
m = p.search(out)
result = (to_hex(value), "code", m.group(1))
else: # rodata address
Expand All @@ -1458,7 +1458,7 @@ def examine_data(value, bits=32):
out = examine_data(value, bits)
result = (to_hex(value), "rodata", out.split(":", 1)[1].strip())
else:
p = re.compile(".*?0x[^ ]*?\s(.*)")
p = re.compile(r".*?0x[^ ]*?\s(.*)")
m = p.search(out)
result = (to_hex(value), "code", m.group(1))

Expand Down Expand Up @@ -1640,7 +1640,7 @@ def elfheader_solib(self, solib=None, name=None):
if not out:
return {}

p = re.compile("^ *(0x\S+) - (0x\S+) is (\.\S+) in (\S+)")
p = re.compile(r"^ *(0x\S+) - (0x\S+) is (\.\S+) in (\S+)")
soheaders = p.findall(out)
headers = [
(to_int(start), to_int(end), hname, os.path.realpath(libname)) for (start, end, hname, libname) in soheaders
Expand Down
4 changes: 2 additions & 2 deletions peda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def format_disasm_code_arm(code, nearby=None):
results.append(line)
else:
color = style = None
m = re.search(".*(0x\S*).*:\s*(\S*)", line)
m = re.search(r".*(0x\S*).*:\s*(\S*)", line)
if not m: # failed to parse
results.append(line)
continue
Expand Down Expand Up @@ -685,7 +685,7 @@ def format_disasm_code_intel(code, nearby=None):
results.append(line)
else:
color = style = None
m = re.search(".*(0x\S*).*:\s*(\S*)", line)
m = re.search(r".*(0x\S*).*:\s*(\S*)", line)
if not m: # failed to parse
results.append(line)
continue
Expand Down