Skip to main content

Adversarial attacks for perceptual image hashing functions

Project description

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:

Component Description
advhash a PyTorch based library for performing adversarial attacks
advhash.attack adversarial attack methods
advhash.hash perceptual hashing functions
advhash.utils utility 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

advhash-0.1.1.tar.gz (23.3 kB view hashes)

Uploaded Source

Built Distribution

advhash-0.1.1-py3-none-any.whl (25.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page