assemblyline: Wrong identification of Python code
Describe the bug As usual, there are a couple of Python code files that were not identified correctly š
cc: @gdesmar
Password for all files: zippy. As usual, they can contact dangerous code.
The following files were identified as text/plain:
- BitForger.py.zip
- possible characteristics:
import urllib.request,subprocess.run,urllib.request.urlretrieve
- possible characteristics:
- _deobfuscated_code_FINAL.py (kopia).zip
- characteristic executor:
exec(lzma.decompress(
- characteristic executor:
- init.py.zip
- quite similar to the (1), but a little longer
- init.py(1).zip
import urllib.parse,import aiohttp
- init.py (kopia).zip
subprocess.Popen
- tools.py.zip
- similar to (2),
exec(lzma.decompress(base64.b64decode
- similar to (2),
The following files were identified as code/ps1. Those are more complicated, as they do contain PowerShell commands, but they are Python scripts:
The same story, but with code/batch identification:
To Reproduce Steps to reproduce the behavior:
- Upload and see the wrong file type
Expected behavior
Identification as code/python.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information if pertinent):
- Assemblyline Version: 4.5.0.x - those files were collected for some time
- Browser: [e.g. chrome, safari]
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18
And a new one š post_install.py.zip
I modified the first executor to allow for different encoding. It will now check for a zlib or lzma or base64 payload inside an execution, instead of a base64 payload inside an optional zlib or lzma step inside an execution. This will identify
_deobfuscated_code_FINAL.py (kopia).zipas a python script. I donāt think it will cause too many false positives, as the rule have a default score that will lower the chances.Regarding the mixed code scripts, I agree that having the list of locations where the yara strings were found (and hopefully their name) could be of great help to deconflict the two languages. Iāll try to look into it, but I think thatās already a great start. š
Eventually, it could be a score bump for āwhat exist firstā - e.g. if the Python characteristic was found earlier in the file than ps1/batch AND was not after some not-Python indicators. I mean, if we have a strong Python indicator at the top of the file, and itās not inside a PowerShell variable assignment, itās reasonable to assume it has to be proceeded by Python. But recognizing if it was or wasnāt inside a string (or something like it), sounds too complex for YARA