Detect confusable usage of unicode homoglyphs, prevent homograph attacks.
a homoglyph is one of two or more graphemes, characters, or glyphs with shapes that appear identical or very similar wikipedia:Homoglyph
Unicode homoglyphs can be a nuisance on the web. Your most popular client, AlaskaJazz, might be upset to be impersonated by a trickster who deliberately chose the username ΑlaskaJazz.
- AlaskaJazz is single script: only Latin characters.
- ΑlaskaJazz is mixed-script: the first character is a greek letter.
You might also want to avoid people being tricked into entering their password on www.microsоft.com or www.faϲebook.com instead of www.microsoft.com or www.facebook.com. Here is a utility to play with these confusable homoglyphs.
Not all mixed-script strings have to be ruled out though, you could only exclude mixed-script strings containing characters that might be confused with a character from some unicode blocks of your choosing.
- Allo and ρττ are fine: single script.
- AlloΓ is fine when our preferred script alias is ‘latin’: mixed script, but Γ is not confusable.
- Alloρ is dangerous: mixed script and ρ could be confused with p.
This library is compatible Python 2 and Python 3.
Is the data up to date?
The unicode blocks aliases and names for each character are extracted from this file provided by the unicode consortium.
The matrix of which character can be confused with which other characters is built using this file provided by the unicode consortium.
This data is stored in two JSON files: categories.json and confusables.json. If you delete them, they will both be recreated by downloading and parsing the two abovementioned files and stored as JSON files again.
- allowed_categories renamed to allowed_aliases
- Fix a TypeError: https://github.com/vhf/confusable_homoglyphs/pull/2
Courtesy of Ryan P Kilby, via https://github.com/vhf/confusable_homoglyphs/pull/6 :
- Changed file paths to be relative to the confusable_homoglyphs package directory instead of the user’s current working directory.
- Data files are now distributed with the packaging.
- Fixes tests so that they use the installed distribution instead of the local files. (Originally, the data files were erroneously showing up during testing, despite not being included in the distribution).
- Moves the data file generation into a simple CLI. This way, users have a method for controlling when the data files are updated.
- Since the data files are now included in the distribution, the CLI is made optional. Its dependencies can be installed with the cli bundle, eg. pip install confusable_homoglyphs[cli].
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size confusable_homoglyphs-3.2.0-py2.py3-none-any.whl (141.2 kB)||File type Wheel||Python version 2.7||Upload date||Hashes View|
|Filename, size confusable_homoglyphs-3.2.0.tar.gz (161.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for confusable_homoglyphs-3.2.0-py2.py3-none-any.whl
Hashes for confusable_homoglyphs-3.2.0.tar.gz