Catalog PyPI
PACKAGE EXPLORERView in registry

advhash

PyPI

Adversarial attacks for perceptual image hashing functions

adversarialattackshashingimage
Versions collected1
Direct dependencies3From release 0.1.1
Last observed20 Oct, 20:03 UTC

README

Version 0.1.1 documentation

AdvHash: Adversarial collision attacks on perceptual hashing functions

CircleCI codecov.io PyPI Version Python Version License: GPL v3

Summary

AdvHash is a Python package that provides a simple to use interface for performing adversarial collision attacks on perceptual hashing functions.

PyTorch is used to re-create the target hashing functions and generating adversarial examples. AdvHash supports both CPU and GPU computations. Install the CUDA enabled version of PyTorch to use a GPU with AdvHash and specify device='cuda' when instantiating an attack or hash.

Adversarial collision attacks on image hashing functions

Adversarial cat Currently AdvHash supports collision attacks on hashing functions from the popular imagehash package using methods described in Adversarial collision attacks on image hashing functions.

Components

AdvHash is divided into multiple granular components:

ComponentDescription
advhasha PyTorch based library for performing adversarial attacks
advhash.attackadversarial attack methods
advhash.hashperceptual hashing functions
advhash.utilsutility functions for performing common resizing, conversion, and comparison operations

Getting Started

Installation

pip install advhash

*Install a CUDA enabled version of PyTorch to use a GPU with AdvHash.

Example Usage

This example shows how the L2Attack can be used to perform an adversarial collision attack on dHash using the resize method as the target split point.

import torch
import numpy as np
from PIL import Image
from advhash.attack.l2 import L2Attack

target_img = Image.open('forest.jpg')
source_img = Image.open('cat.jpg')

target = torch.tensor((np.array(target_img).astype('float32')))
source = torch.tensor((np.array(source_img).astype('float32')))

l2 = L2Attack(hash_fn='dhash', split_point='resize')

im_adv = l2.attack(target, source)

Attacks

Collision Attacks for Image Hashing

  • advhash.attack.l2.L2Attack
  • advhash.attack.hinge.HingeAttack

The above attacks accept a source image, target image, and hashing function as an input. The source image will be perturbed to create an adversarial image that has the same hash as the target image when hashed by the selected hashing function. Some attacks require additional configuration.

Hashing Functions

Future Development

Hashing Functions

  • pHash
  • aHash
  • pqd

Attack Methods

  • TBD

Defense Methods

  • TBD

Contributing

Contributions are welcome! If you plan to contribute new features, methods, or enhancements, please open an issue to discuss the addition further, or comment on an existing issue.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.131 Jul 20213

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
mattpodolak/advhash

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:03 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:d2f4a519383a3f86c4bb99451021ddaf5ba96fab686bc8c681ce4835d6c6c9ad