
Analisar strings ou arquivos em busca de malware usando o Windows Antimalware Scan Interface
py-amsi é uma biblioteca que verifica strings ou arquivos em busca de malware usando a API do Windows Antimalware Scan Interface (AMSI). AMSI é uma interface nativa do Windows que permite que aplicativos solicitem ao antivírus instalado no sistema que analise um arquivo/string. AMSI não está vinculado ao Windows Defender. Provedores de antivírus implementam a interface AMSI para receber chamadas de aplicativos. Esta biblioteca aproveita a API para realizar verificações antivírus em python. Leia mais sobre a API do Windows AMSI aqui.
Via pip
pip install pyamsi
Clonar repositório
git clone https://github.com/Tomiwa-Ot/py-amsi.git
cd py-amsi/
python setup.py install
from pyamsi import Amsi
# Scan a file
Amsi.scan_file(file_path, debug=True) # debug is optional and False by default
# Scan string
Amsi.scan_string(string, string_name, debug=False) # debug is optional and False by default
# Both functions return a dictionary of the format
# {
# 'Sample Size' : 68, // The string/file size in bytes
# 'Risk Level' : 0, // The risk level as suggested by the antivirus
# 'Message' : 'File is clean' // Response message
# }
| Nível de Risco | Significado |
|---|---|
| 0 | AMSI_RESULT_CLEAN (Arquivo está limpo) |
| 1 | AMSI_RESULT_NOT_DETECTED (Nenhuma ameaça detectada) |
| 16384 | AMSI_RESULT_BLOCKED_BY_ADMIN_START (Ameaça bloqueada pelo administrador) |
| 20479 | AMSI_RESULT_BLOCKED_BY_ADMIN_END (Ameaça bloqueada pelo administrador) |
| 32768 | AMSI_RESULT_DETECTED (Arquivo é considerado malware) |