Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not detect elf as other file types #38

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading