Coder Social home page Coder Social logo

homoglyph's Introduction

Detecting Homoglyph Attacks with a Siamese Neural Network

This is sample code for training the siamese neural network and comparing it to edit distance based techniques.

This was tested with 1.2.2 version of keras and python 2.7. We recommend having a GPU to speed up processing.

Prereq

You will need a copy of Arial.ttf to put in the code directory before running. This file should be in the same directory of the python code. If not, you will see an error similar to this:

Traceback (most recent call last):
  File "run_siamese.py", line 144, in <module>
    X1_train = generate_imgs([x[0] for x in data['train']], font_location, font_size, image_size, text_location)
  File "run_siamese.py", line 47, in generate_imgs
    font = ImageFont.truetype(font_location, font_size)
  File "/home/<user>/anaconda2/lib/python2.7/site-packages/PIL/ImageFont.py", line 239, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "/home/<user>/anaconda2/lib/python2.7/site-packages/PIL/ImageFont.py", line 128, in __init__
    self.font = core.getfont(font, size, index, encoding)
IOError: cannot open resource

Mac

You can view this for getting Arial.ttf: https://support.apple.com/guide/font-book/install-and-validate-fonts-fntbk1000/mac

Ubuntu

You can install ttf-mscorefonts-installer

Windows

Look in c:\Windows\Fonts

Code params

The code is very simple and has a couple parameters that can be changed inline. The first is data type. For running the code on process data, set the dataset_type to "process":

dataset_type = 'process'

For domains:

dataset_type = 'domain'

The second parameter allows the code to run on a subset of the data to get results faster. Note that a smaller dataset will get worse results. To set this parameter to a subset set isFast to True:

isFast = True

Too set to the full dataset do:

isFast = False

Run code

Simply run the python code like:

python run_siamese.py

homoglyph's People

Contributors

drhyrum avatar jhfrintrop avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.