Skip to content

Commit

Permalink
Merge pull request longld#60 from laanwj/master
Browse files Browse the repository at this point in the history
Fix RELRO detection in checksec
  • Loading branch information
longld committed Oct 17, 2015
2 parents 0c21045 + d7f7d06 commit c9ceca7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions peda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2536,12 +2536,9 @@ def checksec(self, filename=None):

for line in out.splitlines():
if "GNU_RELRO" in line:
result["RELRO"] = 2 # Partial | NO BIND_NOW + GNU_RELRO
result["RELRO"] |= 2
if "BIND_NOW" in line:
if result["RELRO"] == 2:
result["RELRO"] = 3 # Full | BIND_NOW + GNU_RELRO
else:
result["RELRO"] = 0 # ? | BIND_NOW + NO GNU_RELRO = NO PROTECTION
result["RELRO"] |= 1
if "__stack_chk_fail" in line:
result["CANARY"] = 1
if "GNU_STACK" in line and "RWE" in line:
Expand All @@ -2553,6 +2550,10 @@ def checksec(self, filename=None):
if "_chk@" in line:
result["FORTIFY"] = 1

if result["RELRO"] == 1:
result["RELRO"] = 0 # ? | BIND_NOW + NO GNU_RELRO = NO PROTECTION
# result["RELRO"] == 2 # Partial | NO BIND_NOW + GNU_RELRO
# result["RELRO"] == 3 # Full | BIND_NOW + GNU_RELRO
return result

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

0 comments on commit c9ceca7

Please sign in to comment.