112 lines
5.0 KiB
Python
112 lines
5.0 KiB
Python
# -*- coding: utf-8 -*-
|
||
# confusables - developed by acidvegas in python (https://git.acid.vegas/random)
|
||
# adapted as a weechat script by wrk
|
||
|
||
'''
|
||
This script contains a dictionary of keyboard typable characters unicode variants that are very similar.
|
||
Other possible variants exist, for now we are only matching the ones that do not "look" like unicode.
|
||
This can be used to evade spam filtering by replacing characters with their similar unicode variants.
|
||
|
||
Todo:
|
||
- Convert unicode characters into raw codepoints in the dictionary (Example: \u202e)
|
||
- Add variants for missing typable characters (iIl)
|
||
- Extend to more variants than already in the database
|
||
- Set different odds on character replacement for chance feature on the confuse function
|
||
'''
|
||
|
||
import weechat
|
||
import random
|
||
|
||
def confuse(data, chance=False):
|
||
'''chance set to True will give each replacable character a 50% chance of being replaced'''
|
||
confused = str()
|
||
for char in data:
|
||
if char in confusable and (not chance or random.choice((True,False))):
|
||
confused += random.choice(list(confusable[char]))
|
||
else:
|
||
confused += char
|
||
return confused
|
||
|
||
confusable = {
|
||
' ':' ',
|
||
'.':'܂․.⡀',
|
||
'!':'ǃⵑ!',
|
||
'$':'$',
|
||
'%':'%',
|
||
'&':'ꝸ&',
|
||
':':'ː˸։׃⁚∶ꓽ꞉︰:',
|
||
';':';;',
|
||
'<':'ᐸ<',
|
||
'=':'⹀꓿=',
|
||
'>':'ᐳ>',
|
||
'?':'?',
|
||
'@':'@',
|
||
'0':'߀𝛰〇𐊒𝟬𝜪Oዐ𝞞𝝤ⵔՕ𝟢𝗢𝘖ⲞОΟଠ𝟎𝐎০୦O𐊫𝙾ꓳ𐐄𝟶𝑶𝚶𐓂௦౦೦ഠဝ၀ჿᴏᴑⲟ0o𐐬𐓪',
|
||
'1':'𝚕𝟏𝟙𝟣𝟭𝟷',
|
||
'2':'Ƨᒿ2𝟐𝟤𝟮𝟸',
|
||
'3':'ƷȜЗӠⳌꝪꞫ3',
|
||
'4':'Ꮞ𝟒𝟜𝟦𝟰𝟺',
|
||
'5':'Ƽ5',
|
||
'6':'бᏮⳒ6',
|
||
'7':'7𐓒',
|
||
'8':'8𐌚𝟖𝟠𝟪𝟴',
|
||
'9':'৭୨ⳊꝮ9',
|
||
'A':'ΑАᎪᗅᴀꓮꭺA𐊠',
|
||
'B':'ΒВᏴᗷꓐB𐊂𐊡𝐁𝐵𝑩𝔹𝖡𝗕𝘉𝘽𝚩𝜝𝝗𝞑',
|
||
'C':'СᏟᑕℂⅭ⊂ⲤꓚC𐊢𐐕',
|
||
'D':'ᎠᗞᗪⅮꓓꭰD𝐃𝐷𝑫𝔻𝖣𝗗𝘋𝘿𝙳',
|
||
'E':'ΕЕᎬ⋿ⴹꓰꭼE𐊆',
|
||
'F':'ϜᖴꓝꞘF𐊇𐊥𝟋',
|
||
'G':'ɢԌᏀᏳᏻꓖꮐG𝐆𝐺𝑮𝔾𝖦𝗚𝘎𝙂𝙶',
|
||
'H':'ʜΗНнᎻᕼⲎꓧH𐋏𝐇𝐻𝑯𝖧𝗛𝘏𝙃𝚮𝛨𝜢𝝜𝞖',
|
||
'J':'ͿЈᎫᒍᴊꓙꞲꭻJ𝐉𝐽𝑱𝕁𝖩𝗝𝙹',
|
||
'K':'ΚКᏦᛕKⲔꓗK',
|
||
'L':'ʟᏞᒪⅬⳐⳑꓡꮮL𐐛𐑃',
|
||
'M':'ΜϺМᎷᗰᛖⅯⲘꓟM𐊰𐌑𝐌𝑀𝑴𝕄𝖬𝗠𝘔𝙈𝙼𝚳𝛭𝜧𝝡𝞛',
|
||
'N':'ɴΝⲚꓠN',
|
||
'O':'OΟОՕ௦౦೦ഠဝ၀ჿዐᴏᴑⲞⲟⵔ〇ꓳ0Oo𐊒𐊫𐐄𐐬𐓂𐓪',
|
||
'P':'ΡРᏢᑭᴘᴩℙⲢꓑꮲP𐊕𝐏𝑃𝑷𝖯𝗣𝘗𝙋𝙿𝚸𝛲𝜬𝝦𝞠',
|
||
'Q':'ℚⵕQ𝐐𝑄𝑸𝖰𝗤𝘘𝙌𝚀',
|
||
'R':'ƦʀᎡᏒᖇᚱꓣꭱꮢR𐒴',
|
||
'S':'ЅՏᏕᏚꓢS𐊖𐐠',
|
||
'T':'ΤТтᎢᴛ⊤⟙ⲦꓔꭲT𐊗𐊱𐌕',
|
||
'U':'Սሀᑌ∪⋃ꓴU𐓎',
|
||
'V':'Ѵ٧۷ᏙᐯⅤⴸꓦꛟV',
|
||
'W':'ԜᎳᏔꓪW',
|
||
'X':'ΧХ᙭ᚷⅩ╳ⲬⵝꓫꞳX𐊐𐊴𐌗𐌢',
|
||
'Y':'ΥϒУҮᎩᎽⲨꓬY𐊲',
|
||
'Z':'ΖᏃꓜZ𐋵',
|
||
'a':'ɑαа⍺a𝐚𝑎𝒂𝕒𝖆𝖺𝗮𝘢𝙖𝚊𝛂𝛼𝜶𝝰𝞪',
|
||
'b':'ƄЬᏏᑲᖯb𝐛𝑏𝒃𝖇𝖻𝗯𝘣𝙗𝚋',
|
||
'c':'ϲсᴄⅽⲥꮯc𐐽𝐜𝑐𝒄𝕔𝖈𝖼𝗰𝘤𝙘𝚌',
|
||
'd':'ԁᏧᑯⅆⅾꓒd𝐝𝑑𝒅𝒹𝓭𝖽𝗱𝘥𝙙𝚍',
|
||
'e':'еҽ℮e𝐞𝕖𝖾𝗲𝚎',
|
||
'f':'ẝꞙꬵf',
|
||
'g':'ƍɡցᶃg𝐠𝑔𝒈𝕘𝖌𝗀𝗴𝘨𝙜𝚐',
|
||
'h':'һᏂℎh𝒉𝕙𝗁𝗵𝘩𝙝𝚑',
|
||
'j':'ϳјj𝐣𝚓',
|
||
'k':'k𝐤𝑘𝒌𝕜𝖐𝗄𝗸𝘬𝙠𝚔',
|
||
'm':'m𝕞𝙢𝗺ⅿ',
|
||
'n':'ոռn𝗇𝗻𝘯𝙣𝚗',
|
||
'o':'OΟОՕ௦౦೦ഠဝ၀ჿዐᴏᴑⲞⲟⵔ〇ꓳ0Oo𐊒𐊫𐐄𐐬𐓂𐓪',
|
||
'p':'ρϱр⍴ⲣp𝑝𝕡𝗉𝗽𝘱𝙥𝚙𝛒𝜌𝝆𝞀𝞺',
|
||
'q':'ԛq𝐪𝕢𝗊𝗾𝘲𝙦𝚚',
|
||
'r':'гᴦⲅꭈꮁr𝐫𝗋𝗿𝚛',
|
||
's':'ѕꜱꮪs𐑈',
|
||
't':'t𝘁𝚝',
|
||
'u':'ʋυսᴜꭒu𐓶',
|
||
'v':'νѵᴠⅴ∨⋁ꮩv',
|
||
'w':'ɯѡԝաᴡꮃw',
|
||
'x':'×хⅹ⤫⤬⨯x𝐱𝑥𝒙𝔵𝕩𝖝𝗑𝘅𝘹𝙭𝚡',
|
||
'y':'ɣγуүყỿꭚy',
|
||
'z':'ᴢꮓz𝙯ᴢ𝗓𝕫ꮓ𝚣𝒛'
|
||
}
|
||
|
||
|
||
def cmd_confuse(data, buf, msg):
|
||
weechat.command(buf, f'/input send {confuse(msg)}')
|
||
|
||
return weechat.WEECHAT_RC_OK
|
||
|
||
if weechat.register('confuse', 'acidvegas & wrk', '1.0', 'ISC', 'confuse mfers', '', ''):
|
||
weechat.hook_command('confuse', 'confuse text', '<text>', '', '', 'cmd_confuse', '') |