Skip to content

Instantly share code, notes, and snippets.

@stania
Created April 3, 2013 11:28
Show Gist options
  • Save stania/5300408 to your computer and use it in GitHub Desktop.
Save stania/5300408 to your computer and use it in GitHub Desktop.
prerequisite: gnu mpfr (may can be installed by distribution installer) pycrypto, pycryptopan (both can be installed by pip)
from cryptopan import CryptoPan
import re, sys
c = CryptoPan("".join([chr(x) for x in range(0, 32)]))
p = re.compile(r"^([^ ]+) ([^ ]+)")
def replace(mo):
try:
domain = mo.group(1)
ip = mo.group(2)
domain = domain[:domain.index(".")] + ".famous.site"
ip = c.anonymize(ip)
return domain + " " + ip
except:
return mo.group(1) + " " + c.anonymize(mo.group(2))
for line in sys.stdin:
sys.stdout.write(p.sub(replace, line))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment