wp-beagleSettings.php
7.71 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
* @link https://beaglesecurity.com/
* @since 1.0.7
* @package Beagle Security
*
* @wordpress-plugin
* Plugin Name: Beagle Security - WP Security, Advanced Penetration Testing
* Plugin URI: https://beaglesecurity.com/wordpress-security-testing
* Description: Secure your WordPress website from the latest vulnerabilities with automated in-depth penetration testing.
* Version: 1.0.7
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Beagle Security
* Author URI: https://beaglesecurity.com/
* License: GPL v2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: Beagle wordpress scan
* Domain Path: /languages
*/
/*
Beagle Security - WP Security, Advanced Penetration Testing, 2021 Beagle Security
This plugin is distributed under the terms of the GNU GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; If not, see {License URI}.
*/
/* Basic Securtiy*/
defined('ABSPATH') or die("No Access");
if (!defined('ABSPATH')) {
define('ABSPATH', dirname(__FILE__), '/');
}
class Beagle_WordPress_Scan
{
function __construct()
{
add_action('init', array($this, 'Beagle_WP_table_create'));
}
// for plugin activate
function activate_Beagle_plugin()
{
flush_rewrite_rules();
}
// for plugin deactivate
function deactivate_Beagle_plugin()
{
global $wpdb;
$Beagle_WP_scan_table = $wpdb->prefix . 'beagleScanData';
$sql = "DROP TABLE IF EXISTS $Beagle_WP_scan_table";
$wpdb->query($sql);
delete_option("my_plugin_db_version");
flush_rewrite_rules();
}
function Beagle_WP_table_create()
{
flush_rewrite_rules();
global $wpdb;
$Beagle_WP_scan_table = $wpdb->prefix . "beagleScanData";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS $Beagle_WP_scan_table( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, access_token VARCHAR(50) NOT NULL, application_token VARCHAR(50) NOT NULL, status VARCHAR(50) NOT NULL, result_token VARCHAR(50), verified BOOLEAN NOT NULL,title VARCHAR(20),url VARCHAR(50),runningStatus VARCHAR(10), autoVerify BOOLEAN)DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;";
require_once(ABSPATH . "wp-admin/includes/upgrade.php");
dbDelta($sql);
}
}
if (class_exists('Beagle_WordPress_Scan')) {
$beagleWPscanStart = new Beagle_WordPress_Scan();
// activation hook
register_deactivation_hook(__FILE__, array($beagleWPscanStart, 'activate_Beagle_plugin'));
// deactivation hook
register_deactivation_hook(__FILE__, array($beagleWPscanStart, 'deactivate_Beagle_plugin'));
}
add_action('admin_menu', 'Beagle_Menu_Page');
/*Adding submenu page of plugin to the main menu*/
function Beagle_Menu_Page()
{
add_menu_page('Beagle Plugin', 'Beagle Security', 'manage_options', 'Beagle_Plugin', 'Beagle_WP_Page_Content', 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd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05hZFNzNVljNjRIYTRiTjExeVI4VUZTNGEyeHE0MzVySmxiN3hGaXB6UHR5U3Y4akFMU1pKbjJaWGUgWE1xZW9BaUYwMjQ2WXRwTHJaYmQxMmFmSVl2Rm4yVWlCM012SzFuSXlSelBRUHJTRUZFelhxUSsvUm5OZzF6TWdWcjVHMzRucUZHTyBSOWpIQUFBQUpYUkZXSFJrWVhSbE9tTnlaV0YwWlFBeU1ESXhMVEF5TFRBMlZERXhPalEyT2pJMkt6QXlPakF3U2pPczNRQUFBQ1YwIFJWaDBaR0YwWlRwdGIyUnBabmtBTWpBeU1TMHdNaTB3TmxReE1UbzBOam95Tmlzd01qb3dNRHR1RkdFQUFBQUFTVVZPUks1Q1lJST0iLz4KPC9zdmc+');
}
/*to declare the apis globally*/
global $apiServerBaseUrl;
$apiServerBaseUrl = "https://api.beaglesecurity.com/v1/";
/*calling the option menu to enter access token and application token and to submit it*/
require plugin_dir_path(__FILE__) . 'Admin/optionPageContent.php';
/*hooks the post method to start the test when the user clicks 'start test' button*/
if (isset($_POST['startBeagleTest'])) {
$_POST = array();
add_action('admin_init', 'Beagle_WP_start_Test');
}
/*hooks the post method to stop the test when the user clicks 'stop test' button*/
if (isset($_POST['stopBeagleTest'])) {
add_action('admin_init', 'Beagle_WP_stop_Test');
}
/*hooks the post method to restart the test when the user clicks 'start test' button after pressing stop button*/
if (isset($_POST['restartBeagleTest'])) {
add_action('admin_init', 'Beagle_WP_stop_Test');
}
/*erases the data in database when the user wants to delete the test details*/
if (isset($_POST['delete'])) {
add_action('admin_init', 'Beagle_WP_delete_Test');
}
/*hooks the post method to verify the domain*/
if (isset($_POST['startVerify'])) {
add_action('admin_init', 'Beagle_WP_addDataTo_DB');
}
if (isset($_POST['verify'])) {
add_action('admin_init', 'Beagle_WP_verify_Token');
}
/*calling startTest.php file to begin test*/
require plugin_dir_path(__FILE__) . 'Admin/startTest.php';
/*calling stopTest.php file to stop test*/
require plugin_dir_path(__FILE__) . 'Admin/stopTest.php';
/*calling deleteTest.php file to delete the data of test*/
require plugin_dir_path(__FILE__) . 'Admin/deleteTest.php';
/*calling insertInToTable.php file to add data to db*/
require plugin_dir_path(__FILE__) . 'Admin/insertInToTable.php';
/*calling getStatus.php file to get status of test*/
require plugin_dir_path(__FILE__) . 'Admin/getStatus.php';
/*calling getResultData.php file to get result of test*/
require plugin_dir_path(__FILE__) . 'Admin/getResultData.php';
/*calling verify.php */
require plugin_dir_path(__FILE__) . 'Admin/verifyToken.php';
/*calling updateVerify.php */
require plugin_dir_path(__FILE__) . 'Admin/updateVerify.php';
/*calling updateVerifyFailed.php */
require plugin_dir_path(__FILE__) . 'Admin/autoVerifyFailed.php';
// for status data
add_action('wp_ajax_t4a_ajax_call', 'Beagle_WP_getStatusOf_CurrentTestData');
// for result data
add_action('wp_ajax_t4a_ajax_call_result', 'Beagle_WP_getResultOf_CurrentTestData');
// for delete application
add_action('wp_ajax_t4a_ajax_call_delete', 'Beagle_WP_delete_Test');
// for verify application
add_action('wp_ajax_t4a_ajax_call_verify', 'Beagle_WP_verify_Token');
// for update verify application
add_action('wp_ajax_t4a_ajax_call_verify_update', 'Beagle_WP_verify_Token_Update');
// for update verify failed condition
add_action('wp_ajax_t4a_ajax_call_verify_update_failed', 'Beagle_WP_auto_Verify');