Google Authenticator – WordPress Two Factor Authentication (2FA) - Version 5.3.20

Version Description

  • Google Authenticator-Two Factor Authentication (2FA) : Anti Malware : Fixing issue faced by users during scan.
Download this release

Release Info

Developer cyberlord92
Plugin Icon 128x128 Google Authenticator – WordPress Two Factor Authentication (2FA)
Version 5.3.20
Comparing to
See all releases

Code changes from version 5.3.19 to 5.3.20

controllers/main_controller.php CHANGED
@@ -42,7 +42,7 @@
42
  case 'mo_2fa_troubleshooting':
43
  include $controller . 'troubleshooting.php'; break;
44
  case 'mo_2fa_malwarescan':
45
- include $controller . 'scan_malware.php'; break;
46
  case 'mo_2fa_two_fa':
47
  include $controller . 'twofa' . DIRECTORY_SEPARATOR . 'two_fa.php';
48
  update_option('mo2f_scan_nonce',wp_create_nonce('wpns-quick-scan')); break;
42
  case 'mo_2fa_troubleshooting':
43
  include $controller . 'troubleshooting.php'; break;
44
  case 'mo_2fa_malwarescan':
45
+ include $controller . 'malware_scanner'.DIRECTORY_SEPARATOR.'scan_malware.php'; break;
46
  case 'mo_2fa_two_fa':
47
  include $controller . 'twofa' . DIRECTORY_SEPARATOR . 'two_fa.php';
48
  update_option('mo2f_scan_nonce',wp_create_nonce('wpns-quick-scan')); break;
controllers/malware_scan_ajax.php DELETED
@@ -1,278 +0,0 @@
1
- <?php
2
- class Mo_wpns_scan_malware
3
- {
4
- function __construct(){
5
- add_action( 'admin_init' , array( $this, 'mo_wpns_malware_scanner_functions' ) );
6
- }
7
-
8
- public function mo_wpns_malware_scanner_functions(){
9
- add_action('wp_ajax_mo_wpns_malware_redirect', array( $this, 'mo_wpns_malware_redirect' ));
10
- }
11
-
12
- public function mo_wpns_malware_redirect(){
13
- switch($_POST['call_type'])
14
- {
15
- case "submit_malware_settings_form":
16
- $this->mo_wpns_save_malware_config_form($_POST);
17
- break;
18
- case "malware_scan_initiate":
19
- $this->mo_wpns_start_malware_scan($_POST);
20
- break;
21
- case "wpns_enable_tour":
22
- update_option('skip_tour', 0);
23
- break;
24
- case "wpns_disable_tour":
25
- update_option('skip_tour', 1);
26
- break;
27
- case "malware_progress_bar":
28
- $this->mo_wpns_get_progress();
29
- break;
30
- case "malware_scan_last_result":
31
- $this->mo_wpns_get_scan_result();
32
- break;
33
- case "malware_scan_terminate":
34
- $this->mo_wpns_stop_scan();
35
- break;
36
- }
37
- }
38
-
39
- public function mo_wpns_save_malware_config_form($POSTED){
40
- $nonce = $POSTED['nonce'];
41
- if ( ! wp_verify_nonce( $nonce, 'mo-wpns-scan-settings' ) ){
42
- wp_send_json('ERROR');
43
- return;
44
- }
45
- if(! isset($POSTED['scan_plugin']) && ! isset($POSTED['scan_themes']) && ! isset($POSTED['scan_core'])){
46
- wp_send_json('folder_error');
47
- }elseif (! isset($POSTED['vulnerable_check']) && ! isset($POSTED['sql_check']) && ! isset($POSTED['rfi_check']) && ! isset($POSTED['ext_link']) && ! isset($POSTED['repo_check'])) {
48
- wp_send_json('level_error');
49
- }
50
- else{
51
- isset($POSTED['scan_plugin']) ? update_option('mo_wpns_scan_plugins',sanitize_text_field($POSTED['scan_plugin'])) : update_option('mo_wpns_scan_plugins',0);
52
- isset($POSTED['scan_themes']) ? update_option('mo_wpns_scan_themes',sanitize_text_field($POSTED['scan_themes'])) : update_option('mo_wpns_scan_themes',0);
53
- isset($POSTED['scan_core']) ? update_option('mo_wpns_scan_wp_files',sanitize_text_field($POSTED['scan_core'])) : update_option('mo_wpns_scan_wp_files',0);
54
- update_option('mo_wpns_scan_files_extensions',sanitize_text_field($POSTED['file_type']));
55
- isset($POSTED['vulnerable_check']) ? update_option('mo_wpns_check_vulnerable_code',sanitize_text_field($POSTED['vulnerable_check'])) : update_option('mo_wpns_check_vulnerable_code',0);
56
- isset($POSTED['sql_check']) ? update_option('mo_wpns_check_sql_injection',sanitize_text_field($POSTED['sql_check'])) : update_option('mo_wpns_check_sql_injection',0);
57
- isset($POSTED['ext_link']) ? update_option('mo_wpns_check_external_link',sanitize_text_field($POSTED['ext_link'])) : update_option('mo_wpns_check_external_link',0);
58
- isset($POSTED['repo_check']) ? update_option('mo_wpns_scan_files_with_repo',sanitize_text_field($POSTED['repo_check'])) : update_option('mo_wpns_scan_files_with_repo',0);
59
- $folders_to_skip= $POSTED['skip_path'];
60
- $folders_to_skip = str_replace('\\\\', '/', $folders_to_skip);
61
- $str="";
62
- if(!empty($folders_to_skip)){
63
- $folders_to_skip_array=explode(";",$folders_to_skip);
64
- for($i=0; $i< count($folders_to_skip_array); $i++){
65
- if(is_dir($folders_to_skip_array[$i])){
66
- $str.= $folders_to_skip_array[$i];
67
- if($i!= count($folders_to_skip_array)-1){
68
- $str.=";";
69
- }
70
- }elseif($folders_to_skip_array[$i] == ''){
71
- $str.= $folders_to_skip_array[$i];
72
- }
73
- else{
74
- wp_send_json('path_error');
75
- }
76
- }
77
- update_option( 'mo_wpns_skip_folders', $str);
78
- }else{
79
- update_option('mo_wpns_skip_folders', $folders_to_skip);
80
- }
81
- wp_send_json('save_success');
82
- }
83
- }
84
-
85
- public function mo_wpns_start_malware_scan($POSTED){
86
- $scan_stop_status=get_option('mo_stop_scan');
87
-
88
- if($scan_stop_status=="1"){
89
- wp_send_json('scan_terminating');
90
- exit;
91
- }
92
- if(get_option('mo_wpns_malware_scan_in_progress') == "IN PROGRESS"){
93
- wp_send_json('scanning_already');
94
-
95
- }
96
- global $moWpnsUtility, $dirName;
97
- include_once $dirName. DIRECTORY_SEPARATOR.'handler'.DIRECTORY_SEPARATOR.'malware_scanner.php';
98
- $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler();
99
-
100
- update_option('mo2f_scan_initialize', 0);
101
- update_option('mo_wpns_malware_scan_in_progress','IN PROGRESS');
102
- update_option('mo_wpns_files_scanned',0);
103
- update_option('mo_wpns_infected_files',0);
104
-
105
- update_option('mo_wpns_last_scan_time', time());
106
- $plugin_current= get_plugins();
107
- update_option('mo_wpns_last_plugins', $plugin_current);
108
- $args=array();
109
- $theme_current= wp_get_themes($args);
110
- update_option('mo_wpns_last_themes', $theme_current);
111
-
112
- if(isset($POSTED['scan']) && $POSTED['scan']=='scan_start'){
113
- $scan_configuration = array();
114
- switch($POSTED['scantype'])
115
- {
116
- case "quick_scan":
117
- $nonce = $POSTED['nonce'];
118
- if ( ! wp_verify_nonce( $nonce, 'wpns-quick-scan' ) ){
119
- wp_send_json('ERROR');
120
- return;
121
- }
122
- $scan_configuration = array('plugin_scan' => 1 ,
123
- 'theme_scan' => 1,
124
- 'core_scan' => 0,
125
- 'file_extension' => "",
126
- 'check_vulnerable' => 1,
127
- 'check_sql' => 1,
128
- 'check_rfi' => 1,
129
- 'ext_link_check' => 0,
130
- 'check_repo' => 0,
131
- 'path_skip' => "",
132
- 'type_scan' => "Quick Scan"
133
- );
134
- update_option('mo_wpns_scan_mode','quick_scan');
135
- $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration);
136
- break;
137
- case "standard_scan":
138
- $nonce = $POSTED['nonce'];
139
- if ( ! wp_verify_nonce( $nonce, 'wpns-standard-scan' ) ){
140
- wp_send_json('ERROR');
141
- return;
142
- }
143
- $scan_configuration = array('plugin_scan' => 1 ,
144
- 'theme_scan' => 1,
145
- 'core_scan' => 0,
146
- 'file_extension' => "",
147
- 'check_vulnerable' => 1,
148
- 'check_sql' => 1,
149
- 'check_rfi' => 1,
150
- 'ext_link_check' => 1,
151
- 'check_repo' => 1,
152
- 'path_skip' => "",
153
- 'type_scan' => "Standard Scan"
154
- );
155
- update_option('mo_wpns_scan_mode','standard_scan');
156
- $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration);
157
- break;
158
- case "custom_scan":
159
- $nonce = $POSTED['nonce'];
160
- if ( ! wp_verify_nonce( $nonce, 'wpns-custom-scan' ) ){
161
- wp_send_json('ERROR');
162
- return;
163
- }
164
- $scan_configuration = array('plugin_scan' => get_option('mo_wpns_scan_plugins') ,
165
- 'theme_scan' => get_option('mo_wpns_scan_themes'),
166
- 'core_scan' => get_option('mo_wpns_scan_wp_files'),
167
- 'file_extension' => get_option('mo_wpns_scan_files_extensions'),
168
- 'check_vulnerable' => get_option('mo_wpns_check_vulnerable_code') ,
169
- 'check_sql' => get_option('mo_wpns_check_sql_injection'),
170
- 'check_rfi' => get_option('mo_wpns_check_remote_file_inclusion'),
171
- 'ext_link_check' => get_option('mo_wpns_check_external_link'),
172
- 'check_repo' => get_option('mo_wpns_scan_files_with_repo'),
173
- 'path_skip' => get_option('mo_wpns_skip_folders'),
174
- 'type_scan' => "Custom Scan"
175
- );
176
- update_option('mo_wpns_scan_mode','custom_scan');
177
- $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration);
178
- break;
179
- }
180
- }
181
- }
182
-
183
-
184
- public function mo_wpns_get_progress(){
185
- $status= get_option('mo_wpns_malware_scan_in_progress');
186
- $files_scanned= get_option('mo_wpns_files_scanned');
187
- $total_files = get_option('mo_wpns_total_files');
188
- $check_repo = get_option('mo_wpns_scan_files_with_repo');
189
- $scan_mode= get_option('mo_wpns_scan_mode');
190
- $repo_scan=0;
191
- if($scan_mode == "standard_scan" || ($scan_mode == "custom_scan" && $check_repo == 1)){
192
- $repo_scan=1;
193
- }
194
- if($status == "IN PROGRESS"){
195
- $result=array("status"=>$status, "scanned"=>$files_scanned, "total"=>$total_files, "repo_scan"=> $repo_scan);
196
- wp_send_json($result);
197
- }
198
- else{
199
- $mo_wpns_db_handler = new MoWpnsDB();
200
- $total_scan=$mo_wpns_db_handler->count_files();
201
- $total_malicious=$mo_wpns_db_handler->count_malicious_files();
202
- $malicious_last_scan= get_option('mo_wpns_infected_files');
203
- $result = array("status"=>$status, 'total_files'=>$total_scan, 'total_mal'=>$total_malicious, 'scan_files'=>$total_files, 'mal_files'=>$malicious_last_scan);
204
- wp_send_json($result);
205
- }
206
- }
207
-
208
- function mo_wpns_stop_scan(){
209
-
210
- global $wpdb;
211
- update_option('mo_wpns_malware_scan_in_progress','COMPLETE');
212
- $query="UPDATE `".$wpdb->base_prefix."options` SET `option_value` = '1' WHERE `option_name` = 'mo_stop_scan'";
213
- $test= $wpdb->get_results($query);
214
- $scan_in_progress=true;
215
- while($scan_in_progress){
216
-
217
- $query="SELECT `option_value` from `".$wpdb->base_prefix."options` WHERE `option_name` = 'mo_stop_scan'";
218
- $stop_scan= $wpdb->get_results($query);
219
- $stop_scan_process=$stop_scan[0]->option_value;
220
- if($stop_scan_process=="2"){
221
- $scan_in_progress=false;
222
- }
223
-
224
- sleep(5);
225
-
226
- }
227
-
228
- wp_send_json('success');
229
-
230
- }
231
-
232
- function mo_wpns_get_scan_result(){
233
- $status= get_option('mo_wpns_malware_scan_in_progress');
234
- $mo_wpns_db_handler = new MoWpnsDB();
235
- $result = $mo_wpns_db_handler->get_report();
236
- $str1= $_SERVER['REQUEST_URI'];
237
- $str1= str_replace("admin-ajax.php", "admin.php?page=mo_2fa_malwarescan", $str1);
238
- $currenturl = remove_query_arg('delete',$str1);
239
- $currenturl = remove_query_arg('view',$currenturl);
240
- $currenturl = remove_query_arg('trust',$currenturl);
241
- $currenturl = remove_query_arg('trustchanged',$currenturl);
242
- $htmldata = "";
243
- if(!empty($result)){
244
- foreach($result as $report){
245
- if(empty($report->scan_mode)){
246
- $report->scan_mode="Custom Scan";
247
- }
248
- $repo_count = $report->repo_issues >= 0 ? $report->repo_issues : 0;
249
- $htmldata .= "<tr><td style=text-align:center>".$report->scan_mode."</td>";
250
- $htmldata .= "<td style=text-align:center>";
251
- if(!empty($report->scanned_folders)){
252
- foreach(explode(";",$report->scanned_folders) as $folder){
253
- if(!empty($folder)){
254
- $htmldata .= $folder."<br>";
255
- }
256
- }
257
- }
258
- $htmldata .= "</td><td style=text-align:center>";
259
- $htmldata .= "<span style=color:green id=scan_files>".$report->scanned_files." files scanned<br></span>";
260
- $htmldata .= "<span style=color:red id=malicious_files>".$report->malware_count." malware found<br></span>";
261
- if($report->repo_issues < 0){
262
- $htmldata .= "<span style=color:red id=malicious_files>Issues with repository check<br></span>";
263
- }
264
- $htmldata .= "<span style=color:orange id=warning_files>".($repo_count+$report->malicious_links)." warnings found</span>";
265
- $htmldata .= "</td><td style=text-align:center id=start_time>".date("M j, Y, g:i:s a",$report->start_timestamp)."</td>";
266
- $htmldata .= "<td><a href='".add_query_arg( array('tab' => 'default', 'view' => $report->id), $currenturl )."'>View Details</a> <a href='".add_query_arg( array('tab' => 'default', 'delete' => $report->id), $currenturl )."'>Delete</a></td>";
267
- $htmldata .= "</tr>";
268
-
269
- }
270
- }else{
271
- $htmldata .= '<tr class="odd"><td valign="top" colspan="5" class="dataTables_empty">No data available in table</td></tr>';
272
- }
273
- wp_send_json($htmldata);
274
-
275
- }
276
- }
277
- new Mo_wpns_scan_malware();
278
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
controllers/malware_scanner/malware_scan_ajax.php ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mo_wpns_scan_malware
3
+ {
4
+ function __construct(){
5
+ add_action( 'admin_init' , array( $this, 'mo_wpns_malware_scanner_functions' ) );
6
+
7
+ }
8
+
9
+ public function mo_wpns_malware_scanner_functions(){
10
+ add_action('wp_ajax_mo_wpns_malware_redirect', array( $this, 'mo_wpns_malware_redirect' ));
11
+ }
12
+
13
+ public function mo_wpns_malware_redirect(){
14
+ switch($_POST['call_type'])
15
+ {
16
+ case "submit_malware_settings_form":
17
+ $this->mo_wpns_save_malware_config_form($_POST);
18
+ break;
19
+ case "malware_scan_initiate":
20
+ $this->mo_wpns_start_malware_scan($_POST);
21
+ break;
22
+ case "wpns_enable_tour":
23
+ update_option('skip_tour', 0);
24
+ break;
25
+ case "wpns_disable_tour":
26
+ update_option('skip_tour', 1);
27
+ break;
28
+ case "malware_progress_bar":
29
+ $this->mo_wpns_get_progress();
30
+ break;
31
+ case "malware_scan_last_result":
32
+ $this->mo_wpns_get_scan_result();
33
+ break;
34
+ case "malware_scan_terminate":
35
+ $this->mo_wpns_stop_scan();
36
+ break;
37
+ }
38
+ }
39
+
40
+ public function mo_wpns_save_malware_config_form($POSTED){
41
+ $nonce = $POSTED['nonce'];
42
+ if ( ! wp_verify_nonce( $nonce, 'mo-wpns-scan-settings' ) ){
43
+ wp_send_json('ERROR');
44
+ return;
45
+ }
46
+ if(! isset($POSTED['scan_plugin']) && ! isset($POSTED['scan_themes']) && ! isset($POSTED['scan_core'])){
47
+ wp_send_json('folder_error');
48
+ }elseif (! isset($POSTED['vulnerable_check']) && ! isset($POSTED['sql_check']) && ! isset($POSTED['rfi_check']) && ! isset($POSTED['ext_link']) && ! isset($POSTED['repo_check'])) {
49
+ wp_send_json('level_error');
50
+ }
51
+ else{
52
+
53
+
54
+ isset($POSTED['scan_plugin']) ? update_option('mo_wpns_scan_plugins',sanitize_text_field($POSTED['scan_plugin'])) : update_option('mo_wpns_scan_plugins',0);
55
+ isset($POSTED['scan_themes']) ? update_option('mo_wpns_scan_themes',sanitize_text_field($POSTED['scan_themes'])) : update_option('mo_wpns_scan_themes',0);
56
+ isset($POSTED['scan_core']) ? update_option('mo_wpns_scan_wp_files',sanitize_text_field($POSTED['scan_core'])) : update_option('mo_wpns_scan_wp_files',0);
57
+ update_option('mo_wpns_scan_files_extensions',sanitize_text_field($POSTED['file_type']));
58
+ isset($POSTED['vulnerable_check']) ? update_option('mo_wpns_check_vulnerable_code',sanitize_text_field($POSTED['vulnerable_check'])) : update_option('mo_wpns_check_vulnerable_code',0);
59
+ isset($POSTED['sql_check']) ? update_option('mo_wpns_check_sql_injection',sanitize_text_field($POSTED['sql_check'])) : update_option('mo_wpns_check_sql_injection',0);
60
+ isset($POSTED['ext_link']) ? update_option('mo_wpns_check_external_link',sanitize_text_field($POSTED['ext_link'])) : update_option('mo_wpns_check_external_link',0);
61
+ isset($POSTED['repo_check']) ? update_option('mo_wpns_scan_files_with_repo',sanitize_text_field($POSTED['repo_check'])) : update_option('mo_wpns_scan_files_with_repo',0);
62
+ $mo_wpns_scan_plugins=isset($POSTED['scan_plugin']) ? sanitize_text_field($POSTED['scan_plugin']) : 0;
63
+ $mo_wpns_scan_themes=isset($POSTED['scan_themes']) ? sanitize_text_field($POSTED['scan_themes']) : 0;
64
+ $mo_wpns_scan_wp_files= isset($POSTED['scan_core']) ? sanitize_text_field($POSTED['scan_core']) : 0;
65
+ $mo_wpns_scan_files_extensions= sanitize_text_field($POSTED['file_type']);
66
+ $mo_wpns_check_vulnerable_code=isset($POSTED['vulnerable_check']) ? sanitize_text_field($POSTED['vulnerable_check']) : 0;
67
+ $mo_wpns_check_sql_injection=isset($POSTED['sql_check']) ? sanitize_text_field($POSTED['sql_check']) : 0;
68
+ $mo_wpns_check_external_link=isset($POSTED['ext_link']) ? sanitize_text_field($POSTED['ext_link']) : 0;
69
+ $mo_wpns_scan_files_with_repo=isset($POSTED['repo_check']) ? sanitize_text_field($POSTED['repo_check']) : 0;
70
+ $folders_to_skip= $POSTED['skip_path'];
71
+ $folders_to_skip = str_replace('\\\\', '/', $folders_to_skip);
72
+ $str="";
73
+
74
+ $mo_wpns_skip_folders="";
75
+ if(!empty($folders_to_skip)){
76
+ $folders_to_skip_array=explode(";",$folders_to_skip);
77
+ for($i=0; $i< count($folders_to_skip_array); $i++){
78
+ if(is_dir($folders_to_skip_array[$i])){
79
+ $str.= $folders_to_skip_array[$i];
80
+ if($i!= count($folders_to_skip_array)-1){
81
+ $str.=";";
82
+ }
83
+ }elseif($folders_to_skip_array[$i] == ''){
84
+ $str.= $folders_to_skip_array[$i];
85
+ }
86
+ else{
87
+ wp_send_json('path_error');
88
+ }
89
+ }
90
+ update_option( 'mo_wpns_skip_folders', $str);
91
+ $mo_wpns_skip_folders=$str;
92
+ }else{
93
+ update_option('mo_wpns_skip_folders', $folders_to_skip);
94
+ $mo_wpns_skip_folders=$folders_to_skip;
95
+ }
96
+
97
+ $scan_configuration = array(
98
+ 'plugin_scan' => $mo_wpns_scan_plugins,
99
+ 'theme_scan' => $mo_wpns_scan_themes,
100
+ 'core_scan' => $mo_wpns_scan_wp_files,
101
+ 'file_extension' => $mo_wpns_scan_files_extensions,
102
+ 'check_vulnerable' => $mo_wpns_check_vulnerable_code,
103
+ 'check_sql' => $mo_wpns_check_sql_injection,
104
+ 'ext_link_check' => $mo_wpns_check_external_link,
105
+ 'check_repo' => $mo_wpns_scan_files_with_repo,
106
+ 'path_skip' => $mo_wpns_skip_folders,
107
+ 'type_scan' => "",
108
+ );
109
+
110
+ $encoded_scan_configuration=json_encode($scan_configuration);
111
+ update_option("mo_wpns_scan_configuration",$encoded_scan_configuration);
112
+ wp_send_json('save_success');
113
+ }
114
+ }
115
+
116
+ public function mo_wpns_start_malware_scan($POSTED){
117
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
118
+ if(isset($decoded_scan_configuration)){
119
+ $status = $decoded_scan_configuration->scan_progress;
120
+ }else{
121
+ $status=false;
122
+ $scan_mode=false;
123
+ }
124
+ if($status == "IN PROGRESS"){
125
+ wp_send_json('scanning_already');
126
+ }
127
+ global $moWpnsUtility, $dirName;
128
+
129
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
130
+ $mo2f_malware_db_handler = new MoWpnsDB();
131
+
132
+ $current_time= time();
133
+ update_option('mo_wpns_last_scan_time', $current_time);
134
+ $plugin_current= get_plugins();
135
+ update_option('mo_wpns_last_plugins', $plugin_current);
136
+ $args=array();
137
+ $theme_current= wp_get_themes($args);
138
+ update_option('mo_wpns_last_themes', $theme_current);
139
+
140
+ update_option('mo2f_scan_initialize', 0);
141
+
142
+ $mo_wpns_malware_scan_in_progress="IN PROGRESS";
143
+ $mo_wpns_files_scanned=0;
144
+ $mo_wpns_infected_files=0;
145
+ $mo_wpns_warning_files=0;
146
+ $wordpress_download_status=false;
147
+
148
+ update_option('mo_wpns_infected_files',0);
149
+ update_option('mo_wpns_warning_files',0);
150
+
151
+
152
+ $scan_status = array(
153
+ 'scan_progress' => $mo_wpns_malware_scan_in_progress,
154
+ 'files_scanned' => $mo_wpns_files_scanned,
155
+ 'infected_files' => $mo_wpns_infected_files,
156
+ 'warning_files' => $mo_wpns_warning_files,
157
+ 'total_files' => 0,
158
+ 'check_with_repo' => 0,
159
+ 'scan_mode' => "",
160
+ 'status_download_time' => $wordpress_download_status
161
+ );
162
+
163
+ $encoded_scan_status=json_encode($scan_status);
164
+ update_option("mo_wpns_scan_status",$encoded_scan_status);
165
+
166
+
167
+ $mo2f_malware_db_handler->delete_files_parts();
168
+
169
+ if(isset($POSTED['scan']) && $POSTED['scan']=='scan_start'){
170
+ $scan_configuration = array();
171
+ switch($POSTED['scantype'])
172
+ {
173
+ case "quick_scan":
174
+ $nonce = $POSTED['nonce'];
175
+ if ( ! wp_verify_nonce( $nonce, 'wpns-quick-scan' ) ){
176
+ wp_send_json('ERROR');
177
+ return;
178
+ }
179
+ $scan_configuration = MoWpnsConstants::$quick_scan_configuration;
180
+ update_option('mo_wpns_scan_mode','quick_scan');
181
+ $scan_status = array(
182
+ 'scan_progress' => $mo_wpns_malware_scan_in_progress,
183
+ 'files_scanned' => $mo_wpns_files_scanned,
184
+ 'infected_files' => $mo_wpns_infected_files,
185
+ 'warning_files' => $mo_wpns_warning_files,
186
+ 'total_files' => 0,
187
+ 'check_with_repo' => 0,
188
+ 'scan_mode' => "quick_scan",
189
+ 'status_download_time' => $wordpress_download_status
190
+ );
191
+
192
+ $encoded_scan_status=json_encode($scan_status);
193
+ update_option("mo_wpns_scan_status",$encoded_scan_status);
194
+ $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration, $current_time); //recheck
195
+ break;
196
+ case "standard_scan":
197
+ $nonce = $POSTED['nonce'];
198
+ if ( ! wp_verify_nonce( $nonce, 'wpns-standard-scan' ) ){
199
+ wp_send_json('ERROR');
200
+ return;
201
+ }
202
+ $scan_configuration = MoWpnsConstants::$standard_scan_configuration;
203
+ update_option('mo_wpns_scan_mode','standard_scan');
204
+ $scan_status = array(
205
+ 'scan_progress' => $mo_wpns_malware_scan_in_progress,
206
+ 'files_scanned' => $mo_wpns_files_scanned,
207
+ 'infected_files' => $mo_wpns_infected_files,
208
+ 'warning_files' => $mo_wpns_warning_files,
209
+ 'total_files' => 0,
210
+ 'check_with_repo' => 0,
211
+ 'scan_mode' => "standard_scan",
212
+ 'status_download_time' => $wordpress_download_status
213
+ );
214
+
215
+ $encoded_scan_status=json_encode($scan_status);
216
+ update_option("mo_wpns_scan_status",$encoded_scan_status);
217
+ $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration, $current_time); //recheck
218
+ break;
219
+ case "custom_scan":
220
+ $nonce = $POSTED['nonce'];
221
+ if ( ! wp_verify_nonce( $nonce, 'wpns-custom-scan' ) ){
222
+ wp_send_json('ERROR');
223
+ return;
224
+ }
225
+ $decode_scan_configuration=json_decode(get_option("mo_wpns_scan_configuration"));
226
+ if(is_null($decode_scan_configuration))
227
+ {
228
+ delete_option("mo_wpns_scan_status",$encoded_scan_status);
229
+ wp_send_json("RECONFIGURE");
230
+ }
231
+
232
+ $scan_configuration = array('plugin_scan' => $decode_scan_configuration->plugin_scan,
233
+ 'theme_scan' => $decode_scan_configuration->theme_scan,
234
+ 'core_scan' => $decode_scan_configuration->core_scan,
235
+ 'file_extension' => $decode_scan_configuration->file_extension,
236
+ 'check_vulnerable' => $decode_scan_configuration->check_vulnerable,
237
+ 'check_sql' => $decode_scan_configuration->check_sql,
238
+ 'ext_link_check' => $decode_scan_configuration->ext_link_check,
239
+ 'check_repo' => $decode_scan_configuration->check_repo,
240
+ 'path_skip' => $decode_scan_configuration->path_skip,
241
+ 'type_scan' => "Custom Scan"
242
+ );
243
+
244
+
245
+ $scan_status = array(
246
+ 'scan_progress' => $mo_wpns_malware_scan_in_progress,
247
+ 'files_scanned' => $mo_wpns_files_scanned,
248
+ 'infected_files' => $mo_wpns_infected_files,
249
+ 'warning_files' => $mo_wpns_warning_files,
250
+ 'total_files' => 0,
251
+ 'check_with_repo' => 0,
252
+ 'scan_mode' => "custom_scan",
253
+ 'status_download_time' => $wordpress_download_status
254
+ );
255
+
256
+ $encoded_scan_status=json_encode($scan_status);
257
+ update_option("mo_wpns_scan_status",$encoded_scan_status);
258
+ update_option('mo_wpns_scan_mode','custom_scan');
259
+ update_option('mo2f_custom_scan_config', $scan_configuration);
260
+ $mo_wpns_scan_handler->mo2f_scan_all_files($scan_configuration, $current_time); //recheck
261
+ break;
262
+ }
263
+ }
264
+ }
265
+
266
+
267
+ public function mo_wpns_get_progress(){
268
+
269
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
270
+ $status= $decoded_scan_status->scan_progress;;
271
+ $files_scanned= $decoded_scan_status->files_scanned;
272
+ $total_files = $decoded_scan_status->total_files;
273
+ $check_repo = $decoded_scan_status->check_with_repo;
274
+ $scan_mode= $decoded_scan_status->scan_mode;
275
+ $status_download= $decoded_scan_status->status_download_time;
276
+
277
+ if($status_download != false && $status == "IN PROGRESS"){
278
+ $time_spent_in_downloading= time()-$status_download;
279
+
280
+ if($time_spent_in_downloading > 600){
281
+ error_log("progress check");
282
+ $mo2f_malware_db_handler = new MoWpnsDB();
283
+ $reportid= get_option('mo2f_report_id');
284
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
285
+ if(!empty($last_report)){
286
+ $response['file_count']= $last_report[0]->scanned_files;
287
+ $response['malware_count'] = $last_report[0]->malware_count;
288
+ $response['repo_issues'] = -96;
289
+ $response['malicious_link'] = $last_report[0]->malicious_links;
290
+
291
+ $mo2f_malware_db_handler->scan_report_complete($reportid, $response['file_count'], $response['malware_count'], $response['repo_issues'], $response['malicious_link']);
292
+ }
293
+
294
+ $scan_handler_obj = new mo2f_scanner_parts;
295
+ $scan_handler_obj->mo2f_end_scan();
296
+ }
297
+ }
298
+ $repo_scan=0;
299
+ if($scan_mode == "standard_scan" || ($scan_mode == "custom_scan" && $check_repo == 1)){
300
+ $repo_scan=1;
301
+ }
302
+ if($status == "IN PROGRESS"){
303
+ $result=array("status"=>$status, "scanned"=>$files_scanned, "total"=>$total_files, "repo_scan"=> $repo_scan);
304
+ wp_send_json($result);
305
+ }
306
+ else{
307
+ //stop scan check
308
+ $stop_scan=get_option('mo_stop_scan');
309
+
310
+ $mo_wpns_db_handler = new MoWpnsDB();
311
+ $total_scan=$mo_wpns_db_handler->count_files();
312
+ $total_malicious=$mo_wpns_db_handler->count_malicious_files();
313
+ $last_id=$mo_wpns_db_handler->get_last_id();
314
+ $send_id=$last_id[0]->max;
315
+ $last_scan=$mo_wpns_db_handler->count_files_last_scan($send_id);
316
+ $malicious_last_scan= get_option('mo_wpns_infected_files');
317
+ $warning_last_scan = get_option('mo_wpns_warning_files');
318
+ if($total_scan > 999){
319
+ $total_scan=($total_scan/1000);
320
+ $total_scan= round($total_scan,1)."k";
321
+ }
322
+ if($total_malicious > 999){
323
+ $total_malicious=($total_malicious/1000);
324
+ $total_malicious= round($total_malicious,1)."k";
325
+ }
326
+ if($last_scan > 999){
327
+ $last_scan = ($last_scan/1000);
328
+ $last_scan = round($last_scan,1)."k";
329
+ }
330
+ if($stop_scan){
331
+ $status="ABORTED";
332
+ $result = array("status"=>$status, 'total_files'=>$total_scan, 'total_mal'=>$total_malicious, 'scan_files'=>$last_scan, 'mal_files'=>$malicious_last_scan, 'warnings'=>$warning_last_scan);
333
+ wp_send_json($result);
334
+ }
335
+ $result = array("status"=>$status, 'total_files'=>$total_scan, 'total_mal'=>$total_malicious, 'scan_files'=>$total_files, 'mal_files'=>$malicious_last_scan, 'warnings'=>$warning_last_scan);
336
+ wp_send_json($result);
337
+ }
338
+ }
339
+
340
+ function mo_wpns_stop_scan(){
341
+ error_log("Stop Scan");
342
+ update_option('mo_stop_scan','1');
343
+ $mo2f_malware_db_handler = new MoWpnsDB();
344
+ $mo2f_malware_db_handler->delete_files_parts();
345
+ wp_send_json('success');
346
+ }
347
+
348
+ function mo_wpns_get_scan_result(){
349
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
350
+ $status=$decoded_scan_configuration->scan_progress;
351
+ $mo_wpns_db_handler = new MoWpnsDB();
352
+ $result = $mo_wpns_db_handler->get_report();
353
+ $str1= $_SERVER['REQUEST_URI'];
354
+ $str1= str_replace("admin-ajax.php", "admin.php?page=mo_2fa_malwarescan", $str1);
355
+ $currenturl = remove_query_arg('delete',$str1);
356
+ $currenturl = remove_query_arg('view',$currenturl);
357
+ $currenturl = remove_query_arg('trust',$currenturl);
358
+ $currenturl = remove_query_arg('trustchanged',$currenturl);
359
+ $htmldata = "";
360
+ if(!empty($result)){
361
+ foreach($result as $report){
362
+ if(empty($report->scan_mode)){
363
+ $report->scan_mode="Custom Scan";
364
+ }
365
+ $repo_count = $report->repo_issues >= 0 ? $report->repo_issues : 0;
366
+ $htmldata .= "<tr><td style=text-align:center>".$report->scan_mode."</td>";
367
+ $htmldata .= "<td style=text-align:center>";
368
+ if(!empty($report->scanned_folders)){
369
+ foreach(explode(";",$report->scanned_folders) as $folder){
370
+ if(!empty($folder)){
371
+ $htmldata .= $folder."<br>";
372
+ }
373
+ }
374
+ }
375
+ $htmldata .= "</td><td style=text-align:center>";
376
+ $htmldata .= "<span style=color:green id=scan_files>".$report->scanned_files." files scanned<br></span>";
377
+ $htmldata .= "<span style=color:red id=malicious_files>".$report->malware_count." malware found<br></span>";
378
+ if($report->repo_issues < 0){
379
+ $htmldata .= "<span style=color:orange id=malicious_files>Issues with repository check<br></span>";
380
+ }
381
+ $htmldata .= "<span style=color:orange id=warning_files>".($repo_count+$report->malicious_links)." warnings found</span>";
382
+ $htmldata .= "</td><td style=text-align:center id=start_time>".date("M j, Y, g:i:s a",$report->start_timestamp)."</td>";
383
+ $htmldata .= "<td><a href='".add_query_arg( array('tab' => 'default', 'view' => $report->id), $currenturl )."'>View Details</a> <a href='".add_query_arg( array('tab' => 'default', 'delete' => $report->id), $currenturl )."'>Delete</a></td>";
384
+ $htmldata .= "</tr>";
385
+
386
+ }
387
+ }else{
388
+ $htmldata .= '<tr class="odd"><td valign="top" colspan="5" class="dataTables_empty">No data available in table</td></tr>';
389
+ }
390
+ wp_send_json($htmldata);
391
+
392
+ }
393
+ }
394
+ new Mo_wpns_scan_malware();
395
+ ?>
controllers/{malware_scan_result.php → malware_scanner/malware_scan_result.php} RENAMED
File without changes
controllers/{scan_malware.php → malware_scanner/scan_malware.php} RENAMED
@@ -5,6 +5,6 @@ global $moWpnsUtility,$dirName;
5
  add_option('mo_wpns_skip_folders');
