prefix; return [ ['table' => $p . 'wpmm_waf_events', 'type' => 'web', 'where' => "action IN ('block','log')"], // Each failed login is stored in login_attempts AND mirrored here as "Failed login attempt"; // count it once (under login), not twice. ['table' => $p . 'wpmm_firewall_events', 'type' => 'firewall', 'where' => "NOT (category = 'brute_force' AND reason LIKE 'Failed login attempt%')"], ['table' => $p . 'wpmm_login_attempts', 'type' => 'login', 'where' => '1=1'], ['table' => $p . 'wpmm_honeypot_hits', 'type' => 'honeypot', 'where' => '1=1'], ]; } public static function build() { global $wpdb; $since = gmdate('Y-m-d H:i:s', time() - self::DAYS * DAY_IN_SECONDS); $per_ip = []; $total = 0; $by_type = ['web' => 0, 'firewall' => 0, 'login' => 0, 'honeypot' => 0]; foreach (self::sources() as $src) { if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $src['table'])) !== $src['table']) continue; $t = $src['table']; $count = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $t WHERE created_at >= %s AND {$src['where']}", $since)); $total += $count; $by_type[$src['type']] += $count; if (!$count) continue; $rows = $wpdb->get_results($wpdb->prepare("SELECT ip_address ip, COUNT(*) n FROM $t WHERE created_at >= %s AND {$src['where']} AND ip_address <> '' GROUP BY ip_address ORDER BY n DESC LIMIT 400", $since), ARRAY_A); foreach ((array) $rows as $r) { $ip = (string) $r['ip']; if (!isset($per_ip[$ip])) $per_ip[$ip] = ['n' => 0, 'types' => []]; $per_ip[$ip]['n'] += (int) $r['n']; $per_ip[$ip]['types'][$src['type']] = ($per_ip[$ip]['types'][$src['type']] ?? 0) + (int) $r['n']; } } uasort($per_ip, function ($a, $b) { return $b['n'] <=> $a['n']; }); $per_ip = array_slice($per_ip, 0, 400, true); $geo = $per_ip && class_exists('WPMM_GeoIP') ? WPMM_GeoIP::lookup_many(array_keys($per_ip), 10) : []; $countries = []; $pending = 0; $unknown = 0; foreach ($per_ip as $ip => $info) { if (!array_key_exists($ip, $geo)) { $pending++; continue; } $cc = $geo[$ip]; if ($cc === '' || !preg_match('/^[A-Z]{2}$/', $cc)) { $unknown++; continue; } if (!isset($countries[$cc])) $countries[$cc] = ['cc' => $cc, 'events' => 0, 'ips' => 0, 'types' => []]; $countries[$cc]['events'] += $info['n']; $countries[$cc]['ips']++; foreach ($info['types'] as $k => $v) $countries[$cc]['types'][$k] = ($countries[$cc]['types'][$k] ?? 0) + $v; } usort($countries, function ($a, $b) { return $b['events'] <=> $a['events']; }); $site_cc = ''; $srv = isset($_SERVER['SERVER_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR'])) : ''; if ($srv && filter_var($srv, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) && class_exists('WPMM_GeoIP')) { $site_cc = (string) (WPMM_GeoIP::lookup_many([$srv], 5)[$srv] ?? ''); } return [ 'window_days' => self::DAYS, 'total' => $total, 'by_type' => $by_type, 'ips' => count($per_ip), 'ips_capped' => count($per_ip) >= 400, 'countries' => array_slice($countries, 0, 60), 'pending' => $pending, 'unknown' => $unknown, 'site_cc' => $site_cc, 'geo' => self::geo_status(), // Each requirement for placing attackers on the map, for the checklist under the map. 'geo_checks' => [ 'lookups' => class_exists('WPMM_GeoIP') && WPMM_GeoIP::country_lookup_enabled(), 'licensed' => class_exists('WPMM_License') && WPMM_License::is_valid(), 'service' => !get_transient('wpmm_geo_server_unavailable'), ], 'built_at' => time(), ]; } // Why attackers can or can't be placed on the map: lookups are opt-in (they send IPs to the // Silent Threads service), need an active plan, and pause for an hour if the service is down. public static function geo_status() { if (!class_exists('WPMM_GeoIP') || !WPMM_GeoIP::country_lookup_enabled()) return 'off'; if (!class_exists('WPMM_License') || !WPMM_License::is_valid()) return 'unlicensed'; if (get_transient('wpmm_geo_server_unavailable')) return 'unavailable'; return 'ok'; } public static function ajax() { check_ajax_referer('wpmm_attack_map', 'nonce'); if (!current_user_can('manage_options')) wp_send_json_error(['message' => 'Permission denied'], 403); $data = get_transient(self::CACHE); // Rebuild at once when the reason changed (e.g. country lookups were just turned on). if (is_array($data) && (($data['geo'] ?? '') !== self::geo_status() || !isset($data['geo_checks']))) $data = null; if (!is_array($data)) { $data = self::build(); set_transient(self::CACHE, $data, $data['pending'] ? 2 * MINUTE_IN_SECONDS : 15 * MINUTE_IN_SECONDS); } wp_send_json_success($data); } public static function render_card() { if (!current_user_can('manage_options')) return; $world = WPMM_FS::read(WPMM_PLUGIN_DIR . 'assets/world-map.json'); if (!$world) return; ?>

Where attacks on this site come from

Blocked and logged attacks in the last 30 days: firewall, login attempts and honeypot traps.

-Attacks
-Attacker IPs
-Countries
Top countries
  • Loading...
(function () { var W = ; var root = document.getElementById('wpmm-attack-map'), cv = document.getElementById('wpmm-am-canvas'), tip = document.getElementById('wpmm-am-tip'); if (!root || !cv || !cv.getContext) return; var ctx = cv.getContext('2d'), bits = Uint8Array.from(atob(W.mask), function (c) { return c.charCodeAt(0); }); var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; var data = null, base = null, cell = 4, dpr = Math.min(2, window.devicePixelRatio || 1), running = false, visible = true, last = 0, t0 = performance.now(); function proj(lon, lat) { return [(lon + 180) / W.step * cell, (W.lat_top - lat) / W.step * cell]; } function flag(cc) { return cc.replace(/./g, function (ch) { return String.fromCodePoint(127397 + ch.charCodeAt(0)); }); } function name(cc) { return (W.centroids[cc] && W.centroids[cc][2]) || cc; } function size() { var w = cv.parentNode.clientWidth || 600; cell = w / W.cols; var h = Math.round(W.rows * cell); cv.style.height = h + 'px'; cv.width = Math.round(w * dpr); cv.height = Math.round(h * dpr); base = document.createElement('canvas'); base.width = cv.width; base.height = cv.height; var b = base.getContext('2d'); b.scale(dpr, dpr); b.fillStyle = 'rgba(232,225,213,0.30)'; var r = Math.max(0.8, cell * 0.28); for (var i = 0; i < W.cols * W.rows; i++) { if (!((bits[i >> 3] >> (7 - (i & 7))) & 1)) continue; var cx = (i % W.cols + 0.5) * cell, cy = (Math.floor(i / W.cols) + 0.5) * cell; b.beginPath(); b.arc(cx, cy, r, 0, 6.2832); b.fill(); } } function points() { if (!data) return []; var max = data.countries.length ? data.countries[0].events : 1; return data.countries.filter(function (c) { return W.centroids[c.cc]; }).slice(0, 30).map(function (c, i) { var p = proj(W.centroids[c.cc][0], W.centroids[c.cc][1]); return { c: c, x: p[0], y: p[1], r: 2.5 + 7 * Math.sqrt(c.events / max), ph: (i * 0.37) % 1 }; }); } function frame(now) { if (!base) return; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, cv.width, cv.height); ctx.drawImage(base, 0, 0); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); var t = (now - t0) / 1000, pts = points(); var site = data && data.site_cc && W.centroids[data.site_cc] ? proj(W.centroids[data.site_cc][0], W.centroids[data.site_cc][1]) : null; if (site) { pts.slice(0, 12).forEach(function (p, i) { if (Math.abs(p.x - site[0]) < 2 && Math.abs(p.y - site[1]) < 2) return; var mx = (p.x + site[0]) / 2, my = Math.min(p.y, site[1]) - Math.abs(p.x - site[0]) * 0.25 - 10; ctx.strokeStyle = 'rgba(232,225,213,0.07)'; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(p.x, p.y); ctx.quadraticCurveTo(mx, my, site[0], site[1]); ctx.stroke(); if (!reduce) { var k = ((t * 0.45) + p.ph) % 1, u = 1 - k; var x = u * u * p.x + 2 * u * k * mx + k * k * site[0], y = u * u * p.y + 2 * u * k * my + k * k * site[1]; ctx.fillStyle = 'rgba(232,225,213,0.85)'; ctx.beginPath(); ctx.arc(x, y, 1.8, 0, 6.2832); ctx.fill(); if (k > 0.94) { ctx.strokeStyle = 'rgba(208,104,123,' + ((1 - k) * 12).toFixed(2) + ')'; ctx.lineWidth = 2; ctx.beginPath(); ctx.arc(site[0], site[1], 9 + (k - 0.94) * 120, 0, 6.2832); ctx.stroke(); } } }); } pts.forEach(function (p) { var g = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.r * 2.6); g.addColorStop(0, 'rgba(208,104,123,0.55)'); g.addColorStop(1, 'rgba(208,104,123,0)'); ctx.fillStyle = g; ctx.beginPath(); ctx.arc(p.x, p.y, p.r * 2.6, 0, 6.2832); ctx.fill(); ctx.fillStyle = '#D0687B'; ctx.beginPath(); ctx.arc(p.x, p.y, Math.max(2, p.r * 0.45), 0, 6.2832); ctx.fill(); if (!reduce) { var q = (t * 0.6 + p.ph) % 1; ctx.strokeStyle = 'rgba(208,104,123,' + (0.5 * (1 - q)).toFixed(2) + ')'; ctx.lineWidth = 1.2; ctx.beginPath(); ctx.arc(p.x, p.y, p.r * (0.6 + q * 1.8), 0, 6.2832); ctx.stroke(); } }); if (site) { ctx.fillStyle = 'rgba(181,138,69,0.22)'; ctx.beginPath(); ctx.arc(site[0], site[1], 10, 0, 6.2832); ctx.fill(); ctx.fillStyle = '#B58A45'; ctx.beginPath(); ctx.arc(site[0], site[1], 4, 0, 6.2832); ctx.fill(); } } function loop(now) { if (!running) return; if (now - last > 33) { last = now; frame(now); } requestAnimationFrame(loop); } function start() { if (reduce || running || !visible || document.hidden) { frame(performance.now()); return; } running = true; requestAnimationFrame(loop); } function stop() { running = false; } function fill(d) { data = d; var fmt = function (n) { return Number(n).toLocaleString(); }; document.getElementById('wpmm-am-total').textContent = fmt(d.total); document.getElementById('wpmm-am-ips').textContent = fmt(d.ips) + (d.ips_capped ? '+' : ''); document.getElementById('wpmm-am-countries').textContent = fmt(d.countries.length); var list = document.getElementById('wpmm-am-list'); list.textContent = ''; var why = { off: ['Countries are hidden because country lookups are off. ', 'Turn on country lookups', , ' (Settings, Privacy) to place these attacks on the map.'], unlicensed: ['Placing attackers on the map needs an active plan (the free plan works). ', 'Activate the plugin', , ' to turn it on.'], unavailable: ['The location service could not be reached. The map tries again within the hour.', '', '', ''] }; if (!d.countries.length) { var li = document.createElement('li'); li.style.gridTemplateColumns = '1fr'; li.style.display = 'block'; var w = d.total && d.pending && why[d.geo]; if (w && d.geo_checks) { li.textContent = 'No countries yet. See the checklist below the map.'; } else if (w) { li.appendChild(document.createTextNode(w[0])); if (w[1]) { var a = document.createElement('a'); a.href = w[2]; a.textContent = w[1]; li.appendChild(a); li.appendChild(document.createTextNode(w[3])); } } else { li.textContent = d.total ? (d.pending ? 'Locating attackers... check back in a few minutes.' : 'These attacks came from private or unknown addresses, so they have no country.') : 'No attacks recorded in the last 30 days.'; } list.appendChild(li); } var max = d.countries.length ? d.countries[0].events : 1; d.countries.slice(0, 8).forEach(function (c) { var li = document.createElement('li'); var f = document.createElement('span'); f.textContent = flag(c.cc); var n = document.createElement('span'); n.textContent = name(c.cc); var v = document.createElement('b'); v.textContent = fmt(c.events); var bar = document.createElement('i'); bar.className = 'bar'; bar.style.width = Math.max(4, Math.round(c.events / max * 100)) + '%'; li.appendChild(f); li.appendChild(n); li.appendChild(v); li.appendChild(bar); list.appendChild(li); }); // Under the map: what placing attackers by country needs, and which of it is in place. var help = document.getElementById('wpmm-am-help'); help.textContent = ''; var gc = d.geo_checks; if (gc && d.total && d.pending && d.geo !== 'ok') { var h = document.createElement('strong'); h.textContent = 'Why the map shows no countries yet'; help.appendChild(h); var p0 = document.createElement('p'); p0.textContent = 'The attacks are counted above. Placing them on the map by country needs all three of these:'; help.appendChild(p0); var ul = document.createElement('ul'); [ [gc.lookups, 'Country lookups turned on', 'Off by default, because it sends attacker IP addresses to the Silent Threads service.', 'Turn on in Settings', ], [gc.licensed, 'The plugin activated', 'Any plan works, including the free plan.', 'Activate', ], [gc.service, 'The location service reachable', 'If it can\'t be reached, the plugin tries again within the hour.', '', ''] ].forEach(function (r) { var li = document.createElement('li'); li.className = r[0] ? 'is-ok' : 'is-missing'; var mark = document.createElement('span'); mark.className = 'mark'; mark.textContent = r[0] ? '✓' : '✕'; mark.setAttribute('aria-label', r[0] ? 'Done' : 'Missing'); var body = document.createElement('span'); var t = document.createElement('b'); t.textContent = r[1]; body.appendChild(t); body.appendChild(document.createTextNode(' — ' + r[2])); if (!r[0] && r[3]) { body.appendChild(document.createTextNode(' ')); var a = document.createElement('a'); a.href = r[4]; a.textContent = r[3]; body.appendChild(a); } li.appendChild(mark); li.appendChild(body); ul.appendChild(li); }); help.appendChild(ul); help.hidden = false; } else { help.hidden = true; } var note = []; if (d.site_cc && W.centroids[d.site_cc]) note.push('Gold marks this site\'s server (' + name(d.site_cc) + ').'); if (d.pending && (d.geo === 'ok' || !d.geo)) note.push('Locating ' + d.pending + ' more IP address(es) - the map fills in automatically.'); if (d.pending && d.countries.length && why[d.geo]) note.push(d.pending + ' IP address(es) are not placed: ' + why[d.geo][0].trim()); if (d.unknown) note.push(d.unknown + ' IP address(es) could not be located.'); document.getElementById('wpmm-am-note').textContent = note.join(' '); frame(performance.now()); start(); } function load() { var fd = new FormData(); fd.append('action', 'wpmm_attack_map'); fd.append('nonce', ); fetch(, {method: 'POST', body: fd, credentials: 'same-origin'}) .then(function (r) { return r.json(); }).then(function (r) { if (r && r.success) fill(r.data); }).catch(function () {}); } cv.addEventListener('mousemove', function (e) { var rect = cv.getBoundingClientRect(), x = e.clientX - rect.left, y = e.clientY - rect.top, hit = null; points().forEach(function (p) { if (Math.hypot(p.x - x, p.y - y) <= Math.max(8, p.r * 1.4)) hit = p; }); if (!hit) { tip.style.display = 'none'; return; } var ty = hit.c.types || {}, parts = []; if (ty.web) parts.push(ty.web + ' web'); if (ty.login) parts.push(ty.login + ' login'); if (ty.firewall) parts.push(ty.firewall + ' firewall'); if (ty.honeypot) parts.push(ty.honeypot + ' honeypot'); tip.textContent = flag(hit.c.cc) + ' ' + name(hit.c.cc) + ' - ' + hit.c.events.toLocaleString() + ' attacks (' + parts.join(', ') + ')'; tip.style.display = 'block'; tip.style.left = Math.min(x + 12, rect.width - tip.offsetWidth - 4) + 'px'; tip.style.top = Math.max(0, y - 30) + 'px'; }); cv.addEventListener('mouseleave', function () { tip.style.display = 'none'; }); if ('IntersectionObserver' in window) new IntersectionObserver(function (es) { visible = es[0].isIntersecting; visible ? start() : stop(); }).observe(root); document.addEventListener('visibilitychange', function () { document.hidden ? stop() : start(); }); if ('ResizeObserver' in window) new ResizeObserver(function () { size(); frame(performance.now()); }).observe(cv.parentNode); else size(); size(); (window.requestIdleCallback || function (f) { setTimeout(f, 200); })(load); setInterval(function () { if (!document.hidden) load(); }, 5 * 60 * 1000); })();