
Framework para hashing de permissões declaradas em extensões do Chromium e APKs, permitindo clustering, caça e pivoting entre pacotes potencialmente maliciosos.
O Permhash é uma estrutura extensível para calcular o hash das permissões declaradas aplicadas a extensões de navegador baseadas em Chromium e APKs, permitindo agrupamento, caça e pivotação semelhantes ao hash de importação e ao hash de rich header.
O Permhash atualmente é capaz de processar quatro tipos de arquivos, mas é extensível além disso:
Instale a biblioteca permhash
pip install permhash
Importe o permhash
from permhash import functions as permhash
Use o permhash
# The path variable should be the full path to the file you wish to use to calculate the permhash.
# Calculate the permhash for a CRX
ph = permhash.permhash_crx(path)
# Calculate the permhash for a CRX manifest
ph = permhash.permhash_crx_manifest(path)
# Calculate the permhash for an APK
ph = permhash.permhash_apk(path)
# Calculate the permhash for an APK manifest
ph = permhash.permhash_apk_manifest(path)
Um exemplo de cálculo de permhash em lote.
import csv
import os
from permhash import functions as permhash
def bulk_permhash_crx_manifest(path, output):
"""
Computes the permhash from a directory of CRX manifests
Outputs the results in a csv passed as input
:param path: The targeted directory
:type path: string
:param output:
:type path: string
"""
with open(output, mode="w", encoding="utf-8") as results:
out_writer = csv.writer(
results, delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL
)
out_writer.writerow(["filename", "permhash"])
for filename in os.listdir(path):
if path.endswith("/"):
full_path = path + filename
else:
full_path = path + "/" + filename
calculated_permhash = permhash.permhash_crx_manifest(full_path)
if calculated_permhash:
out_writer.writerow([filename, calculated_permhash])
O Permhash também pode ser usado como uma ferramenta de linha de comando. Forneça o caminho completo para o arquivo para calcular o permhash na opção --path/-p e o tipo de arquivo analisado na opção --type/-t. O comando exibirá o permhash ou False se for um arquivo inválido.
permhash --type crx --path '[PATH TO CRX File]'
permhash --type crx_manifest --path '[PATH TO CRX Manifest File]'
permhash --type apk --path '[PATH TO APK File]'
permhash --type apk_manifest --path '[PATH TO APK Manifest Files]'
Consulte o Blog do Mandiant sobre Permhash para mais detalhes.
O Grupo do Google Permhash pode ser usado para facilitar a discussão.
Este não é um produto oficialmente suportado pelo Google.