6
  update_site_option('mo2f_visit_malware',true);
7
 
8
- include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'malware_scan.php';
9
  ?>
10
 
5
  add_option('mo_wpns_skip_folders');
6
  update_site_option('mo2f_visit_malware',true);
7
 
8
+ include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'malware_scan.php';
9
  ?>
10
 
controllers/malware_scanner/scan_malware_report.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_report_view.php';
4
+
5
+ ?>
controllers/malware_scanner/scan_malware_settings.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_settings_view.php';
3
+ ?>
controllers/malware_scanner/scan_malware_summary.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_summary_view.php';
4
+
5
+ ?>
controllers/navbar.php CHANGED
@@ -25,37 +25,37 @@
25
  {
26
  case 'mo_2fa_login_and_spam':
27
  update_option('mo_2f_switch_loginspam', 1);
28
- if($tab_count < 7)
29
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
30
  break;
31
  case 'mo_2fa_backup':
32
  update_option('mo_2f_switch_backup', 1);
33
- if($tab_count < 7)
34
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
35
  break;
36
  case 'mo_2fa_waf':
37
  update_option('mo_2f_switch_waf', 1);
38
- if($tab_count < 7)
39
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
40
  break;
41
  case 'mo_2fa_advancedblocking':
42
  update_option('mo_2f_switch_adv_block', 1);
43
- if($tab_count < 7)
44
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
45
  break;
46
  case 'mo_2fa_notifications':
47
  update_option('mo_2f_switch_notif', 1);
48
- if($tab_count < 7)
49
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
50
  break;
51
  case 'mo_2fa_reports':
52
  update_option('mo_2f_switch_reports', 1);
53
- if($tab_count < 7)
54
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
55
  break;
56
  case 'mo_2fa_malwarescan':
57
  update_option('mo_2f_switch_malware', 1);
58
- if($tab_count < 7)
59
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
60
  break;
61
  }
25
  {
26
  case 'mo_2fa_login_and_spam':
27
  update_option('mo_2f_switch_loginspam', 1);
28
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_loginspam'))
29
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
30
  break;
31
  case 'mo_2fa_backup':
32
  update_option('mo_2f_switch_backup', 1);
33
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_backup'))
34
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
35
  break;
36
  case 'mo_2fa_waf':
37
  update_option('mo_2f_switch_waf', 1);
38
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_waf'))
39
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
40
  break;
41
  case 'mo_2fa_advancedblocking':
42
  update_option('mo_2f_switch_adv_block', 1);
43
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_adv_block'))
44
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
45
  break;
46
  case 'mo_2fa_notifications':
47
  update_option('mo_2f_switch_notif', 1);
48
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_notif'))
49
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
50
  break;
51
  case 'mo_2fa_reports':
52
  update_option('mo_2f_switch_reports', 1);
53
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_reports'))
54
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
55
  break;
56
  case 'mo_2fa_malwarescan':
57
  update_option('mo_2f_switch_malware', 1);
58
+ if($tab_count < 7 && !get_site_option('mo_2f_switch_malware'))
59
  update_site_option('mo2f_tab_count', get_site_option('mo2f_tab_count')+1);
60
  break;
61
  }
controllers/scan_malware_report.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
-
3
- include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'scan_report_view.php';
4
-
5
- ?>
 
 
 
 
 
controllers/scan_malware_settings.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'scan_settings_view.php';
3
- ?>
 
 
 
controllers/scan_malware_summary.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- if(get_option('mo_wpns_malware_scan_in_progress')=='IN PROGRESS')
3
- $scan_in_progress="disabled";
4
- else
5
- $scan_in_progress="";
6
- include_once $dirName . 'views'.DIRECTORY_SEPARATOR.'scan_summary_view.php';
7
-
8
- ?>
 
 
 
 
 
 
 
 
database/database_functions.php CHANGED
@@ -27,7 +27,7 @@
27
  $this->skipfiles = $wpdb->base_prefix.'wpns_malware_skip_files';
28
  $this->hashfile = $wpdb->base_prefix.'wpns_malware_hash_file';
29
  $this->backupdetails = $wpdb->base_prefix.'wpns_backup_report';
30
-
31
  }
32
 
33
  function mo_plugin_activate(){
@@ -118,8 +118,10 @@
118
  }
119
  $result= $wpdb->get_var("SHOW COLUMNS FROM `$tableName` LIKE 'scan_mode'");
120
  if(is_null($result)){
121
- $sql = "ALTER TABLE `$tableName` ADD `scan_mode` mediumtext NOT NULL DEFAULT 'Custom Scan' AFTER `id` ;";
122
  $results1 = $wpdb->query($sql);
 
 
123
  }
124
 
125
  $tableName = $this->scanreportdetails;
@@ -138,6 +140,14 @@
138
  dbDelta($sql);
139
  }
140
 
 
 
 
 
 
 
 
 
141
  $tableName = $this->hashfile;
142
  if($wpdb->get_var("show tables like '$tableName'") != $tableName)
143
  {
@@ -432,7 +442,7 @@
432
  return;
433
  }
434
 
435
- function create_scan_report($folderNames, $scan_type, $start_timestamp){
436
  global $wpdb;
437
  $wpdb->insert(
438
  $this->malwarereportTable,
@@ -440,7 +450,10 @@
440
  'scan_mode' => $scan_type,
441
  'scanned_folders' => $folderNames,
442
  'scanned_files' => 0,
443
- 'start_timestamp' => $start_timestamp
 
 
 
444
  )
445
  );
446
  $result = $wpdb->get_results( "SELECT * FROM ".$this->malwarereportTable." order by id DESC LIMIT 1");
@@ -503,12 +516,14 @@
503
 
504
  function insert_hash($source_file_path,$hash_of_file, $scan_data){
505
  global $wpdb;
 
506
  $query= "INSERT INTO ".$this->hashfile."(`file name`,`file hash`,`scan_data`) VALUES('".$source_file_path."', '".$hash_of_file."', '".serialize($scan_data)."') ON DUPLICATE KEY UPDATE `file hash`='".$hash_of_file."' AND `scan_data`='".serialize($scan_data)."'";
507
  $res=$wpdb->query( $query );
508
  }
509
 
510
  function update_hash($source_file_path, $hash_of_file, $scan_data){
511
  global $wpdb;
 
512
  $query= "UPDATE ".$this->hashfile." SET `file hash`='".$hash_of_file."',`scan_data`='".serialize($scan_data)."' WHERE `file name`='".$source_file_path."'";
513
  $res=$wpdb->query( $query );
514
  }
@@ -519,6 +534,108 @@
519
  $res=$wpdb->query( $query );
520
  }
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  function get_last_id(){
523
  global $wpdb;
524
  $result= $wpdb->get_results("SELECT MAX(Id) AS max FROM ".$this->malwarereportTable);
@@ -536,6 +653,26 @@
536
  $wpdb->query(
537
  "DELETE FROM ".$this->malwarereportTable." WHERE id = ".$reportid
538
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  }
540
 
541
  function get_report(){
27
  $this->skipfiles = $wpdb->base_prefix.'wpns_malware_skip_files';
28
  $this->hashfile = $wpdb->base_prefix.'wpns_malware_hash_file';
29
  $this->backupdetails = $wpdb->base_prefix.'wpns_backup_report';
30
+ $this->filescan = $wpdb->base_prefix.'wpns_files_scan';
31
  }
32
 
33
  function mo_plugin_activate(){
118
  }
119
  $result= $wpdb->get_var("SHOW COLUMNS FROM `$tableName` LIKE 'scan_mode'");
120
  if(is_null($result)){
121
+ $sql = "ALTER TABLE `$tableName` ADD `scan_mode` mediumtext AFTER `id` ;";
122
  $results1 = $wpdb->query($sql);
123
+ $sql1= "UPDATE $this->malwarereportTable SET `scan_mode`='Custom Scan';";
124
+ $resluts = $wpdb->query($sql1);
125
  }
126
 
127
  $tableName = $this->scanreportdetails;
140
  dbDelta($sql);
141
  }
142
 
143
+ $tableName = $this->filescan;
144
+ if($wpdb->get_var("show tables like '$tableName'") != $tableName)
145
+ {
146
+ $sql = "CREATE TABLE " . $tableName . " (
147
+ `id` bigint NOT NULL AUTO_INCREMENT, `path` mediumtext NOT NULL, `name_hash` varchar(45) NOT NULL, `malware_service` int NOT NULL, `repo_check` int NOT NULL, `link_check` int NOT NULL, PRIMARY KEY id (id), UNIQUE KEY name_hash (name_hash) );";
148
+ dbDelta($sql);
149
+ }
150
+
151
  $tableName = $this->hashfile;
152
  if($wpdb->get_var("show tables like '$tableName'") != $tableName)
153
  {
442
  return;
443
  }
444
 
445
+ function create_scan_report($folderNames, $scan_type, $start_timestamp, $repo_check_status_code){
446
  global $wpdb;
447
  $wpdb->insert(
448
  $this->malwarereportTable,
450
  'scan_mode' => $scan_type,
451
  'scanned_folders' => $folderNames,
452
  'scanned_files' => 0,
453
+ 'start_timestamp' => $start_timestamp,
454
+ 'malware_count' => 0,
455
+ 'repo_issues' => $repo_check_status_code,
456
+ 'malicious_links' => 0
457
  )
458
  );
459
  $result = $wpdb->get_results( "SELECT * FROM ".$this->malwarereportTable." order by id DESC LIMIT 1");
516
 
517
  function insert_hash($source_file_path,$hash_of_file, $scan_data){
518
  global $wpdb;
519
+ $source_file_path = addslashes($source_file_path);
520
  $query= "INSERT INTO ".$this->hashfile."(`file name`,`file hash`,`scan_data`) VALUES('".$source_file_path."', '".$hash_of_file."', '".serialize($scan_data)."') ON DUPLICATE KEY UPDATE `file hash`='".$hash_of_file."' AND `scan_data`='".serialize($scan_data)."'";
521
  $res=$wpdb->query( $query );
522
  }
523
 
524
  function update_hash($source_file_path, $hash_of_file, $scan_data){
525
  global $wpdb;
526
+ $source_file_path = addslashes($source_file_path);
527
  $query= "UPDATE ".$this->hashfile." SET `file hash`='".$hash_of_file."',`scan_data`='".serialize($scan_data)."' WHERE `file name`='".$source_file_path."'";
528
  $res=$wpdb->query( $query );
529
  }
534
  $res=$wpdb->query( $query );
535
  }
536
 
537
+ function get_infected_file($filename){
538
+ global $wpdb;
539
+ $filename = addslashes($filename);
540
+ $result = $wpdb->get_results( "SELECT * FROM ".$this->scanreportdetails." where filename=".$filename );
541
+ return $result;
542
+ }
543
+
544
+ function insert_files_in_parts($file_path_array){
545
+ global $wpdb;
546
+ if(!empty($file_path_array)){
547
+ $size=sizeof($file_path_array);
548
+ $default=0;
549
+ $query="INSERT INTO ".$this->filescan."(`path`, `name_hash`, `malware_service`, `repo_check`, `link_check`) VALUES";
550
+ for ($i=1; $i <= $size ; $i++) {
551
+ $value= $file_path_array[$i];
552
+ $value = addslashes($value);
553
+ $hash_value= md5($value);
554
+ $query.= "('".$value."', '".$hash_value."', '".$default."', '".$default."', '".$default."')";
555
+ if($i < $size){
556
+ $query.= ",";
557
+ }
558
+ }
559
+ $query.=";";
560
+ $res=$wpdb->query( $query );
561
+ }
562
+ }
563
+
564
+ function update_files_scan($file_path_array, $file_count){
565
+ global $wpdb;
566
+ $query="INSERT INTO ".$this->filescan."(`name_hash`, `malware_service`) VALUES";
567
+ for ($i=0; $i < $file_count ; $i++) {
568
+ $value= $file_path_array[$i]->path;
569
+ $value = addslashes($value);
570
+ $value = md5($value);
571
+ $query.= "('".$value."', 1)";
572
+ if($i < $file_count-1){
573
+ $query.= ",";
574
+ }
575
+ }
576
+ $query.=" ON DUPLICATE KEY UPDATE `malware_service`= VALUES(malware_service);";
577
+ $res=$wpdb->query( $query );
578
+ }
579
+
580
+ function update_files_scan_ext_link($file_path_array, $file_count){
581
+ global $wpdb;
582
+ $query="INSERT INTO ".$this->filescan."(`name_hash`, `link_check`) VALUES";
583
+ for ($i=0; $i < $file_count ; $i++) {
584
+ $value= $file_path_array[$i]->path;
585
+ $value = addslashes($value);
586
+ $value = md5($value);
587
+ $query.= "('".$value."', 1)";
588
+ if($i < $file_count-1){
589
+ $query.= ",";
590
+ }
591
+ }
592
+ $query.=" ON DUPLICATE KEY UPDATE `link_check`= VALUES(link_check);";
593
+ $res=$wpdb->query( $query );
594
+ }
595
+
596
+ function update_files_scan_repo($file_path_array, $file_count){
597
+ global $wpdb;
598
+ $query="INSERT INTO ".$this->filescan."(`name_hash`, `repo_check`) VALUES";
599
+ for ($i=0; $i < $file_count ; $i++) {
600
+ $value= $file_path_array[$i]->path;
601
+ $value = addslashes($value);
602
+ $value = md5($value);
603
+ $query.= "('".$value."', 1)";
604
+ if($i < $file_count-1){
605
+ $query.= ",";
606
+ }
607
+ }
608
+ $query.=" ON DUPLICATE KEY UPDATE `repo_check`= VALUES(repo_check);";
609
+ $res=$wpdb->query( $query );
610
+ }
611
+
612
+ function get_files_in_parts(){
613
+ global $wpdb;
614
+ $sql= 'SELECT * FROM '.$this->filescan.' WHERE `malware_service`= 0 LIMIT 100';
615
+ $result=$wpdb->get_results($sql);
616
+ return $result;
617
+ }
618
+
619
+ function get_files_for_link(){
620
+ global $wpdb;
621
+ $sql= 'SELECT * FROM '.$this->filescan.' WHERE `link_check`= 0 LIMIT 100';
622
+ $result=$wpdb->get_results($sql);
623
+ return $result;
624
+ }
625
+
626
+ function get_files_for_repo(){
627
+ global $wpdb;
628
+ $sql= 'SELECT * FROM '.$this->filescan.' WHERE `repo_check`= 0 LIMIT 100';
629
+ $result=$wpdb->get_results($sql);
630
+ return $result;
631
+ }
632
+
633
+ function delete_files_parts(){
634
+ global $wpdb;
635
+ $sql= "TRUNCATE TABLE ".$this->filescan.";";
636
+ $res=$wpdb->query($sql);
637
+ }
638
+
639
  function get_last_id(){
640
  global $wpdb;
641
  $result= $wpdb->get_results("SELECT MAX(Id) AS max FROM ".$this->malwarereportTable);
653
  $wpdb->query(
654
  "DELETE FROM ".$this->malwarereportTable." WHERE id = ".$reportid
655
  );
656
+ $warning_count=0;
657
+ $malware_count=0;
658
+ $last_id=$this->get_last_id();
659
+ $send_id=$last_id[0]->max;
660
+ if(!is_null($send_id)){
661
+ $res = $this->get_report_with_id($send_id);
662
+ $record = $res[0];
663
+ if($record->malware_count >= 0){
664
+ $malware_count = $record->malware_count;
665
+ }
666
+ if($record->repo_issues < 0){
667
+ $warning_count = $record->repo_issues;
668
+ }else{
669
+ $warning_count = $record->repo_issues + $record->malicious_links;
670
+ }
671
+ }
672
+
673
+ update_option('mo_wpns_infected_files', $malware_count);
674
+ update_option('mo_wpns_warning_files', $warning_count);
675
+
676
  }
