Skip to content

Commit 7a9efcf

Browse files
committed
security: set checksec libc and set fortified score
1 parent 5e364c8 commit 7a9efcf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

hooks/security.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66
from tempfile import NamedTemporaryFile
77

8-
from checksec.elf import ELFSecurity, PIEType, RelroType
8+
from checksec.elf import ELFSecurity, PIEType, RelroType, set_libc
99
from checksec.errors import ErrorNotAnElf, ErrorParsingFailed
1010
from see import Hook
1111

@@ -113,6 +113,8 @@ def download_libc(self, event):
113113
# copy libc
114114
shutil.copy(libc_inode.local_file, self.local_guest_libc.name)
115115
self.logger.info("Copied guest libc %s to %s", libc_inode.path, self.local_guest_libc.name)
116+
# setup checksec libc
117+
set_libc(Path(self.local_guest_libc.name))
116118

117119
def check_file(self, event):
118120
# event args
@@ -146,16 +148,16 @@ def check_file(self, event):
146148
shutil.copy(inode.local_file, dst)
147149
return
148150
else:
149-
relro = elf.has_relro
151+
relro = elf.relro
150152
canary = elf.has_canary
151153
nx = elf.has_nx
152-
pie = elf.is_pie
154+
pie = elf.pie
153155
rpath = elf.has_rpath
154156
runpath = elf.has_runpath
155157
symbols = not elf.is_stripped
156158
fortified = elf.is_fortified
157-
fortify_source = 0 # TODO
158-
fortifyable = 0 # TODO
159+
fortify_source = len(elf.fortified)
160+
fortifyable = len(elf.fortifiable)
159161

160162
checksec_file = ChecksecFile(relro, canary, nx, pie, rpath, runpath,
161163
symbols, fortify_source, fortified, fortifyable)

0 commit comments

Comments
 (0)