Skip to content

Commit fe0aede

Browse files
authored
Merge pull request #137 from tecknicaltom/lief-0.15.1
Update lief to 0.15.1
2 parents f604f67 + 976d530 commit fe0aede

File tree

4 files changed

+61
-58
lines changed

4 files changed

+61
-58
lines changed

checksec/elf.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import FrozenSet, List, Optional
77

88
import lief
9-
from lief.ELF import E_TYPE
109

1110
from .binary import BinarySecurity
1211
from .errors import ErrorParsingFailed
@@ -118,20 +117,20 @@ def set_dyn_syms(self) -> FrozenSet[str]:
118117

119118
@property
120119
def relro(self) -> RelroType:
121-
if self.bin.get(lief.ELF.SEGMENT_TYPES.GNU_RELRO) is None:
120+
if self.bin.get(lief.ELF.Segment.TYPE.GNU_RELRO) is None:
122121
return RelroType.No
123122

124-
flags = self.bin.get(lief.ELF.DYNAMIC_TAGS.FLAGS)
123+
flags = self.bin.get(lief.ELF.DynamicEntry.TAG.FLAGS)
125124
if flags is None:
126125
bind_now = False
127126
else:
128-
bind_now = lief.ELF.DYNAMIC_FLAGS.BIND_NOW in flags
127+
bind_now = flags.has(lief.ELF.DynamicEntryFlags.FLAG.BIND_NOW)
129128

130-
flags_1 = self.bin.get(lief.ELF.DYNAMIC_TAGS.FLAGS_1)
129+
flags_1 = self.bin.get(lief.ELF.DynamicEntry.TAG.FLAGS_1)
131130
if flags_1 is None:
132131
now = False
133132
else:
134-
now = lief.ELF.DYNAMIC_FLAGS_1.NOW in flags_1
133+
now = flags_1.has(lief.ELF.DynamicEntryFlags.FLAG.NOW)
135134

136135
if bind_now or now:
137136
return RelroType.Full
@@ -151,44 +150,38 @@ def has_canary(self) -> bool:
151150

152151
@property
153152
def pie(self) -> PIEType:
154-
if self.bin.header.file_type == E_TYPE.DYNAMIC:
155-
if self.bin.has(lief.ELF.DYNAMIC_TAGS.DEBUG):
153+
if self.bin.header.file_type == lief.ELF.Header.FILE_TYPE.DYN:
154+
if self.bin.has(lief.ELF.DynamicEntry.TAG.DEBUG_TAG):
156155
return PIEType.PIE
157156
else:
158157
return PIEType.DSO
159-
elif self.bin.header.file_type == E_TYPE.RELOCATABLE:
158+
elif self.bin.header.file_type == lief.ELF.Header.FILE_TYPE.REL:
160159
return PIEType.REL
161160
return PIEType.No
162161

163162
@property
164163
def has_rpath(self) -> bool:
165-
try:
166-
if self.bin.get(lief.ELF.DYNAMIC_TAGS.RPATH):
167-
return True
168-
except lief.not_found:
169-
pass
164+
if self.bin.get(lief.ELF.DynamicEntry.TAG.RPATH):
165+
return True
170166
return False
171167

172168
@property
173169
def has_runpath(self) -> bool:
174-
try:
175-
if self.bin.get(lief.ELF.DYNAMIC_TAGS.RUNPATH):
176-
return True
177-
except lief.not_found:
178-
pass
170+
if self.bin.get(lief.ELF.DynamicEntry.TAG.RUNPATH):
171+
return True
179172
return False
180173

181174
@property
182175
@lru_cache()
183176
def symbols(self) -> List[str]:
184-
return [symbol.name for symbol in self.bin.static_symbols]
177+
return [symbol.name for symbol in self.bin.symtab_symbols]
185178

186179
@property
187180
def is_stripped(self) -> bool:
188-
# TODO: hwo to reset static_symbols iterator for the next call to symbols() ?
181+
# TODO: how to reset symtab_symbols iterator for the next call to symbols() ?
189182
# consumes only the first symbol from iterator, saving CPU cycles
190183
try:
191-
next(self.bin.static_symbols)
184+
next(self.bin.symtab_symbols)
192185
except StopIteration:
193186
return True
194187
else:

checksec/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# cannot use is_elf because of circular dependency
1313
import lief
14-
from lief.logging import LOGGING_LEVEL as lief_loglvl
14+
from lief.logging import LEVEL as lief_loglvl
1515

1616

1717
class LibcNotFoundError(Exception):
@@ -33,7 +33,7 @@ class LibcNotFoundError(Exception):
3333
0: lief_loglvl.TRACE,
3434
logging.DEBUG: lief_loglvl.DEBUG,
3535
logging.INFO: lief_loglvl.INFO,
36-
logging.WARNING: lief_loglvl.WARNING,
36+
logging.WARNING: lief_loglvl.WARN,
3737
logging.ERROR: lief_loglvl.ERROR,
3838
logging.CRITICAL: lief_loglvl.CRITICAL,
3939
}

poetry.lock

Lines changed: 43 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ checksec = 'checksec.__main__:entrypoint'
1414

1515
[tool.poetry.dependencies]
1616
python = ">=3.10,<3.13"
17-
lief = "0.14.1"
17+
lief = "0.15.1"
1818
docopt = "0.6.2"
1919
rich = "^13.4"
2020
pylddwrap = "^1.0"

0 commit comments

Comments
 (0)