677
 
678
  function get_report(){
handler/login.php CHANGED
@@ -31,6 +31,10 @@
31
  global $moWpnsUtility,$dirName;
32
  $WAFEnabled = get_option('WAFEnabled');
33
  $WAFLevel = get_option('WAF');
 
 
 
 
34
  if($WAFEnabled == 1)
35
  {
36
  if($WAFLevel == 'PluginLevel')
31
  global $moWpnsUtility,$dirName;
32
  $WAFEnabled = get_option('WAFEnabled');
33
  $WAFLevel = get_option('WAF');
34
+
35
+ $mo2f_scanner_parts = new mo2f_scanner_parts();
36
+ $mo2f_scanner_parts->file_cron_scan();
37
+
38
  if($WAFEnabled == 1)
39
  {
40
  if($WAFLevel == 'PluginLevel')
handler/malware_scanner.php DELETED
@@ -1,703 +0,0 @@
1
- <?php
2
-
3
- class Mo_wpns_Scan_Handler{
4
- private $total_files_to_scan;
5
- public $scanned_files = array();
6
- function __construct(){
7
-
8
- }
9
- function mo2f_scan_all_files($scan_config){
10
- $scan_stop_status=get_option('mo_stop_scan');
11
-
12
- if($scan_stop_status=="1"){
13
- wp_send_json('scan_terminating');
14
- exit;
15
- }
16
- update_option('mo_stop_scan','0');
17
- ini_set('memory_limit', '-1');
18
- ini_set('max_execution_time', 0);
19
- $result = array();
20
- $folderpaths = array();
21
- $wp_repo_file = array();
22
- $folderNames = "";
23
- $repo_check_status = $scan_config['check_repo'];
24
- $repo_check_status_code = 0;
25
- $base = dirname(dirname(dirname(dirname(plugin_dir_path(__FILE__)))));
26
- $hostname = 'wordpress.org';
27
- $wordpress_server_status = $this->mo_wpns_check_malware_server_status($hostname);
28
- if (!is_writable($base.DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."uploads")) {
29
- $scan_config['check_repo'] = 0;
30
- $repo_check_status_code = -97;
31
- }
32
- if (!$wordpress_server_status) {
33
- $scan_config['check_repo'] = 0;
34
- $repo_check_status_code = -98;
35
- }
36
- $repo_file_path=$base.DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."uploads".DIRECTORY_SEPARATOR."miniorangescan";
37
- if($scan_config['core_scan'] == 1){
38
- $folderpaths['base'] = $base;
39
- $folderNames .= "WP Files;";
40
- }
41
- if($scan_config['plugin_scan'] == 1){
42
- $folderpaths['plugins'] = $base.DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."plugins";
43
- $folderNames .= "Plugins;";
44
- }
45
- if($scan_config['theme_scan'] == 1){
46
- $folderpaths['themes'] = $base.DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."themes";
47
- $folderNames .= "Themes;";
48
- }
49
- if($scan_config['check_repo'] == 1){
50
- $folderNames .= "WP Repo Files;";
51
- }
52
- $this->count_total_files($folderpaths, $base, $scan_config);
53
-
54
- if ( ! function_exists( 'get_plugins' ) ) {
55
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
56
- }
57
- if ( ! function_exists( 'plugins_api' ) ) {
58
- require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
59
- }
60
- if($scan_config['check_repo'] == 1){
61
- if(!is_dir($repo_file_path)){
62
- mkdir($repo_file_path);
63
- }
64
- if($scan_config['core_scan'] == 1){
65
- require(ABSPATH . 'wp-includes/version.php');
66
- //wordpress name to be changed to be changed based on version
67
- $zip_name="wp-".$wp_version;
68
- $wp_repo_file['base']=$repo_file_path.DIRECTORY_SEPARATOR.$zip_name;
69
- update_option('downloaded_wordpress_repo_name', $zip_name);
70
- if(!is_dir($repo_file_path.DIRECTORY_SEPARATOR.$zip_name)){
71
- $result = $this->download_repo($zip_name, $wp_version, $repo_file_path);
72
- if($result === -99){
73
- $scan_config['check_repo'] = 0;
74
- $repo_check_status_code = -99;
75
- }else if(!$result){
76
- $scan_config['check_repo'] = 0;
77
- $repo_check_status_code = -100;
78
- }
79
- }
80
- }
81
- if($scan_config['plugin_scan'] == 1 && $scan_config['check_repo']){
82
- $wp_plugin_repo_file=$repo_file_path.DIRECTORY_SEPARATOR."plugins";
83
- if(!is_dir($wp_plugin_repo_file)){
84
- mkdir($wp_plugin_repo_file);
85
- }
86
- $wp_repo_file['plugins']=$wp_plugin_repo_file;
87
- $plugin_list=get_site_transient( 'update_plugins' );
88
- $all_plugins=array();
89
- foreach ($plugin_list as $key => $value) {
90
- if($key=='response'||$key=='no_update'){
91
- foreach ($value as $ke => $val) {
92
- $all_plugins[$ke] = $val;
93
- }
94
- }
95
- }
96
- $result = $this->iterator_plugins_themes($all_plugins, $wp_plugin_repo_file, 'plugins');
97
- if($result === -99){
98
- $scan_config['check_repo'] = 0;
99
- $repo_check_status_code = -99;
100
- }else if(!$result){
101
- $scan_config['check_repo'] = 0;
102
- $repo_check_status_code = -100;
103
- }
104
- }
105
- if($scan_config['theme_scan'] == 1 && $scan_config['check_repo']){
106
- $wp_theme_repo_file=$repo_file_path.DIRECTORY_SEPARATOR."themes";
107
- if(!is_dir($wp_theme_repo_file)){
108
- mkdir($wp_theme_repo_file);
109
- }
110
- $wp_repo_file['themes']=$wp_theme_repo_file;
111
- $all_themes=get_site_transient( 'update_themes' )->checked;
112
- $result = $this->iterator_plugins_themes($all_themes, $wp_theme_repo_file, 'themes');
113
- if($result === -99){
114
- $scan_config['check_repo'] = 0;
115
- $repo_check_status_code = -99;
116
- }else if(!$result){
117
- $scan_config['check_repo'] = 0;
118
- $repo_check_status_code = -100;
119
- }
120
- }
121
- }
122
- $mo2f_malware_db_handler = new MoWpnsDB();
123
- $time = current_time('timestamp');
124
- $result = $this->get_scan_result($mo2f_malware_db_handler, $folderpaths, $wp_repo_file, $scan_config, $base);
125
- $reportid = $mo2f_malware_db_handler->create_scan_report($folderNames, $scan_config['type_scan'], $time);
126
- if($result['scan']){
127
- foreach ($result['scan'] as $key => $value) {
128
- $mo2f_malware_db_handler->add_report_details($reportid, $key, $value);
129
- }
130
- }
131
- $result['repo_issues'] = $repo_check_status!=$scan_config['check_repo'] ? $repo_check_status_code : $result['repo_issues'];
132
- $mo2f_malware_db_handler->scan_report_complete($reportid, $result['file_count'], $result['malware_count'], $result['repo_issues'], $result['malicious_link']);
133
- if(is_dir($repo_file_path)){
134
- $this->remove_dir($repo_file_path);
135
- }
136
- update_option('mo_wpns_malware_scan_in_progress','COMPLETE');
137
- $total_scan=$mo2f_malware_db_handler->count_files();
138
- $total_malicious=$mo2f_malware_db_handler->count_malicious_files();
139
- $last_scan=$mo2f_malware_db_handler->count_files_last_scan($reportid);
140
- $malicious_last_scan=$mo2f_malware_db_handler->count_malicious_last_scan($reportid);
141
- if($total_scan > 999){
142
- $total_scan=($total_scan/1000);
143
- $total_scan= round($total_scan,1)."k";
144
- }
145
- if($total_malicious > 999){
146
- $total_malicious=($total_malicious/1000);
147
- $total_malicious= round($total_malicious,1)."k";
148
- }
149
- $response=array('total_files'=>$total_scan, 'total_mal'=>$total_malicious, 'scan_files'=>$last_scan, 'mal_files'=>$malicious_last_scan);
150
- wp_send_json($response);
151
- }
152
-
153
- function iterator_plugins_themes($themes_or_plugins, $path, $type=''){
154
- foreach($themes_or_plugins as $key => $data){
155
- if($type=='plugins'){
156
- $plugin_slug=$data->slug;
157
- $plugin_directory_location=dirname(dirname(dirname($path))).DIRECTORY_SEPARATOR.'plugins';
158
- $plugin_data=get_plugin_data($plugin_directory_location.DIRECTORY_SEPARATOR.$data->plugin);
159
- $plugin_version=$plugin_data['Version'];
160
- if(!is_dir($path.DIRECTORY_SEPARATOR.$plugin_slug)){
161
- $result= $this->download_repo($plugin_slug, $plugin_version, $path, $type);
162
- if($result === -99){
163
- return -99;
164
- }else if(!$result){
165
- return false;
166
- }
167
- }
168
- } else if($type=='themes'){
169
- if(!is_dir($path.DIRECTORY_SEPARATOR.$key)){
170
- $result= $this->download_repo($key, $data, $path, $type);
171
- if($result === -99){
172
- return -99;
173
- }else if(!$result){
174
- return false;
175
- }
176
- }
177
- }
178
- }
179
- return true;
180
- }
181
-
182
- function download_repo($zip_name, $version, $path, $type=''){
183
- if ($type=='plugins') {
184
- $download_link="https://downloads.wordpress.org/plugin/".$zip_name.".".$version.".zip";
185
- $plugin_name=$zip_name.'.'.$version;
186
- $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
187
- if( $download_result){
188
- $result = $this->unzip_downloaded_repo($zip_name, $path);
189
- return $result;
190
- }else {
191
- $download_link="https://downloads.wordpress.org/plugin/".$zip_name.".zip";
192
- $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
193
- if( $download_result){
194
- $result = $this->unzip_downloaded_repo($zip_name, $path);
195
- return $result;
196
- }else {
197
- error_log("Unable to download Plugin: ".$plugin_name);
198
- return -99;
199
- }
200
- return -99;
201
- }
202
- } else if($type=='themes'){
203
- $theme_name=$zip_name.'.'.$version;
204
- $download_link="https://downloads.wordpress.org/theme/".$theme_name.".zip";
205
- $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
206
- if( $download_result){
207
- $result = $this->unzip_downloaded_repo($zip_name, $path);
208
- return $result;
209
- }else {
210
- $download_link="https://downloads.wordpress.org/theme/".$zip_name.".zip";
211
- $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
212
- if( $download_result){
213
- $result = $this->unzip_downloaded_repo($zip_name, $path);
214
- return $result;
215
- }else {
216
- error_log("Unable to download Theme: ".$theme_name);
217
- return -99;
218
- }
219
- return -99;
220
- }
221
- } else {
222
- $download_link="https://wordpress.org/wordpress-".$version.".zip";
223
- $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.'.zip', file_get_contents($download_link));
224
- if($download_result){
225
- $result=$this->unzip_downloaded_repo($zip_name, $path);
226
- return $result;
227
- } else {
228
- error_log("Unable to download wordpress-".$version);
229
- return -99;
230
- }
231
- }
232
- return false;
233
- }
234
-
235
- function unzip_downloaded_repo($name, $path){
236
- $zip = new ZipArchive;
237
- $folder_path=$path.DIRECTORY_SEPARATOR.$name.".zip";
238
- $res = $zip->open($folder_path);
239
- if ($res === TRUE) {
240
- // extract it to the path we determined above
241
- $result = $zip->extractTo($path);
242
- $zip->close();
243
- if ($name == get_option('downloaded_wordpress_repo_name')) {
244
- rename($path.DIRECTORY_SEPARATOR."wordpress", $path.DIRECTORY_SEPARATOR.$name);
245
- }
246
- unlink($folder_path);
247
- return true;
248
- } else {
249
- return false;
250
- }
251
- }
252
-
253
- function get_scan_result($mo2f_malware_db_handler=null, $folderpaths=array(), $repo_folder_path=array(), $scan_config, $base){
254
- if(!empty($folderpaths)){
255
- if ( in_array( 'curl', get_loaded_extensions() ) ) {
256
- $scanresults=array();
257
- $nooffiles=0;
258
- $scan_malware_count = 0;
259
- $repo_issue_count = 0;
260
- $malicious_link_count = 0;
261
- $file_ext = $scan_config['file_extension'];
262
- $host = 'http://scanner.api.xecurify.com/malwareservice/rest/file/upload';
263
- $extensions = array();
264
- $hostname = 'scanner.api.xecurify.com';
265
- $malware_server_status = $this->mo_wpns_check_malware_server_status($hostname);
266
- if(empty($file_ext)){
267
- }else{
268
- if(strpos($file_ext,';') !=false){
269
- $extensions = explode(";", $file_ext);
270
- }else{
271
- array_push($extensions, $file_ext);
272
- }
273
- }
274
- $folder_skip_array= empty($scan_config['path_skip']) ? array() : explode(";", $scan_config['path_skip']);
275
- $skip_path_array= array();
276
- for($i=0; $i<count($folder_skip_array); $i++){
277
- $pathParts = explode('/', rtrim(str_replace('\\', '/', $folder_skip_array[$i])));
278
- $n= sizeof($pathParts)-1;
279
- $folder= $pathParts[$n];
280
- array_push($skip_path_array, $folder);
281
- }
282
- $enable_extns = $scan_config['type_scan'] == "Custom Scan" && !empty($file_ext) ? false : true;
283
- $iterat=0;
284
- foreach ($folderpaths as $value) {
285
- $onearr = array();
286
- if (is_dir($value)) {
287
-
288
- foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($value, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
289
- if ($item->isFile()) {
290
- $scanresult=array();
291
- $source_file_path = $value . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
292
- $arr = array();
293
- global $wpdb;
294
-
295
- if($iterat>100){
296
- $query="SELECT `option_value` from `".$wpdb->base_prefix."options` WHERE `option_name` = 'mo_stop_scan'";
297
- $stop_scan= $wpdb->get_results($query);
298
- $stop_scan_process=$stop_scan[0]->option_value;
299
-
300
- if($stop_scan_process=="1"){
301
- update_option('mo_wpns_malware_scan_in_progress','COMPLETE');
302
- update_option('mo_wpns_files_scanned',0);
303
- update_option('mo_wpns_infected_files',0);
304
- update_option("mo_stop_scan",'2');
305
- error_log("Scan Stopped");
306
- wp_send_json('aborted');
307
- exit;
308
- }else{
309
- $iterat=0;
310
- }
311
- }else{
312
- $iterat++;
313
- }
314
-
315
-
316
- if ($value == $base && ($scan_config['core_scan'] == 1)){
317
- $arr = explode(DIRECTORY_SEPARATOR, $iterator->getSubPathName());
318
- if(($arr[count($arr)-1]== 'index.php' && (count($arr)==1 || in_array($arr[count($arr)-2], array('wp-content', 'plugins', 'themes'))) && !in_array('miniorangescan', $arr)) || (!in_array('plugins', $arr) && !in_array('themes', $arr) && !in_array('miniorangescan', $arr))){
319
-
320
- }else{
321
- continue;
322
- }
323
- }elseif ($value == $base.DIRECTORY_SEPARATOR.'wp-content'.DIRECTORY_SEPARATOR.'plugins' && explode(DIRECTORY_SEPARATOR,$iterator->getSubPathName())[0]=='index.php'){
324
- continue;
325
- } elseif ($value == $base.DIRECTORY_SEPARATOR.'wp-content'.DIRECTORY_SEPARATOR.'themes' && explode(DIRECTORY_SEPARATOR,$iterator->getSubPathName())[0]=='index.php'){
326
- continue;
327
- }
328
- $flag_skip=0;
329
- if($scan_config['type_scan'] == "Custom Scan" && !empty($folder_skip_array)){
330
- for($q=0; $q<count($skip_path_array); $q++){
331
- if(strpos($source_file_path, $skip_path_array[$q])){
332
- $flag_skip=1;
333
- break;
334
- }
335
- }
336
- }
337
- if($flag_skip == 1){
338
- continue;
339
- }
340
- $ext = pathinfo($source_file_path, PATHINFO_EXTENSION);
341
- $ext= strtolower($ext);
342
- $extns = $enable_extns ? true : (in_array($ext, $extensions) ? true : false);
343
- if($extns){
344
- $nooffiles++;
345
- if($nooffiles - get_option('mo_wpns_files_scanned') > 50){
346
- update_option('mo_wpns_files_scanned', $nooffiles);
347
- }
348
- }
349
-
350
- $hash_of_file= md5_file($source_file_path);
351
- $res=$mo2f_malware_db_handler->check_hash($hash_of_file);
352
-
353
- $datascan = empty($res)?true:(isset($res[0]->scan_data) ? unserialize($res[0]->scan_data):false);
354
- $scanmalware = is_array($datascan)?$datascan['malware']==0:(!empty($datascan) ? $datascan: true);
355
- $repocheck = is_array($datascan)?$datascan['repo']==0:(!empty($datascan) ? $datascan: true);
356
- $extlink = is_array($datascan)?$datascan['ext_link']==0:(!empty($datascan) ? $datascan: true);
357
- $malware_status = $scanmalware? 0 : 1;
358
- $repo_status = $repocheck? 0 : 1;
359
- $link_status = $extlink? 0 : 1;
360
- if(!empty($res) && !$extlink && !$repocheck && !$scanmalware ){}
361
-
362
- else{
363
- $flag_update=0;
364
- $file_content=file_get_contents($source_file_path);
365
-
366
- $source_file_path_size = str_replace("\\", "/", $source_file_path);
367
- if(($scan_config['check_vulnerable'] == 1 || $scan_config['check_sql'] == 1) && !in_array($ext, array('zip','sitx','7z','rar','gz','tar.gz','jpg','jpeg','png','gif','svg','tiff','raw')) && filesize($source_file_path_size) < 1048576 && $malware_server_status && $extns && $scanmalware){
368
- $malware_status = 1;
369
- $cfile=curl_file_create($source_file_path, 'test/plain', time().basename($source_file_path));
370
- $postdata = array('file' => $cfile);
371
-
372
- $content_type = 'multipart/form-data';
373
- $issues = $this->mo_wpns_malware_scan_request($postdata, $host, $content_type);
374
- if ($issues) {
375
- $scan_malware_count++;
376
- $scanresult['scan'] = $issues;
377
- $flag_update=1;
378
- }
379
- }else{
380
-
381
- }
382
-
383
- if($scan_config['check_repo'] == 1 && $repocheck && $extns){
384
- if(!in_array('wp-config.php', $arr) && !in_array($ext, array('zip', 'log', 'htaccess','sitx','7z','rar','gz','tar.gz','jpg','jpeg','png','gif','svg','tiff','raw'))){
385
- if(!empty($arr) && ($arr[count($arr)-1]== 'index.php' && (count($arr)==1 || in_array($arr[count($arr)-2], array('wp-content', 'plugins', 'themes'))) && !in_array('uploads', $arr)) || !in_array('wp-content', $arr)){
386
- $repo_status = 1;
387
- if($value==$base){
388
- $repo_file_path=$repo_folder_path['base'];
389
- } elseif ($value == $base.DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins') {
390
- $repo_file_path=$repo_folder_path['plugins'];
391
- } elseif ($value == $base.DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'themes') {
392
- $repo_file_path=$repo_folder_path['themes'];
393
- }
394
- $issues = $this->check_with_repo_files($file_content, $repo_file_path.DIRECTORY_SEPARATOR.$iterator->getSubPathName());
395
- if(!empty($issues)){
396
- $repo_issue_count++;
397
- $scanresult['repo']=$issues;
398
- $flag_update=1;
399
- }
400
- }
401
- }
402
- }
403
- if($extns && $extlink){
404
- if(!in_array($ext, array('zip', 'log','sitx','7z','rar','gz','tar.gz','jpg','jpeg','png','gif','svg','tiff','raw'))){
405
- if($scan_config['ext_link_check'] == 1){
406
- $link_status = 1;
407
- $elresult= $this->check_external_link($file_content);
408
- if(!empty($elresult)){
409
- $malicious_link_count++;
410
- $flag_update=1;
411
- $scanresult['extl']=$elresult;
412
- }
413
- }
414
- }
415
- }
416
- if($flag_update == 0){
417
- $malware_status = ($scan_config['check_vulnerable'] || $scan_config['check_sql']) && $malware_status ? 1 : 0;
418
- $repo_status = $scan_config['check_repo'] && $repo_status ? 1 : 0;
419
- $link_status = $scan_config['ext_link_check'] && $link_status ? 1: 0;
420
- $scan_data = array('malware'=>$malware_status, 'repo'=>$repo_status, 'ext_link'=>$link_status);
421
- if(empty($res)){
422
- $mo2f_malware_db_handler->insert_hash($source_file_path, $hash_of_file, $scan_data);
423
- }else{
424
- $mo2f_malware_db_handler->update_hash($source_file_path, $hash_of_file, $scan_data);
425
- }
426
- }else{
427
- $infected_files=get_option('mo_wpns_infected_files');
428
- $infected_files++;
429
- if(!empty($res)){
430
- $mo2f_malware_db_handler->delete_hash($source_file_path);
431
- }
432
- update_option('mo_wpns_infected_files', $infected_files);
433
- }
434
- }
435
- if(!empty($scanresult))
436
- $scanresults[$source_file_path]=$scanresult;
437
- }
438
- }
439
- }
440
- }
441
- $malware_server_status = $this->mo_wpns_check_malware_server_status($hostname);
442
- if($malware_server_status){
443
- $host = 'http://scanner.api.xecurify.com/malwareservice/rest/file/data';
444
- $postdata = http_build_query(array('fileCount' => $nooffiles, 'maliciousCount' => $scan_malware_count));
445
- $content_type = 'application/x-www-form-urlencoded';
446
- $lastRequest = $this->mo_wpns_malware_scan_request($postdata, $host, $content_type);
447
- }
448
- update_option('mo_wpns_files_scanned', $nooffiles);
449
- return array('file_count'=> $nooffiles, 'malware_count'=>$scan_malware_count, 'repo_issues'=>$repo_issue_count, 'malicious_link'=>$malicious_link_count, 'scan'=>$scanresults);
450
- }else{
451
- return array('message'=>'CURL not installed on the server.');
452
- }
453
- } else {
454
- return array('message'=>'No folder selected for scanning.');
455
- }
456
- }
457
-
458
- function mo_wpns_check_malware_server_status($host){
459
- $fsock = @fsockopen($host, 80, $errno, $errstr, 5);
460
- if ( ! $fsock ){
461
- return FALSE;
462
- }else{
463
- fclose($fsock);
464
- return TRUE;
465
- }
466
- }
467
-
468
- function mo_wpns_malware_scan_request($postdata = array(), $host, $content_type){
469
- $response = null;
470
- $ch=curl_init($host);
471
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false );
472
- curl_setopt( $ch, CURLOPT_ENCODING, "" );
473
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
474
- curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
475
- curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
476
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: '.$content_type) );
477
- curl_setopt( $ch, CURLOPT_POST, true );
478
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata);
479
- $results=curl_exec($ch);
480
- curl_close($ch);
481
- if($results==false){
482
- error_log('Unable to scan file: '.$postdata['file']->name.' with result: '.$result);
483
- }else{
484
- $result = json_decode($results, true);
485
- if(isset($result['status'])){
486
- if ($result['status'] == 'success') {
487
- if($result['result']!='OK')
488
- $response = $result['result'];
489
- }else if($result['status']=='error'){
490
- error_log("Exception on server");
491
- }
492
- }else if(strpos($results, 'Summary')){
493
-
494
- }else{
495
- error_log("Any other issues on server");
496
- }
497
- }
498
- return $response;
499
- }
500
-
501
- function check_with_repo_files($file_content, $repo_file_path){
502
- $issues = array();
503
- if(file_exists($repo_file_path)){
504
- $content=@file_get_contents($repo_file_path);
505
- $hash_repo = md5($content);
506
- $hash_file = md5($file_content);
507
- if ($hash_file != $hash_repo) {
508
- $flag=1;
509
- $issues=array("exist" => "Mismatch in Files");
510
- }
511
- } else {
512
- $issues=array('exist'=>'Unwanted File Found');
513
- }
514
- return $issues;
515
- }
516
-
517
- function getlines($contents, $href){
518
- $newissues = 0;
519
- $lines = preg_split("/((\r?\n)|(\r\n?))/", $contents);
520
- for($i=0; $i<count($lines); $i++){
521
- $line = $lines[$i];
522
- if (strpos($line, $href) !== false) {
523
- $newissues = $i+1;
524
- }
525
- }
526
- return $newissues;
527
- }
528
-
529
- function check_external_link($contents){
530
- $issues = array();
531
- $hrefs = preg_match_all('/<a\s+(?:[^"\'>]+|"[^"]*"|\'[^\']*\')*href=("[^"]+"|\'[^\'‌​]+\'|[^<>\s]+)/i', $contents, $matches) ? $matches: array();
532
- if(isset($hrefs[1])){
533
- foreach($hrefs[1] as $href){
534
- if($this->isexternal($href)){
535
- $line=$this->getlines($contents, $href);
536
- $issues[] = array("i"=>"eld", "d"=>$href, "l"=>$line);
537
- }
538
- }
539
- }
540
- return $issues;
541
- }
542
-
543
- function isexternal($url) {
544
- $url = trim($url);
545
- $url = trim($url,';');
546
- $url = trim($url,'(');
547
- $url = trim($url,')');
548
- $url = trim($url,"'");
549
- $url = trim($url,'"');
550
- $components = parse_url($url);
551
- if(isset($components['host'])){
552
- if(preg_match('/(wordpress|google|miniorange|xecurify|facebook|themeisle|adobe|phppot)/i', $components['host']) === 1) {}
553
- else{
554
- if(!empty($components['host']) && strpos(strtolower($components['host']),strtolower($_SERVER['HTTP_HOST'])) === false){
555
- return true;
556
- }
557
- }
558
- }
559
- return false;
560
- }
561
- function check_vulnerable_code($contents){
562
- $issues = array();
563
- $tokens = token_get_all($contents);
564
-
565
- for($i=0; $i< sizeof($tokens); $i++) {
566
- $token = $tokens[$i];
567
- if (is_array($token)) {
568
- if(in_array(token_name($token[0]), array("T_EVAL"))){
569
- $issue = $this->getFunctionArgumentsOrEnclosedString("eval", $tokens, $i+1, "vlc", false);
570
- if(!empty($issue))
571
- $issues[] = $issue;
572
- } else if(in_array(token_name($token[0]), array("T_STRING"))){
573
- if(in_array($token[1],array("popen","fsockopen"))){
574
- $issue = $this->getFunctionArgumentsOrEnclosedString($token[1], $tokens, $i+1, "vlc", true);
575
- if(!empty($issue))
576
- $issues[] = $issue;
577
- } else if(in_array($token[1],array("assert"))){
578
- $issue = $this->getFunctionArgumentsOrEnclosedString($token[1], $tokens, $i+1, "vlc", false);
579
- if(!empty($issue))
580
- $issues[] = $issue;
581
- } else if(in_array($token[1],array("exec","shell_exec","passthru","system","proc_"))){
582
- $issue = $this->getFunctionArgumentsOrEnclosedString($token[1], $tokens, $i+1, "shc", false);
583
- if(!empty($issue))
584
- $issues[] = $issue;
585
- } else if(in_array($token[1],array("mysql_connect","mysqli_connect","mysqli_real_connect","PDO"))){
586
- $issue = $this->getFunctionArgumentsOrEnclosedString($token[1], $tokens, $i+1, "sqc", false);
587
- if(!empty($issue))
588
- $issues[] = $issue;
589
- }
590
- }
591
- }
592
- }
593
- return $issues;
594
- }
595
-
596
- function getFunctionArgumentsOrEnclosedString($issueFunction, $tokens, $start, $issuetype, $checkForExternalLink){
597
-
598
- $flag = 1;
599
- $argument = "";
600
- $line = "";
601
- $issue = array();
602
- for($j=$start; $j< sizeof($tokens); $j++) {
603
- $innertoken = $tokens[$j];
604
- if ($flag==1 && is_array($innertoken)) {
605
- $argument .= $innertoken[1];
606
- if(empty($line))
607
- $line = $innertoken[2];
608
- } else if($innertoken==";"){
609
- $argument .= ";";
610
- if($checkForExternalLink){
611
- if($this->isexternal($argument)){
612
- $issue = array("l"=>$line, "t"=> $issueFunction, "i"=>$issuetype, "d"=>$argument);
613
- }
614
- } else {
615
- $issue = array("l"=>$line, "t"=> $issueFunction, "i"=>$issuetype, "d"=>$argument);
616
- }
617
- break;
618
- } else if($flag==1){
619
- $argument .= $innertoken;
620
- }
621
- }
622
- return $issue;
623
- }
624
-
625
- function remove_dir($repo_path){
626
- $dir=$repo_path;
627
- $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
628
- $files = new RecursiveIteratorIterator($it,RecursiveIteratorIterator::CHILD_FIRST);
629
- foreach($files as $file) {
630
- if ($file->isDir()){
631
- rmdir($file->getRealPath());
632
- } else {
633
- unlink($file->getRealPath());
634
- }
635
- }
636
- rmdir($dir);
637
- }
638
-
639
- function count_total_files($folder_paths, $base, $scan_config){
640
-
641
- $file_count=0;
642
- $file_ext = $scan_config['file_extension'];
643
- $extensions = array();
644
- if(empty($file_ext)){
645
-
646
- }else{
647
- if(strpos($file_ext,';') !=false){
648
- $extensions = explode(";", $file_ext);
649
- }else{
650
- array_push($extensions, $file_ext);
651
- }
652
- }
653
- $enable_extns = $scan_config['type_scan'] == "Custom Scan" && !empty($file_ext) ? false : true;
654
- $folder_skip_array= empty($scan_config['path_skip']) ? array() : explode(";", $scan_config['path_skip']);
655
- $skip_path_array= array();
656
- for($i=0; $i<count($folder_skip_array); $i++){
657
- $pathParts = explode('/', $folder_skip_array[$i]);
658
- $n= sizeof($pathParts)-1;
659
- $folder= $pathParts[$n];
660
- array_push($skip_path_array, $folder);
661
- }
662
- foreach ($folder_paths as $value) {
663
- if (is_dir($value)) {
664
- foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($value, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
665
- if ($item->isFile()) {
666
- $source_file_path = $value . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
667
- if ($value == $base && ($scan_config['core_scan'] == 1)){
668
- $arr = explode(DIRECTORY_SEPARATOR, $iterator->getSubPathName());
669
- if(($arr[count($arr)-1]== 'index.php' && (count($arr)==1 || in_array($arr[count($arr)-2], array('wp-content', 'plugins', 'themes'))) && !in_array('miniorange', $arr)) || (!in_array('plugins', $arr) && !in_array('themes', $arr) && !in_array('miniorange', $arr))){
670
-
671
- }else{
672
- continue;
673
- }
674
- }elseif ($value == $base.DIRECTORY_SEPARATOR.'wp-content'.DIRECTORY_SEPARATOR.'plugins' && explode(DIRECTORY_SEPARATOR,$iterator->getSubPathName())[0]=='index.php'){
675
- continue;
676
- } elseif ($value == $base.DIRECTORY_SEPARATOR.'wp-content'.DIRECTORY_SEPARATOR.'themes' && explode(DIRECTORY_SEPARATOR,$iterator->getSubPathName())[0]=='index.php'){
677
- continue;
678
- }
679
- $flag_skip=0;
680
- if (!empty($folder_skip_array)) {
681
- for($q=0; $q<count($skip_path_array); $q++){
682
- if(strpos($source_file_path, $skip_path_array[$q])){
683
- $flag_skip=1;
684
- break;
685
- }
686
- }
687
- }
688
- if($flag_skip == 1){
689
- continue;
690
- }
691
- $ext = pathinfo($source_file_path, PATHINFO_EXTENSION);
692
- $extns = $enable_extns ? true : (in_array($ext, $extensions)? true : false);
693
- if($extns)
694
- $file_count++;
695
- }
696
- }
697
- }
698
- }
699
- update_option('mo_wpns_total_files', $file_count);
700
- }
701
- }
702
- new Mo_wpns_Scan_Handler;
703
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
handler/malware_scanner/malware_scanner_cron.php ADDED
@@ -0,0 +1,1020 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mo_wpns_Scan_Handler_Cron{
4
+ private $total_files_to_scan;
5
+ public $scanned_files = array();
6
+ function __construct(){
7
+
8
+ }
9
+
10
+ function mo2f_scan_all_files($scan_config, $start_time){
11
+ ini_set('memory_limit', '-1');
12
+ ini_set('max_execution_time', 0);
13
+ $time_limit= ini_get('max_execution_time');
14
+
15
+ $result = array();
16
+ $folderpaths = array();
17
+ $wp_repo_file = array();
18
+ $folderNames = "";
19
+ $repo_check_status_code=0;
20
+ update_option('mo_stop_scan','0');
21
+ $base = get_home_path();
22
+ $hostname = 'wordpress.org';
23
+ $wordpress_server_status = $this->mo_wpns_check_malware_server_status($hostname); //check only if writable
24
+ $uploads_dir = wp_upload_dir();
25
+ $uploads_path= $uploads_dir['basedir'];
26
+ if (!is_writable($uploads_path)) { //
27
+ $scan_config['check_repo'] = 0;
28
+ $repo_check_status_code = -97;
29
+ }
30
+ if (!$wordpress_server_status && $repo_check_status_code == 0) {
31
+ $scan_config['check_repo'] = 0;
32
+ $repo_check_status_code = -98;
33
+ }
34
+ if($scan_config['core_scan'] == 1){
35
+ $folderpaths['base'] = $base;
36
+ $folderNames .= "WP Files;";
37
+ }
38
+ if($scan_config['plugin_scan'] == 1){
39
+ $folderpaths['plugins'] = WP_PLUGIN_DIR;
40
+ $folderNames .= "Plugins;";
41
+ }
42
+ if($scan_config['theme_scan'] == 1){
43
+ $folderpaths['themes'] = get_theme_root();
44
+ $folderNames .= "Themes;";
45
+ }
46
+ if($scan_config['check_repo'] == 1){
47
+ $folderNames .= "WP Repo Files;";
48
+ }
49
+
50
+ $this->count_total_files($folderpaths, $base, $scan_config);
51
+ update_option('mo2f_repo_status', $repo_check_status_code);
52
+
53
+ $mo2f_malware_db_handler = new MoWpnsDB();
54
+ $reportid = $mo2f_malware_db_handler->create_scan_report($folderNames, $scan_config['type_scan'], $start_time, $repo_check_status_code);
55
+ update_option('mo2f_report_id', $reportid);
56
+
57
+ $scan_handler_obj = new mo2f_scanner_parts;
58
+
59
+ //wp remote get
60
+ $scanverification=$this->createKeyCurrentScan($scan_config['type_scan'],$reportid);
61
+
62
+ $response=$this->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 1);
63
+
64
+ wp_send_json('success');
65
+ }
66
+
67
+ function createKeyCurrentScan($scan_mode,$reportid){
68
+
69
+ $scanverification=md5($scan_mode. MO2f_Utility::random_str(24).$reportid);
70
+ update_option("mo2f_scanverification",$scanverification);
71
+ return $scanverification;
72
+ }
73
+
74
+ function mo2f_wp_remote_get($scan_mode, $reportid, $scanverification,$scan_stage_complete=1){
75
+ //set time out based on time left or 10 secs
76
+
77
+ $http_header_array =array("Content-Type"=>"application/json","charset"=>"UTF-8","Authorization"=>"Basic");
78
+ $url = get_site_url()."?scan_request=1"."&scanverification=".$scanverification."&reportid=".$reportid."&scan_stage_complete=".$scan_stage_complete."&scan_mode=".$scan_mode;//scanverification,report_id, scan_stage_complete and scan_mode
79
+
80
+ $args = array(
81
+ 'method' => 'GET',
82
+ 'body' => '',
83
+ 'timeout' => '5',
84
+ 'redirection' => '5',
85
+ 'httpversion' => '1.0',
86
+ 'blocking' => true,
87
+ 'headers' => $http_header_array
88
+ );
89
+ $response= wp_remote_get($url,$args);
90
+ //$response->errors['http_request_failed']['0'];
91
+
92
+ }
93
+
94
+ function mo2f_download_core_wp($repo_file_path, $scan_config, $reportid, $scanverification){
95
+ error_log("downloading core");
96
+ $repo_check_status = $scan_config['check_repo'];
97
+ $repo_check_status_code=get_option('mo2f_repo_status');
98
+ $wp_repo_file=get_option('mo2f_repo_path');
99
+
100
+ if ( ! function_exists( 'get_plugins' ) ) {
101
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
102
+ }
103
+ if ( ! function_exists( 'plugins_api' ) ) {
104
+ require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
105
+ }
106
+
107
+ if($scan_config['core_scan'] == 1 && $scan_config['check_repo'] && ($repo_check_status_code == 0)){
108
+ if(!is_dir($repo_file_path)){
109
+ mkdir($repo_file_path);
110
+ }
111
+ $download_status=time();
112
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
113
+ $decoded_scan_configuration->status_download_time=$download_status;
114
+ $encoded_scan_configuration=json_encode($decoded_scan_configuration);
115
+ update_option("mo_wpns_scan_status",$encoded_scan_configuration);
116
+ require(ABSPATH . 'wp-includes/version.php');
117
+ //wordpress name to be changed to be changed based on version
118
+ $zip_name="wp-".$wp_version;
119
+ $wp_repo_file['base']=$repo_file_path.DIRECTORY_SEPARATOR.$zip_name;
120
+ update_option('downloaded_wordpress_repo_name', $zip_name);
121
+ if(!is_dir($repo_file_path.DIRECTORY_SEPARATOR.$zip_name)){
122
+ $result = $this->download_repo($zip_name, $wp_version, $repo_file_path);
123
+ if($result === -99){
124
+ $scan_config['check_repo'] = 0;
125
+ $repo_check_status_code = -99;
126
+ }else if(!$result){
127
+ $scan_config['check_repo'] = 0;
128
+ $repo_check_status_code = -100;
129
+ }
130
+ }
131
+ }
132
+
133
+ if($repo_check_status != $scan_config['check_repo']){
134
+ update_option('mo2f_repo_status', $repo_check_status_code);
135
+ $scan_stage_complete=6;
136
+ }else{
137
+ update_option('mo2f_repo_path', $wp_repo_file);
138
+ $scan_stage_complete=6;
139
+ }
140
+
141
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
142
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, $scan_stage_complete);
143
+
144
+ }
145
+
146
+ function mo2f_download_plugins_wp($repo_file_path, $scan_config, $start_time, $time_limit, $reportid, $scanverification){
147
+ error_log("downloading plugins");
148
+ $repo_check_status = $scan_config['check_repo'];
149
+ $repo_check_status_code=get_option('mo2f_repo_status');
150
+ $flag=0;
151
+ $wp_repo_file=array();
152
+ if ( ! function_exists( 'get_plugins' ) ) {
153
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
154
+ }
155
+ if ( ! function_exists( 'plugins_api' ) ) {
156
+ require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
157
+ }
158
+
159
+ if($scan_config['plugin_scan'] == 1 && $scan_config['check_repo'] && ($repo_check_status_code == 0)){
160
+ if(!is_dir($repo_file_path)){
161
+ mkdir($repo_file_path);
162
+ }
163
+ $wp_plugin_repo_file=$repo_file_path.DIRECTORY_SEPARATOR."plugins";
164
+ if(!is_dir($wp_plugin_repo_file)){
165
+ mkdir($wp_plugin_repo_file);
166
+ }
167
+ $download_status=time();
168
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
169
+ $decoded_scan_configuration->status_download_time=$download_status;
170
+ $encoded_scan_configuration=json_encode($decoded_scan_configuration);
171
+ update_option("mo_wpns_scan_status",$encoded_scan_configuration);
172
+ $wp_repo_file['plugins']=$wp_plugin_repo_file;
173
+ $plugin_list=get_site_transient( 'update_plugins' );
174
+ $all_plugins=array();
175
+ foreach ($plugin_list as $key => $value) {
176
+ if($key=='response'||$key=='no_update'){
177
+ foreach ($value as $ke => $val) {
178
+ $all_plugins[$ke] = $val;
179
+ }
180
+ }
181
+ }
182
+ $result = $this->iterator_plugins_themes($all_plugins, $wp_plugin_repo_file, 'plugins', $start_time, $time_limit,$scan_config,$reportid, $scanverification);
183
+ if($result === -99){
184
+ $scan_config['check_repo'] = 0;
185
+ $repo_check_status_code = -99;
186
+ }else if(!$result){
187
+ $scan_config['check_repo'] = 0;
188
+ $repo_check_status_code = -100;
189
+ }else if($result === 'incomplete'){
190
+ $flag=1;
191
+ }
192
+ }
193
+ if($repo_check_status != $scan_config['check_repo']){
194
+ update_option('mo2f_repo_status', $repo_check_status_code);
195
+ $scan_stage_complete=6;
196
+ }else{
197
+ if($flag == 1){
198
+ $scan_stage_complete=3;
199
+ }else{
200
+ update_option('mo2f_repo_path', $wp_repo_file);
201
+ update_option('mo2f_download_done',0);
202
+ $scan_stage_complete=4;
203
+ }
204
+ }
205
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
206
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, $scan_stage_complete);
207
+
208
+ }
209
+
210
+ function mo2f_download_themes_wp($repo_file_path, $scan_config, $start_time, $time_limit,$reportid, $scanverification){
211
+ error_log("downloading themes");
212
+ $repo_check_status = $scan_config['check_repo'];
213
+ $repo_check_status_code=get_option('mo2f_repo_status');
214
+ $flag=0;
215
+ $wp_repo_file=get_option('mo2f_repo_path');
216
+ if ( ! function_exists( 'get_plugins' ) ) {
217
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
218
+ }
219
+ if ( ! function_exists( 'plugins_api' ) ) {
220
+ require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
221
+ }
222
+
223
+ if($scan_config['theme_scan'] == 1 && $scan_config['check_repo'] && ($repo_check_status_code == 0)){
224
+ if(!is_dir($repo_file_path)){
225
+ mkdir($repo_file_path);
226
+ }
227
+ $wp_theme_repo_file=$repo_file_path.DIRECTORY_SEPARATOR."themes";
228
+ if(!is_dir($wp_theme_repo_file)){
229
+ mkdir($wp_theme_repo_file);
230
+ }
231
+ $download_status=time();
232
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
233
+ $decoded_scan_configuration->status_download_time=$download_status;
234
+ $encoded_scan_configuration=json_encode($decoded_scan_configuration);
235
+ update_option("mo_wpns_scan_status",$encoded_scan_configuration);
236
+ $wp_repo_file['themes']=$wp_theme_repo_file;
237
+ $all_themes=get_site_transient( 'update_themes' )->checked;
238
+ $result = $this->iterator_plugins_themes($all_themes, $wp_theme_repo_file, 'themes', $start_time, $time_limit,$scan_config,$reportid,$scanverification);
239
+ if($result === -99){
240
+ $scan_config['check_repo'] = 0;
241
+ $repo_check_status_code = -99;
242
+ }else if(!$result){
243
+ $scan_config['check_repo'] = 0;
244
+ $repo_check_status_code = -100;
245
+ }else if($result === 'incomplete'){
246
+ $flag=1;
247
+ }
248
+ }
249
+ if($repo_check_status != $scan_config['check_repo']){
250
+ update_option('mo2f_repo_status', $repo_check_status_code);
251
+ $scan_stage_complete=6;
252
+ }else{
253
+ if($flag == 1){
254
+ $scan_stage_complete=4;
255
+
256
+ }else{
257
+ update_option('mo2f_repo_path', $wp_repo_file);
258
+ update_option('mo2f_download_done',0);
259
+ $scan_stage_complete=5;
260
+ }
261
+ }
262
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
263
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, $scan_stage_complete);
264
+ }
265
+
266
+ function iterator_plugins_themes($themes_or_plugins, $path, $type='', $start_time, $time_limit, $scan_config,$reportid, $scanverification){
267
+ $downloaded_already= get_option('mo2f_download_done');
268
+ if($downloaded_already == false){
269
+ $downloaded_already=0;
270
+ }
271
+ $i=0;
272
+ foreach($themes_or_plugins as $key => $data){
273
+ $i++;
274
+ $exec_status= $this->check_exec_limit($start_time, $time_limit);
275
+ if(! $exec_status){//wp_remote_get
276
+ update_option('mo2f_download_done', $i-1);
277
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
278
+ if($type=='plugins'){
279
+ $scan_stage_complete=3;
280
+ }else if($type=='themes'){
281
+ $scan_stage_complete=4;
282
+ }
283
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, $scan_stage_complete);
284
+ return 'incomplete';
285
+ }
286
+ if($i <= $downloaded_already){
287
+ continue;
288
+ }
289
+ if($type=='plugins'){
290
+ if(! file_exists(WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.$data->plugin)){
291
+ continue;
292
+ }
293
+ $plugin_slug=$data->slug;
294
+ $plugin_directory_location=dirname(dirname(dirname($path))).DIRECTORY_SEPARATOR.'plugins';
295
+ $plugin_data=get_plugin_data($plugin_directory_location.DIRECTORY_SEPARATOR.$data->plugin);
296
+ $plugin_version=$plugin_data['Version'];
297
+ if(!is_dir($path.DIRECTORY_SEPARATOR.$plugin_slug)){
298
+ $result= $this->download_repo($plugin_slug, $plugin_version, $path, $type);
299
+ if($result === -99){
300
+ return -99;
301
+ }else if(!$result){
302
+ return false;
303
+ }
304
+ }
305
+ } else if($type=='themes'){
306
+ $installed_themes = wp_get_themes();
307
+ $flag_theme=0;
308
+ foreach ($installed_themes as $theme_name => $attributes) {
309
+ if($key == $theme_name){
310
+ $flag_theme=1;
311
+ break;
312
+ }
313
+ }
314
+ if(!is_dir($path.DIRECTORY_SEPARATOR.$key) && $flag_theme == 1){
315
+ $result= $this->download_repo($key, $data, $path, $type);
316
+ if($result === -99){
317
+ return -99;
318
+ }else if(!$result){
319
+ return false;
320
+ }
321
+ }
322
+ }
323
+ }
324
+ return true;
325
+ }
326
+
327
+ function download_repo($zip_name, $version, $path, $type=''){
328
+ if ($type=='plugins') {
329
+ $download_link="https://downloads.wordpress.org/plugin/".$zip_name.".".$version.".zip";
330
+ $plugin_name=$zip_name.'.'.$version;
331
+
332
+ $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
333
+ if( $download_result){
334
+ $result = $this->unzip_downloaded_repo($zip_name, $path);
335
+ return $result;
336
+ }else {
337
+ $download_link="https://downloads.wordpress.org/plugin/".$zip_name.".zip";
338
+ $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
339
+ if( $download_result){
340
+ $result = $this->unzip_downloaded_repo($zip_name, $path);
341
+ return $result;
342
+ }else {
343
+ error_log("Unable to download Plugin: ".$plugin_name);
344
+ return -99;
345
+ }
346
+ return -99;
347
+ }
348
+ } else if($type=='themes'){
349
+ $theme_name=$zip_name.'.'.$version;
350
+ $download_link="https://downloads.wordpress.org/theme/".$theme_name.".zip";
351
+ $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
352
+ if( $download_result){
353
+ $result = $this->unzip_downloaded_repo($zip_name, $path);
354
+ return $result;
355
+ }else {
356
+ $download_link="https://downloads.wordpress.org/theme/".$zip_name.".zip";
357
+ $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.".zip", file_get_contents($download_link));
358
+ if( $download_result){
359
+ $result = $this->unzip_downloaded_repo($zip_name, $path);
360
+ return $result;
361
+ }else {
362
+ error_log("Unable to download Theme: ".$theme_name);
363
+ return -99;
364
+ }
365
+ return -99;
366
+ }
367
+ } else {
368
+ $download_link="https://wordpress.org/wordpress-".$version.".zip";
369
+ $download_result=@file_put_contents($path.DIRECTORY_SEPARATOR.$zip_name.'.zip', file_get_contents($download_link));
370
+ if($download_result){
371
+ $result=$this->unzip_downloaded_repo($zip_name, $path);
372
+ return $result;
373
+ } else {
374
+ error_log("Unable to download wordpress-".$version);
375
+ return -99;
376
+ }
377
+ }
378
+ return false;
379
+ }
380
+
381
+ function unzip_downloaded_repo($name, $path){
382
+ $zip = new ZipArchive;
383
+ $folder_path=$path.DIRECTORY_SEPARATOR.$name.".zip";
384
+ $res = $zip->open($folder_path);
385
+ if ($res === TRUE) {
386
+ // extract it to the path we determined above
387
+ $result = $zip->extractTo($path);
388
+ $zip->close();
389
+ if ($name == get_option('downloaded_wordpress_repo_name')) {
390
+ rename($path.DIRECTORY_SEPARATOR."wordpress", $path.DIRECTORY_SEPARATOR.$name);
391
+ }
392
+ unlink($folder_path);
393
+ return true;
394
+ } else {
395
+ return false;
396
+ }
397
+ }
398
+
399
+ function mo_wpns_check_malware_server_status($host){
400
+ $fsock = @fsockopen($host, 80, $errno, $errstr, 5);
401
+ if ( ! $fsock ){
402
+ return FALSE;
403
+ }else{
404
+ fclose($fsock);
405
+ return TRUE;
406
+ }
407
+ }
408
+
409
+ function mo_wpns_malware_scan_request($postdata = array(), $host, $content_type){
410
+ $response = null;
411
+ $ch=curl_init($host);
412
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false );
413
+ curl_setopt( $ch, CURLOPT_ENCODING, "" );
414
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
415
+ curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
416
+ curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
417
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: '.$content_type) );
418
+ curl_setopt( $ch, CURLOPT_POST, true );
419
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata);
420
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
421
+ $results=curl_exec($ch);
422
+ curl_close($ch);
423
+ if($results==false){
424
+ // error_log('Unable to scan file: '.$postdata['file']->name.' with result: '.$result);
425
+ }else{
426
+ $result = json_decode($results, true);
427
+ if(isset($result['status'])){
428
+ if ($result['status'] == 'success') {
429
+ if($result['result']!='OK')
430
+ $response = $result['result'];
431
+ }else if($result['status']=='error'){
432
+ error_log("Exception on server");
433
+ }
434
+ }else if(strpos($results, 'Summary')){
435
+
436
+ }else{
437
+ error_log("Any other issues on server");
438
+ }
439
+ }
440
+ return $response;
441
+ }
442
+
443
+ function check_with_repo_files($file_content, $repo_file_path){
444
+ $issues = array();
445
+ if(file_exists($repo_file_path)){
446
+ $content=@file_get_contents($repo_file_path);
447
+ $hash_repo = md5($content);
448
+ $hash_file = md5($file_content);
449
+ if ($hash_file != $hash_repo) {
450
+ $flag=1;
451
+ $issues=array("exist" => "Mismatch in Files");
452
+ }
453
+ } else {
454
+ $issues=array('exist'=>'Unwanted File Found');
455
+ }
456
+ return $issues;
457
+ }
458
+
459
+ function getlines($contents, $href){
460
+ $newissues = 0;
461
+ $lines = preg_split("/((\r?\n)|(\r\n?))/", $contents);
462
+ for($i=0; $i<count($lines); $i++){
463
+ $line = $lines[$i];
464
+ if (strpos($line, $href) !== false) {
465
+ $newissues = $i+1;
466
+ }
467
+ }
468
+ return $newissues;
469
+ }
470
+
471
+ function check_external_link($contents){
472
+ $issues = array();
473
+ $hrefs = preg_match_all('/<a\s+(?:[^"\'>]+|"[^"]*"|\'[^\']*\')*href=("[^"]+"|\'[^\'‌​]+\'|[^<>\s]+)/i', $contents, $matches) ? $matches: array();
474
+ if(isset($hrefs[1])){
475
+ foreach($hrefs[1] as $href){
476
+ if($this->isexternal($href)){
477
+ $line=$this->getlines($contents, $href);
478
+ $issues[] = array("i"=>"eld", "d"=>$href, "l"=>$line);
479
+ }
480
+ }
481
+ }
482
+ return $issues;
483
+ }
484
+
485
+ function isexternal($url) {
486
+ $url = trim($url);
487
+ $url = trim($url,';');
488
+ $url = trim($url,'(');
489
+ $url = trim($url,')');
490
+ $url = trim($url,"'");
491
+ $url = trim($url,'"');
492
+ $components = parse_url($url);
493
+ if(isset($components['host'])){
494
+ if(preg_match('/(wordpress|google|miniorange|xecurify|facebook|themeisle|adobe|phppot|php.net)/i', $components['host']) === 1) {}
495
+ else{
496
+ if(!empty($components['host']) && strpos(strtolower($components['host']),strtolower($_SERVER['HTTP_HOST'])) === false){
497
+ return true;
498
+ }
499
+ }
500
+ }
501
+ return false;
502
+ }
503
+
504
+ function getFunctionArgumentsOrEnclosedString($issueFunction, $tokens, $start, $issuetype, $checkForExternalLink){
505
+
506
+ $flag = 1;
507
+ $argument = "";
508
+ $line = "";
509
+ $issue = array();
510
+ for($j=$start; $j< sizeof($tokens); $j++) {
511
+ $innertoken = $tokens[$j];
512
+ if ($flag==1 && is_array($innertoken)) {
513
+ $argument .= $innertoken[1];
514
+ if(empty($line))
515
+ $line = $innertoken[2];
516
+ } else if($innertoken==";"){
517
+ $argument .= ";";
518
+ if($checkForExternalLink){
519
+ if($this->isexternal($argument)){
520
+ $issue = array("l"=>$line, "t"=> $issueFunction, "i"=>$issuetype, "d"=>$argument);
521
+ }
522
+ } else {
523
+ $issue = array("l"=>$line, "t"=> $issueFunction, "i"=>$issuetype, "d"=>$argument);
524
+ }
525
+ break;
526
+ } else if($flag==1){
527
+ $argument .= $innertoken;
528
+ }
529
+ }
530
+ return $issue;
531
+ }
532
+
533
+ function remove_dir($repo_path){
534
+ $dir=$repo_path;
535
+ $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
536
+ $files = new RecursiveIteratorIterator($it,RecursiveIteratorIterator::CHILD_FIRST);
537
+ foreach($files as $file) {
538
+ if ($file->isDir()){
539
+ rmdir($file->getPathname());
540
+ } else {
541
+ unlink($file->getPathname());
542
+ }
543
+ }
544
+ rmdir($dir);
545
+ }
546
+
547
+ function count_total_files($folder_paths, $base, $scan_config){
548
+ if(isset($folder_paths['base'])){
549
+ $temp= $folder_paths['base'];
550
+ $folder_paths = array('base' => $temp);
551
+ }
552
+ $mo2f_malware_db_handler = new MoWpnsDB();
553
+ $file_count=0;
554
+ $nooffiles=0;
555
+ $file_path_array=array();
556
+ $skip_path_array= array();
557
+ $folder_skip_array=array();
558
+ $extensions = array();
559
+ if($scan_config['type_scan'] == "Custom Scan"){
560
+ $file_ext = $scan_config['file_extension'];
561
+ if(empty($file_ext)){
562
+
563
+ }else{
564
+ if(strpos($file_ext,';') !=false){
565
+ $extensions = explode(";", $file_ext);
566
+ }else{
567
+ array_push($extensions, $file_ext);
568
+ }
569
+ }
570
+ $folder_skip_array= empty($scan_config['path_skip']) ? array() : explode(";", $scan_config['path_skip']);
571
+
572
+ for($i=0; $i<count($folder_skip_array); $i++){
573
+ $pathParts = explode('/', $folder_skip_array[$i]);
574
+ $n= sizeof($pathParts)-1;
575
+ $folder= $pathParts[$n];
576
+ array_push($skip_path_array, $folder);
577
+ }
578
+ }
579
+ foreach ($folder_paths as $value) {
580
+ $file_list= list_files($value,100);
581
+ foreach ($file_list as $key => $value1) {
582
+
583
+ $source_file_path= $value1;
584
+
585
+ if(is_dir($source_file_path)){
586
+ continue;
587
+ }
588
+ $size_of_file=filesize($source_file_path);
589
+
590
+ $arr= explode(DIRECTORY_SEPARATOR, $source_file_path);
591
+ $theme_path=get_theme_root();
592
+ if ($value == $base && ($scan_config['core_scan'] == 1)){
593
+ // $arr = explode(DIRECTORY_SEPARATOR, $iterator->getSubPathName());
594
+ if(($arr[count($arr)-1]== 'index.php' && (count($arr)==1 || in_array($arr[count($arr)-2], array('wp-content', 'plugins', 'themes'))) && !in_array('miniorangescan', $arr)) || (!in_array('plugins', $arr) && !in_array('themes', $arr) && !in_array('miniorangescan', $arr))){
595
+
596
+ }else{
597
+ continue;
598
+ }
599
+ }elseif ($value == WP_PLUGIN_DIR && $arr[count($arr)-1]=='index.php'){
600
+ continue;
601
+ }elseif ($value == $theme_path && $arr[count($arr)-1]=='index.php'){
602
+ continue;
603
+ }
604
+ $ext = pathinfo($source_file_path, PATHINFO_EXTENSION);
605
+ if($scan_config['type_scan'] == "Custom Scan"){
606
+ $flag_skip=0;
607
+ if (!empty($folder_skip_array)) {
608
+ for($q=0; $q<count($skip_path_array); $q++){
609
+ if(strpos($source_file_path, $skip_path_array[$q])){
610
+ $flag_skip=1;
611
+ break;
612
+ }
613
+ }
614
+ }
615
+ if($flag_skip == 1){
616
+ continue;
617
+ }
618
+
619
+ if(!empty($extensions)){
620
+ if(!in_array($ext, $extensions)){
621
+ continue;
622
+ }
623
+ }
624
+ }
625
+ if(in_array($ext, array('zip', 'log', 'htaccess','sitx','7z','rar','gz','tar.gz','jpg','jpeg','png','gif','svg','tiff','raw'))){
626
+ continue;
627
+ }
628
+ $file_count++;
629
+ $nooffiles=$nooffiles+1;
630
+ $file_path_array[$nooffiles]= $source_file_path;
631
+ if($nooffiles>0 && $nooffiles%100==0){
632
+ $mo2f_malware_db_handler->insert_files_in_parts($file_path_array);
633
+ $nooffiles=0;
634
+ $file_path_array=array();
635
+ }
636
+ }
637
+ $mo2f_malware_db_handler->insert_files_in_parts($file_path_array);
638
+ $nooffiles=0;
639
+ $file_path_array=array();
640
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
641
+ $decoded_scan_status->total_files=$file_count;
642
+ $encoded_scan_status=json_encode($decoded_scan_status);
643
+ update_option("mo_wpns_scan_status",$encoded_scan_status);
644
+ }
645
+ }
646
+
647
+ function get_scan_result_parts($mo2f_malware_db_handler=null, $folderpaths=array(), $scan_config, $start_time, $time_limit){
648
+ if(!empty($folderpaths)){
649
+ if ( in_array( 'curl', get_loaded_extensions() ) ) {
650
+ $scanresults=array();
651
+ $nooffiles=0;
652
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
653
+ $previous_scanned = $decoded_scan_status->files_scanned;
654
+
655
+ $scan_malware_count = 0;
656
+ $repo_issue_count = 0;
657
+ $malicious_link_count = 0;
658
+ $file_ext = $scan_config['file_extension'];
659
+ $host = 'http://scanner.api.xecurify.com/malwareservice/rest/file/upload';//constants
660
+ $extensions = array();
661
+ $hostname = 'scanner.api.xecurify.com';// put in constants file
662
+ $malware_server_status = $this->mo_wpns_check_malware_server_status($hostname);
663
+ if(empty($file_ext)){
664
+ }else{
665
+ if(strpos($file_ext,';') !=false){
666
+ $extensions = explode(";", $file_ext);
667
+ }else{
668
+ array_push($extensions, $file_ext);
669
+ }
670
+ }
671
+ $folder_skip_array= empty($scan_config['path_skip']) ? array() : explode(";", $scan_config['path_skip']);
672
+ $skip_path_array= array();
673
+ for($i=0; $i<count($folder_skip_array); $i++){
674
+ $pathParts = explode('/', rtrim(str_replace('\\', '/', $folder_skip_array[$i])));
675
+ $n= sizeof($pathParts)-1;
676
+ $folder= $pathParts[$n];
677
+ array_push($skip_path_array, $folder);
678
+ }
679
+ $enable_extns = $scan_config['type_scan'] == "Custom Scan" && !empty($file_ext) ? false : true;
680
+
681
+ foreach ($folderpaths as $value) {
682
+ $status=$this->check_exec_limit($start_time, $time_limit);//check limit for each file.
683
+ if(!$status){//wp_remote_get
684
+ $mo_wpns_files_scanned=(0.7*$nooffiles)+$previous_scanned;
685
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
686
+ $encoded_scan_status=json_encode($decoded_scan_status);
687
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
688
+ return array('file_count'=> $nooffiles, 'malware_count'=>$scan_malware_count, 'repo_issues'=>$repo_issue_count, 'malicious_link'=>$malicious_link_count, 'scan'=>$scanresults);
689
+ //time limit close by. Returned status of current scan. Update DB and make next request.
690
+ }
691
+
692
+ $scanresult=array();
693
+ $source_file_path=$value->path;
694
+ if(!file_exists($source_file_path)){
695
+ $nooffiles++;
696
+ continue;
697
+ }
698
+ $ext = pathinfo($source_file_path, PATHINFO_EXTENSION);
699
+ $ext= strtolower($ext);
700
+ $extns = $enable_extns ? true : (in_array($ext, $extensions) ? true : false);
701
+ if($extns){
702
+ $nooffiles++;
703
+ if((0.7*$nooffiles) > 50){
704
+ $mo_wpns_files_scanned=((0.7*$nooffiles)+$previous_scanned);
705
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
706
+ $encoded_scan_status=json_encode($decoded_scan_status);
707
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
708
+
709
+ }
710
+ }
711
+
712
+ $hash_of_file= md5_file($source_file_path);
713
+ $res=$mo2f_malware_db_handler->check_hash($hash_of_file);
714
+
715
+ $datascan = empty($res)?true:(isset($res[0]->scan_data) ? unserialize($res[0]->scan_data):false);
716
+ $scanmalware = is_array($datascan)?$datascan['malware']==0:(!empty($datascan) ? $datascan: true);
717
+ $malware_status = $scanmalware? 0 : 1;
718
+
719
+ if(!empty($res) && !$scanmalware ){}
720
+
721
+ else{
722
+ $flag_update=0;
723
+ $file_content=file_get_contents($source_file_path);
724
+
725
+ $source_file_path_size = str_replace("\\", "/", $source_file_path);
726
+ if(($scan_config['check_vulnerable'] == 1 || $scan_config['check_sql'] == 1) && !in_array($ext, array('zip','sitx','7z','rar','gz','tar.gz','jpg','jpeg','png','gif','svg','tiff','raw')) && filesize($source_file_path_size) < 1048576 && $malware_server_status && $extns && $scanmalware){
727
+ $malware_status = 1;
728
+ $cfile=curl_file_create($source_file_path, 'test/plain', time().basename($source_file_path));
729
+ $postdata = array('file' => $cfile);
730
+
731
+ $content_type = 'multipart/form-data';
732
+ $issues = $this->mo_wpns_malware_scan_request($postdata, $host, $content_type);
733
+ //$issues='';
734
+ if ($issues) {
735
+ $scan_malware_count++;
736
+ $scanresult['scan'] = $issues;
737
+ $flag_update=1;
738
+ }
739
+ }else{
740
+
741
+ }
742
+
743
+ if($flag_update == 0){
744
+ $malware_status = ($scan_config['check_vulnerable'] || $scan_config['check_sql']) && $malware_status ? 1 : 0;
745
+ $repo_status=0;
746
+ $link_status=0;
747
+ $scan_data = array('malware'=>$malware_status, 'repo'=>$repo_status, 'ext_link'=>$link_status);
748
+ if(empty($res)){
749
+ $mo2f_malware_db_handler->insert_hash($source_file_path, $hash_of_file, $scan_data);
750
+ }else{
751
+ $mo2f_malware_db_handler->update_hash($source_file_path, $hash_of_file, $scan_data);
752
+ }
753
+ }else{
754
+ $infected_files=get_option('mo_wpns_infected_files');
755
+ $infected_files++;
756
+ update_option('mo_wpns_infected_files', $infected_files);
757
+ }
758
+ }
759
+ if(!empty($scanresult))
760
+ $scanresults[$source_file_path]=$scanresult;
761
+
762
+ }
763
+
764
+ $mo_wpns_files_scanned=((0.7*$nooffiles)+$previous_scanned);
765
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
766
+ $encoded_scan_status=json_encode($decoded_scan_status);
767
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
768
+
769
+ return array('file_count'=> $nooffiles, 'malware_count'=>$scan_malware_count, 'repo_issues'=>$repo_issue_count, 'malicious_link'=>$malicious_link_count, 'scan'=>$scanresults);
770
+ }else{
771
+ return array('message'=>'CURL not installed on the server.');
772
+ }
773
+ } else {
774
+ return array('message'=>'No folder selected for scanning.');
775
+ }
776
+ }
777
+
778
+ function scan_for_ext_link($files_to_scan, $scan_config, $start_time, $time_limit, $reportid){
779
+ $mo2f_malware_db_handler = new MoWpnsDB();
780
+ $scanresults=array();
781
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
782
+ $previous_scanned = $decoded_scan_status->files_scanned;
783
+
784
+ $nooffiles=0;
785
+ $malicious_link_count=0;
786
+ // $repo_issue_count=0;
787
+ foreach ($files_to_scan as $value) {
788
+ $status=$this->check_exec_limit($start_time, $time_limit);//check limit for each file.
789
+ if(!$status){//wp_remote_get
790
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
791
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
792
+ $encoded_scan_status=json_encode($decoded_scan_status);
793
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
794
+ return array('file_count'=> $nooffiles, 'malicious_link'=>$malicious_link_count, 'scan'=>$scanresults);
795
+ //time limit close by. Returned status of current scan. Update DB and make next request.
796
+ }
797
+ $flag_update=0;
798
+ $nooffiles++;
799
+ if((0.15*$nooffiles)> 50){// remove get_option
800
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
801
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
802
+ $encoded_scan_status=json_encode($decoded_scan_status);
803
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
804
+ }
805
+ $source_file_path=$value->path;
806
+ if(!file_exists($source_file_path) || filesize($source_file_path) > 5242880){//5MB size limit
807
+ continue;
808
+ }
809
+ $hash_of_file= md5_file($source_file_path);
810
+ $res=$mo2f_malware_db_handler->check_hash($hash_of_file);
811
+ $datascan = empty($res)?true:(isset($res[0]->scan_data) ? unserialize($res[0]->scan_data):false);
812
+ //$repocheck = is_array($datascan)?$datascan['repo']==0:(!empty($datascan) ? $datascan: true);
813
+ $extlink = is_array($datascan)?$datascan['ext_link']==0:(!empty($datascan) ? $datascan: true);
814
+ //$repo_status = $repocheck? 0 : 1;
815
+ $link_status = $extlink? 0 : 1;
816
+ if(is_array($datascan)){
817
+ $malware_status= $datascan['malware'];
818
+ }else{
819
+ $malware_status=0;
820
+ }
821
+
822
+ $scanresult=array();
823
+
824
+ $file_content=file_get_contents($source_file_path);
825
+ if($scan_config['ext_link_check'] == 1 && $extlink){
826
+ $link_status=1;
827
+ $elresult= $this->check_external_link($file_content);
828
+ if(!empty($elresult)){
829
+ $malicious_link_count++;
830
+ $flag_update=1;
831
+ $scanresult['extl']=$elresult;
832
+ }
833
+ }
834
+
835
+ //repo check code to be added
836
+ if($flag_update == 0){
837
+ //$repo_status = $scan_config['check_repo'] && $repo_status ? 1 : 0;
838
+ $link_status = $scan_config['ext_link_check'] && $link_status ? 1: 0;
839
+ $repo_status=0;
840
+
841
+ $scan_data = array('malware'=>$malware_status, 'repo'=>$repo_status, 'ext_link'=>$link_status);
842
+ $infected_array=$mo2f_malware_db_handler->get_detail_report_with_id($reportid);
843
+ $file_already_infected=false;
844
+ foreach ($infected_array as $key => $value) {
845
+ if($value->filename == $source_file_path){
846
+ $file_already_infected=true;
847
+ break;
848
+ }
849
+ }
850
+
851
+ if($file_already_infected){
852
+
853
+ }elseif(empty($res)){
854
+ $mo2f_malware_db_handler->insert_hash($source_file_path, $hash_of_file, $scan_data);
855
+ }else{
856
+ $mo2f_malware_db_handler->update_hash($source_file_path, $hash_of_file, $scan_data);
857
+ }
858
+ }else{
859
+ $infected_files=get_option('mo_wpns_warning_files');
860
+ $infected_files++;
861
+ update_option('mo_wpns_warning_files', $infected_files);
862
+ }
863
+ if(!empty($scanresult))
864
+ $scanresults[$source_file_path]=$scanresult;
865
+ }
866
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
867
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
868
+ $encoded_scan_status=json_encode($decoded_scan_status);
869
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
870
+ return array('file_count'=> $nooffiles, 'malicious_link'=>$malicious_link_count, 'scan'=>$scanresults);
871
+ }
872
+
873
+ function scan_with_repo($files_to_scan, $scan_config, $start_time, $time_limit, $reportid, $repo_file_path){
874
+ $mo2f_malware_db_handler = new MoWpnsDB();
875
+ $scanresults=array();
876
+ $default_themes = array('twentynineteen', 'twentyseventeen', 'twentysixteen', 'twentytwenty');
877
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
878
+ $previous_scanned = $decoded_scan_status->files_scanned;
879
+ $nooffiles=0;
880
+ $repo_issue_count=0;
881
+ foreach ($files_to_scan as $value) {
882
+ $status=$this->check_exec_limit($start_time, $time_limit);//check limit for each file.
883
+ if(!$status){//wp_remote_get
884
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
885
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
886
+ $encoded_scan_status=json_encode($decoded_scan_status);
887
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
888
+ return array('file_count'=> $nooffiles, 'repo_issues'=>$repo_issue_count, 'scan'=>$scanresults);
889
+ //time limit close by. Returned status of current scan. Update DB and make next request.
890
+ }
891
+ $flag_update=0;
892
+ $nooffiles++;
893
+ if((0.15*$nooffiles) > 50){
894
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
895
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
896
+ $encoded_scan_status=json_encode($decoded_scan_status);
897
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
898
+ }
899
+ $source_file_path=$value->path;
900
+ if(!file_exists($source_file_path) || filesize($source_file_path) > 5242880){//5MB size limit
901
+ continue;
902
+ }
903
+ $hash_of_file= md5_file($source_file_path);
904
+ $res=$mo2f_malware_db_handler->check_hash($hash_of_file);
905
+ $datascan = empty($res)?true:(isset($res[0]->scan_data) ? unserialize($res[0]->scan_data):false);
906
+ $repocheck = is_array($datascan)?$datascan['repo']==0:(!empty($datascan) ? $datascan: true);
907
+ $repo_status = $repocheck? 0 : 1;
908
+ if(is_array($datascan)){
909
+ $malware_status = $datascan['malware'];
910
+ $link_status = $datascan['ext_link'];
911
+ }else{
912
+ $malware_status=0;
913
+ $link_status=0;
914
+ }
915
+ $scanresult=array();
916
+
917
+ if($repocheck){
918
+ $file_content=file_get_contents($source_file_path);
919
+ $file_path_slash_correction = str_replace('/', '\\', $source_file_path);
920
+ $source_file_path_array=explode("\\", $file_path_slash_correction);
921
+ $theme_flag=0;
922
+ foreach ($default_themes as $theme_key) {
923
+ if(in_array($theme_key, $source_file_path_array)){
924
+ $theme_flag=1;
925
+ break;
926
+ }
927
+ }
928
+ if($theme_flag){
929
+ continue;
930
+ }
931
+ if(in_array('wp-content', $source_file_path_array) && !in_array('plugins', $source_file_path_array) && !in_array('themes', $source_file_path_array)){
932
+ continue;
933
+ }
934
+ $repo_file_to_check=$repo_file_path;
935
+ $path_flag=0;
936
+ $path_key= array('wp-admin', 'wp-includes', 'plugins', 'themes');
937
+ foreach ($path_key as $paths_key) {
938
+ if(in_array($paths_key, $source_file_path_array)){
939
+ $index= array_search($paths_key, $source_file_path_array);
940
+ if($paths_key == 'wp-admin' || $paths_key == 'wp-includes'){
941
+ $wordpress_name = get_option('downloaded_wordpress_repo_name');
942
+ $repo_file_to_check.=DIRECTORY_SEPARATOR.$wordpress_name;
943
+ }
944
+ for($i=$index; $i<sizeof($source_file_path_array); $i++){
945
+ $repo_file_to_check.=DIRECTORY_SEPARATOR.$source_file_path_array[$i];
946
+ }
947
+ $path_flag=1;
948
+
949
+ break;
950
+ }
951
+ }
952
+ if($path_flag == 0){
953
+ $last_index=sizeof($source_file_path_array)-1;
954
+ $wordpress_name = get_option('downloaded_wordpress_repo_name');
955
+ $repo_file_to_check.=DIRECTORY_SEPARATOR.$wordpress_name.DIRECTORY_SEPARATOR.$source_file_path_array[$last_index];
956
+ }
957
+ $repo_status=1;
958
+ $issues = $this->check_with_repo_files($file_content, $repo_file_to_check);
959
+ if(!empty($issues)){
960
+ $repo_issue_count++;
961
+ $scanresult['repo']=$issues;
962
+ $flag_update=1;
963
+ }
964
+ }
965
+
966
+ if($flag_update == 0){
967
+ $repo_status = $scan_config['check_repo'] && $repo_status ? 1 : 0;
968
+ //$link_status = $scan_config['ext_link_check'] && $link_status ? 1: 0;
969
+
970
+ $scan_data = array('malware'=>$malware_status, 'repo'=>$repo_status, 'ext_link'=>$link_status);
971
+ $infected_array=$mo2f_malware_db_handler->get_detail_report_with_id($reportid);
972
+ $file_already_infected=false;
973
+ foreach ($infected_array as $key => $value) {
974
+ if($value->filename == $source_file_path){
975
+ $file_already_infected=true;
976
+ break;
977
+ }
978
+ }
979
+
980
+ if($file_already_infected){
981
+
982
+ }elseif(empty($res)){
983
+ $mo2f_malware_db_handler->insert_hash($source_file_path, $hash_of_file, $scan_data);
984
+ }else{
985
+ $mo2f_malware_db_handler->update_hash($source_file_path, $hash_of_file, $scan_data);
986
+ }
987
+ }else{
988
+ $infected_files=get_option('mo_wpns_warning_files');
989
+ $infected_files++;
990
+ if(!empty($res)){
991
+ $mo2f_malware_db_handler->delete_hash($source_file_path);
992
+ }
993
+ update_option('mo_wpns_warning_files', $infected_files);
994
+ }
995
+ if(!empty($scanresult))
996
+ $scanresults[$source_file_path]=$scanresult;
997
+ }
998
+ $mo_wpns_files_scanned=(0.15*$nooffiles)+$previous_scanned;
999
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
1000
+ $encoded_scan_status=json_encode($decoded_scan_status);
1001
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
1002
+ return array('file_count'=> $nooffiles, 'repo_issues'=>$repo_issue_count, 'scan'=>$scanresults);
1003
+ }
1004
+
1005
+ function check_exec_limit($start_time, $time_limit){
1006
+ if($time_limit == 0){
1007
+ return true;
1008
+ }else{
1009
+ $time_remaining= $time_limit - (time()-$start_time);
1010
+ if($time_remaining > 10){
1011
+ return true;
1012
+ }else{
1013
+ return false;
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ }
1019
+ new Mo_wpns_Scan_Handler_Cron;
1020
+ ?>
handler/malware_scanner/scanner_set_cron.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class mo2f_scanner_parts
4
+ {
5
+ function __construct(){
6
+ }
7
+
8
+
9
+ function check_scan_status(){
10
+
11
+ global $wpdb;
12
+ $query="SELECT `option_value` from `".$wpdb->base_prefix."options` WHERE `option_name` = 'mo_stop_scan'";
13
+ $stop_scan= $wpdb->get_results($query);
14
+ $stop_scan_process=$stop_scan[0]->option_value;
15
+ if($stop_scan_process=="1") {
16
+ $this->mo2f_end_scan();
17
+ error_log( "Scan Stopped" );
18
+ return "1";
19
+ }
20
+ else{
21
+ return "0";
22
+ }
23
+ }
24
+ function file_cron_scan(){//main cron function
25
+
26
+ $scan_request = isset($_GET['scan_request'])? $_GET['scan_request']:false;
27
+ if($scan_request) {
28
+ $status=$this->check_scan_status();
29
+
30
+ if($status){
31
+ exit;
32
+ //abort
33
+ }
34
+ $scan_mode = isset( $_GET['scan_mode'] ) ? $_GET['scan_mode'] : false;
35
+ $scan_stage_complete = isset( $_GET['scan_stage_complete'] ) ? $_GET['scan_stage_complete'] : false;
36
+ $reportid = isset( $_GET['reportid'] ) ? $_GET['reportid'] : false;
37
+
38
+ $scanverification = isset( $_GET['scanverification'] ) ? $_GET['scanverification'] : false;
39
+ $scanverification_code = get_option( "mo2f_scanverification" );
40
+ if ( $scanverification != $scanverification_code ) {
41
+ error_log( "Request Does not exists" );
42
+ exit;
43
+ }
44
+
45
+ $mo2f_malware_db_handler = new MoWpnsDB();
46
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
47
+
48
+ //switch case stage wise
49
+ if ( $scan_mode == 'Quick Scan' ) {
50
+ $scan_config = MoWpnsConstants::$quick_scan_configuration;
51
+ } elseif ( $scan_mode == 'Standard Scan' ) {
52
+ $scan_config = MoWpnsConstants::$standard_scan_configuration;
53
+ } else {
54
+ $scan_config = get_option( 'mo2f_custom_scan_config' ); // send with remote_get
55
+ }
56
+
57
+ $repo_status_code = get_option('mo2f_repo_status');
58
+ if ( ($scan_config['check_repo'] == 0 || $repo_status_code < 0) && $scan_stage_complete == 3 ) {//repo check not required so scan ended
59
+
60
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
61
+ $mo_wpns_files_scanned=$decoded_scan_status->total_files;
62
+ $decoded_scan_status->files_scanned=$mo_wpns_files_scanned;
63
+ $encoded_scan_status=json_encode($decoded_scan_status);
64
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
65
+ $this->mo2f_end_scan();
66
+ exit;
67
+ }
68
+
69
+ $uploads_dir = wp_upload_dir();
70
+ $uploads_path= $uploads_dir['basedir'];
71
+ $repo_file_path = $uploads_path . DIRECTORY_SEPARATOR . "miniorangescan";
72
+ $current_time = time();
73
+ $time_limit = ini_get( 'max_execution_time' );
74
+ switch ( $scan_stage_complete ) {
75
+ case 1:
76
+ $this->mo2f_scan_with_service( $scan_config, $reportid, $scanverification);
77
+ break;
78
+ case 2:
79
+ $this->mo2f_check_ext_link( $scan_config,$reportid,$scanverification);
80
+ break;
81
+ case 3:
82
+ $mo_wpns_scan_handler->mo2f_download_plugins_wp( $repo_file_path, $scan_config, $current_time, $time_limit,$reportid, $scanverification);
83
+ break;
84
+ case 4:
85
+ $mo_wpns_scan_handler->mo2f_download_themes_wp( $repo_file_path, $scan_config, $current_time, $time_limit,$reportid, $scanverification);
86
+ break;
87
+ case 5:
88
+ $mo_wpns_scan_handler->mo2f_download_core_wp( $repo_file_path, $scan_config,$reportid, $scanverification);
89
+ break;
90
+ case 6:
91
+ $this->mo2f_check_with_repo( $scan_config, $repo_file_path,$reportid,$scanverification);
92
+ break;
93
+ case 7:
94
+ $this->mo2f_end_scan();
95
+ break;
96
+ }
97
+ }
98
+ }
99
+
100
+ function mo2f_scan_with_service($scan_config, $reportid, $scanverification){
101
+
102
+ $mo2f_malware_db_handler = new MoWpnsDB();
103
+ $files_to_scan=$mo2f_malware_db_handler->get_files_in_parts();
104
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
105
+
106
+ if(empty($files_to_scan)){//service scan ended
107
+ error_log("scan with service ended");
108
+
109
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
110
+ $scan_malware_count=$last_report[0]->malware_count;
111
+ $last_scan=$mo2f_malware_db_handler->count_files_last_scan($reportid);
112
+
113
+ $hostname = 'scanner.api.xecurify.com';
114
+ $malware_server_status = $mo_wpns_scan_handler->mo_wpns_check_malware_server_status($hostname);
115
+ if($malware_server_status){
116
+ $host = 'http://scanner.api.xecurify.com/malwareservice/rest/file/data';
117
+ $postdata = http_build_query(array('fileCount' => $last_scan, 'maliciousCount' => $scan_malware_count));
118
+ $content_type = 'application/x-www-form-urlencoded';
119
+ $lastRequest = $mo_wpns_scan_handler->mo_wpns_malware_scan_request($postdata, $host, $content_type);
120
+ }
121
+ //start link check
122
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
123
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 2);
124
+
125
+ }else{//sending next 100 files
126
+ error_log("sending next 100 files");
127
+ ini_set('memory_limit', '-1');
128
+ ini_set('max_execution_time', 0);
129
+ $current_time= time();
130
+ $time_limit= ini_get('max_execution_time');
131
+ $result=$mo_wpns_scan_handler->get_scan_result_parts($mo2f_malware_db_handler, $files_to_scan, $scan_config, $current_time, $time_limit);
132
+
133
+ if($result['scan']){
134
+ foreach ($result['scan'] as $key => $value) {
135
+ $value=array('scan'=>'Premium');
136
+ $mo2f_malware_db_handler->add_report_details($reportid, $key, $value);
137
+ }
138
+ }
139
+ $mo2f_malware_db_handler->update_files_scan($files_to_scan, $result['file_count']);
140
+
141
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
142
+ $result['file_count']= $last_report[0]->scanned_files + $result['file_count'];
143
+ $result['malware_count'] = $last_report[0]->malware_count + $result['malware_count'];
144
+ $result['malicious_link'] = 0;
145
+ $result['repo_issues'] = $last_report[0]->repo_issues;
146
+
147
+ $mo2f_malware_db_handler->scan_report_complete($reportid, $result['file_count'], $result['malware_count'], $result['repo_issues'], $result['malicious_link']);
148
+
149
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
150
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 1);
151
+
152
+ }
153
+ }
154
+
155
+ function mo2f_check_ext_link($scan_config, $reportid, $scanverification){
156
+ $mo2f_malware_db_handler = new MoWpnsDB();
157
+ $files_to_scan=$mo2f_malware_db_handler->get_files_for_link();
158
+
159
+ if(!empty($files_to_scan) && $scan_config['ext_link_check']){
160
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
161
+ $current_time= time();
162
+ $time_limit= ini_get('max_execution_time');
163
+ $response=$mo_wpns_scan_handler->scan_for_ext_link($files_to_scan, $scan_config, $current_time, $time_limit, $reportid);
164
+
165
+ if($response['scan']){
166
+ foreach ($response['scan'] as $key => $value) {
167
+ $mo2f_malware_db_handler->add_report_details($reportid, $key, $value);
168
+ }
169
+ }
170
+ $mo2f_malware_db_handler->update_files_scan_ext_link($files_to_scan, $response['file_count']);
171
+
172
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
173
+ $response['file_count']= $last_report[0]->scanned_files;
174
+ $response['malware_count'] = $last_report[0]->malware_count;
175
+ $response['repo_issues'] = $last_report[0]->repo_issues;
176
+ $response['malicious_link'] = $last_report[0]->malicious_links + $response['malicious_link'];
177
+
178
+ $mo2f_malware_db_handler->scan_report_complete($reportid, $response['file_count'], $response['malware_count'], $response['repo_issues'], $response['malicious_link']);
179
+
180
+ $response=$mo_wpns_scan_handler->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 2);
181
+ }else{
182
+ $decoded_scan_status=json_decode(get_option('mo_wpns_scan_status'));
183
+ $mo_wpns_files_scanned=$decoded_scan_status->total_files;
184
+ $decoded_scan_status->files_scanned=0.85*$mo_wpns_files_scanned;
185
+ $encoded_scan_status=json_encode($decoded_scan_status);
186
+ update_option('mo_wpns_scan_status', $encoded_scan_status);
187
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
188
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 3);
189
+
190
+ }
191
+ }
192
+
193
+ function mo2f_check_with_repo($scan_config, $repo_file_path,$reportid, $scanverification){
194
+ $download_status=false;
195
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
196
+ $decoded_scan_configuration->status_download_time=$download_status;
197
+ $encoded_scan_configuration=json_encode($decoded_scan_configuration);
198
+ update_option("mo_wpns_scan_status",$encoded_scan_configuration);
199
+ $mo2f_malware_db_handler = new MoWpnsDB();
200
+ $response=array();
201
+ $repo_status = get_option('mo2f_repo_status');
202
+ if($repo_status != 0){//repo download issues. End scan without repository scan
203
+ if($repo_status == -99 || $repo_status == -100){
204
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
205
+ if(!empty($last_report)){
206
+ $response['file_count']= $last_report[0]->scanned_files;
207
+ $response['malware_count'] = $last_report[0]->malware_count;
208
+ $response['malicious_link'] = $last_report[0]->malicious_links;
209
+ $response['repo_issues']=$repo_status;
210
+ $mo2f_malware_db_handler->scan_report_complete($reportid, $response['file_count'], $response['malware_count'], $response['repo_issues'], $response['malicious_link']);
211
+ }
212
+ }
213
+ $this->mo2f_end_scan();
214
+ exit;
215
+ }else{
216
+ $files_to_scan=$mo2f_malware_db_handler->get_files_for_repo();
217
+ if(empty($files_to_scan)){//all files checked
218
+ $this->mo2f_end_scan();
219
+ }else{//send files for repo check
220
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
221
+ $current_time= time();
222
+ $time_limit= ini_get('max_execution_time');
223
+ $response=$mo_wpns_scan_handler->scan_with_repo($files_to_scan, $scan_config, $current_time, $time_limit, $reportid, $repo_file_path);
224
+
225
+ if($response['scan']){
226
+ foreach ($response['scan'] as $key => $value) {
227
+ $mo2f_malware_db_handler->add_report_details($reportid, $key, $value);
228
+ }
229
+ }
230
+ $mo2f_malware_db_handler->update_files_scan_repo($files_to_scan, $response['file_count']);
231
+
232
+ $last_report = $mo2f_malware_db_handler->get_report_with_id($reportid);
233
+ $response['file_count']= $last_report[0]->scanned_files;
234
+ $response['malware_count'] = $last_report[0]->malware_count;
235
+ $response['repo_issues'] = $last_report[0]->repo_issues + $response['repo_issues'];
236
+ $response['malicious_link'] = $last_report[0]->malicious_links;
237
+
238
+ $mo2f_malware_db_handler->scan_report_complete($reportid, $response['file_count'], $response['malware_count'], $response['repo_issues'], $response['malicious_link']);
239
+ $Mo_wpns_Scan_Handler_Cron = new Mo_wpns_Scan_Handler_Cron();
240
+ $response=$Mo_wpns_Scan_Handler_Cron->mo2f_wp_remote_get($scan_config['type_scan'], $reportid, $scanverification, 6);
241
+ }
242
+ }
243
+ }
244
+
245
+ function mo2f_end_scan(){
246
+ $mo_wpns_scan_handler = new Mo_wpns_Scan_Handler_Cron();
247
+ $mo2f_malware_db_handler = new MoWpnsDB();
248
+ $uploads_dir = wp_upload_dir();
249
+ $uploads_path= $uploads_dir['basedir'];
250
+ $repo_file_path = $uploads_path . DIRECTORY_SEPARATOR . "miniorangescan";
251
+ if(is_dir($repo_file_path)){
252
+ $mo_wpns_scan_handler->remove_dir($repo_file_path);
253
+ }
254
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
255
+ $decoded_scan_configuration->scan_progress="COMPLETE";
256
+ $encoded_scan_configuration=json_encode($decoded_scan_configuration);
257
+ update_option("mo_wpns_scan_status",$encoded_scan_configuration);
258
+ $mo2f_malware_db_handler->delete_files_parts();
259
+ error_log('done');
260
+ //exit;//end scan
261
+ }
262
+
263
+ }new mo2f_scanner_parts;
helper/constants.php CHANGED
@@ -11,7 +11,7 @@
11
  const ERR_403 = "403";
