Created
August 15, 2022 17:07
-
-
Save SmugZombie/7aed85a580faaebe64f8a78a25bb2c28 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
<?php | |
function defangPayload($payload){ | |
$re = '/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w\-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/im'; | |
preg_match_all($re, $payload, $matches, PREG_SET_ORDER, 0); | |
foreach ($matches as $key => $value) { | |
$payload = str_replace($value[0], preg_replace('/\./', "[.]", $value[0]), $payload); | |
} | |
return $payload; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment