/home/altere25/infinet.finance/wp-content/plugins/ninjafirewall/lib
NameSizeModeActions
share/-0755rm
.htaccess3780644editdlrm
anti_malware.php26510644editdlrm
custom_firewall.php19440644editdlrm
custom_plugin.php19400644editdlrm
dashboard.php236880644editdlrm
dashboard_about.php27270644editdlrm
dashboard_statistics.php73490644editdlrm
email_sodium.php71630644editdlrm
events.php114230644editdlrm
event_notifications.php194280644editdlrm
event_updates.php93580644editdlrm
firewall.php633850644editdlrm
firewall_options.php172620644editdlrm
firewall_policies.php719870644editdlrm
fw_centlog.php24220644editdlrm
fw_fileguard.php36890644editdlrm
fw_livelog.php56840644editdlrm
help.php485860644editdlrm
i18n-extra.php310210644editdlrm
index.html830644editdlrm
init_update.php75410644editdlrm
install.php123810644editdlrm
install_default.php105260644editdlrm
loader.php5470644editdlrm
login_protection.php231210644editdlrm
logs.php33540644editdlrm
logs_firewall_log.php117970644editdlrm
logs_live_log.php202850644editdlrm
monitoring.php31560644editdlrm
monitoring_file_check.php291850644editdlrm
monitoring_file_guard.php62180644editdlrm
network.php34470644editdlrm
nfw_log.php42250644editdlrm
scheduled_tasks.php55990644editdlrm
security_rules.php28590644editdlrm
security_rules_editor.php73150644editdlrm
security_rules_update.php203090644editdlrm
sign.pub8010644editdlrm
thickbox.php207990644editdlrm
utils.php576700644editdlrm
widget.php48280644editdlrm
wpplus.php175210644editdlrm
Edit: /home/altere25/infinet.finance/wp-content/plugins/ninjafirewall/lib/monitoring_file_check.php (29185B)

' . $err . '

'; } elseif ( $success ) { echo '

' . $success . '

'; } // If we don't have a snapshopt, offer to create one : if (! file_exists($nfmon_snapshot) ) { ?>


(,).

 

' . __('Exclusion:', 'ninjafirewall') . ' '; foreach ($res as $exc) { echo '' . htmlspecialchars($exc) . ' '; } echo '

'; } echo '

' . __('Symlinks:', 'ninjafirewall') . ' '; if ( empty($nfw_options['snapnoslink']) ) { echo __('follow', 'ninjafirewall'); } else { echo __('do not follow', 'ninjafirewall'); } echo '

'; if (! empty($nfw_options['snapproc']) ) { echo '

' . sprintf( __('Processing time: %s seconds', 'ninjafirewall'), $nfw_options['snapproc']) . '

'; } ?>

   

/>   


'; } else { echo '
'; } echo ''; $more_info = __('Click a file to get more info about it.', 'ninjafirewall'); if ($new_file) { echo ''; } if ($del_file) { echo ' '; } if ($mod_file) { echo ' '; } echo '
'; echo __('New files:', 'ninjafirewall') . ' ' . count($new_file). '
'; echo '

' . $more_info . '

' . __('Deleted files:', 'ninjafirewall') .' '. count($del_file). '
' . '
' . __('Modified files:', 'ninjafirewall') .' '. count($mod_file). '
' . '

' . $more_info . '

'; } else { echo __('None', 'ninjafirewall') . '
'; } ?>



DISABLE_WP_CRON' ) ?>

diff($sched); ?>

format('%a') % 7, $diff->format('%h'), $diff->format('%i'), $diff->format('%s') ) ?>

