示例#1
0
def compareByVisuallySimilarChars(word1, word2):
	# rn and m. deal with it. cant go char by char
    for i,j in zip(word1,word2):
        try:
            if (not homoglyphs.Homoglyphs().get_combinations(i) == homoglyphs.Homoglyphs().get_combinations(j) or 
            dictionaries.similarChars[i] in dictionaries.similarChars[j] or i==j):
                return False
        except KeyError:
            pass
    return True
示例#2
0
def homograph_to_latin(domain):
    """Convert homograph domain to LATIN characters

        Args:
            none

        Return:
            none

    """
    homoglyphs = hg.Homoglyphs(languages={"en"}, strategy=hg.STRATEGY_LOAD)

    new_domain = []
    str_domain = ""

    for char in domain:
        charset = hg.Categories.detect(char)
        if charset != "LATIN":
            char_converted = homoglyphs.to_ascii(char)
            char_converted = "".join(char_converted)
            new_domain.append(char_converted)
        else:
            new_domain.append(char)

    str_domain = "".join(new_domain)

    return str_domain
示例#3
0
 def find_username_skeleton(username):
     skeleton = ''
     for ch in username:
         homoglyph = hg.Homoglyphs(languages={'fr'}, strategy=hg.STRATEGY_LOAD).to_ascii(ch)
         if len(homoglyph) > 0:
             if homoglyph[0].strip() != '':
                 skeleton += homoglyph[0]
     return skeleton.lower()
示例#4
0
def stop_copy(input):
	output=''
	for letter in input:
		if random.randint(1,9)==1:
			if letter==_S:new_letter=_S
			else:new_letters=hg.Homoglyphs().get_combinations(letter);new_letter=random.choice(new_letters)
		else:new_letter=letter
		output+=new_letter
	return output
示例#5
0
def homoify(token: str, homo_percent: float = 0.3):
    if len(token) <= 3:  # dont homoglyph censor stuff this small
        return token
    swaps = int(ceil(len(token) * homo_percent))
    indexes = random.choices(range(1, len(token)), k=swaps)
    for i in indexes:
        token = "".join([
            token[w] if w != i else random.choice(
                hg.Homoglyphs().get_combinations(token[w]))
            for w in range(len(token))
        ])
    return token
示例#6
0
def permute_characters(text, replaces=2):
    chars = list(set([c for c in text.replace(' ', '')]))
    for i in range(0, replaces):
        old_char = random.choice(chars)
        if isinstance(old_char, tuple):
            continue
        new_char = random.choice(hg.Homoglyphs().get_combinations(old_char))
        chars.pop(chars.index(old_char))
        chars.append((old_char, new_char))
    chars_map = []
    for c in chars:
        if isinstance(c, tuple):
            chars_map.append(c)
        else:
            chars_map.append((c, c))
    for old_char, new_char in chars_map:
        text = text.replace(old_char, new_char)
    return text
示例#7
0
    def switch_all_letters(self):
        """
        The following function generates all the possible combinations using homoglyphs

        """
        url = get_tld(self.url, as_object=True, fix_protocol=True)
        domain = url.domain
        domains = hg.Homoglyphs().get_combinations(domain)
        a = []
        i = 0
        print("Generated " + str(len(domains)) + " domains\n")
        for domain in domains:
            idna_domain = domain.encode('idna').decode('idna')

            if not a.__contains__(idna_domain):
                a.append(domain.encode('idna').decode('idna'))
            i = i + 1
            print(
                str(i) + ' out of ' + str(len(domains)) + ' domains: ' +
                str(len(a)))
        return a
def compare(domain, domain_list, threshold, check_homoglyphs):
    result = []
    domain = domain.lower()
    if check_homoglyphs:
        homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD)
        print("loaded homoglyphs")
        variants = homoglyphs.to_ascii(domain)
        print("found {} variants: {}".format(len(variants), variants))
    else:
        variants = [domain]
    for domain_appearance in variants:
        print("checking {}".format(domain_appearance))
        domain_appearance = domain_appearance.lower()
        for good_domain in domain_list:
            good_domain = good_domain.lower()
            score = jellyfish.jaro_winkler(unicode(domain),
                                           unicode(good_domain))
            print("{} matched {} at score: {}".format(domain_appearance,
                                                      good_domain, score))
            if score >= threshold:
                result.append(good_domain)
        return (True, result)