12
  const DEFAULT_CUSTOMER_KEY = "16555";
13
  const DEFAULT_API_KEY = "fFd2XcvTGDemZvbw1bcUesNJWEqKbbUq";
14
- const DB_VERSION = 146;
15
  const SUPPORT_EMAIL = 'info@xecurify.com';
16
  const IP_LOOKUP_TEMPLATE = '<span style="font-size:14px;font-weight:bold">GENERAL INFORMATION</span><table style="margin-left:2%;"><tr><td style="width:100px;">Response</td><td >:</td><td>{{status}}</td></tr><tr><td style="width:100px;">IP Address</td><td>:</td><td>{{ip}}</td></tr><tr><td>HostName</td><td>:</td><td>{{hostname}}</td></tr><tr><td>TimeZone</td><td>:</td><td>{{timezone}}</td></tr><tr><td>Time Difference</td><td>:</td><td>{{offset}}</td></tr></table><hr><span style="font-size:14px;font-weight:bold">LOCATION INFORMATION</span><table style="margin-left:2%;"><tr><td>Latitude</td><td>:</td><td>{{latitude}}</td></tr><tr><td>Longitude</td><td>:</td><td>{{longitude}}</td></tr><tr><td>Region</td><td>:</td><td>{{region}}</td></tr><tr><td>Country</td><td>:</td><td>{{country}}</td></tr><tr><td>City</td><td>:</td><td>{{city}}</td></tr><tr><td>Continent</td><td>:</td><td>{{continent}}</td></tr><tr><td>Curreny Code</td><td>:</td><td>{{curreny_code}}</td></tr><tr><td>Curreny Symbol</td><td>:</td><td>{{curreny_symbol}}</td></tr><tr><td>Per Dollar Value</td><td>:</td><td>{{per_dollar_value}}</td></tr></table>';
17
  const CURRENT_BROWSER = '<span style="font-size:10px;color:red;">( Current Browser )</span>';
@@ -42,7 +42,32 @@
42
  const WPFILES = 'wpfiles';
43
  const DATABASE = 'db';
44
 
45
- public static $repo_status_code = array(-97 => '<i>uploads Folder</i> permission denied', -98 => '2 Factor authentication plugin unable to reach wordpress repository files. Please contact miniOrange.', -99 => 'Unable to download Wordpress, plugins and themes from Repository', -100 => 'Unable to unzip the Wordpress, plugins and themes');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  function __construct()
48
  {
11
  const ERR_403 = "403";
12
  const DEFAULT_CUSTOMER_KEY = "16555";
13
  const DEFAULT_API_KEY = "fFd2XcvTGDemZvbw1bcUesNJWEqKbbUq";
14
+ const DB_VERSION = 148;
15
  const SUPPORT_EMAIL = 'info@xecurify.com';
16
  const IP_LOOKUP_TEMPLATE = '<span style="font-size:14px;font-weight:bold">GENERAL INFORMATION</span><table style="margin-left:2%;"><tr><td style="width:100px;">Response</td><td >:</td><td>{{status}}</td></tr><tr><td style="width:100px;">IP Address</td><td>:</td><td>{{ip}}</td></tr><tr><td>HostName</td><td>:</td><td>{{hostname}}</td></tr><tr><td>TimeZone</td><td>:</td><td>{{timezone}}</td></tr><tr><td>Time Difference</td><td>:</td><td>{{offset}}</td></tr></table><hr><span style="font-size:14px;font-weight:bold">LOCATION INFORMATION</span><table style="margin-left:2%;"><tr><td>Latitude</td><td>:</td><td>{{latitude}}</td></tr><tr><td>Longitude</td><td>:</td><td>{{longitude}}</td></tr><tr><td>Region</td><td>:</td><td>{{region}}</td></tr><tr><td>Country</td><td>:</td><td>{{country}}</td></tr><tr><td>City</td><td>:</td><td>{{city}}</td></tr><tr><td>Continent</td><td>:</td><td>{{continent}}</td></tr><tr><td>Curreny Code</td><td>:</td><td>{{curreny_code}}</td></tr><tr><td>Curreny Symbol</td><td>:</td><td>{{curreny_symbol}}</td></tr><tr><td>Per Dollar Value</td><td>:</td><td>{{per_dollar_value}}</td></tr></table>';
17
  const CURRENT_BROWSER = '<span style="font-size:10px;color:red;">( Current Browser )</span>';
42
  const WPFILES = 'wpfiles';
43
  const DATABASE = 'db';
44
 
45
+ public static $repo_status_code = array(-96 => 'Maximum execution time exceeded while downloading files from repository. Please contact miniOrange.', -97 => '<i>Uploads Folder</i> permission denied', -98 => '2 Factor authentication plugin unable to reach wordpress repository files. Please contact miniOrange.', -99 => 'Unable to download Wordpress, plugins and themes from Repository', -100 => 'Unable to unzip the Wordpress, plugins and themes');
46
+
47
+ public static $quick_scan_configuration = array('plugin_scan' => 1 ,
48
+ 'theme_scan' => 1,
49
+ 'core_scan' => 0,
50
+ 'file_extension' => "",
51
+ 'check_vulnerable' => 1,
52
+ 'check_sql' => 1,
53
+ 'check_rfi' => 1,
54
+ 'ext_link_check' => 0,
55
+ 'check_repo' => 0,
56
+ 'path_skip' => "",
57
+ 'type_scan' => "Quick Scan"
58
+ );
59
+ public static $standard_scan_configuration = array('plugin_scan' => 1 ,
60
+ 'theme_scan' => 1,
61
+ 'core_scan' => 0,
62
+ 'file_extension' => "",
63
+ 'check_vulnerable' => 1,
64
+ 'check_sql' => 1,
65
+ 'check_rfi' => 1,
66
+ 'ext_link_check' => 1,
67
+ 'check_repo' => 1,
68
+ 'path_skip' => "",
69
+ 'type_scan' => "Standard Scan"
70
+ );
71
 
72
  function __construct()
73
  {
helper/messages.php CHANGED
@@ -111,7 +111,7 @@
111
  const NOTIF_ENABLE = 'Notification options are available. Configure it in the Notification tab.';
112
  const NOTIF_DISABLE = 'Notifications are disabled.';
113
  const NEW_PLUGIN_THEME_CHECK = "<div class='custom-notice notice notice-warning new_plugin_theme-notice'><p><p class='notice-message'>We detected a change in plugins/themes folder. Kindly scan for better security.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='new_plugin_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='new_plugin_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
114
- const INFECTED_FILE = "<div class='custom-notice notice notice-warning file_infected-notice'><p><p class='notice-message'>Your last scan found infected files on your website. Kindly fix them to avoid any threats.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='infected_file_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='infected_file_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
115
  const WEEKLY_SCAN_CHECK = "<div class='custom-notice notice notice-warning weekly_notice-notice'><p><p class='notice-message'>You last scanned your website a week ago. Scan now to imrove security.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='weekly_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='weekly_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
116
 
117
 
111
  const NOTIF_ENABLE = 'Notification options are available. Configure it in the Notification tab.';
112
  const NOTIF_DISABLE = 'Notifications are disabled.';
113
  const NEW_PLUGIN_THEME_CHECK = "<div class='custom-notice notice notice-warning new_plugin_theme-notice'><p><p class='notice-message'>We detected a change in plugins/themes folder. Kindly scan for better security.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='new_plugin_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='new_plugin_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
114
+ const INFECTED_FILE = "<div class='custom-notice notice notice-warning file_infected-notice'><p><p class='notice-message'>Your last scan found infections/warnings on your website. Kindly fix them to avoid any threats.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='infected_file_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='infected_file_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
115
  const WEEKLY_SCAN_CHECK = "<div class='custom-notice notice notice-warning weekly_notice-notice'><p><p class='notice-message'>You last scanned your website a week ago. Scan now to imrove security.</p><a class='notice-button' href='admin.php?page=mo_2fa_malwarescan' style='margin-right: 15px;'>SCAN</a><button class='weekly_dismiss notice-button' style='margin-right: 15px;'><i>DISMISS</i></button><button class='weekly_dismiss_always notice-button'><i>NEVER SHOW AGAIN</i></button></p></div>";
116
 
117
 
includes/css/style_settings.css CHANGED
@@ -1,89 +1,3 @@
1
-
2
- .mo_popup {
3
- display: flex;
4
- flex-flow: row wrap;
5
- width:100%;
6
- }
7
- .mo_popup_div {
8
- flex: 1;
9
- padding: 0.5rem;
10
- }
11
- #mo_popup_id input[type="radio"] {
12
- display: none;
13
- &:not(:disabled) ~ label {
14
- cursor: pointer;
15
- }
16
- &:disabled ~ label {
17
- color: hsla(150, 5%, 75%, 1);
18
- border-color: hsla(150, 5%, 75%, 1);
19
- box-shadow: none;
20
- cursor: not-allowed;
21
- }
22
- }
23
- .mo_popup_lable {
24
- height: 100%;
25
- display: block;
26
- background: white;
27
- border: 2px solid #20b2aa;
28
- border-radius: 20px;
29
- padding: 1rem;
30
- margin-bottom: 1rem;
31
- /*//margin: 1rem;*/
32
- text-align: center;
33
- box-shadow: 0px 3px 10px -2px hsla(150, 5%, 65%, 0.5);
34
- position: relative;
35
- margin-top: 10px;
36
- }
37
-
38
- #mo_popup_id input[type="radio"]:checked + label {
39
- background: #20b2aa;
40
- color: hsla(215, 0%, 100%, 1);
41
- &::after {
42
- color: hsla(215, 5%, 25%, 1);
43
- font-family: FontAwesome;
44
- border: 2px solid hsla(150, 75%, 45%, 1);
45
- content: "\f00c";
46
- font-size: 24px;
47
- position: absolute;
48
- top: -25px;
49
- left: 50%;
50
- transform: translateX(-50%);
51
- height: 50px;
52
- width: 50px;
53
- line-height: 50px;
54
- text-align: center;
55
- border-radius: 50%;
56
- background: white;
57
- box-shadow: 0px 2px 5px -2px hsla(0, 0%, 0%, 0.25);
58
- }
59
- }
60
-
61
- #mo_popup_id input[type="radio"]#control_05:checked + label {
62
- background: red;
63
- border-color: red;
64
- }
65
-
66
-
67
- @media only screen and (max-width: 700px) {
68
- section {
69
- flex-direction: column;
70
- }
71
- }
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
  .mo_wpns_help_title {
88
  font-size:17px;
89
  width:100%;
@@ -1727,6 +1641,7 @@ a{
1727
  border-style: solid;
1728
  border-radius: 3px;
1729
  box-shadow: 0 1px 0 #CFCFCF;
 
1730
  }
1731
 
1732
  .custom-notice{
@@ -1819,6 +1734,11 @@ padding-right: 11px;
1819
  font-size: 1.2em;
1820
  text-align: center;
1821
  }
 
 
 
 
 
1822
  .hmdiv{
1823
  font-weight: 600;
1824
  font-size: 1.2em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .mo_wpns_help_title {
2
  font-size:17px;
3
  width:100%;
1641
  border-style: solid;
1642
  border-radius: 3px;
1643
  box-shadow: 0 1px 0 #CFCFCF;
1644
+
1645
  }
1646
 
1647
  .custom-notice{
1734
  font-size: 1.2em;
1735
  text-align: center;
1736
  }
1737
+ .title_hdiv{
1738
+ font-weight: 600;
1739
+ font-size: 1.0em;
1740
+ text-align: center;
1741
+ }
1742
  .hmdiv{
1743
  font-weight: 600;
1744
  font-size: 1.2em;
miniorange_2_factor_settings.php CHANGED
@@ -3,19 +3,18 @@
3
  * Plugin Name: miniOrange 2 Factor Authentication
4
  * Plugin URI: https://miniorange.com
5
  * Description: This plugin provides various two-factor authentication methods as an additional layer of security after the default wordpress login. We Support Google/Authy/LastPass Authenticator, QR Code, Push Notification, Soft Token and Security Questions(KBA) for 1 User in the free version of the plugin.
6
- * Version: 5.3.19
7
  * Author: miniOrange
8
  * Author URI: https://miniorange.com
9
  * License: GPL2
10
  */
11
  define( 'MO_HOST_NAME', 'https://login.xecurify.com' );
12
- define( 'MO2F_VERSION', '5.3.19' );
13
  define( 'MO2F_TEST_MODE', false );
14
  class Miniorange_twoFactor{
15
 
16
  function __construct()
17
  {
18
-
19
  register_deactivation_hook(__FILE__ , array( $this, 'mo_wpns_deactivate' ) );
20
  register_activation_hook (__FILE__ , array( $this, 'mo_wpns_activate' ) );
21
  add_action( 'admin_menu' , array( $this, 'mo_wpns_widget_menu' ) );
@@ -285,9 +284,12 @@
285
  require('helper/messages.php');
286
  require('views/common-elements.php');
287
  require('controllers/wpns-loginsecurity-ajax.php');
288
- require('controllers/malware_scan_ajax.php');
289
  require('controllers/backup_ajax.php');
290
  require('controllers/dashboard_ajax.php');
 
 
 
291
 
292
  }
293
 
3
  * Plugin Name: miniOrange 2 Factor Authentication
4
  * Plugin URI: https://miniorange.com
5
  * Description: This plugin provides various two-factor authentication methods as an additional layer of security after the default wordpress login. We Support Google/Authy/LastPass Authenticator, QR Code, Push Notification, Soft Token and Security Questions(KBA) for 1 User in the free version of the plugin.
6
+ * Version: 5.3.20
7
  * Author: miniOrange
8
  * Author URI: https://miniorange.com
9
  * License: GPL2
10
  */
11
  define( 'MO_HOST_NAME', 'https://login.xecurify.com' );
12
+ define( 'MO2F_VERSION', '5.3.20' );
13
  define( 'MO2F_TEST_MODE', false );
14
  class Miniorange_twoFactor{
15
 
16
  function __construct()
17
  {
 
18
  register_deactivation_hook(__FILE__ , array( $this, 'mo_wpns_deactivate' ) );
19
  register_activation_hook (__FILE__ , array( $this, 'mo_wpns_activate' ) );
20
  add_action( 'admin_menu' , array( $this, 'mo_wpns_widget_menu' ) );
284
  require('helper/messages.php');
285
  require('views/common-elements.php');
286
  require('controllers/wpns-loginsecurity-ajax.php');
287
+ require('controllers/malware_scanner/malware_scan_ajax.php');
288
  require('controllers/backup_ajax.php');
289
  require('controllers/dashboard_ajax.php');
290
+ require('handler/malware_scanner/malware_scanner_cron.php');
291
+ require('handler/malware_scanner/scanner_set_cron.php');
292
+
293
 
294
  }
295
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://miniorange.com/
6
  Requires at least: 3.0.1
7
  Tested up to: 5.3
8
  Requires PHP: 5.3.0
9
- Stable tag: 5.3.19
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -272,6 +272,9 @@ miniOrange authentication service has 15+ authentication methods.One time passco
272
 
273
  == Changelog ==
274
 
 
 
 
275
  = 5.3.19 =
276
  * Google Authenticator-Two Factor Authentication (2FA) : Security : Giving users choice of two factor.
277
 
@@ -721,6 +724,9 @@ More descriptive setup messages and UI changes.
721
 
722
  == Upgrade Notice ==
723
 
 
 
 
724
  = 5.3.19 =
725
  * Google Authenticator-Two Factor Authentication (2FA) : Security : Giving users choice of two factor.
726
 
6
  Requires at least: 3.0.1
7
  Tested up to: 5.3
8
  Requires PHP: 5.3.0
9
+ Stable tag: 5.3.20
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
272
 
273
  == Changelog ==
274
 
275
+ = 5.3.20 =
276
+ * Google Authenticator-Two Factor Authentication (2FA) : Anti Malware : Fixing issue faced by users during scan.
277
+
278
  = 5.3.19 =
279
  * Google Authenticator-Two Factor Authentication (2FA) : Security : Giving users choice of two factor.
280
 
724
 
725
  == Upgrade Notice ==
726
 
727
+ = 5.3.20 =
728
+ * Google Authenticator-Two Factor Authentication (2FA) : Anti Malware : Fixing issue faced by users during scan.
729
+
730
  = 5.3.19 =
731
  * Google Authenticator-Two Factor Authentication (2FA) : Security : Giving users choice of two factor.
732
 
uninstall.php CHANGED
@@ -121,6 +121,7 @@
121
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_scan_report_details" );
122
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_skip_files" );
123
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_hash_file" );
 
124
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_attack_logs" );
125
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_ip_rate_details" );
126
 
@@ -347,4 +348,17 @@
347
  delete_option( 'donot_show_infected_file_notice');
348
  delete_option( 'donot_show_new_plugin_theme_notice');
349
  delete_option( 'donot_show_weekly_scan_notice');
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  ?>
121
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_scan_report_details" );
122
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_skip_files" );
123
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_malware_hash_file" );
124
+ $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_files_scan" );
125
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_attack_logs" );
126
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpns_ip_rate_details" );
127
 
348
  delete_option( 'donot_show_infected_file_notice');
349
  delete_option( 'donot_show_new_plugin_theme_notice');
350
  delete_option( 'donot_show_weekly_scan_notice');
351
+ delete_option( 'mo_wpns_warning_files');
352
+ //delete_option( 'wordpress_download_status');
353
+ delete_option( 'mo2f_custom_scan_config');
354
+ delete_option( 'mo2f_report_id');
355
+ delete_option( 'mo_stop_scan');
356
+ delete_option( 'mo2f_repo_status');
357
+ delete_option( 'mo2f_scanverification');
358
+ delete_option( 'mo2f_repo_path');
359
+ delete_option( 'mo2f_download_done');
360
+ delete_option( 'downloaded_wordpress_repo_name');
361
+ delete_option( 'mo_wpns_scan_status');
362
+ delete_option( 'mo_wpns_scan_configuration');
363
+
364
  ?>
views/{malware_scan.php → malware_scanner/malware_scan.php} RENAMED
@@ -20,7 +20,7 @@
20
  <table style="width: 100%;">
21
  <tr>
22
  <td style="width:100%;vertical-align:top;" id="configurationForm">
23
- <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'scan_malware_summary.php'; ?>
24
  </tr>
25
  </table>
26
  </div>
@@ -30,7 +30,7 @@
30
  <table style="width: 100%;">
31
  <tr>
32
  <td style="width:100%;vertical-align:top;" id="configurationForm">
33
- <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'scan_malware_settings.php'; ?>
34
  </tr>
35
  </table>
36
  </div>
@@ -40,7 +40,7 @@
40
  <table style="width: 100%;">
41
  <tr>
42
  <td style="width:100%;vertical-align:top;" id="configurationForm">
43
- <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'scan_malware_report.php'; ?>
44
  </tr>
45
  </table>
46
  </div>
20
  <table style="width: 100%;">
21
  <tr>
22
  <td style="width:100%;vertical-align:top;" id="configurationForm">
23
+ <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_malware_summary.php'; ?>
24
  </tr>
25
  </table>
26
  </div>
30
  <table style="width: 100%;">
31
  <tr>
32
  <td style="width:100%;vertical-align:top;" id="configurationForm">
33
+ <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_malware_settings.php'; ?>
34
  </tr>
35
  </table>
36
  </div>
40
  <table style="width: 100%;">
41
  <tr>
42
  <td style="width:100%;vertical-align:top;" id="configurationForm">
43
+ <?php include_once $dirName . 'controllers'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'scan_malware_report.php'; ?>
44
  </tr>
45
  </table>
46
  </div>
views/{scan_report_view.php → malware_scanner/scan_report_view.php} RENAMED
@@ -9,7 +9,7 @@
9
  <hr>
10
  <div id="scandata">
11
  <?php
12
- include_once $dirName. 'controllers'.DIRECTORY_SEPARATOR.'malware_scan_result.php';
13
  echo showScanResults();
14
  ?>
15
  </div>
@@ -24,14 +24,27 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
24
  <div style=float:right><b>Scan Time :</b> <?php echo date("M j, Y, g:i:s a",$record->start_timestamp); ?><br><b>Completion Time :</b> <?php echo date("M j, Y, g:i:s a",$record->completed_timestamp); ?></div><br><br><hr><br>
25
  <div width="100%">
26
  <?php
27
- echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b>Found critical issues</b>";
 
 
 
 
 
 
 
 
 
28
  echo "<input id='malware_button' class='mmp_green' type='button' name='malware_button' value='Show less' style='float:right'></div>";
 
 
 
 
29
  echo "<hr>";
30
  echo "<div id='malware_content' style='display:block'>";
31
- $malwarecount = 0;
32
  ?>
33
  <table id="malware_table" style="text-align:center" class="display" cellspacing="0" width="100%">
34
- <thead><tr><th>File Name</th><th>Malware Details</th></tr></thead>
35
  <tbody>
36
  <?php
37
  foreach($detailreport as $report){
@@ -39,16 +52,12 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
39
  $filename = $report->filename;
40
 
41
  if(isset($issues['scan'])){
42
- $malwarecount++;
43
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
44
  $t= htmlspecialchars($issues['scan']);
45
- echo '<div><span class="issue mmp_point" onclick="mo_wpns_show_details(this)">Details</span><div class="issuecontent hidden" data-content="'.$t.'"></div></div>';
46
  }
47
  echo "</div>";
48
  }
49
- if ($malwarecount<=0) {
50
- echo "<div style='text-align:center; width: 100%; color: green; font-size: large;'><b>No critical issues found</b></div>";
51
- }
52
  ?>
53
  </tbody>
54
  </table>
@@ -56,11 +65,29 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
56
  echo "</div>";
57
  echo "</div>";
58
 
59
- echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b>Found Repository check Warnings in your Site</b>";
60
- echo "<input id='repo_button' class='mmp_green' type='button' name='repo_button' value='Show more' style='float:right'></div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  echo "<hr>";
62
  echo "<div id='repo_content' style='display:none'>";
63
- $repochekcount = 0;
64
  ?>
65
  <table id="repo_table" style="text-align:center" class="display" cellspacing="0" width="100%">
66
  <thead><tr><th>File Name</th><th>Repository Comparison Details</th></tr></thead>
@@ -71,18 +98,12 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
71
  $filename = $report->filename;
72
 
73
  if(isset($issues['repo'])){
74
- $repochekcount++;
75
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
76
  $t= htmlspecialchars($issues['repo']['exist']);
77
  echo '<div><span class="issue mmp_point" onclick="mo_wpns_show_details(this)">Details</span><div class="issuecontent hidden" data-content="'.$t.'"></div></div>';
78
  }
79
  echo "</div>";
80
  }
81
- if($record->repo_issues < 0){
82
- echo "<div style='text-align:center; width: 100%; color: red; font-size: large;'><b>".$repo_status_code[$record->repo_issues]."</b></div>";
83
- }else if ($repochekcount==0) {
84
- echo "<div style='text-align:center; width: 100%; color: green; font-size: large;'><b>No Repository check warning found</b></div>";
85
- }
86
  ?>
87
  </tbody>
88
  </table>
@@ -90,12 +111,23 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
90
  echo "</div>";
91
  echo "</div>";
92
 
93
-
94
- echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b>Found External links in your Site</b>";
95
- echo "<input id='extl_button' class='mmp_green' type='button' name='extl_button' value='Show more' style='float:right'></div>";
 
 
 
 
 
 
 
 
 
 
 
 
96
  echo "<hr>";
97
  echo "<div id='extl_content' style='display:none'>";
98
- $maliciouslinkcount = 0;
99
  ?>
100
  <table id="extl_table" style="text-align:center" class="display" cellspacing="0" width="100%">
101
  <thead><tr><th>File Name</th><th>External Link Details</th></tr></thead>
@@ -105,7 +137,6 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
105
  $issues = unserialize($report->report);
106
  $filename = $report->filename;
107
  if(isset($issues['extl'])){
108
- $maliciouslinkcount++;
109
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
110
  $t='';
111
  for ($i=0; $i <sizeof($issues['extl']) ; $i++) {
@@ -117,9 +148,6 @@ function show_scan_details($detailreport, $result, $ignorefiles, $last_scan){
117
  }
118
  echo "</div>";
119
  }
120
- if ($maliciouslinkcount<=0) {
121
- echo "<div style='text-align:center; width: 100%; color: green; font-size: large;'><b>No malicious links found</b></div>";
122
- }
123
  ?>
124
  </tbody>
125
  </table>
@@ -165,7 +193,7 @@ function show_scan_report($currenturl, $result){
165
  echo "<span style=color:green id=scan_files>".$report->scanned_files." files scanned<br></span>";
166
  echo "<span style=color:red id=malicious_files>".$report->malware_count." malware found<br></span>";
167
  if($report->repo_issues < 0){
168
- echo "<span style=color:red id=malicious_files>Issues with repository check<br></span>";
169
  }
170
  echo "<span style=color:orange id=warning_files>".($repo_count+$report->malicious_links)." warnings found</span>";
171
  echo "</td><td style=text-align:center id=start_time>".date("M j, Y, g:i:s a",$report->start_timestamp)."</td>";
9
  <hr>
10
  <div id="scandata">
11
  <?php
12
+ include_once $dirName. 'controllers'.DIRECTORY_SEPARATOR.'malware_scanner'.DIRECTORY_SEPARATOR.'malware_scan_result.php';
13
  echo showScanResults();
14
  ?>
15
  </div>
24
  <div style=float:right><b>Scan Time :</b> <?php echo date("M j, Y, g:i:s a",$record->start_timestamp); ?><br><b>Completion Time :</b> <?php echo date("M j, Y, g:i:s a",$record->completed_timestamp); ?></div><br><br><hr><br>
25
  <div width="100%">
26
  <?php
27
+ $malwarecount = 0;
28
+ foreach($detailreport as $report){
29
+ $issues = unserialize($report->report);
30
+ if(isset($issues['scan'])){
31
+ $malwarecount++;
32
+ break;
33
+ }
34
+ }
35
+ if($malwarecount == 0){
36
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: green; font-size: medium'>No critical issues found.</b>";
37
  echo "<input id='malware_button' class='mmp_green' type='button' name='malware_button' value='Show less' style='float:right'></div>";
38
+ }else{
39
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: red; font-size: medium'>Found critical issues</b>";
40
+ echo "<input id='malware_button' class='mmp_green' type='button' name='malware_button' value='Show less' style='float:right'></div>";
41
+ }
42
  echo "<hr>";
43
  echo "<div id='malware_content' style='display:block'>";
44
+
45
  ?>
46
  <table id="malware_table" style="text-align:center" class="display" cellspacing="0" width="100%">
47
+ <thead><tr><th >File Name</th><th style="width: 25%">Malware Details<a href="admin.php?page=mo_2fa_upgrade"> <b style="color: red; font-size: medium;">[Premium]</b> </a></th></tr></thead>
48
  <tbody>
49
  <?php
50
  foreach($detailreport as $report){
52
  $filename = $report->filename;
53
 
54
  if(isset($issues['scan'])){
 
55
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
56
  $t= htmlspecialchars($issues['scan']);
57
+ echo '<div><span class="issue mmp_point">Details</span><div class="issuecontent hidden" data-content=""></div></div>';
58
  }
59
  echo "</div>";
60
  }
 
 
 
61
  ?>
62
  </tbody>
63
  </table>
65
  echo "</div>";
66
  echo "</div>";
67
 
68
+ $repochekcount = 0;
69
+ if($record->repo_issues < 0){
70
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: orange; font-size: medium'>".$repo_status_code[$record->repo_issues]."</b>";
71
+ echo "<input id='repo_button' class='mmp_green' type='button' name='repo_button' value='Show more' style='float:right'></div>";
72
+ }else{
73
+ foreach($detailreport as $report){
74
+ $issues = unserialize($report->report);
75
+ if(isset($issues['repo'])){
76
+ $repochekcount++;
77
+ break;
78
+ }
79
+ }
80
+ if($repochekcount==0){
81
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: green; font-size: medium'>No Repository check warning found</b>";
82
+ echo "<input id='repo_button' class='mmp_green' type='button' name='repo_button' value='Show more' style='float:right'></div>";
83
+ }else{
84
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: orange; font-size: medium'>Found Repository check Warnings in your Site</b>";
85
+ echo "<input id='repo_button' class='mmp_green' type='button' name='repo_button' value='Show more' style='float:right'></div>";
86
+ }
87
+ }
88
+
89
  echo "<hr>";
90
  echo "<div id='repo_content' style='display:none'>";
 
91
  ?>
92
  <table id="repo_table" style="text-align:center" class="display" cellspacing="0" width="100%">
93
  <thead><tr><th>File Name</th><th>Repository Comparison Details</th></tr></thead>
98
  $filename = $report->filename;
99
 
100
  if(isset($issues['repo'])){
 
101
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
102
  $t= htmlspecialchars($issues['repo']['exist']);
103
  echo '<div><span class="issue mmp_point" onclick="mo_wpns_show_details(this)">Details</span><div class="issuecontent hidden" data-content="'.$t.'"></div></div>';
104
  }
105
  echo "</div>";
106
  }
 
 
 
 
 
107
  ?>
108
  </tbody>
109
  </table>
111
  echo "</div>";
112
  echo "</div>";
113
 
114
+ $maliciouslinkcount = 0;
115
+ foreach($detailreport as $report){
116
+ $issues = unserialize($report->report);
117
+ if(isset($issues['extl'])){
118
+ $maliciouslinkcount++;
119
+ break;
120
+ }
121
+ }
122
+ if($maliciouslinkcount == 0){
123
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: green; font-size: medium'>No malicious links found</b>";
124
+ echo "<input id='extl_button' class='mmp_green' type='button' name='extl_button' value='Show more' style='float:right'></div>";
125
+ }else{
126
+ echo "<div style='margin: 5px 0; border: 1px solid; border-radius: 5px; padding: 10px'><div><b style='color: orange; font-size: medium'>Found External links in your Site</b>";
127
+ echo "<input id='extl_button' class='mmp_green' type='button' name='extl_button' value='Show more' style='float:right'></div>";
128
+ }
129
  echo "<hr>";
130
  echo "<div id='extl_content' style='display:none'>";
 
131
  ?>
132
  <table id="extl_table" style="text-align:center" class="display" cellspacing="0" width="100%">
133
  <thead><tr><th>File Name</th><th>External Link Details</th></tr></thead>
137
  $issues = unserialize($report->report);
138
  $filename = $report->filename;
139
  if(isset($issues['extl'])){
 
140
  echo "<tr><td style=text-align:center>".$filename."</td><td>";
141
  $t='';
142
  for ($i=0; $i <sizeof($issues['extl']) ; $i++) {
148
  }
149
  echo "</div>";
150
  }
 
 
 
151
  ?>
152
  </tbody>
153
  </table>
193
  echo "<span style=color:green id=scan_files>".$report->scanned_files." files scanned<br></span>";
194
  echo "<span style=color:red id=malicious_files>".$report->malware_count." malware found<br></span>";
195
  if($report->repo_issues < 0){
196
+ echo "<span style=color:orange id=malicious_files>Issues with repository check<br></span>";
197
  }
198
  echo "<span style=color:orange id=warning_files>".($repo_count+$report->malicious_links)." warnings found</span>";
199
  echo "</td><td style=text-align:center id=start_time>".date("M j, Y, g:i:s a",$report->start_timestamp)."</td>";
views/{scan_settings_view.php → malware_scanner/scan_settings_view.php} RENAMED
@@ -48,7 +48,7 @@
48
  Checks if anyone creating backlinks from your website. Backlinks to blacklisted sites can add your website to spam websites list.<br><br>
49
  <input type="checkbox" name="mo_wpns_scan_files_with_repo" id="mo_wpns_scan_files_with_repo" value="1" <?php checked(get_option('mo_wpns_scan_files_with_repo') == 1);?>> <b>Check Files with repository</b><br>
50
  Check the Wordpress, plugin and theme files with its repository. It is helpful to determine if extra files added to or missing any of repository files.<br><br>
51
- <input type="checkbox" name="mo_wpns_check_remote_file_inclusion" id="mo_wpns_check_remote_file_inclusion" value="1" <?php checked(get_option('mo_wpns_check_remote_file_inclusion') == 1);?>> <b>Remote File Inclusion</b><br>
52
  Inclusion of remote files can be harmful as code return in remote files will be executed on your server.<br><br>
53
  <input type="checkbox" name="mo_wpns_adv_sign" id="mo_wpns_adv_sign" value="1" <?php checked(get_option('mo_wpns_adv_sign') == 1);?>> <b>Use Advanced Signatures For Malware Detection.</b><b class="mo_red"> (Deep Scan) </b><br>
54
  Advanced Signatures help to scan your website better. miniOrange has it own premium signatures used to detect more advanced malwares in the files.<br><br>
@@ -89,7 +89,7 @@
89
  <?php }
90
  ?>
91
  </table>
92
- <a style="cursor:pointer" onclick="add_white_url();">Add More URLs</a>
93
  </td>
94
  </tr>
95
  <tr><td>&nbsp;</td><td></td></tr>
@@ -105,7 +105,7 @@
105
  <?php }
106
  ?>
107
  </table>
108
- <a style="cursor:pointer" onclick="add_custom_sign();">Add More Signatures</a>
109
  </td>
110
  </tr>
111
  <tr>
@@ -178,7 +178,6 @@
178
  "ext_link":jQuery("input[name= mo_wpns_check_external_link]:checked").val(),
179
  "repo_check":jQuery("input[name= mo_wpns_scan_files_with_repo]:checked").val(),
180
  "skip_path":str,
181
- "check_rfi":jQuery("input[name= mo_wpns_check_remote_file_inclusion]:checked").val(),
182
  "nonce":jQuery("#mo_wpns_scan_settings_url").val()
183
  };
184
  jQuery.post(ajaxurl, data, function(response){
48
  Checks if anyone creating backlinks from your website. Backlinks to blacklisted sites can add your website to spam websites list.<br><br>
49
  <input type="checkbox" name="mo_wpns_scan_files_with_repo" id="mo_wpns_scan_files_with_repo" value="1" <?php checked(get_option('mo_wpns_scan_files_with_repo') == 1);?>> <b>Check Files with repository</b><br>
50
  Check the Wordpress, plugin and theme files with its repository. It is helpful to determine if extra files added to or missing any of repository files.<br><br>
51
+ <input type="checkbox" name="mo_wpns_check_remote_file_inclusion" id="mo_wpns_check_remote_file_inclusion" value="1" <?php checked(get_option('mo_wpns_check_remote_file_inclusion') == 1);?>> <b>Remote File Inclusion</b><b class="mo_red"> (Deep Scan) </b><br>
52
  Inclusion of remote files can be harmful as code return in remote files will be executed on your server.<br><br>
53
  <input type="checkbox" name="mo_wpns_adv_sign" id="mo_wpns_adv_sign" value="1" <?php checked(get_option('mo_wpns_adv_sign') == 1);?>> <b>Use Advanced Signatures For Malware Detection.</b><b class="mo_red"> (Deep Scan) </b><br>
54
  Advanced Signatures help to scan your website better. miniOrange has it own premium signatures used to detect more advanced malwares in the files.<br><br>
89
  <?php }
90
  ?>
91
  </table>
92
+ <!-- <a style="cursor:pointer" onclick="add_white_url();">Add More URLs</a> -->
93
  </td>
94
  </tr>
95
  <tr><td>&nbsp;</td><td></td></tr>
105
  <?php }
106
  ?>
107
  </table>
108
+ <!-- <a style="cursor:pointer" onclick="add_custom_sign();">Add More Signatures</a> -->
109
  </td>
110
  </tr>
111
  <tr>
178
  "ext_link":jQuery("input[name= mo_wpns_check_external_link]:checked").val(),
179
  "repo_check":jQuery("input[name= mo_wpns_scan_files_with_repo]:checked").val(),
180
  "skip_path":str,
 
181
  "nonce":jQuery("#mo_wpns_scan_settings_url").val()
182
  };
183
  jQuery.post(ajaxurl, data, function(response){
views/{scan_summary_view.php → malware_scanner/scan_summary_view.php} RENAMED
@@ -56,8 +56,8 @@ add_action('admin_footer','mo_wpns_start_scan');
56
  <div id="mo_wpns_progress_bar" class="mo_wpns_progress_bar">0%</div>
57
  </div>
58
  <div id="mo_stop_button_div" style="display: none;">
59
- <input type="button" name="mo_stop_button" id="mo_stop_button" class="mo_wpns_scan_button" value="Stop Scan" style="margin-left: 45%;">
60
- </div >
61
  </div>
62
 
63
  <?php
@@ -65,19 +65,26 @@ function mo_wpns_start_scan(){
65
  if ( ('admin.php' != basename( $_SERVER['PHP_SELF'] )) || ($_GET['page'] != 'mo_2fa_malwarescan') ) {
66
  return;
67
  }
68
- ?>
 
 
 
 
 
 
 
 
69
  <script>
70
- var status_var,progress_bar,scan_progress,stop_scan_progress;
71
  jQuery(document).ready(function(){
72
- scan_progress= "<?php echo get_option('mo_wpns_malware_scan_in_progress'); ?>";
73
- stop_scan_progress= "<?php echo get_option('mo_stop_scan'); ?>";
74
-
75
  if(scan_progress=="IN PROGRESS"){
76
  status_progress();
77
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
78
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
79
  jQuery('input[name="standard_scan_button"]').attr('disabled', true);
80
- var mode_scan="<?php echo get_option('mo_wpns_scan_mode'); ?>";
81
  if(mode_scan=="quick_scan"){
82
  document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
83
  document.getElementById('custom_scan_button').style.backgroundColor = '#b0d2cf';
@@ -96,27 +103,27 @@ function mo_wpns_start_scan(){
96
  document.getElementById('standard_scan_button').style.backgroundColor = '#b0d2cf';
97
  document.getElementById('custom_scan_button').value="Scanning..."
98
  }
99
- status_var = 1;
100
  document.getElementById("mo_progress").style.display="block";
101
  document.getElementById('mo_stop_button_div').style.display="block";
102
-
103
- if(stop_scan_progress==1){
104
-
105
- jQuery('input[name="mo_stop_button"]').attr('disabled', true);
106
- jQuery('input[name="mo_stop_button"]').val("Stop Scanning...");
107
- document.getElementById('mo_stop_button').style.backgroundColor = '#b0d2cf';
108
- }
109
- progress_bar = setInterval(status_progress, 2000);
110
  }
111
  jQuery('input[name="quick_scan_button"]').click(function(){
112
  document.getElementById("quick_scan_button").value = "Scanning...";
 
113
  document.getElementById("mo_progress").style.display="block";
114
- jQuery('input[name="mo_stop_button"]').val("Stop Scan");
115
- document.getElementById('mo_stop_button_div').style.display="block";
116
  document.getElementById("progress_message").innerHTML = "Scan progress...";
 
 
117
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
118
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
119
- progress_bar= setInterval(status_progress, 2000);
120
 
121
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
122
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
@@ -133,9 +140,9 @@ function mo_wpns_start_scan(){
133
  'nonce':jQuery('#wpns_quick_scan_nonce').val()
134
  };
135
  jQuery.post(ajaxurl, data, function(response){
136
-
137
  jQuery('#mo_scan_message').show();
138
  jQuery('#mo_scan_message').empty();
 
139
  if(response == "scanning_already"){
140
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
141
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
@@ -147,34 +154,10 @@ function mo_wpns_start_scan(){
147
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
148
  jQuery("#mo_scan_message").append("Nonce did not match.");
149
  window.scrollTo({ top: 0, behavior: "smooth"});
150
- }else if(response=='aborted'){
151
- jQuery('#mo_scan_message').hide();
152
- }else if(response=="scan_terminating"){
153
- jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
154
- jQuery("#mo_scan_message").append("Please wait for some time and try again.");
155
- window.scrollTo({ top: 0, behavior: "smooth"});
156
- document.getElementById("quick_scan_button").value = "Quick Scan";
157
- document.getElementById('quick_scan_button').style.backgroundColor = '#b0d2cf';
158
-
159
-
160
  }else{
161
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
162
- jQuery("#mo_scan_message").append("Scan has been completed. You can see the results in the Scan Reports tab.");
163
- document.getElementById('mo_stop_button_div').style.display="none";
164
- window.scrollTo({ top: 0, behavior: "smooth" });
165
- jQuery('#summary_all_scan_text').html(response['total_files']);
166
- jQuery('#summary_current_scan_text').html(response['scan_files']);
167
- jQuery('#summary_all_infect_text').html(response['total_mal']);
168
- jQuery('#summary_current_infect_text').html(response['mal_files']);
169
  }
170
-
171
- jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
172
- document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
173
- jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
174
- document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
175
- jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
176
- document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
177
- document.getElementById("quick_scan_button").value = "Quick Scan";
178
  }
179
 
180
 
@@ -185,12 +168,12 @@ function mo_wpns_start_scan(){
185
  document.getElementById("standard_scan_button").value = "Scanning...";
186
 
187
  document.getElementById("mo_progress").style.display="block";
188
- jQuery('input[name="mo_stop_button"]').val("Stop Scan");
189
- document.getElementById('mo_stop_button_div').style.display="block";
190
  document.getElementById("progress_message").innerHTML = "Scan progress...";
 
 
191
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
192
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
193
- progress_bar= setInterval(status_progress, 2000);
194
 
195
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
196
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
@@ -209,6 +192,7 @@ function mo_wpns_start_scan(){
209
  jQuery.post(ajaxurl, data, function(response){
210
  jQuery('#mo_scan_message').show();
211
  jQuery('#mo_scan_message').empty();
 
212
  if(response == "scanning_already"){
213
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
214
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
@@ -220,33 +204,10 @@ function mo_wpns_start_scan(){
220
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
221
  jQuery("#mo_scan_message").append("Nonce did not match.");
222
  window.scrollTo({ top: 0, behavior: "smooth"});
223
- }else if(response=='aborted'){
224
- jQuery('#mo_scan_message').hide();
225
- }if(response=='scan_terminating'){
226
- jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
227
- jQuery("#mo_scan_message").append("Please wait for some time and try again.");
228
- window.scrollTo({ top: 0, behavior: "smooth"});
229
- document.getElementById("standard_scan_button").value = "Standard Scan";
230
- document.getElementById('standard_scan_button').style.backgroundColor = '#b0d2cf';
231
- jQuery('#mo_scan_message').hide();
232
  }else{
233
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
234
- jQuery("#mo_scan_message").append("Scan has been completed. You can see the results in the Scan Reports tab.");
235
- document.getElementById('mo_stop_button_div').style.display="none";
236
- window.scrollTo({ top: 0, behavior: "smooth" });
237
- jQuery('#summary_all_scan_text').html(response['total_files']);
238
- jQuery('#summary_current_scan_text').html(response['scan_files']);
239
- jQuery('#summary_all_infect_text').html(response['total_mal']);
240
- jQuery('#summary_current_infect_text').html(response['mal_files']);
241
  }
242
-
243
- jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
244
- document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
245
- jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
246
- document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
247
- jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
248
- document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
249
- document.getElementById("standard_scan_button").value = "Standard Scan";
250
  }
251
 
252
  });
@@ -256,12 +217,12 @@ function mo_wpns_start_scan(){
256
  document.getElementById("custom_scan_button").value = "Scanning...";
257
 
258
  document.getElementById("mo_progress").style.display="block";
259
- jQuery('input[name="mo_stop_button"]').val("Stop Scan");
260
- document.getElementById('mo_stop_button_div').style.display="block";
261
  document.getElementById("progress_message").innerHTML = "Scan progress...";
 
 
262
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
263
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
264
- progress_bar= setInterval(status_progress, 2000);
265
 
266
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
267
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
@@ -280,81 +241,56 @@ function mo_wpns_start_scan(){
280
  jQuery.post(ajaxurl, data, function(response){
281
  jQuery('#mo_scan_message').show();
282
  jQuery('#mo_scan_message').empty();
 
283
  if(response == "scanning_already"){
284
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
285
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
286
  window.scrollTo({ top: 0, behavior: "smooth"});
287
  document.getElementById("custom_scan_button").value = "Custom Scan";
288
  document.getElementById('custom_scan_button').style.backgroundColor = '#b0d2cf';
289
- }if(response=='scan_terminating'){
290
- jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
291
- jQuery("#mo_scan_message").append("Please wait for some time and try again.");
292
- window.scrollTo({ top: 0, behavior: "smooth"});
293
- document.getElementById("custom_scan_button").value = "Custom Scan";
294
- document.getElementById('custom_scan_button').style.backgroundColor = '#b0d2cf';
295
- jQuery('#mo_scan_message').hide();
296
  }else{
297
  if(response=="ERROR"){
298
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
299
  jQuery("#mo_scan_message").append("Nonce did not match.");
300
  window.scrollTo({ top: 0, behavior: "smooth"});
301
- }else if(response=='aborted'){
302
- jQuery('#mo_scan_message').hide();
 
 
303
  }else{
304
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
305
- jQuery("#mo_scan_message").append("Scan has been completed. You can see the results in the Scan Reports tab.");
306
- document.getElementById('mo_stop_button_div').style.display="none";
307
- window.scrollTo({ top: 0, behavior: "smooth" });
308
- jQuery('#summary_all_scan_text').html(response['total_files']);
309
- jQuery('#summary_current_scan_text').html(response['scan_files']);
310
- jQuery('#summary_all_infect_text').html(response['total_mal']);
311
- jQuery('#summary_current_infect_text').html(response['mal_files']);
312
  }
313
-
314
- jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
315
- document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
316
- jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
317
- document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
318
- jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
319
- document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
320
- document.getElementById("custom_scan_button").value = "Custom Scan";
321
  }
322
 
323
  });
324
  });
325
 
326
  jQuery('input[name="mo_stop_button"]').click(function(){
327
- jQuery('input[name="mo_stop_button"]').attr('disabled', true);
328
-
329
- jQuery('input[name="mo_stop_button"]').val("Stop Scanning...");
330
- document.getElementById('mo_stop_button').style.backgroundColor = '#b0d2cf';
331
-
332
- var data={
333
- 'action':'mo_wpns_malware_redirect',
334
- 'call_type':'malware_scan_terminate'
335
- };
336
- jQuery.post(ajaxurl, data, function(response){
337
- jQuery('input[name="mo_stop_button"]').removeAttr('disabled');
338
- document.getElementById('mo_stop_button').style.backgroundColor = '#20b2aa';
339
-
340
- jQuery('input[name="mo_stop_button"]').val("Stop Scanning...");
341
- jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
342
- document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
343
- document.getElementById("quick_scan_button").value = "Quick Scan";
344
- jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
345
- document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
346
- document.getElementById("standard_scan_button").value = "Standard Scan";
347
- jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
348
- document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
349
- document.getElementById("custom_scan_button").value = "Custom Scan";
350
  document.getElementById("mo_progress").style.display="none";
351
-
352
- jQuery('#mo_scan_message').show();
353
  jQuery('#mo_scan_message').empty();
354
- jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
355
- jQuery("#mo_scan_message").append("Scan has been aborted.");
356
- window.scrollTo({ top: 0, behavior: "smooth" });
357
- });
358
  });
359
  });
360
 
@@ -364,44 +300,80 @@ function mo_wpns_start_scan(){
364
  'call_type':'malware_progress_bar'
365
  };
366
  jQuery.post(ajaxurl, data, function(response){
 
367
  var bar= document.getElementById("mo_wpns_progress_bar");
368
  if(response['status']=="COMPLETE"){
369
  document.getElementById("progress_message").innerHTML = "Scan completed";
370
  bar.style.width= 100 + "%";
371
  bar.innerHTML = 100 + "%";
372
- if(status_var == 1){
373
- jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
374
- document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
375
- document.getElementById('quick_scan_button').value="Quick Scan";
376
- jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
377
- document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
378
- document.getElementById('standard_scan_button').value="Standard Scan";
379
- jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
380
- document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
381
- document.getElementById('custom_scan_button').value="Custom Scan";
382
- jQuery('#summary_all_scan_text').html(response['total_files']);
383
- jQuery('#summary_current_scan_text').html(response['scan_files']);
384
- jQuery('#summary_all_infect_text').html(response['total_mal']);
385
- jQuery('#summary_current_infect_text').html(response['mal_files']);
386
-
387
-
388
- }
389
- jQuery('input[name="mo_stop_button"]').val("Stop Scan");
390
- document.getElementById('mo_stop_button_div').style.display="none";
391
- document.getElementById('mo_stop_button').style.backgroundColor = '#20b2aa';
392
- jQuery('input[name="mo_stop_button"]').removeAttr('disabled');
 
 
 
393
  clearInterval(progress_bar);
394
- }else{
395
- if(response['total'] == 0 || response['total'] == false){
396
- var width= 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
  }else{
398
  var width= (response['scanned']/response['total'])*100;
399
  width = Math.round(width);
400
  }
401
- //alert(width);
402
  bar.style.width= width + "%";
403
- if(response['repo_scan']==1 && width==0){
404
  document.getElementById("progress_message").innerHTML= "Downloading plugins/themes/wordpress files from repository...";
 
405
  }else{
406
  document.getElementById("progress_message").innerHTML= "Scan progress...";
407
  bar.innerHTML = width + "%";
@@ -421,12 +393,15 @@ function show_summary(){
421
  $total_malicious=0;
422
  $last_scan=0;
423
  $malicious_last_scan=0;
 
424
  }else{
425
  $result = $mo_wpns_db_handler->get_report_with_id($send_id);
426
  $total_scan=$mo_wpns_db_handler->count_files();
427
  $total_malicious=$mo_wpns_db_handler->count_malicious_files();
428
  $last_scan=$mo_wpns_db_handler->count_files_last_scan($send_id);
429
- $malicious_last_scan=$mo_wpns_db_handler->count_malicious_last_scan($send_id);
 
 
430
  if($total_scan > 999){
431
  $total_scan=($total_scan/1000);
432
  $total_scan= round($total_scan,1)."k";
@@ -435,28 +410,37 @@ function show_summary(){
435
  $total_malicious=($total_malicious/1000);
436
  $total_malicious= round($total_malicious,1)."k";
437
  }
 
 
 
 
438
  }
439
  ?>
440
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivl" id="summary_all_scan">
441
- <div class="hdiv"><b>Total Files Scanned</b></div>
442
  <hr class="line">
443
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_all_scan_text"> <?php echo $total_scan ?> </p>
444
  </div>
445
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivr mo_wpns_msdivl" id="summary_all_infect">
446
- <div class="hdiv"><b>Total Infected Files</b></div>
447
  <hr class="line">
448
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_all_infect_text"> <?php echo $total_malicious ?> </p>
449
  </div>
450
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivl mo_wpns_msdivr" id="summary_current_scan">
451
- <div class="hdiv"><b>Files scanned in last scan</b></div>
452
  <hr class="line">
453
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_current_scan_text"> <?php echo $last_scan ?> </p>
454
  </div>
455
- <div class="mo_wpns_sub_scansummary mo_wpns_msdivr" id="summary_current_infect">
456
- <div class="hdiv"><b>Infected Files in last scan</b></div>
457
  <hr class="line">
458
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_current_infect_text"> <?php echo $malicious_last_scan ?> </p>
459
  </div>
 
 
 
 
 
460
 
461
  <?php
462
  }
56
  <div id="mo_wpns_progress_bar" class="mo_wpns_progress_bar">0%</div>
57
  </div>
58
  <div id="mo_stop_button_div" style="display: none;">
59
+ <input type="button" name="mo_stop_button" id="mo_stop_button" class="mo_wpns_scan_button" value="Stop Scan" style="margin-left: 45%;">
60
+ </div >
61
  </div>
62
 
63
  <?php
65
  if ( ('admin.php' != basename( $_SERVER['PHP_SELF'] )) || ($_GET['page'] != 'mo_2fa_malwarescan') ) {
66
  return;
67
  }
68
+ $decoded_scan_configuration=json_decode(get_option('mo_wpns_scan_status'));
69
+ if(!isset($decoded_scan_configuration)){
70
+ $status=false;
71
+ $scan_mode=false;
72
+ }else {
73
+ $status = $decoded_scan_configuration->scan_progress;
74
+ $scan_mode = $decoded_scan_configuration->scan_mode;
75
+ }
76
+ ?>
77
  <script>
78
+ var progress_bar,scan_progress,stop_scan_progress;
79
  jQuery(document).ready(function(){
80
+ scan_progress= "<?php echo $status; ?>";
81
+ stop_scan_progress= "<?php echo get_option('mo_stop_scan'); ?>";
 
82
  if(scan_progress=="IN PROGRESS"){
83
  status_progress();
84
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
85
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
86
  jQuery('input[name="standard_scan_button"]').attr('disabled', true);
87
+ var mode_scan="<?php echo $scan_mode; ?>";
88
  if(mode_scan=="quick_scan"){
89
  document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
90
  document.getElementById('custom_scan_button').style.backgroundColor = '#b0d2cf';
103
  document.getElementById('standard_scan_button').style.backgroundColor = '#b0d2cf';
104
  document.getElementById('custom_scan_button').value="Scanning..."
105
  }
 
106
  document.getElementById("mo_progress").style.display="block";
107
  document.getElementById('mo_stop_button_div').style.display="block";
108
+
109
+ if(stop_scan_progress==1){
110
+
111
+ jQuery('input[name="mo_stop_button"]').attr('disabled', true);
112
+ jQuery('input[name="mo_stop_button"]').val("Stop Scanning...");
113
+ document.getElementById('mo_stop_button').style.backgroundColor = '#b0d2cf';
114
+ }
115
+ progress_bar = setInterval(status_progress, 10000);
116
  }
117
  jQuery('input[name="quick_scan_button"]').click(function(){
118
  document.getElementById("quick_scan_button").value = "Scanning...";
119
+
120
  document.getElementById("mo_progress").style.display="block";
 
 
121
  document.getElementById("progress_message").innerHTML = "Scan progress...";
122
+ jQuery('input[name="mo_stop_button"]').val("Stop Scan");
123
+ document.getElementById('mo_stop_button_div').style.display="block";
124
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
125
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
126
+ progress_bar= setInterval(status_progress, 10000);
127
 
128
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
129
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
140
  'nonce':jQuery('#wpns_quick_scan_nonce').val()
141
  };
142
  jQuery.post(ajaxurl, data, function(response){
 
143
  jQuery('#mo_scan_message').show();
144
  jQuery('#mo_scan_message').empty();
145
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
146
  if(response == "scanning_already"){
147
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
148
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
154
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
155
  jQuery("#mo_scan_message").append("Nonce did not match.");
156
  window.scrollTo({ top: 0, behavior: "smooth"});
 
 
 
 
 
 
 
 
 
 
157
  }else{
158
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
159
+ jQuery("#mo_scan_message").append("Malware Scan has started. You can see the results in scan reports tab after it is completed.");
 
 
 
 
 
 
160
  }
 
 
 
 
 
 
 
 
161
  }
162
 
163
 
168
  document.getElementById("standard_scan_button").value = "Scanning...";
169
 
170
  document.getElementById("mo_progress").style.display="block";
 
 
171
  document.getElementById("progress_message").innerHTML = "Scan progress...";
172
+ jQuery('input[name="mo_stop_button"]').val("Stop Scan");
173
+ document.getElementById('mo_stop_button_div').style.display="block";
174
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
175
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
176
+ progress_bar= setInterval(status_progress, 10000);
177
 
178
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
179
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
192
  jQuery.post(ajaxurl, data, function(response){
193
  jQuery('#mo_scan_message').show();
194
  jQuery('#mo_scan_message').empty();
195
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
196
  if(response == "scanning_already"){
197
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
198
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
204
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
205
  jQuery("#mo_scan_message").append("Nonce did not match.");
206
  window.scrollTo({ top: 0, behavior: "smooth"});
 
 
 
 
 
 
 
 
 
207
  }else{
208
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
209
+ jQuery("#mo_scan_message").append("Malware scan has started. You can see the results in scan reports tab after it is completed.");
 
 
 
 
 
 
210
  }
 
 
 
 
 
 
 
 
211
  }
212
 
213
  });
217
  document.getElementById("custom_scan_button").value = "Scanning...";
218
 
219
  document.getElementById("mo_progress").style.display="block";
 
 
220
  document.getElementById("progress_message").innerHTML = "Scan progress...";
221
+ jQuery('input[name="mo_stop_button"]').val("Stop Scan");
222
+ document.getElementById('mo_stop_button_div').style.display="block";
223
  document.getElementById("mo_wpns_progress_bar").style.width= 0 + "%";
224
  document.getElementById("mo_wpns_progress_bar").innerHTML= 0 + "%";
225
+ progress_bar= setInterval(status_progress, 10000);
226
 
227
  jQuery('input[name="quick_scan_button"]').attr('disabled', true);
228
  jQuery('input[name="custom_scan_button"]').attr('disabled', true);
241
  jQuery.post(ajaxurl, data, function(response){
242
  jQuery('#mo_scan_message').show();
243
  jQuery('#mo_scan_message').empty();
244
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
245
  if(response == "scanning_already"){
246
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
247
  jQuery("#mo_scan_message").append("A scan is currently ongoing.");
248
  window.scrollTo({ top: 0, behavior: "smooth"});
249
  document.getElementById("custom_scan_button").value = "Custom Scan";
250
  document.getElementById('custom_scan_button').style.backgroundColor = '#b0d2cf';
 
 
 
 
 
 
 
251
  }else{
252
  if(response=="ERROR"){
253
  jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
254
  jQuery("#mo_scan_message").append("Nonce did not match.");
255
  window.scrollTo({ top: 0, behavior: "smooth"});
256
+ }else if(response=="RECONFIGURE"){
257
+ jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
258
+ jQuery("#mo_scan_message").append("Please save your custom configuration again");
259
+ window.scrollTo({ top: 0, behavior: "smooth"});
260
  }else{
261
  jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
262
+ jQuery("#mo_scan_message").append("Malware Scan has started. You can see the results in scan reports tab after it is completed.");
 
 
 
 
 
 
263
  }
 
 
 
 
 
 
 
 
264
  }
265
 
266
  });
267
  });
268
 
269
  jQuery('input[name="mo_stop_button"]').click(function(){
270
+ var button_value = document.getElementById("mo_stop_button").value;
271
+ if(button_value == 'Stop Scan'){
272
+ jQuery('input[name="mo_stop_button"]').attr('disabled', true);
273
+
274
+ jQuery('input[name="mo_stop_button"]').val("Stop Scanning...");
275
+ document.getElementById('mo_stop_button').style.backgroundColor = '#b0d2cf';
276
+ var data={
277
+ 'action':'mo_wpns_malware_redirect',
278
+ 'call_type':'malware_scan_terminate'
279
+ };
280
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
281
+ jQuery.post(ajaxurl, data, function(response){
282
+ jQuery('#mo_scan_message').show();
283
+ jQuery('#mo_scan_message').empty();
284
+ jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
285
+ jQuery("#mo_scan_message").append("Scan is stopping...");
286
+ window.scrollTo({ top: 0, behavior: "smooth" });
287
+ });
288
+ }else{
 
 
 
 
289
  document.getElementById("mo_progress").style.display="none";
290
+ jQuery('#mo_scan_message').hide();
 
291
  jQuery('#mo_scan_message').empty();
292
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
293
+ }
 
 
294
  });
295
  });
296
 
300
  'call_type':'malware_progress_bar'
301
  };
302
  jQuery.post(ajaxurl, data, function(response){
303
+ jQuery("#mo_scan_message").removeClass("notice-error notice-success");
304
  var bar= document.getElementById("mo_wpns_progress_bar");
305
  if(response['status']=="COMPLETE"){
306
  document.getElementById("progress_message").innerHTML = "Scan completed";
307
  bar.style.width= 100 + "%";
308
  bar.innerHTML = 100 + "%";
309
+ jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
310
+ document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
311
+ document.getElementById('quick_scan_button').value="Quick Scan";
312
+ jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
313
+ document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
314
+ document.getElementById('standard_scan_button').value="Standard Scan";
315
+ jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
316
+ document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
317
+ document.getElementById('custom_scan_button').value="Custom Scan";
318
+ jQuery('#summary_all_scan_text').html(response['total_files']);
319
+ jQuery('#summary_current_scan_text').html(response['scan_files']);
320
+ jQuery('#summary_all_infect_text').html(response['total_mal']);
321
+ jQuery('#summary_current_infect_text').html(response['mal_files']);
322
+ jQuery('#summary_current_warning_text').html(response['warnings']);
323
+
324
+ jQuery('#mo_scan_message').show();
325
+ jQuery('#mo_scan_message').empty();
326
+ jQuery("#mo_scan_message").addClass("notice notice-success is-dismissible");
327
+ jQuery("#mo_scan_message").append("Malware Scan is complete. You can see the results in scan reports tab now.");
328
+ window.scrollTo({ top: 0, behavior: "smooth" });
329
+
330
+ jQuery('input[name="mo_stop_button"]').val("Dismiss bar");
331
+ document.getElementById('mo_stop_button').style.backgroundColor = '#20b2aa';
332
+ jQuery('input[name="mo_stop_button"]').removeAttr('disabled');
333
  clearInterval(progress_bar);
334
+ }else if(response['status']=="ABORTED"){
335
+ document.getElementById("progress_message").innerHTML = "Scan Aborted";
336
+ bar.style.width= 100 + "%";
337
+ bar.innerHTML = 100 + "%";
338
+
339
+ jQuery('input[name="quick_scan_button"]').removeAttr('disabled');
340
+ document.getElementById('quick_scan_button').style.backgroundColor = '#20b2aa';
341
+ document.getElementById('quick_scan_button').value="Quick Scan";
342
+ jQuery('input[name="standard_scan_button"]').removeAttr('disabled');
343
+ document.getElementById('standard_scan_button').style.backgroundColor = '#20b2aa';
344
+ document.getElementById('standard_scan_button').value="Standard Scan";
345
+ jQuery('input[name="custom_scan_button"]').removeAttr('disabled');
346
+ document.getElementById('custom_scan_button').style.backgroundColor = '#20b2aa';
347
+ document.getElementById('custom_scan_button').value="Custom Scan";
348
+ jQuery('#summary_all_scan_text').html(response['total_files']);
349
+ jQuery('#summary_current_scan_text').html(response['scan_files']);
350
+ jQuery('#summary_all_infect_text').html(response['total_mal']);
351
+ jQuery('#summary_current_infect_text').html(response['mal_files']);
352
+ jQuery('#summary_current_warning_text').html(response['warnings']);
353
+
354
+ jQuery('#mo_scan_message').show();
355
+ jQuery('#mo_scan_message').empty();
356
+ jQuery("#mo_scan_message").addClass("notice notice-error is-dismissible");
357
+ jQuery("#mo_scan_message").append("Malware Scan is aborted. You can check the results.");
358
+ window.scrollTo({ top: 0, behavior: "smooth" });
359
+ jQuery('input[name="mo_stop_button"]').val("Dismiss bar");
360
+ document.getElementById('mo_stop_button').style.backgroundColor = '#20b2aa';
361
+ jQuery('input[name="mo_stop_button"]').removeAttr('disabled');
362
+ clearInterval(progress_bar);
363
+ }else{
364
+ jQuery('#mo_scan_message').hide();
365
+ jQuery('#mo_scan_message').empty();
366
+ if(response['total'] === false || response['total'] == 0){
367
+ var width = 0;
368
  }else{
369
  var width= (response['scanned']/response['total'])*100;
370
  width = Math.round(width);
371
  }
372
+
373
  bar.style.width= width + "%";
374
+ if(response['repo_scan']==1 && width==85){
375
  document.getElementById("progress_message").innerHTML= "Downloading plugins/themes/wordpress files from repository...";
376
+ bar.innerHTML = width + "%";
377
  }else{
378
  document.getElementById("progress_message").innerHTML= "Scan progress...";
379
  bar.innerHTML = width + "%";
393
  $total_malicious=0;
394
  $last_scan=0;
395
  $malicious_last_scan=0;
396
+ $warning_last_scan=0;
397
  }else{
398
  $result = $mo_wpns_db_handler->get_report_with_id($send_id);
399
  $total_scan=$mo_wpns_db_handler->count_files();
400
  $total_malicious=$mo_wpns_db_handler->count_malicious_files();
401
  $last_scan=$mo_wpns_db_handler->count_files_last_scan($send_id);
402
+ // $malicious_last_scan=$mo_wpns_db_handler->count_malicious_last_scan($send_id);
403
+ $malicious_last_scan = get_option('mo_wpns_infected_files');
404
+ $warning_last_scan = get_option('mo_wpns_warning_files');
405
  if($total_scan > 999){
406
  $total_scan=($total_scan/1000);
407
  $total_scan= round($total_scan,1)."k";
410
  $total_malicious=($total_malicious/1000);
411
  $total_malicious= round($total_malicious,1)."k";
412
  }
413
+ if($last_scan > 999){
414
+ $last_scan = ($last_scan/1000);
415
+ $last_scan = round($last_scan,1)."k";
416
+ }
417
  }
418
  ?>
419
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivl" id="summary_all_scan">
420
+ <div class="title_hdiv"><b>Total Files Scanned</b></div>
421
  <hr class="line">
422
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_all_scan_text"> <?php echo $total_scan ?> </p>
423
  </div>
424
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivr mo_wpns_msdivl" id="summary_all_infect">
425
+ <div class="title_hdiv"><b>Total Infected Files</b></div>
426
  <hr class="line">
427
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_all_infect_text"> <?php echo $total_malicious ?> </p>
428
  </div>
429
  <div class="mo_wpns_sub_scansummary mo_wpns_msdivl mo_wpns_msdivr" id="summary_current_scan">
430
+ <div class="title_hdiv"><b>Files scanned in last scan</b></div>
431
  <hr class="line">
432
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_current_scan_text"> <?php echo $last_scan ?> </p>
433
  </div>
434
+ <div class="mo_wpns_sub_scansummary mo_wpns_msdivl mo_wpns_msdivr" id="summary_current_infect">
435
+ <div class="title_hdiv"><b>Infections in last scan</b></div>
436
  <hr class="line">
437
  <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_current_infect_text"> <?php echo $malicious_last_scan ?> </p>
438
  </div>
439
+ <div class="mo_wpns_sub_scansummary mo_wpns_msdivr" id="summary_current_warning">
440
+ <div class="title_hdiv"><b>Warnings in last scan</b></div>
441
+ <hr class="line">
442
+ <p class="wpns_font_size mo_wpns_scan_summary_text" id="summary_current_warning_text"> <?php echo $warning_last_scan ?> </p>
443
+ </div>
444
 
445
  <?php
446
  }