: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$dataForFile = $this->dataForFile($file, $record->realPath);
foreach($hresults as $result){
if(preg_match('/wfBrowscapCache\.php$/', $file)){
if (empty($result['URL'])) {
if ($result['badList'] == 'goog-malware-shavar') {
'severity' => wfIssues::SEVERITY_CRITICAL,
'ignoreP' => $record->realPath,
'ignoreC' => md5_file($record->realPath),
'shortMsg' => __('File contains suspected malware URL: ', 'wordfence') . esc_html($record->getDisplayPath()),
'longMsg' => wp_kses(sprintf(
/* translators: 1. Malware signature matched text. 2. Malicious URL. 3. Malicious URL. */
__('This file contains a suspected malware URL listed on Google\'s list of malware sites. Wordfence decodes %1$s when scanning files so the URL may not be visible if you view this file. The URL is: %2$s - More info available at <a href="http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%3$s&client=googlechrome&hl=en-US" target="_blank" rel="noopener noreferrer">Google Safe Browsing diagnostic page<span class="screen-reader-text"> (opens in new tab)</span></a>.', 'wordfence'),
esc_html($this->patterns['word3']),
esc_html($result['URL']),
urlencode($result['URL'])
), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()), 'span'=>array('class'))),
'data' => array_merge(array(
'realFile' => $record->realPath,
'badURL' => $result['URL'],
'gsb' => 'goog-malware-shavar',
'highSense' => $options['scansEnabled_highSense']
else if ($result['badList'] == 'googpub-phish-shavar') {
'severity' => wfIssues::SEVERITY_CRITICAL,
'ignoreP' => $record->realPath,
'ignoreC' => md5_file($record->realPath),
'shortMsg' => __('File contains suspected phishing URL: ', 'wordfence') . esc_html($record->getDisplayPath()),
'longMsg' => __('This file contains a URL that is a suspected phishing site that is currently listed on Google\'s list of known phishing sites. The URL is: ', 'wordfence') . esc_html($result['URL']),
'data' => array_merge(array(
'realFile' => $record->realPath,
'badURL' => $result['URL'],
'gsb' => 'googpub-phish-shavar',
'highSense' => $options['scansEnabled_highSense']
else if ($result['badList'] == 'wordfence-dbl') {
'severity' => wfIssues::SEVERITY_CRITICAL,
'ignoreP' => $record->realFile,
'ignoreC' => md5_file($record->realPath),
'shortMsg' => __('File contains suspected malware URL: ', 'wordfence') . esc_html($record->getDisplayPath()),
'longMsg' => __('This file contains a URL that is currently listed on Wordfence\'s domain blocklist. The URL is: ', 'wordfence') . esc_html($result['URL']),
'data' => array_merge(array(
'realFile' => $record->realPath,
'badURL' => $result['URL'],
'gsb' => 'wordfence-dbl',
'highSense' => $options['scansEnabled_highSense']
wfUtils::afterProcessingFile();
wordfence::status(4, 'info', __('Finalizing malware scan results', 'wordfence'));
if (!empty($this->results)) {
$safeFiles = $this->scanEngine->isSafeFile(array_keys($this->resultFilesByShac));
foreach ($safeFiles as $hash) {
foreach ($this->resultFilesByShac[$hash] as $file)
unset($this->results[$file]);
if ($backtrackLimit !== false) { ini_set('pcre.backtrack_limit', $backtrackLimit); }
protected function writeScanningStatus() {
wordfence::status(2, 'info', sprintf(
/* translators: 1. Number of fils. 2. Seconds in millisecond precision. */
__('Scanned contents of %1$d additional files at %2$.2f per second', 'wordfence'),
$this->totalFilesScanned,
($this->totalFilesScanned / (microtime(true) - $this->startTime))
protected function addResult($result) {
if (isset($result['data']['file'])) {
$file = $result['data']['file'];
$existing = array_key_exists($file, $this->results) ? $this->results[$file] : null;
if ($existing === null || $existing['severity'] > $result['severity']) {
$this->results[$file] = $result;
if (isset($result['data']['shac'])) {
$shac = $result['data']['shac'];
if (!array_key_exists($shac, $this->resultFilesByShac))
$this->resultFilesByShac[$shac] = [];
$this->resultFilesByShac[$shac][] = $file;
$this->results[] = $result;
private function dataForFile($file, $fullPath = null) {
$loader = $this->scanEngine->getKnownFilesLoader();
if ($isKnownFile = $loader->isKnownFile($file)) {
if ($loader->isKnownCoreFile($file)) {
} else if ($loader->isKnownPluginFile($file)) {
$data['cType'] = 'plugin';
list($itemName, $itemVersion, $cKey) = $loader->getKnownPluginData($file);
$data = array_merge($data, array(
'cVersion' => $itemVersion,
} else if ($loader->isKnownThemeFile($file)) {
$data['cType'] = 'theme';
list($itemName, $itemVersion, $cKey) = $loader->getKnownThemeData($file);
$data = array_merge($data, array(
'cVersion' => $itemVersion,
if ($fullPath !== null) {
$bootstrapPath = wordfence::getWAFBootstrapPath();
$htaccessPath = wfUtils::getHomePath() . '.htaccess';
$userIni = ini_get('user_ini.filename');
$userIniPath = wfUtils::getHomePath() . $userIni;
if ($fullPath == $htaccessPath) {
else if ($userIniPath !== false && $fullPath == $userIniPath) {
else if ($fullPath == $bootstrapPath) {
$localFile = realpath($this->path . $file);
$isWPConfig = $localFile === ABSPATH . 'wp-config.php';
$data['canDiff'] = $isKnownFile;
$data['canFix'] = $isKnownFile && !$isWPConfig;
$data['canDelete'] = !$isKnownFile && !$canRegenerate && !$suppressDelete && !$isWPConfig;
$data['canRegenerate'] = $canRegenerate && !$isWPConfig;
$data['wpconfig'] = $isWPConfig;
* Convenience class for interfacing with the wfFileMods table.
* @property string $filename
* @property string $filenameMD5
* @property string $newMD5
* @property string $stoppedOnSignature
* @property string $stoppedOnPosition
* @property string $isSafeFile
class wordfenceMalwareScanFile {
protected $_filenameMD5Hex;
protected $_stoppedOnSignature;
protected $_stoppedOnPosition;
protected static function getDB() {
public static function countRemaining() {
return $db->querySingle("SELECT COUNT(*) FROM " . wfDB::networkTable('wfFileMods') . " WHERE oldMD5 != newMD5 AND knownFile = 0");
public static function files($limit = 500) {
$result = $db->querySelect("SELECT filename, real_path, filenameMD5, HEX(newMD5) AS newMD5, HEX(SHAC) AS SHAC, stoppedOnSignature, stoppedOnPosition, isSafeFile FROM " . wfDB::networkTable('wfFileMods') . " WHERE oldMD5 != newMD5 AND knownFile = 0 AND isSafeFile != '1' LIMIT %d", $limit);
foreach ($result as $row) {
$files[] = new wordfenceMalwareScanFile($row['filename'], $row['real_path'], $row['filenameMD5'], $row['newMD5'], $row['SHAC'], $row['stoppedOnSignature'], $row['stoppedOnPosition'], $row['isSafeFile']);
public static function fileForPath($file) {
$row = $db->querySingleRec("SELECT filename, real_path, filenameMD5, HEX(newMD5) AS newMD5, HEX(SHAC) AS SHAC, stoppedOnSignature, stoppedOnPosition, isSafeFile FROM " . wfDB::networkTable('wfFileMods') . " WHERE filename = '%s'", $file);
return new wordfenceMalwareScanFile($row['filename'], $row['real_path'], $row['filenameMD5'], $row['newMD5'], $row['SHAC'], $row['stoppedOnSignature'], $row['stoppedOnPosition'], $row['isSafeFile']);
public function __construct($filename, $realPath, $filenameMD5, $newMD5, $shac, $stoppedOnSignature, $stoppedOnPosition, $isSafeFile) {
$this->_filename = $filename;
$this->_realPath = $realPath;
$this->_filenameMD5 = $filenameMD5;
$this->_filenameMD5Hex = bin2hex($filenameMD5);
$this->_newMD5 = $newMD5;
$this->_shac = strtoupper($shac);
$this->_stoppedOnSignature = $stoppedOnSignature;
$this->_stoppedOnPosition = $stoppedOnPosition;
$this->_isSafeFile = $isSafeFile;
public function __get($key) {
return $this->_filenameMD5;
return $this->_filenameMD5Hex;
case 'stoppedOnSignature':
return $this->_stoppedOnSignature;
case 'stoppedOnPosition':
return $this->_stoppedOnPosition;
return $this->_isSafeFile;
public function __toString() {
return "Record [filename: {$this->filename}, realPath: {$this->realPath}, filenameMD5: {$this->filenameMD5}, newMD5: {$this->newMD5}, stoppedOnSignature: {$this->stoppedOnSignature}, stoppedOnPosition: {$this->stoppedOnPosition}]";
public static function markCompleteBatch($records) {
wfDB::networkTable('wfFileMods'),
'filenameMD5' => array_map(function($record) { return $record->filenameMD5Hex; }, $records)
'filenameMD5' => 'UNHEX(%s)'
public function updateStoppedOn($signature, $position) {
$this->_stoppedOnSignature = $signature;
$this->_stoppedOnPosition = $position;
$db->queryWrite("UPDATE " . wfDB::networkTable('wfFileMods') . " SET stoppedOnSignature = '%s', stoppedOnPosition = %d WHERE filenameMD5 = UNHEX(%s)", $this->stoppedOnSignature, $this->stoppedOnPosition, $this->filenameMD5Hex);
public function getDisplayPath() {
if (preg_match('#(^|/)..(/|$)#', $this->filename))