
Framework de hachage des permissions déclarées dans les extensions Chromium et les APK, permettant le clustering, la chasse et le pivotement à travers des paquets potentiellement malveillants.
Permhash est un framework extensible permettant de hacher les permissions déclarées appliquées aux extensions de navigateur basées sur Chromium et aux APK, ce qui permet le clustering, la chasse et le pivotement, à l'instar du hachage d'imports et du hachage d'en-têtes riches.
Permhash peut actuellement traiter quatre types de fichiers, mais est extensible au-delà de cela :
Installez la bibliothèque permhash
pip install permhash
Importez permhash
from permhash import functions as permhash
Utilisez 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)
Un exemple de calcul de permhash en masse.
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])
Permhash peut également être utilisé comme outil en ligne de commande. Fournissez le chemin complet du fichier pour calculer le permhash avec l'option --path/-p et le type de fichier analysé avec l'option --type/-t. La commande affichera le permhash ou False si le fichier est invalide.
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]'
Consultez le blog Mandiant Permhash pour plus de détails.
Le groupe Google Permhash peut être utilisé pour faciliter les discussions.
Ceci n'est pas un produit officiellement pris en charge par Google.