-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from tstromberg/main
Rule tuning from PyPI & Homebrew analysis
- Loading branch information
Showing
49 changed files
with
326 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
|
||
rule sudo_editor : suspicious { | ||
meta: | ||
description = "references /etc/sudoers" | ||
hash_2020_FinSpy_helper2 = "af4ad3b8bf81a877a47ded430ac27fdcb3ddd33d3ace52395f76cbdde46dbfe0" | ||
hash_2017_AptorDoc_Dok_AppStore = "4131d4737fe8dfe66d407bfd0a0df18a4a77b89347471cc012da8efc93c661a5" | ||
strings: | ||
$etc_sudoers = "/etc/sudoers" | ||
$nopasswd = "NOPASSWD:" | ||
$not_sample = "sudoers man page" | ||
$not_vim = "VIMRUNTIME" | ||
condition: | ||
filesize < 5242880 and ($etc_sudoers or $nopasswd) and not $not_sample | ||
filesize < 5242880 and ($etc_sudoers or $nopasswd) and none of ($not*) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import "math" | ||
|
||
rule setuptools_cmd_exec : suspicious { | ||
meta: | ||
description = "Python library installer that executes external commands" | ||
strings: | ||
$setup = "setup(" fullword | ||
$setuptools = "setuptools" | ||
$distutils = "distutils" | ||
$s_sys_val = /os.system\([\"\'\w\ \-\)\/]{0,64}/ | ||
$s_subprocess_val = /subprocess.\w{0,32}\([\"\'\/\w\ \-\)]{0,64}/ | ||
$s_import = "import subprocess" | ||
condition: | ||
$setup and ($setuptools or $distutils) and any of ($s_*) | ||
} | ||
|
||
rule setuptools_eval : critical { | ||
meta: | ||
description = "Python library installer that evaluates arbitrary code" | ||
strings: | ||
$setup = "setup(" fullword | ||
$setuptools = "setuptools" | ||
$distutils = "distutils" | ||
$s_sys_val = /eval\([\"\'\w\ \-\)\/]{0,64}/ fullword | ||
$s_subprocess_val = /exec\([\"\'\/\w\ \-\)]{0,64}/ fullword | ||
condition: | ||
$setup and ($setuptools or $distutils) and any of ($s_*) | ||
} | ||
|
||
rule setuptools_url_access : suspicious { | ||
meta: | ||
description = "Python library installer that accesses external URLs" | ||
strings: | ||
$setup = "setup(" fullword | ||
$setuptools = "setuptools" | ||
$distutils = "distutils" | ||
$s_requests = /requests.get\([\"\'\w\ \-\)\/]{0,64}/ | ||
$s_urlopen = /urlopen\([\"\'\w\ \-\)\/]{0,64}/ | ||
condition: | ||
$setup and ($setuptools or $distutils) and any of ($s_*) | ||
} | ||
|
||
|
||
|
||
rule setuptools_random : critical { | ||
meta: | ||
description = "Python library installer that exhibits random behavior" | ||
strings: | ||
$setup = "setup(" fullword | ||
$setuptools = "setuptools" | ||
$distutils = "distutils" | ||
$s_sys_val = "import random" fullword | ||
condition: | ||
$setup and ($setuptools or $distutils) and any of ($s_*) | ||
} | ||
|
||
|
||
|
||
rule setuptools_builtins : notable { | ||
meta: | ||
description = "Python library installer that directly references builtins" | ||
strings: | ||
$setup = "setup(" fullword | ||
$setuptools = "setuptools" | ||
$distutils = "distutils" | ||
$s_sys_val = "__builtins__" fullword | ||
condition: | ||
$setup and ($setuptools or $distutils) and any of ($s_*) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
rule base64_http_val : critical { | ||
meta: | ||
description = "contains base64 Python code" | ||
strings: | ||
$exec = "exec(" base64 | ||
$eval = "eval(" base64 | ||
$import = "__import__" base64 | ||
$importlib = "importlib" base64 | ||
$import_module = "import_module" base64 | ||
$urllib = "urllib.request" base64 | ||
$requests_get = "requests.get" base64 | ||
$urlopen = "urlopen" base64 | ||
$read = "read()" base64 | ||
$decode = "decode()" base64 | ||
condition: | ||
2 of them | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
rule excessive_bitwise_math : notable { | ||
meta: | ||
description = "excessive use of bitwise math" | ||
strings: | ||
$x = /\-{0,1}\d{1,8} \<\< \-{0,1}\d{1,8}/ | ||
condition: | ||
filesize < 128000 and #x > 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.