Created
November 22, 2021 15:34
-
-
Save yitznewton/db39b78828d6f9116e7fa5637405f5fe to your computer and use it in GitHub Desktop.
phpinfo() with passwords redacted
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 | |
// outputs phpinfo() with passwords redacted | |
ob_start(); | |
phpinfo(); | |
$phpinfoString = ob_get_clean(); | |
$phpinfoDom = new DOMDocument(); | |
$phpinfoDom->loadHTML($phpinfoString); | |
$x = new DOMXPath($phpinfoDom); | |
$passwordCells = $x->query('//td[@class="e" and (contains(., "PASSWORD") or contains(., "password"))]/../td[@class="v"]'); | |
foreach ($passwordCells as $cell) { | |
$cell->nodeValue = '[redacted]'; | |
} | |
echo $phpinfoDom->saveHTML(); | |
ob_end_clean(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment