Skip to content

Commit c9ceca7

Browse files
committed
Merge pull request #60 from laanwj/master
Fix RELRO detection in checksec
2 parents 0c21045 + d7f7d06 commit c9ceca7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

peda.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,12 +2536,9 @@ def checksec(self, filename=None):
25362536

25372537
for line in out.splitlines():
25382538
if "GNU_RELRO" in line:
2539-
result["RELRO"] = 2 # Partial | NO BIND_NOW + GNU_RELRO
2539+
result["RELRO"] |= 2
25402540
if "BIND_NOW" in line:
2541-
if result["RELRO"] == 2:
2542-
result["RELRO"] = 3 # Full | BIND_NOW + GNU_RELRO
2543-
else:
2544-
result["RELRO"] = 0 # ? | BIND_NOW + NO GNU_RELRO = NO PROTECTION
2541+
result["RELRO"] |= 1
25452542
if "__stack_chk_fail" in line:
25462543
result["CANARY"] = 1
25472544
if "GNU_STACK" in line and "RWE" in line:
@@ -2553,6 +2550,10 @@ def checksec(self, filename=None):
25532550
if "_chk@" in line:
25542551
result["FORTIFY"] = 1
25552552

2553+
if result["RELRO"] == 1:
2554+
result["RELRO"] = 0 # ? | BIND_NOW + NO GNU_RELRO = NO PROTECTION
2555+
# result["RELRO"] == 2 # Partial | NO BIND_NOW + GNU_RELRO
2556+
# result["RELRO"] == 3 # Full | BIND_NOW + GNU_RELRO
25562557
return result
25572558

25582559
def _verify_rop_gadget(self, start, end, depth=5):

0 commit comments

Comments
 (0)