Homoglyphs – Get Similar Letters, Convert To ASCII, Detect Possible Languages And UTF-8 Group

Homoglyphs — python library for getting homoglyphs and converting to ASCII.FeaturesIt’s smarter version of confusable_homoglyphs:Autodect or manual choosing category (aliases from ISO 15924).Auto or manual load only needed alphabets in memory.Converting to ASCII.More configurable.More stable.Installationsudo pip install homoglyphsUsageImporting:import homoglyphs as hgLanguages#detecthg.Languages.detect(‘w’)# {‘pl’, ‘da’, ‘nl’, ‘fi’, ‘cz’, ‘sr’, ‘pt’, ‘it’, ‘en’, ‘es’, ‘sk’, ‘de’, ‘fr’, ‘ro’}hg.Languages.detect(‘т’)# {‘mk’, ‘ru’, ‘be’, ‘bg’, ‘sr’}hg.Languages.detect(‘.’)# set()# get alphabet for languageshg.Languages.get_alphabet([‘ru’])# {‘в’, ‘Ё’, ‘К’, ‘Т’, …, ‘Р’, ‘З’, ‘Э’}CategoriesCategories — (aliases from ISO 15924).#detecthg.Categories.detect(‘w’)# ‘LATIN’hg.Categories.detect(‘т’)# ‘CYRILLIC’hg.Categories.detect(‘.’)# ‘COMMON’# get alphabet for categorieshg.Categories.get_alphabet([‘CYRILLIC’])# {‘ӗ’, ‘Ԍ’, ‘Ґ’, ‘Я’, …, ‘Э’, ‘ԕ’, ‘ӻ’}HomoglyphsGet homoglyphs:# get homoglyphs (latin alphabet initialized by default)hg.Homoglyphs().get_combinations(‘q’)# [‘q’, ‘𝐪’, ‘𝑞’, ‘𝒒’, ‘𝓆’, ‘𝓺’, ‘𝔮’, ‘𝕢’, ‘𝖖’, ‘𝗊’, ‘𝗾’, ‘𝘲’, ‘𝙦’, ‘𝚚’]Alphabet loading:# load alphabet on init by categorieshomoglyphs = hg.Homoglyphs(categories=(‘LATIN’, ‘COMMON’, ‘CYRILLIC’)) # alphabet loaded herehomoglyphs.get_combinations(‘гы’)# [‘rы’, ‘гы’, ‘ꭇы’, ‘ꭈы’, ‘𝐫ы’, ‘𝑟ы’, ‘𝒓ы’, ‘𝓇ы’, ‘𝓻ы’, ‘𝔯ы’, ‘𝕣ы’, ‘𝖗ы’, ‘𝗋ы’, ‘𝗿ы’, ‘𝘳ы’, ‘𝙧ы’, ‘𝚛ы’]# load alphabet on init by languageshomoglyphs = hg.Homoglyphs(languages={‘ru’, ‘en’}) # alphabet will be loaded herehomoglyphs.get_combinations(‘гы’)# [‘rы’, ‘гы’]# manual set alphabet on init # eng rushomoglyphs = hg.Homoglyphs(alphabet=’abc абс’)homoglyphs.get_combinations(‘с’)# [‘c’, ‘с’]# load alphabet on demandhomoglyphs = hg.Homoglyphs(languages={‘en’}, strategy=hg.STRATEGY_LOAD)# ^ alphabet will be loaded here for “en" languagehomoglyphs.get_combinations(‘гы’)# ^ alphabet will be loaded here for "ru" language# [‘rы’, ‘гы’]You can combine categories, languages, alphabet and any strategies as you want.Converting glyphs to ASCII charshomoglyphs = hg.Homoglyphs(languages={‘en’}, strategy=hg.STRATEGY_LOAD)# converthomoglyphs.to_ascii(‘тест’)# [‘tect’]homoglyphs.to_ascii(‘ХР123.’) # this is cyrillic "х" and "р"# [‘XP123.’, ‘XPI23.’, ‘XPl23.’]# string with chars which can’t be converted by default will be ignoredhomoglyphs.to_ascii(‘лол’)# []# you can set strategy for removing not converted non-ASCII chars from resulthomoglyphs = hg.Homoglyphs( languages={‘en’}, strategy=hg.STRATEGY_LOAD, ascii_strategy=hg.STRATEGY_REMOVE,)homoglyphs.to_ascii(‘лол’)# [‘o’]Download Homoglyphs

Link: http://feedproxy.google.com/~r/PentestTools/~3/a3KNII37Xy8/homoglyphs-get-similar-letters-convert.html