Skip to content

Commit

Permalink
Merge pull request #38 from MmAaXx500/its-not-js
Browse files Browse the repository at this point in the history
Do not detect elf as other file types
  • Loading branch information
doomedraven authored Apr 28, 2024
2 parents 01ac831 + d45b500 commit a31a152
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions sflock/ident.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@
]
)

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

def detect_shellcode(f):

Expand Down Expand Up @@ -267,7 +269,7 @@ def sct(f):


def xxe(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

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


def hta(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

STRINGS = [
Expand Down Expand Up @@ -322,7 +324,7 @@ def office_one(f):


def office_webarchive(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

STRINGS = [
Expand Down Expand Up @@ -403,7 +405,7 @@ def office_ole(f):


def powershell(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

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


def javascript(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

JS_STRS = [
Expand Down Expand Up @@ -456,7 +458,7 @@ def javascript(f):


def wsf(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

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


def pub(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

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


def visualbasic(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

VB_STRS = [
Expand Down Expand Up @@ -534,7 +536,7 @@ def dmg(f):


def vbe_jse(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

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


def inf(f):
if f.contents.startswith(b"MZ"):
if is_executable(f):
return None

STRINGS = [
Expand Down

0 comments on commit a31a152

Please sign in to comment.