Skip to content

Commit

Permalink
Added 'ignore private IP' feature, and updated readme file with usage…
Browse files Browse the repository at this point in the history
… and screenshots.
  • Loading branch information
Micah Babinski committed Jan 21, 2022
1 parent e03fa94 commit 6f3f39a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DefangText.py → Defanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".", "[.]"))
Expand Down
Binary file added Images/AfterDefang.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/BeforeDefang.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 6f3f39a

Please sign in to comment.