-
Notifications
You must be signed in to change notification settings - Fork 6
/
wp-hardening.php
115 lines (90 loc) · 2.96 KB
/
wp-hardening.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php /** @noinspection PhpUnused */
if (!defined('ABSPATH')) exit ('Peekaboo!');
/*
Plugin Name: WP Hardening
Plugin URI: https://www.getastra.com/
Description: Harden your WordPress security by fixing 20 common security loopholes by just a click.
Version: 1.1.2
Author: Astra Security
Author URI: https://www.getastra.com/
Stable tag: 1.1.2
*/
// core initiation
if (!class_Exists('wphMainStart')) {
class wphMainStart
{
public $locale;
function __construct($locale, $includes, $path)
{
$this->locale = $locale;
// include files
foreach ($includes as $single_path) {
include($path . $single_path);
}
// calling localization
add_action('plugins_loaded', array($this, 'myplugin_init'));
//register_activation_hook(__FILE__, array( $this, 'set_cron') );
}
function myplugin_init()
{
$plugin_dir = dirname(plugin_basename(__FILE__)) . '/languages';
load_plugin_textdomain($this->locale, false, $plugin_dir);
}
function set_cron()
{
// cron to check issues
wp_clear_scheduled_hook('whp_task_hook');
if (!wp_next_scheduled('whp_task_hook')) {
wp_schedule_event(time(), 'daily', 'whp_task_hook');
}
}
}
}
// initiate main class
new wphMainStart('whp', array(
'modules/formElementsClass.php',
'modules/functions.php',
'modules/scripts.php',
'modules/hooks.php',
'modules/ajax.php',
'modules/settings.php',
), dirname(__FILE__) . '/');
register_activation_hook(__FILE__, 'whp_plugin_activation');
function whp_plugin_activation()
{
// init fixers
$init_array = array(
'hide_wp_version_number' => 'on',
'remove_wp_meta_gen_tag' => 'on',
'remove_wpml_meta_gen_tag' => 'on',
'remove_revo_slider_meta_gen_tag' => 'on',
'remove_vc_meta_gen_tag' => 'on',
'remove_css_meta_gen_tag' => 'on',
'remove_js_meta_gen_tag' => 'on',
'stop_user_enumeration' => 'on',
'change_login_url' => 'off',
'disable_xml_rpc' => 'on',
'disable_json_api' => 'on',
'hide_includes_dir_listing' => 'on',
'disable_file_editor' => 'on',
);
update_option('whp_fixer_option', $init_array);
update_site_option('whp_admin_page', 'login');
update_option('whp_admin_page', 'login');
// hide wp-in
if (is_writable(ABSPATH . "wp-includes")) {
$handle = fopen(ABSPATH . "wp-includes/index.php", "w");
fclose($handle);
}
}
/**
* Add settings action link to the plugins page.
*/
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'add_action_links' );
function add_action_links ( $links ) {
$settings_link = array(
'<a href="' . admin_url( 'admin.php?page=wphwp_harden_fixers') . '">' . __('Settings') . '</a>',
);
return array_merge( $links, $settings_link );
}
?>