PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 6.3.2
Wordfence Security – Firewall, Malware Scan, and Login Security v6.3.2
8.2.2 8.2.1 8.2.0 3.7.1 3.7.2 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.1 4.0.1 4.0.2 4.0.3 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.1 5.1.2 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.1 5.3.10 5.3.11 5.3.12 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 6.0.1 6.0.10 6.0.11 6.0.12 6.0.14 6.0.15 6.0.16 6.0.17 6.0.18 6.0.19 6.0.2 6.0.20 6.0.21 6.0.22 6.0.23 6.0.24 6.0.25 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.1 6.1.10 6.1.11 6.1.12 6.1.14 6.1.15 6.1.16 6.1.17 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.10 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.14 6.3.15 6.3.16 6.3.17 6.3.18 6.3.19 6.3.2 6.3.20 6.3.21 6.3.22 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.14 7.1.15 7.1.16 7.1.17 7.1.18 7.1.19 7.1.2 7.1.20 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.10.0 7.10.1 7.10.2 7.10.3 7.10.4 7.10.5 7.10.6 7.10.7 7.11.0 7.11.1 7.11.2 7.11.3 7.11.4 7.11.5 7.11.6 7.11.7 7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.4.0 7.4.1 7.4.10 7.4.11 7.4.12 7.4.14 7.4.2 7.4.3 trunk 7.4.4 1.1 7.4.5 1.2 7.4.6 1.3 7.4.7 1.3.1 7.4.8 1.3.2 7.4.9 1.3.3 7.5.0 1.4.2 7.5.1 1.4.3 7.5.10 1.4.4 7.5.11 1.4.5 7.5.2 1.4.6 7.5.3 1.4.7 7.5.4 1.4.8 7.5.5 1.5.1 7.5.6 1.5.2 7.5.7 1.5.3 7.5.8 1.5.4 7.5.9 1.5.5 7.6.0 1.5.6 7.6.1 2.0.1 7.6.2 2.0.2 7.7.0 2.0.3 7.7.1 2.0.5 7.8.0 2.0.6 7.8.1 2.0.7 7.8.2 2.1.0 7.9.0 2.1.1 7.9.1 2.1.2 7.9.2 2.1.3 7.9.3 2.1.4 8.0.0 2.1.5 8.0.1 3.0.2 8.0.2 3.0.3 8.0.3 3.0.4 8.0.4 3.0.5 8.0.5 3.0.6 8.1.0 3.0.7 8.1.1 3.0.8 8.1.2 3.0.9 8.1.3 3.1.0 8.1.4 3.1.1 v1.4.1 3.1.2 3.1.4 3.1.6 3.2.1 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.1 3.4.4 3.4.5 3.5.1 3.5.2 3.6.1 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
wordfence / lib / wfCrawl.php
wordfence / lib Last commit date
Diff 9 years ago dashboard 9 years ago .htaccess 14 years ago Diff.php 14 years ago GeoIP.dat 9 years ago GeoIPv6.dat 9 years ago IPTraf.php 9 years ago compat.php 10 years ago conntest.php 11 years ago cronview.php 10 years ago dashboard.php 9 years ago dbview.php 11 years ago diffResult.php 11 years ago email_genericAlert.php 9 years ago email_newIssues.php 9 years ago email_passwdChanged.php 10 years ago email_pleaseChangePasswd.php 10 years ago email_unlockRequest.php 11 years ago live_activity.php 9 years ago menu_activity.php 9 years ago menu_blocking.php 9 years ago menu_blocking_advancedBlocking.php 9 years ago menu_blocking_blockedIPs.php 9 years ago menu_blocking_countryBlocking.php 9 years ago menu_dashboard.php 9 years ago menu_firewall.php 9 years ago menu_firewall_bruteForce.php 9 years ago menu_firewall_rateLimiting.php 9 years ago menu_firewall_waf.php 9 years ago menu_options.php 9 years ago menu_scan.php 9 years ago menu_scan_options.php 9 years ago menu_scan_scan.php 9 years ago menu_scan_schedule.php 9 years ago menu_tools.php 9 years ago menu_tools_diagnostic.php 9 years ago menu_tools_passwd.php 9 years ago menu_tools_twoFactor.php 9 years ago menu_tools_whois.php 9 years ago pageTitle.php 9 years ago schedWeekEntry.php 12 years ago sysinfo.php 10 years ago unknownFiles.php 11 years ago viewFullActivityLog.php 9 years ago wf503.php 9 years ago wfAPI.php 9 years ago wfAction.php 14 years ago wfActivityReport.php 9 years ago wfArray.php 13 years ago wfBrowscap.php 12 years ago wfBrowscapCache.php 9 years ago wfBulkCountries.php 13 years ago wfCache.php 9 years ago wfConfig.php 9 years ago wfCountryMap.php 13 years ago wfCrawl.php 10 years ago wfCrypt.php 11 years ago wfDB.php 9 years ago wfDashboard.php 9 years ago wfDiagnostic.php 9 years ago wfDict.php 14 years ago wfDirectoryIterator.php 11 years ago wfGeoIP.php 9 years ago wfHelperBin.php 11 years ago wfHelperString.php 11 years ago wfIPWhitelist.php 9 years ago wfIssues.php 9 years ago wfLockedOut.php 9 years ago wfLog.php 9 years ago wfMD5BloomFilter.php 9 years ago wfNotification.php 9 years ago wfRESTAPI.php 9 years ago wfRate.php 10 years ago wfScan.php 9 years ago wfScanEngine.php 9 years ago wfSchema.php 9 years ago wfStyle.php 9 years ago wfUnlockMsg.php 10 years ago wfUpdateCheck.php 9 years ago wfUtils.php 9 years ago wfView.php 10 years ago wfViewResult.php 11 years ago wordfenceClass.php 9 years ago wordfenceConstants.php 9 years ago wordfenceHash.php 9 years ago wordfenceScanner.php 9 years ago wordfenceURLHoover.php 9 years ago
wfCrawl.php
183 lines
1 <?php
2 require_once('wfUtils.php');
3 class wfCrawl {
4 public static function isCrawler($UA){
5 $browscap = new wfBrowscap();
6 $b = $browscap->getBrowser($UA);
7 if (!$b || $b['Parent'] == 'DefaultProperties') {
8 $log = new wfLog(wfConfig::get('apiKey'), wfUtils::getWPVersion());
9 $IP = wfUtils::getIP();
10 return !(isset($_COOKIE['wordfence_verifiedHuman']) && $log->validateVerifiedHumanCookie($_COOKIE['wordfence_verifiedHuman'], $UA, $IP));
11 }
12 else if (isset($b['Crawler']) && $b['Crawler']) {
13 return true;
14 }
15
16 return false;
17 }
18 public static function verifyCrawlerPTR($hostPattern, $IP){
19 global $wpdb; $table = $wpdb->base_prefix . 'wfCrawlers';
20 $db = new wfDB();
21 $IPn = wfUtils::inet_pton($IP);
22 $status = $db->querySingle("select status from $table where IP=%s and patternSig=UNHEX(MD5('%s')) and lastUpdate > unix_timestamp() - %d", $IPn, $hostPattern, WORDFENCE_CRAWLER_VERIFY_CACHE_TIME);
23 if($status){
24 if($status == 'verified'){
25 return true;
26 } else {
27 return false;
28 }
29 }
30 $host = wfUtils::reverseLookup($IP);
31 if(! $host){
32 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'noPTR', '', 'noPTR', '');
33 return false;
34 }
35 if(preg_match($hostPattern, $host)){
36 $resultIPs = wfUtils::resolveDomainName($host);
37 $addrsMatch = false;
38 foreach($resultIPs as $resultIP){
39 if($resultIP == $IP){
40 $addrsMatch = true;
41 break;
42 }
43 }
44 if($addrsMatch){
45 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'verified', $host, 'verified', $host);
46 return true;
47 } else {
48 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'fwdFail', $host, 'fwdFail', $host);
49 return false;
50 }
51 } else {
52 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'badPTR', $host, 'badPTR', $host);
53 return false;
54 }
55 }
56 public static function isGooglebot($userAgent = null){
57 if ($userAgent === null) {
58 $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
59 }
60 return (bool) preg_match('/Googlebot\/\d\.\d/', $userAgent);
61 }
62 public static function isGoogleCrawler($userAgent = null){
63 if ($userAgent === null) {
64 $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
65 }
66 foreach (self::$googPat as $pat) {
67 if (preg_match($pat . 'i', $userAgent)) {
68 return true;
69 }
70 }
71 return false;
72 }
73 private static $googPat = array(
74 '@^Mozilla/5\\.0 \\(.*Google Keyword Tool.*\\)$@',
75 '@^Mozilla/5\\.0 \\(.*Feedfetcher\\-Google.*\\)$@',
76 '@^Feedfetcher\\-Google\\-iGoogleGadgets.*$@',
77 '@^searchbot admin\\@google\\.com$@',
78 '@^Google\\-Site\\-Verification.*$@',
79 '@^Google OpenSocial agent.*$@',
80 '@^.*Googlebot\\-Mobile/2\\..*$@',
81 '@^AdsBot\\-Google\\-Mobile.*$@',
82 '@^google \\(.*Enterprise.*\\)$@',
83 '@^Mediapartners\\-Google.*$@',
84 '@^GoogleFriendConnect.*$@',
85 '@^googlebot\\-urlconsole$@',
86 '@^.*Google Web Preview.*$@',
87 '@^Feedfetcher\\-Google.*$@',
88 '@^AppEngine\\-Google.*$@',
89 '@^Googlebot\\-Video.*$@',
90 '@^Googlebot\\-Image.*$@',
91 '@^Google\\-Sitemaps.*$@',
92 '@^Googlebot/Test.*$@',
93 '@^Googlebot\\-News.*$@',
94 '@^.*Googlebot/2\\.1.*$@',
95 '@^AdsBot\\-Google.*$@',
96 '@^Google$@'
97 );
98
99
100 /**
101 * Has correct user agent and PTR record points to .googlebot.com domain.
102 *
103 * @param string|null $ip
104 * @param string|null $ua
105 * @return bool
106 */
107 public static function isVerifiedGoogleCrawler($ip = null, $ua = null) {
108 static $verified;
109 if (!isset($verified)) {
110 $verified = array();
111 }
112 if ($ip === null) {
113 $ip = wfUtils::getIP();
114 }
115 if (array_key_exists($ip, $verified)) {
116 return $verified[$ip];
117 }
118 if (self::isGoogleCrawler($ua)) {
119 if (self::verifyCrawlerPTR(wordfence::getLog()->getGooglePattern(), $ip)) {
120 $verified[$ip] = true;
121 return $verified[$ip];
122 }
123 if (self::verifyGooglebotViaNOC1($ip)) {
124 $verified[$ip] = true;
125 return $verified[$ip];
126 }
127 }
128 $verified[$ip] = false;
129 return $verified[$ip];
130 }
131
132 /**
133 * @param string|null $ip
134 * @return bool
135 */
136 public static function verifyGooglebotViaNOC1($ip = null) {
137 global $wpdb;
138 $table = $wpdb->base_prefix . 'wfCrawlers';
139 if ($ip === null) {
140 $ip = wfUtils::getIP();
141 }
142 $db = new wfDB();
143 $IPn = wfUtils::inet_pton($ip);
144 $patternSig = 'googlenoc1';
145 $status = $db->querySingle("select status from $table
146 where IP=%s
147 and patternSig=UNHEX(MD5('%s'))
148 and lastUpdate > unix_timestamp() - %d",
149 $IPn,
150 $patternSig,
151 WORDFENCE_CRAWLER_VERIFY_CACHE_TIME);
152 if ($status === 'verified') {
153 return true;
154 } else if ($status === 'fakeBot') {
155 return false;
156 }
157
158 $api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
159 try {
160 $data = $api->call('verify_googlebot', array(
161 'ip' => $ip,
162 ));
163 if (is_array($data) && !empty($data['verified'])) {
164 // Cache results
165 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate)
166 values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp())
167 ON DUPLICATE KEY UPDATE status='%3\$s', lastUpdate=unix_timestamp()",
168 $IPn, $patternSig, 'verified');
169 return true;
170 } else {
171 $db->queryWrite("insert into $table (IP, patternSig, status, lastUpdate)
172 values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp())
173 ON DUPLICATE KEY UPDATE status='%3\$s', lastUpdate=unix_timestamp()",
174 $IPn, $patternSig, 'fakeBot');
175 }
176 } catch (Exception $e) {
177 // Do nothing, bail
178 }
179 return false;
180 }
181 }
182 ?>
183