Last active
August 29, 2015 14:01
-
-
Save jfinstrom/b48bf0fa909dc50149fd to your computer and use it in GitHub Desktop.
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 | |
# Copyright (c) 2014 James Finstrom. | |
# Copyright (c) 2014 Schmoozecom Inc | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms are permitted | |
# provided that the above copyright notice and this paragraph are | |
# duplicated in all such forms and that any documentation, | |
# advertising materials, and other materials related to such | |
# distribution and use acknowledge that the software was developed by Schmoozecom. | |
# The name of Schmoozecom may not be used to endorse or promote products derived | |
# from this software without specific prior written permission. | |
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
# | |
# command | asteriskLogClenser.py | |
# | |
# Output can be further redirected if needed. | |
# | |
# Note this is **very** basic and may not completely clean the logs of private information including things like passwords or # pin codes that may be passed to the log. This is only a first step before making your log public it shouldn't be the last. | |
# Only you can ensure your security | |
import re | |
import sys | |
#process standard input | |
for line in sys.stdin: | |
#strip IP addresses | |
line = re.sub(r'"(.*)(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})(.*)"',r"\1IP.AD.DRE.SS\3", line ) | |
#strip phone numbers not extensions or DID's with less than 7 digits. | |
line = re.sub(r'"(.*)(\d{7,11})(.*)"',r"\1PHONENUMBER\3", line ) | |
#strip emails and usernames. | |
line = re.sub(r'"(.*)(^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$)(.*)"', r"\[email protected]\3", line) | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not function as intended. .. I need to be more smarterer about my methodology. More soon.