Skip to content

Instantly share code, notes, and snippets.

@yitznewton
Created November 22, 2021 15:34
Show Gist options
  • Save yitznewton/db39b78828d6f9116e7fa5637405f5fe to your computer and use it in GitHub Desktop.
Save yitznewton/db39b78828d6f9116e7fa5637405f5fe to your computer and use it in GitHub Desktop.
phpinfo() with passwords redacted
<?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