@@ -134,14 +134,6 @@ def check_ELF_separate_code(executable):
134
134
return False
135
135
return True
136
136
137
- def check_PE_PIE (executable ) -> bool :
138
- '''
139
- Check for position independent executable (PIE),
140
- allowing for address space randomization.
141
- '''
142
- binary = lief .parse (executable )
143
- return binary .is_pie
144
-
145
137
def check_PE_DYNAMIC_BASE (executable ) -> bool :
146
138
'''PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR)'''
147
139
binary = lief .parse (executable )
@@ -159,32 +151,13 @@ def check_PE_RELOC_SECTION(executable) -> bool:
159
151
binary = lief .parse (executable )
160
152
return binary .has_relocations
161
153
162
- def check_PE_NX (executable ) -> bool :
163
- '''NX: DllCharacteristics bit 0x100 signifies nxcompat (DEP)'''
164
- binary = lief .parse (executable )
165
- return binary .has_nx
166
-
167
- def check_MACHO_PIE (executable ) -> bool :
168
- '''
169
- Check for position independent executable (PIE), allowing for address space randomization.
170
- '''
171
- binary = lief .parse (executable )
172
- return binary .is_pie
173
-
174
154
def check_MACHO_NOUNDEFS (executable ) -> bool :
175
155
'''
176
156
Check for no undefined references.
177
157
'''
178
158
binary = lief .parse (executable )
179
159
return binary .header .has (lief .MachO .HEADER_FLAGS .NOUNDEFS )
180
160
181
- def check_MACHO_NX (executable ) -> bool :
182
- '''
183
- Check for no stack execution
184
- '''
185
- binary = lief .parse (executable )
186
- return binary .has_nx
187
-
188
161
def check_MACHO_LAZY_BINDINGS (executable ) -> bool :
189
162
'''
190
163
Check for no lazy bindings.
@@ -200,6 +173,21 @@ def check_MACHO_Canary(executable) -> bool:
200
173
binary = lief .parse (executable )
201
174
return binary .has_symbol ('___stack_chk_fail' )
202
175
176
+ def check_PIE (executable ) -> bool :
177
+ '''
178
+ Check for position independent executable (PIE),
179
+ allowing for address space randomization.
180
+ '''
181
+ binary = lief .parse (executable )
182
+ return binary .is_pie
183
+
184
+ def check_NX (executable ) -> bool :
185
+ '''
186
+ Check for no stack execution
187
+ '''
188
+ binary = lief .parse (executable )
189
+ return binary .has_nx
190
+
203
191
CHECKS = {
204
192
'ELF' : [
205
193
('PIE' , check_ELF_PIE ),
@@ -209,16 +197,16 @@ def check_MACHO_Canary(executable) -> bool:
209
197
('separate_code' , check_ELF_separate_code ),
210
198
],
211
199
'PE' : [
212
- ('PIE' , check_PE_PIE ),
200
+ ('PIE' , check_PIE ),
213
201
('DYNAMIC_BASE' , check_PE_DYNAMIC_BASE ),
214
202
('HIGH_ENTROPY_VA' , check_PE_HIGH_ENTROPY_VA ),
215
- ('NX' , check_PE_NX ),
203
+ ('NX' , check_NX ),
216
204
('RELOC_SECTION' , check_PE_RELOC_SECTION )
217
205
],
218
206
'MACHO' : [
219
- ('PIE' , check_MACHO_PIE ),
207
+ ('PIE' , check_PIE ),
220
208
('NOUNDEFS' , check_MACHO_NOUNDEFS ),
221
- ('NX' , check_MACHO_NX ),
209
+ ('NX' , check_NX ),
222
210
('LAZY_BINDINGS' , check_MACHO_LAZY_BINDINGS ),
223
211
('Canary' , check_MACHO_Canary )
224
212
]
0 commit comments