Refang¶
Refang defanged text and defang values for safe reports.
Functions:
-
refang–Rewrite defanged text into plain text.
-
refang_tracked–Refang
textand map each output character back to the original. -
defang–Defang one indicator for a report.
Attributes:
-
Span–
refang
¶
Rewrite defanged text into plain text.
Replacements, in order:
hxxpstohttps,hxxptohttp,fxptoftp[.],(.),{.},[dot],(dot),{dot}, anddotto.[at],(at),[@], and(@)to@[://]to://and[:]to:
extra is a list of (regex, replacement) pairs applied before the
built-in rules. Patterns are case-sensitive unless the regex says otherwise.
Parameters:
-
text(str) –Arbitrary input. It is not required to contain indicators.
-
extra(Sequence[tuple[str, str]] | None, default:None) –Optional substitutions applied first.
Returns:
-
str–The refanged string.
refang_tracked
¶
Refang text and map each output character back to the original.
Each span is (start, end) in the original string. A replacement that
shrinks the text, such as [.] to ., maps the new character onto the
whole original slice.
Parameters:
-
text(str) –Original input.
-
extra(Sequence[tuple[str, str]] | None, default:None) –Optional substitutions applied first.
Returns:
defang
¶
Defang one indicator for a report.
Dots become [.]. URLs also rewrite a leading http to hxxp and a
leading ftp to fxp (so https becomes hxxps). Email addresses
rewrite the first @ as [at].
Parameters:
-
value(str) –Indicator value, already refanged.
-
kind(IOCType | str | None, default:None) –Type key. Only
urlandemailchange more than the dots.
Returns:
-
str–The defanged value.