Skip to content

Commit a31a152

Browse files
authored
Merge pull request #38 from MmAaXx500/its-not-js
Do not detect elf as other file types
2 parents 01ac831 + d45b500 commit a31a152

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

sflock/ident.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@
196196
]
197197
)
198198

199+
def is_executable(f):
200+
return f.contents.startswith((b"MZ", b"\x7fELF"))
199201

200202
def detect_shellcode(f):
201203

@@ -267,7 +269,7 @@ def sct(f):
267269

268270

269271
def xxe(f):
270-
if f.contents.startswith(b"MZ"):
272+
if is_executable(f):
271273
return None
272274

273275
STRINGS = [
@@ -285,7 +287,7 @@ def xxe(f):
285287

286288

287289
def hta(f):
288-
if f.contents.startswith(b"MZ"):
290+
if is_executable(f):
289291
return None
290292

291293
STRINGS = [
@@ -322,7 +324,7 @@ def office_one(f):
322324

323325

324326
def office_webarchive(f):
325-
if f.contents.startswith(b"MZ"):
327+
if is_executable(f):
326328
return None
327329

328330
STRINGS = [
@@ -403,7 +405,7 @@ def office_ole(f):
403405

404406

405407
def powershell(f):
406-
if f.contents.startswith(b"MZ"):
408+
if is_executable(f):
407409
return None
408410

409411
POWERSHELL_STRS = [
@@ -428,7 +430,7 @@ def powershell(f):
428430

429431

430432
def javascript(f):
431-
if f.contents.startswith(b"MZ"):
433+
if is_executable(f):
432434
return None
433435

434436
JS_STRS = [
@@ -456,7 +458,7 @@ def javascript(f):
456458

457459

458460
def wsf(f):
459-
if f.contents.startswith(b"MZ"):
461+
if is_executable(f):
460462
return None
461463

462464
match = re.search(b'<script\\s+language="(J|VB|Perl)Script"', f.contents, re.I)
@@ -465,7 +467,7 @@ def wsf(f):
465467

466468

467469
def pub(f):
468-
if f.contents.startswith(b"MZ"):
470+
if is_executable(f):
469471
return None
470472

471473
PUB_STRS = [
@@ -482,7 +484,7 @@ def pub(f):
482484

483485

484486
def visualbasic(f):
485-
if f.contents.startswith(b"MZ"):
487+
if is_executable(f):
486488
return None
487489

488490
VB_STRS = [
@@ -534,7 +536,7 @@ def dmg(f):
534536

535537

536538
def vbe_jse(f):
537-
if f.contents.startswith(b"MZ"):
539+
if is_executable(f):
538540
return None
539541

540542
if b"#@~^" in f.contents[:100]:
@@ -556,7 +558,7 @@ def udf(f):
556558

557559

558560
def inf(f):
559-
if f.contents.startswith(b"MZ"):
561+
if is_executable(f):
560562
return None
561563

562564
STRINGS = [

0 commit comments

Comments
 (0)