示例#9
0
_C=None
_B=True
_A=False
import discord,base64
from operator import itemgetter
import requests,random,asyncio,psutil,urllib,datetime,random,sys,traceback,urllib.parse,urllib.request
from json import loads
from discord.ext.commands import has_permissions,MissingPermissions
from discord.ext import commands
from discord.utils import find
import time,redis,os,json,subprocess
from profanityfilter import ProfanityFilter
import homoglyphs as hg
pf=ProfanityFilter()
pf.set_censor('#')
homoglyphs=hg.Homoglyphs(languages={'en'},strategy=hg.STRATEGY_LOAD)
userspecific=_B
yesemoji='👍'
noemoji='👎'
numberemojis=['1️⃣','2️⃣','3️⃣','4️⃣']
categories={_W:'9',_c:_z,_d:'11',_e:'12',_f:'13',_g:'14',_h:'15',_i:'16',_j:'17',_k:'18',_l:'19',_m:'20',_n:'21',_o:'22',_p:'23',_q:'24',_r:'25',_s:'26',_t:'27',_u:'28',_v:'29',_w:'30',_x:'31',_y:'32'}
TOKEN=os.getenv('bottoken')
if TOKEN==_C:TOKEN=input('Token Please:')
redisurl=os.getenv('REDIS_URL')
if redisurl==_C:redisurl=input('Please enter the REDIS URL:')
dbl_token=os.getenv('DBL_TOKEN')
HEROKU_RELEASE_CREATED_AT=os.getenv('HEROKU_RELEASE_CREATED_AT')
HEROKU_RELEASE_VERSION=os.getenv('HEROKU_RELEASE_VERSION')
HEROKU_SLUG_COMMIT=os.getenv('HEROKU_SLUG_COMMIT')
HEROKU_SLUG_DESCRIPTION=os.getenv('HEROKU_SLUG_DESCRIPTION')
triviadb=redis.from_url(redisurl)
示例#10
0
===========================================================================
'''

# Standard Stuff
import sys, socket

# Homoglyphs
# pip3 install homoglyphs
import homoglyphs as hg

######################################################################

if __name__ == '__main__':

    # Init homoglyphs with English, Bulgarian, Russian and Greek
    homoglyphs = hg.Homoglyphs(languages={'en', 'bg', 'ru', 'el'})

    # Grep input from stdin
    for line in sys.stdin:

        # Strip leading/ending dots/spaces
        entry = line.strip().strip('.').lower()

        # Get TLD
        if entry.count('.') > 0:
            tld = entry.split('.')[-1]

            # Only generate for IDN enabled TLDs
            if tld in ('ac', 'ar', 'asia', 'at', 'biz', 'br', 'cat', 'ch',
                       'cl', 'cn', 'com', 'de', 'dk', 'es', 'fi', 'gr', 'hu',
                       'il', 'info', 'io', 'ir', 'is', 'jp', 'kr', 'li', 'lt',
示例#11
0
verbose = False
classes = 'LATIN', 'CYRILLIC', 'GREEK', 'COPTIC'

if '-v' in sys.argv:
    verbose = True
    del sys.argv[sys.argv.index('-v')]

if '-c' in sys.argv:
    idx = sys.argv.index('-c')
    del sys.argv[idx]
    classes = sys.argv[idx]
    del sys.argv[idx]
    classes = classes.upper().split(',')

if len(sys.argv) < 2:
    print("usage: %s [-c <latin,cyrillic,coptic,greek,...>] string" %
          sys.argv[0])
    sys.exit(0)

homoglyphs = hg.Homoglyphs(categories=(classes))

total = 1
res = []
for a in ' '.join(sys.argv[1:]):
    c = homoglyphs.get_combinations(a) or [a]
    total *= len(c)
    res.append(choice(c))
print(''.join(res))
if verbose:
    print("total combinations:", total)
示例#12
0
""" encode a text file using homoglyphs """
from random import SystemRandom
import homoglyphs as hg
from ansitoimg.render import ansiToHTMLRaster
from stegstash.utils import otp, getMap, toFile, toBin

HOMOGLYPHS = hg.Homoglyphs(categories=('LATIN', 'COMMON', 'CYRILLIC'))


def simpleEncode(openPath, writePath, data):
	"""encode a text file with data using homoglyphs

	Args:
		openPath (string): path to the original text file to open
		writePath (string): path to write the stego-text file
		data (string|bytes|<file>): data to encode
	"""
	with open(openPath, encoding="utf-8") as openData:
		fileData = openData.read()
	position = 0
	output = []
	data = toBin(data)
	for char in data + b"\x00":
		shift = 0
		while shift < 8:
			result, shift = encodeGlyph(fileData, position, char, shift)
			output.append(result)
			position += 1
	output.append(fileData[position:])
	with open(writePath, "w", encoding="utf-8") as writeData:
		writeData.write("".join(output))
示例#13
0
 def __init__(self, domain_string: str, phishing_domains: list) -> None:
     super(HomoglyphGeneratorStrategy,
           self).__init__(domain_string, phishing_domains)
     self.glyphs_generator = hg.Homoglyphs(languages={'en'},
                                           categories=('COMMON', 'LATIN'))
     self.glyphs_dict = dict()