Last active
June 27, 2022 21:54
-
-
Save jasimmonsv/dee4c7304c0c29d6601f125d9365a270 to your computer and use it in GitHub Desktop.
SED URL and IP defang
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
# replaces IP addresses with brackets around `.` :: 192[.]168[.]1[.]42 | |
s/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\1[.]\2[.]\3[.]\4/g | |
# replaces all http(s) instances with hxxp(s) | |
s/http/hxxp/g |
\(
- sed beginning of lookup group
[0-9]
- range of numbers between 0-9
\{1,\}
- One or more instance of previous lookup
\)
- sed close of lookup group
\1
- sed reference to first lookup group
\2
- sed reference to second lookup group... etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sed -f ./defang.sed ./<file_name>
will output URLs and IP addresses as:192[.]168[.]1[.]10
andhxxps://google.com