'. htmlspecialchars($_POST['snapdir']) .''); } if ( strlen($_POST['snapdir']) > 1 ) { $_POST['snapdir'] = trim($_POST['snapdir'], ' '); $_POST['snapdir'] = rtrim($_POST['snapdir'], '/'); } if (! file_exists($_POST['snapdir']) ) { return sprintf( __('The directory %s does not exist.', 'ninjafirewall'), ''. htmlspecialchars($_POST['snapdir']) .''); } if (! is_readable($_POST['snapdir']) ) { return sprintf( __('The directory %s is not readable.', 'ninjafirewall'), ''. htmlspecialchars($_POST['snapdir']) .''); } if ( isset($_POST['snapnoslink']) ) { $snapnoslink = 1; } else { $snapnoslink = 0; } $snapexclude = ''; if (! empty( $_POST['snapexclude'] ) ) { $_POST['snapexclude'] = trim( $_POST['snapexclude'] ); $_POST['snapexclude'] = preg_replace( '/\s*,\s*/', ',', $_POST['snapexclude'] ); $tmp = preg_quote( $_POST['snapexclude'], '/' ); $snapexclude = str_replace(',', '|', $tmp); } @ini_set('max_execution_time', 0); $snapproc = nf_fc_metrics('start'); if ($fh = fopen($nfmon_snapshot, 'w') ) { fwrite($fh, '' . "\n"); $res = scd($_POST['snapdir'], $snapexclude, $fh, $snapnoslink); fclose($fh); // Error ? if ($res) { if (file_exists($nfmon_snapshot) ) { unlink($nfmon_snapshot); } return $res; } // Save scan dir : $nfw_options = nfw_get_option('nfw_options'); $nfw_options['snapproc'] = nf_fc_metrics('stop', $snapproc ); $nfw_options['snapexclude'] = $_POST['snapexclude']; $nfw_options['snapdir'] = $_POST['snapdir']; $nfw_options['snapnoslink'] = $snapnoslink; nfw_update_option('nfw_options', $nfw_options); } else { return sprintf( __('Cannot write to %s.', 'ninjafirewall'), ''. $nfmon_snapshot .''); } } // --------------------------------------------------------------------- function scd($snapdir, $snapexclude, $fh, $snapnoslink) { if (is_readable($snapdir) ) { if ($dh = opendir($snapdir) ) { while ( FALSE !== ($file = readdir($dh)) ) { if ( $file == '.' || $file == '..') { continue; } $full_path = $snapdir . '/' . $file; if ( $snapexclude ) { if ( preg_match("/$snapexclude/", $full_path) ) { continue; } } if (is_readable($full_path)) { if ( $snapnoslink && is_link($full_path)) { continue; } if ( is_dir($full_path) ) { scd($full_path, $snapexclude, $fh, $snapnoslink); } elseif (is_file($full_path) ) { $file_stat = stat($full_path); fwrite($fh, $full_path . '::' . sprintf ("%04o", $file_stat['mode'] & 0777) . ':' . $file_stat['uid'] . ':' . $file_stat['gid'] . ':' . $file_stat['size'] . ':' . $file_stat['mtime'] . ':' . $file_stat['ctime'] . "\n"); } } } closedir($dh); } else { return sprintf(__('Error : cannot open %s directory.', 'ninjafirewall'), ''. htmlspecialchars($snapdir) .''); } } else { return sprintf(__('Error : %s directory is not readable.', 'ninjafirewall'), ''. htmlspecialchars($snapdir) .''); } } // --------------------------------------------------------------------- function nf_sub_monitoring_scan($nfmon_snapshot, $nfmon_diff) { $nfw_options = nfw_get_option('nfw_options'); if (empty($nfw_options['enabled']) ) { return; } @ini_set('max_execution_time', 0); if (! isset($nfw_options['snapexclude']) || ! isset($nfw_options['snapdir']) || ! isset($nfw_options['snapnoslink']) ) { return sprintf( __('Missing options line %s, please try again.', 'ninjafirewall'), __LINE__ ); } $tmp = preg_quote($nfw_options['snapexclude'], '/'); $snapexclude = str_replace(',', '|', $tmp); if ($fh = fopen($nfmon_snapshot . '_tmp', 'w') ) { fwrite($fh, '' . "\n"); $res = scd($nfw_options['snapdir'], $snapexclude, $fh, $nfw_options['snapnoslink']); fclose($fh); } else { return sprintf( __('Cannot create %s.', 'ninjafirewall'), ''. $nfmon_snapshot . '_tmp'); } // Error ? if ($res) { if (file_exists($nfmon_snapshot . '_tmp') ) { unlink($nfmon_snapshot . '_tmp'); } return $res; } // Compare both snapshots : $old_files = $file = $new_files = array(); $modified_files = $match = array(); if (! $fh = fopen($nfmon_snapshot, 'r') ) { return __('Error reading old snapshot file.', 'ninjafirewall'); } while (! feof($fh) ) { $match = explode('::', rtrim(fgets($fh)) . '::' ); if (! empty($match[1]) ) { $old_files[$match[0]] = $match[1]; } } fclose($fh); if (! $fh = fopen($nfmon_snapshot . '_tmp', 'r') ) { return __('Error reading new snapshot file.', 'ninjafirewall'); } while (! feof($fh) ) { $match = explode('::', rtrim(fgets($fh)) . '::' ); if ( empty($match[1]) ) { continue; } // New file ? if ( empty( $old_files[$match[0]] ) ) { $new_files[$match[0]] = $match[1]; continue; } // Modified file ? if ( $old_files[$match[0]] != $match[1] ) { $modified_files[$match[0]] = $old_files[$match[0]] . '::' . $match[1]; } // Delete it from old files list : unset( $old_files[$match[0]] ); } fclose ($fh); // Write changes to file, if any : if ($new_files || $modified_files || $old_files) { $fh = fopen($nfmon_diff, 'w'); fwrite($fh, '' . "\n"); if ( $new_files ) { foreach ( $new_files as $fkey => $fvalue ) { fwrite($fh, $fkey . '::N::' . $fvalue . "\n"); } } if ( $modified_files ) { foreach ( $modified_files as $fkey => $fvalue ) { fwrite($fh, $fkey . '::M::' . $fvalue . "\n"); } } if ( $old_files ) { foreach ( $old_files as $fkey => $fvalue ) { fwrite($fh, $fkey . '::D::' . $fvalue . "\n"); } } fclose($fh); rename( $nfmon_snapshot . '_tmp', $nfmon_snapshot); } else { if (file_exists($nfmon_diff) ) { // Keep last changes : rename($nfmon_diff, $nfmon_diff. '.php'); } unlink( $nfmon_snapshot . '_tmp'); } } // --------------------------------------------------------------------- function nf_scheduled_scan() { $nfw_options = nfw_get_option('nfw_options'); if (! isset($_POST['sched_scan']) || ! preg_match('/^[1-3]$/', $_POST['sched_scan']) ) { $nfw_options['sched_scan'] = 0; } else { $nfw_options['sched_scan'] = $_POST['sched_scan']; } if ( empty($_POST['report_scan']) ) { $nfw_options['report_scan'] = 0; } else { $nfw_options['report_scan'] = 1; } nfw_update_option('nfw_options', $nfw_options); // Update cronjobs nfw_create_scheduled_tasks('nfscanevent'); } // --------------------------------------------------------------------- function nf_scan_email($nfmon_diff, $log_dir) { $nfw_options = nfw_get_option('nfw_options'); // Changes were detected : if ( $nfmon_diff ) { $stat = stat($nfmon_diff); $data = '== NinjaFirewall File Check (diff)'. "\n"; $data.= '== ' . site_url() . "\n"; $data.= '== ' . date_i18n('M d, Y @ H:i:s O', $stat['ctime']) . "\n\n"; $data.= '[+] = ' . __('New file', 'ninjafirewall') . ' [!] = ' . __('Modified file', 'ninjafirewall') . ' [-] = ' . __('Deleted file', 'ninjafirewall') . "\n\n"; $n = 0; $m = 0; $d = 0; $fh = fopen($nfmon_diff, 'r'); while (! feof($fh) ) { $res = explode('::', fgets($fh) ); if ( empty($res[1]) ) { continue; } // New file : if ($res[1] == 'N') { $data .= '[+] ' . $res[0] . "\n"; ++$n; // Deleted file : } elseif ($res[1] == 'D') { $data .= '[-] ' . $res[0] . "\n"; ++$d; // Modified file: } elseif ($res[1] == 'M') { $data .= '[!] ' . $res[0] . "\n"; ++$m; } } fclose($fh); $data .= "\n== EOF\n"; @file_put_contents($log_dir . 'nf_filecheck.txt', $data, LOCK_EX); $subject = __('[NinjaFirewall] Alert: File Check detection', 'ninjafirewall'); $msg = __('NinjaFirewall detected that changes were made to your files.', 'ninjafirewall') . "\n\n"; if ( is_multisite() ) { $msg .=__('Blog:', 'ninjafirewall') .' '. network_home_url('/') . "\n"; } else { $msg .=__('Blog:', 'ninjafirewall') .' '. home_url('/') . "\n"; } $msg .= sprintf( __('Date: %s', 'ninjafirewall'), ucfirst(date_i18n('M d, Y @ H:i:s O')) )."\n\n"; // Display summary in the email body: $msg .= sprintf( __('New files: %s', 'ninjafirewall'), $n ) ."\n"; $msg .= sprintf( __('Modified files: %s', 'ninjafirewall'), $m ) ."\n"; $msg .= sprintf( __('Deleted files: %s', 'ninjafirewall'), $d ) ."\n\n"; $msg .= __('See attached file for details.', 'ninjafirewall') . "\n\n" . NF_PG_SIGNATURE ."\n\n". NF_PG_MORESEC; nfw_mail( $subject, $msg, 'unsubscribe', $headers = '', $log_dir . 'nf_filecheck.txt' ); unlink($log_dir . 'nf_filecheck.txt'); } else { // User asked to always receive a report after a scheduled scan : $subject = __('[NinjaFirewall] File Check report', 'ninjafirewall'); $msg = __('NinjaFirewall did not detect changes in your files.', 'ninjafirewall') . "\n\n"; if ( is_multisite() ) { $msg .=__('Blog:', 'ninjafirewall') .' '. network_home_url('/') . "\n"; } else { $msg .=__('Blog:', 'ninjafirewall') .' '. home_url('/') . "\n"; } $msg .= sprintf( __('Date: %s', 'ninjafirewall'), ucfirst(date_i18n('M d, Y @ H:i:s O')) ) . "\n\n" . NF_PG_SIGNATURE ."\n\n". NF_PG_MORESEC; nfw_mail( $subject, $msg, 'unsubscribe' ); } } // --------------------------------------------------------------------- function nf_fc_metrics( $action = 'start', $starttime = 0 ) { if ( function_exists('hrtime') ) { $metrics = 'hrtime'; } else { $metrics = 'microtime'; } // Start chrono if ( $action == 'start') { return $metrics( true ); } // Stop chrono and return elapsed time if ( $metrics == 'hrtime') { return number_format( ( $metrics( true ) - $starttime ) / 1000000000, 2 ); } else { return number_format( $metrics( true ) - $starttime, 2 ); } } // --------------------------------------------------------------------- // EOF