Skip to content

Commit 462c7a7

Browse files
authored
Merge pull request #1839 from CybercentreCanada/identify_lzma_executor
Adding lzma executor and diverse python indicators
2 parents b0f3d66 + 9b27d79 commit 462c7a7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

assemblyline/common/custom.yara

+12-2
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,12 @@ rule code_python {
792792
793793
$strong_py20 = "asyncio.run("
794794
$strong_py21 = "asyncio.sleep("
795+
$strong_py22 = "pty.spawn("
796+
$strong_py23 = "platform.system()"
797+
$strong_py24 = "subprocess.run("
798+
$strong_py25 = "subprocess.Popen("
799+
$strong_py26 = "base64.b64decode("
800+
$strong_py27 = "socket.socket("
795801
796802
// Setup.py indicators
797803
$strong_py50 = "python_requires" ascii wide
@@ -828,16 +834,20 @@ rule code_python {
828834
$strong_py152 = "os.rename("
829835
830836
831-
// High confidence one-liner used to execute base64 blobs
837+
// High confidence one-liner used to execute encoded blobs
832838
// reference: https://github.com/DataDog/guarddog/blob/main/guarddog/analyzer/sourcecode/exec-base64.yml
833-
$executor1 = /((exec|eval|check_output|run|call|[Pp]open|os\.system)\(|lambda[ \t]+\w{1,100}[ \t]*:[ \t]*)((zlib|__import__\((['"]zlib['"]|['"]\\x0*7a\\x0*6c\\x0*69\\x0*62['"]|['"]\\0*172\\0*154\\0*151\\0*142['"])\))\.decompress\()?(base64|__import__\((['"]base64['"]|['"]\\x0*62\\x0*61\\x0*73\\x0*65\\x0*36\\x0*34['"]|['"]\\0*142\\0*141\\0*163\\0*145\\0*66\\0*64['"])\))\.b64decode\(/
839+
$executor1 = /((exec|eval|check_output|run|call|[Pp]open|os\.system)\(|lambda[ \t]+\w{1,100}[ \t]*:)\s*(((zlib|__import__\((['"]zlib['"]|['"]\\x0*7a\\x0*6c\\x0*69\\x0*62['"]|['"]\\0*172\\0*154\\0*151\\0*142['"])\)|lzma|__import__\((['"]lzma['"]|['"]\\x0*6c\\x0*7a\\x0*6d\\x0*61['"]|['"]\\0*154\\0*172\\0*155\\0*141['"])\))\.decompress\()|(base64|__import__\((['"]base64['"]|['"]\\x0*62\\x0*61\\x0*73\\x0*65\\x0*36\\x0*34['"]|['"]\\0*142\\0*141\\0*163\\0*145\\0*66\\0*64['"])\))\.b64decode\()/
834840
$executor2 = /(marshal|__import__\((['"]marshal['"]|['"]\\x0*6d\\x0*61\\x0*72\\x0*73\\x0*68\\x0*61\\x0*6c['"]|['"]\\0*155\\0*141\\0*162\\0*163\\0*150\\0*141\\0*154['"])\)|pickle|__import__\((['"]pickle['"]|['"]\\x0*70\\x0*69\\x0*63\\x0*6b\\x0*6c\\x0*65['"]|['"]\\0*160\\0*151\\0*143\\0*153\\0*154\\0*145['"])\))\.loads\(/
835841
836842
condition:
837843
mime startswith "text"
838844
and (
839845
2 of ($strong_py*)
840846
or any of ($executor*)
847+
or (
848+
filesize < 1024
849+
and 1 of ($strong_py*)
850+
)
841851
)
842852
}
843853

0 commit comments

Comments
 (0)