diff --git a/DefangText.py b/Defanger.py similarity index 96% rename from DefangText.py rename to Defanger.py index 14e8435..81fb226 100644 --- a/DefangText.py +++ b/Defanger.py @@ -16,13 +16,13 @@ # function to defang input text def Defang(inputText, ignorePrivate=True): - url_candidates = [x[0] for x in re.findall(r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))", inputText)] + url_candidates = [x[0] for x in re.findall(r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?]))", inputText)] if len(url_candidates) > 0: for url in url_candidates: inputText = inputText.replace(url, url.replace(".", "[.]")) inputText = inputText.replace("http:", "hxxp:").replace("https:", "hxxps:") - ftp_candidates = [x[0] for x in re.findall(r"(?i)\b((?:ftp?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))", inputText)] + ftp_candidates = [x[0] for x in re.findall(r"(?i)\b((?:ftp?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?]))", inputText)] if len(ftp_candidates) > 0: for ftp in ftp_candidates: inputText = inputText.replace(ftp, ftp.replace(".", "[.]")) diff --git a/Images/AfterDefang.PNG b/Images/AfterDefang.PNG new file mode 100644 index 0000000..7b500f7 Binary files /dev/null and b/Images/AfterDefang.PNG differ diff --git a/Images/BeforeDefang.PNG b/Images/BeforeDefang.PNG new file mode 100644 index 0000000..28fd1b8 Binary files /dev/null and b/Images/BeforeDefang.PNG differ diff --git a/README.md b/README.md index 91fbb3f..bd26e08 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ # Defanger A GUI application to defang text, rendering otherwise-potentially malicious IP addresses and URLs harmless. Built using standard Python libraries. -Don't get too excited. It's notepad with a "Defang Text" button. +## Usage + +Simply run the Defanger.py script (requires Python 3) to be presented with the GUI. You can then enter or paste the text you wish to defang. + +By default, defanger will ignore (not defang) private IP addresses, although you can uncheck this option to defang all IP addresses. + +Once you have defanged the input text, you can copy it to the clipboard, clear the defanger, or close using the buttons at the bottom. + +## Example +Before defanging: +![alt text](https://github.com/mbabinski/Defanger/blob/main/Images/BeforeDefang.PNG?raw=true) + +After defanging: +![alt text](https://github.com/mbabinski/Defanger/blob/main/Images/AfterDefang.PNG?raw=true) \ No newline at end of file