@@ -1,4 +1,7 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | require_once(BB2_CORE . "/roundtripdns.inc.php"); |
4 | 7 | |
@@ -6,8 +9,13 @@ discard block |
||
6 | 9 | |
7 | 10 | function bb2_google($package) |
8 | 11 | { |
9 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
10 | - if (match_cidr($package['ip'], array("66.249.64.0/19", "64.233.160.0/19", "72.14.192.0/18", "203.208.32.0/19", "74.125.0.0/16", "216.239.32.0/19", "209.85.128.0/17")) === FALSE) { |
|
12 | + if (@is_ipv6($package['ip'])) |
|
13 | + { |
|
14 | + return false; |
|
15 | + } |
|
16 | + # TODO |
|
17 | + if (match_cidr($package['ip'], array("66.249.64.0/19", "64.233.160.0/19", "72.14.192.0/18", "203.208.32.0/19", "74.125.0.0/16", "216.239.32.0/19", "209.85.128.0/17")) === FALSE) |
|
18 | + { |
|
11 | 19 | return false; # Soft fail, must pass other screening |
12 | 20 | #return "f1182195"; # Hard fail |
13 | 21 | } |
@@ -22,8 +30,13 @@ discard block |
||
22 | 30 | |
23 | 31 | function bb2_msnbot($package) |
24 | 32 | { |
25 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
26 | - if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "131.253.21.0/24", "131.253.22.0/23", "131.253.24.0/21", "131.253.32.0/20", "40.76.0.0/14")) === FALSE) { |
|
33 | + if (@is_ipv6($package['ip'])) |
|
34 | + { |
|
35 | + return false; |
|
36 | + } |
|
37 | + # TODO |
|
38 | + if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "131.253.21.0/24", "131.253.22.0/23", "131.253.24.0/21", "131.253.32.0/20", "40.76.0.0/14")) === FALSE) |
|
39 | + { |
|
27 | 40 | return false; # Soft fail, must pass other screening |
28 | 41 | #return "e4de0453"; # Hard fail |
29 | 42 | } |
@@ -38,8 +51,13 @@ discard block |
||
38 | 51 | |
39 | 52 | function bb2_yahoo($package) |
40 | 53 | { |
41 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
42 | - if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) { |
|
54 | + if (@is_ipv6($package['ip'])) |
|
55 | + { |
|
56 | + return false; |
|
57 | + } |
|
58 | + # TODO |
|
59 | + if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) |
|
60 | + { |
|
43 | 61 | return false; # Soft fail, must pass other screening |
44 | 62 | #return '71436a15'; # Hard fail |
45 | 63 | } |
@@ -54,8 +72,13 @@ discard block |
||
54 | 72 | |
55 | 73 | function bb2_baidu($package) |
56 | 74 | { |
57 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
58 | - if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === FALSE) { |
|
75 | + if (@is_ipv6($package['ip'])) |
|
76 | + { |
|
77 | + return false; |
|
78 | + } |
|
79 | + # TODO |
|
80 | + if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === FALSE) |
|
81 | + { |
|
59 | 82 | return false; # Soft fail, must pass other screening |
60 | 83 | } |
61 | 84 | return 1; # Real Baidu bot; bypass all other checks |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | function bb2_google($package) |
8 | 8 | { |
9 | 9 | if (@is_ipv6($package['ip'])) return false; # TODO |
10 | - if (match_cidr($package['ip'], array("66.249.64.0/19", "64.233.160.0/19", "72.14.192.0/18", "203.208.32.0/19", "74.125.0.0/16", "216.239.32.0/19", "209.85.128.0/17")) === FALSE) { |
|
10 | + if (match_cidr($package['ip'], array("66.249.64.0/19", "64.233.160.0/19", "72.14.192.0/18", "203.208.32.0/19", "74.125.0.0/16", "216.239.32.0/19", "209.85.128.0/17")) === false) { |
|
11 | 11 | return false; # Soft fail, must pass other screening |
12 | 12 | #return "f1182195"; # Hard fail |
13 | 13 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | function bb2_msnbot($package) |
24 | 24 | { |
25 | 25 | if (@is_ipv6($package['ip'])) return false; # TODO |
26 | - if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "131.253.21.0/24", "131.253.22.0/23", "131.253.24.0/21", "131.253.32.0/20", "40.76.0.0/14")) === FALSE) { |
|
26 | + if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "131.253.21.0/24", "131.253.22.0/23", "131.253.24.0/21", "131.253.32.0/20", "40.76.0.0/14")) === false) { |
|
27 | 27 | return false; # Soft fail, must pass other screening |
28 | 28 | #return "e4de0453"; # Hard fail |
29 | 29 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | function bb2_yahoo($package) |
40 | 40 | { |
41 | 41 | if (@is_ipv6($package['ip'])) return false; # TODO |
42 | - if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) { |
|
42 | + if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === false) { |
|
43 | 43 | return false; # Soft fail, must pass other screening |
44 | 44 | #return '71436a15'; # Hard fail |
45 | 45 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | function bb2_baidu($package) |
56 | 56 | { |
57 | 57 | if (@is_ipv6($package['ip'])) return false; # TODO |
58 | - if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === FALSE) { |
|
58 | + if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === false) { |
|
59 | 59 | return false; # Soft fail, must pass other screening |
60 | 60 | } |
61 | 61 | return 1; # Real Baidu bot; bypass all other checks |
@@ -6,57 +6,57 @@ |
||
6 | 6 | |
7 | 7 | function bb2_google($package) |
8 | 8 | { |
9 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
9 | + if (@is_ipv6($package['ip'])) return false; # TODO |
|
10 | 10 | if (match_cidr($package['ip'], array("66.249.64.0/19", "64.233.160.0/19", "72.14.192.0/18", "203.208.32.0/19", "74.125.0.0/16", "216.239.32.0/19", "209.85.128.0/17")) === FALSE) { |
11 | - return false; # Soft fail, must pass other screening |
|
11 | + return false; # Soft fail, must pass other screening |
|
12 | 12 | #return "f1182195"; # Hard fail |
13 | 13 | } |
14 | 14 | # Disabled due to http://bugs.php.net/bug.php?id=53092 |
15 | 15 | # if (!bb2_roundtripdns($package['ip'], "googlebot.com")) { |
16 | 16 | # return "f1182195"; |
17 | 17 | # } |
18 | - return 1; # Real Googlebot; bypass all other checks |
|
18 | + return 1; # Real Googlebot; bypass all other checks |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | // Analyze user agents claiming to be msnbot |
22 | 22 | |
23 | 23 | function bb2_msnbot($package) |
24 | 24 | { |
25 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
25 | + if (@is_ipv6($package['ip'])) return false; # TODO |
|
26 | 26 | if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "131.253.21.0/24", "131.253.22.0/23", "131.253.24.0/21", "131.253.32.0/20", "40.76.0.0/14")) === FALSE) { |
27 | - return false; # Soft fail, must pass other screening |
|
27 | + return false; # Soft fail, must pass other screening |
|
28 | 28 | #return "e4de0453"; # Hard fail |
29 | 29 | } |
30 | 30 | # Disabled due to http://bugs.php.net/bug.php?id=53092 |
31 | 31 | # if (!bb2_roundtripdns($package['ip'], "msn.com")) { |
32 | 32 | # return "e4de0453"; |
33 | 33 | # } |
34 | - return 1; # Real msnbot; bypass all other checks |
|
34 | + return 1; # Real msnbot; bypass all other checks |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | // Analyze user agents claiming to be Yahoo! |
38 | 38 | |
39 | 39 | function bb2_yahoo($package) |
40 | 40 | { |
41 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
41 | + if (@is_ipv6($package['ip'])) return false; # TODO |
|
42 | 42 | if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) { |
43 | - return false; # Soft fail, must pass other screening |
|
43 | + return false; # Soft fail, must pass other screening |
|
44 | 44 | #return '71436a15'; # Hard fail |
45 | 45 | } |
46 | 46 | # Disabled due to http://bugs.php.net/bug.php?id=53092 |
47 | 47 | # if (!bb2_roundtripdns($package['ip'], "crawl.yahoo.net")) { |
48 | 48 | # return "71436a15"; |
49 | 49 | # } |
50 | - return 1; # Real Yahoo bot; bypass all other checks |
|
50 | + return 1; # Real Yahoo bot; bypass all other checks |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Analyze user agents claiming to be Baidu |
54 | 54 | |
55 | 55 | function bb2_baidu($package) |
56 | 56 | { |
57 | - if (@is_ipv6($package['ip'])) return false; # TODO |
|
57 | + if (@is_ipv6($package['ip'])) return false; # TODO |
|
58 | 58 | if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === FALSE) { |
59 | - return false; # Soft fail, must pass other screening |
|
59 | + return false; # Soft fail, must pass other screening |
|
60 | 60 | } |
61 | - return 1; # Real Baidu bot; bypass all other checks |
|
61 | + return 1; # Real Baidu bot; bypass all other checks |
|
62 | 62 | } |
@@ -1,8 +1,12 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Defines the responses which Bad Behavior might return. |
4 | 7 | |
5 | -function bb2_get_response($key) { |
|
8 | +function bb2_get_response($key) |
|
9 | +{ |
|
6 | 10 | $bb2_responses = array( |
7 | 11 | '00000000' => array('response' => 200, 'explanation' => '', 'log' => 'Permitted'), |
8 | 12 | '136673cd' => array('response' => 403, 'explanation' => 'Your Internet Protocol address is listed on a blacklist of addresses involved in malicious or illegal activity. See the listing below for more details on specific blacklists and removal procedures.', 'log' => 'IP address found on external blacklist'), |
@@ -47,6 +51,9 @@ discard block |
||
47 | 51 | 'f9f2b8b9' => array('response' => 403, 'explanation' => 'You do not have permission to access this server. This may be caused by a malfunctioning proxy server or browser privacy software.', 'log' => 'A User-Agent is required but none was provided.'), |
48 | 52 | ); |
49 | 53 | |
50 | - if (array_key_exists($key, $bb2_responses)) return $bb2_responses[$key]; |
|
54 | + if (array_key_exists($key, $bb2_responses)) |
|
55 | + { |
|
56 | + return $bb2_responses[$key]; |
|
57 | + } |
|
51 | 58 | return array('00000000'); |
52 | 59 | } |
@@ -1,15 +1,20 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Specialized screening for trackbacks |
4 | 7 | function bb2_trackback($package) |
5 | 8 | { |
6 | 9 | // Web browsers don't send trackbacks |
7 | - if ($package['is_browser']) { |
|
10 | + if ($package['is_browser']) |
|
11 | + { |
|
8 | 12 | return 'f0dcb3fd'; |
9 | 13 | } |
10 | 14 | |
11 | 15 | // Proxy servers don't send trackbacks either |
12 | - if (array_key_exists('Via', $package['headers_mixed']) || array_key_exists('Max-Forwards', $package['headers_mixed']) || array_key_exists('X-Forwarded-For', $package['headers_mixed']) || array_key_exists('Client-Ip', $package['headers_mixed'])) { |
|
16 | + if (array_key_exists('Via', $package['headers_mixed']) || array_key_exists('Max-Forwards', $package['headers_mixed']) || array_key_exists('X-Forwarded-For', $package['headers_mixed']) || array_key_exists('Client-Ip', $package['headers_mixed'])) |
|
17 | + { |
|
13 | 18 | return 'd60b87c7'; |
14 | 19 | } |
15 | 20 | |
@@ -17,8 +22,10 @@ discard block |
||
17 | 22 | // Real ones do not contain Accept:, and have a charset defined |
18 | 23 | // Real WP trackbacks may contain Accept: depending on the HTTP |
19 | 24 | // transport being used by the sending host |
20 | - if (strpos($package['headers_mixed']['User-Agent'], "WordPress/") !== FALSE) { |
|
21 | - if (strpos($package['headers_mixed']['Content-Type'], "charset=") === FALSE) { |
|
25 | + if (strpos($package['headers_mixed']['User-Agent'], "WordPress/") !== FALSE) |
|
26 | + { |
|
27 | + if (strpos($package['headers_mixed']['Content-Type'], "charset=") === FALSE) |
|
28 | + { |
|
22 | 29 | return 'e3990b47'; |
23 | 30 | } |
24 | 31 | } |
@@ -33,34 +40,41 @@ discard block |
||
33 | 40 | // if ($r = bb2_blackhole($package)) return $r; |
34 | 41 | |
35 | 42 | // MovableType needs specialized screening |
36 | - if (stripos($package['headers_mixed']['User-Agent'], "MovableType") !== FALSE) { |
|
37 | - if (strcmp($package['headers_mixed']['Range'], "bytes=0-99999")) { |
|
43 | + if (stripos($package['headers_mixed']['User-Agent'], "MovableType") !== FALSE) |
|
44 | + { |
|
45 | + if (strcmp($package['headers_mixed']['Range'], "bytes=0-99999")) |
|
46 | + { |
|
38 | 47 | return "7d12528e"; |
39 | 48 | } |
40 | 49 | } |
41 | 50 | |
42 | 51 | // Trackbacks need special screening |
43 | 52 | $request_entity = $package['request_entity']; |
44 | - if (isset($request_entity['title']) && isset($request_entity['url']) && isset($request_entity['blog_name'])) { |
|
53 | + if (isset($request_entity['title']) && isset($request_entity['url']) && isset($request_entity['blog_name'])) |
|
54 | + { |
|
45 | 55 | return bb2_trackback($package); |
46 | 56 | } |
47 | 57 | |
48 | 58 | // Catch a few completely broken spambots |
49 | - foreach ($request_entity as $key => $value) { |
|
59 | + foreach ($request_entity as $key => $value) |
|
60 | + { |
|
50 | 61 | $pos = strpos($key, " document.write"); |
51 | - if ($pos !== FALSE) { |
|
62 | + if ($pos !== FALSE) |
|
63 | + { |
|
52 | 64 | return "dfd9b1ad"; |
53 | 65 | } |
54 | 66 | } |
55 | 67 | |
56 | 68 | // If Referer exists, it should refer to a page on our site |
57 | - if (!$settings['offsite_forms'] && array_key_exists('Referer', $package['headers_mixed'])) { |
|
69 | + if (!$settings['offsite_forms'] && array_key_exists('Referer', $package['headers_mixed'])) |
|
70 | + { |
|
58 | 71 | $url = parse_url($package['headers_mixed']['Referer']); |
59 | 72 | $url['host'] = preg_replace('|^www\.|', '', $url['host']); |
60 | 73 | $host = preg_replace('|^www\.|', '', $package['headers_mixed']['Host']); |
61 | 74 | # Strip port |
62 | 75 | $host = preg_replace('|:\d+$|', '', $host); |
63 | - if (strcasecmp($host, $url['host'])) { |
|
76 | + if (strcasecmp($host, $url['host'])) |
|
77 | + { |
|
64 | 78 | return "cd361abb"; |
65 | 79 | } |
66 | 80 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | // Real ones do not contain Accept:, and have a charset defined |
18 | 18 | // Real WP trackbacks may contain Accept: depending on the HTTP |
19 | 19 | // transport being used by the sending host |
20 | - if (strpos($package['headers_mixed']['User-Agent'], "WordPress/") !== FALSE) { |
|
21 | - if (strpos($package['headers_mixed']['Content-Type'], "charset=") === FALSE) { |
|
20 | + if (strpos($package['headers_mixed']['User-Agent'], "WordPress/") !== false) { |
|
21 | + if (strpos($package['headers_mixed']['Content-Type'], "charset=") === false) { |
|
22 | 22 | return 'e3990b47'; |
23 | 23 | } |
24 | 24 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // if ($r = bb2_blackhole($package)) return $r; |
34 | 34 | |
35 | 35 | // MovableType needs specialized screening |
36 | - if (stripos($package['headers_mixed']['User-Agent'], "MovableType") !== FALSE) { |
|
36 | + if (stripos($package['headers_mixed']['User-Agent'], "MovableType") !== false) { |
|
37 | 37 | if (strcmp($package['headers_mixed']['Range'], "bytes=0-99999")) { |
38 | 38 | return "7d12528e"; |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // Catch a few completely broken spambots |
49 | 49 | foreach ($request_entity as $key => $value) { |
50 | 50 | $pos = strpos($key, " document.write"); |
51 | - if ($pos !== FALSE) { |
|
51 | + if ($pos !== false) { |
|
52 | 52 | return "dfd9b1ad"; |
53 | 53 | } |
54 | 54 | } |
@@ -1,18 +1,24 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Enforce adherence to protocol version claimed by user-agent. |
4 | 7 | |
5 | 8 | function bb2_protocol($settings, $package) |
6 | 9 | { |
7 | 10 | // We should never see Expect: for HTTP/1.0 requests |
8 | - if (array_key_exists('Expect', $package['headers_mixed']) && stripos($package['headers_mixed']['Expect'], "100-continue") !== FALSE && !strcmp($package['server_protocol'], "HTTP/1.0")) { |
|
11 | + if (array_key_exists('Expect', $package['headers_mixed']) && stripos($package['headers_mixed']['Expect'], "100-continue") !== FALSE && !strcmp($package['server_protocol'], "HTTP/1.0")) |
|
12 | + { |
|
9 | 13 | return "a0105122"; |
10 | 14 | } |
11 | 15 | |
12 | 16 | // Is it claiming to be HTTP/1.1? Then it shouldn't do HTTP/1.0 things |
13 | 17 | // Blocks some common corporate proxy servers in strict mode |
14 | - if ($settings['strict'] && !strcmp($package['server_protocol'], "HTTP/1.1")) { |
|
15 | - if (array_key_exists('Pragma', $package['headers_mixed']) && strpos($package['headers_mixed']['Pragma'], "no-cache") !== FALSE && !array_key_exists('Cache-Control', $package['headers_mixed'])) { |
|
18 | + if ($settings['strict'] && !strcmp($package['server_protocol'], "HTTP/1.1")) |
|
19 | + { |
|
20 | + if (array_key_exists('Pragma', $package['headers_mixed']) && strpos($package['headers_mixed']['Pragma'], "no-cache") !== FALSE && !array_key_exists('Cache-Control', $package['headers_mixed'])) |
|
21 | + { |
|
16 | 22 | return "41feed15"; |
17 | 23 | } |
18 | 24 | } |
@@ -27,7 +33,8 @@ discard block |
||
27 | 33 | // First-gen Amazon Kindle is broken; Amazon has been notified 9/24/08 |
28 | 34 | // NOTE: RFC 2965 is obsoleted by RFC 6265. Current software MUST NOT |
29 | 35 | // use Cookie2 or $Version in Cookie. |
30 | - if (@strpos($package['headers_mixed']['Cookie'], '$Version=0') !== FALSE && !array_key_exists('Cookie2', $package['headers_mixed']) && strpos($package['headers_mixed']['User-Agent'], "Kindle/") === FALSE) { |
|
36 | + if (@strpos($package['headers_mixed']['Cookie'], '$Version=0') !== FALSE && !array_key_exists('Cookie2', $package['headers_mixed']) && strpos($package['headers_mixed']['User-Agent'], "Kindle/") === FALSE) |
|
37 | + { |
|
31 | 38 | return '6c502ff1'; |
32 | 39 | } |
33 | 40 | return false; |
@@ -37,7 +44,8 @@ discard block |
||
37 | 44 | { |
38 | 45 | @$ua = $package['headers_mixed']['User-Agent']; |
39 | 46 | |
40 | - if (!strcmp($package['request_method'], "POST") && empty($ua)) { |
|
47 | + if (!strcmp($package['request_method'], "POST") && empty($ua)) |
|
48 | + { |
|
41 | 49 | return "f9f2b8b9"; |
42 | 50 | } |
43 | 51 | |
@@ -46,11 +54,13 @@ discard block |
||
46 | 54 | // Worse yet, some Javascript client-side apps do the same in |
47 | 55 | // blatant violation of the protocol and good sense. |
48 | 56 | // if (strpos($package['request_uri'], "#") !== FALSE || strpos($package['headers_mixed']['Referer'], "#") !== FALSE) { |
49 | - if ($settings['strict'] && strpos($package['request_uri'], "#") !== FALSE) { |
|
57 | + if ($settings['strict'] && strpos($package['request_uri'], "#") !== FALSE) |
|
58 | + { |
|
50 | 59 | return "dfd9b1ad"; |
51 | 60 | } |
52 | 61 | // A pretty nasty SQL injection attack on IIS servers |
53 | - if (strpos($package['request_uri'], ";DECLARE%20@") !== FALSE) { |
|
62 | + if (strpos($package['request_uri'], ";DECLARE%20@") !== FALSE) |
|
63 | + { |
|
54 | 64 | return "dfd9b1ad"; |
55 | 65 | } |
56 | 66 | |
@@ -59,14 +69,17 @@ discard block |
||
59 | 69 | // NOTE: this blocks the whois.sc bot. No big loss. |
60 | 70 | // Exceptions: MT (not fixable); LJ (refuses to fix; may be |
61 | 71 | // blocked again in the future); Facebook |
62 | - if ($settings['strict'] && array_key_exists('Range', $package['headers_mixed']) && strpos($package['headers_mixed']['Range'], "=0-") !== FALSE) { |
|
63 | - if (strncmp($ua, "MovableType", 11) && strncmp($ua, "URI::Fetch", 10) && strncmp($ua, "php-openid/", 11) && strncmp($ua, "facebookexternalhit", 19)) { |
|
72 | + if ($settings['strict'] && array_key_exists('Range', $package['headers_mixed']) && strpos($package['headers_mixed']['Range'], "=0-") !== FALSE) |
|
73 | + { |
|
74 | + if (strncmp($ua, "MovableType", 11) && strncmp($ua, "URI::Fetch", 10) && strncmp($ua, "php-openid/", 11) && strncmp($ua, "facebookexternalhit", 19)) |
|
75 | + { |
|
64 | 76 | return "7ad04a8a"; |
65 | 77 | } |
66 | 78 | } |
67 | 79 | |
68 | 80 | // Content-Range is a response header, not a request header |
69 | - if (array_key_exists('Content-Range', $package['headers_mixed'])) { |
|
81 | + if (array_key_exists('Content-Range', $package['headers_mixed'])) |
|
82 | + { |
|
70 | 83 | return '7d12528e'; |
71 | 84 | } |
72 | 85 | |
@@ -76,13 +89,16 @@ discard block |
||
76 | 89 | if ($settings['strict'] && |
77 | 90 | array_key_exists('via', $package['headers']) && |
78 | 91 | strpos($package['headers']['via'],'Clearswift') === FALSE && |
79 | - strpos($ua,'CoralWebPrx') === FALSE) { |
|
92 | + strpos($ua,'CoralWebPrx') === FALSE) |
|
93 | + { |
|
80 | 94 | return "9c9e4979"; |
81 | 95 | } |
82 | 96 | |
83 | 97 | // pinappleproxy is used by referrer spammers |
84 | - if (array_key_exists('Via', $package['headers_mixed'])) { |
|
85 | - if (stripos($package['headers_mixed']['Via'], "pinappleproxy") !== FALSE || stripos($package['headers_mixed']['Via'], "PCNETSERVER") !== FALSE || stripos($package['headers_mixed']['Via'], "Invisiware") !== FALSE) { |
|
98 | + if (array_key_exists('Via', $package['headers_mixed'])) |
|
99 | + { |
|
100 | + if (stripos($package['headers_mixed']['Via'], "pinappleproxy") !== FALSE || stripos($package['headers_mixed']['Via'], "PCNETSERVER") !== FALSE || stripos($package['headers_mixed']['Via'], "Invisiware") !== FALSE) |
|
101 | + { |
|
86 | 102 | return "939a6fbb"; |
87 | 103 | } |
88 | 104 | } |
@@ -91,53 +107,65 @@ discard block |
||
91 | 107 | // RFC 2616 14.39 |
92 | 108 | // Blocks Microsoft ISA Server 2004 in strict mode. Contact Microsoft |
93 | 109 | // to obtain a hotfix. |
94 | - if ($settings['strict'] && array_key_exists('Te', $package['headers_mixed'])) { |
|
95 | - if (!preg_match('/\bTE\b/', $package['headers_mixed']['Connection'])) { |
|
110 | + if ($settings['strict'] && array_key_exists('Te', $package['headers_mixed'])) |
|
111 | + { |
|
112 | + if (!preg_match('/\bTE\b/', $package['headers_mixed']['Connection'])) |
|
113 | + { |
|
96 | 114 | return "582ec5e4"; |
97 | 115 | } |
98 | 116 | } |
99 | 117 | |
100 | - if (array_key_exists('Connection', $package['headers_mixed'])) { |
|
118 | + if (array_key_exists('Connection', $package['headers_mixed'])) |
|
119 | + { |
|
101 | 120 | // Connection: keep-alive and close are mutually exclusive |
102 | - if (preg_match('/\bKeep-Alive\b/i', $package['headers_mixed']['Connection']) && preg_match('/\bClose\b/i', $package['headers_mixed']['Connection'])) { |
|
121 | + if (preg_match('/\bKeep-Alive\b/i', $package['headers_mixed']['Connection']) && preg_match('/\bClose\b/i', $package['headers_mixed']['Connection'])) |
|
122 | + { |
|
103 | 123 | return "a52f0448"; |
104 | 124 | } |
105 | 125 | // Close shouldn't appear twice |
106 | - if (preg_match('/\bclose,\s?close\b/i', $package['headers_mixed']['Connection'])) { |
|
126 | + if (preg_match('/\bclose,\s?close\b/i', $package['headers_mixed']['Connection'])) |
|
127 | + { |
|
107 | 128 | return "a52f0448"; |
108 | 129 | } |
109 | 130 | // Keey-Alive shouldn't appear twice either |
110 | - if (preg_match('/\bkeep-alive,\s?keep-alive\b/i', $package['headers_mixed']['Connection'])) { |
|
131 | + if (preg_match('/\bkeep-alive,\s?keep-alive\b/i', $package['headers_mixed']['Connection'])) |
|
132 | + { |
|
111 | 133 | return "a52f0448"; |
112 | 134 | } |
113 | 135 | // Keep-Alive format in RFC 2068; some bots mangle these headers |
114 | - if (stripos($package['headers_mixed']['Connection'], "Keep-Alive: ") !== FALSE) { |
|
136 | + if (stripos($package['headers_mixed']['Connection'], "Keep-Alive: ") !== FALSE) |
|
137 | + { |
|
115 | 138 | return "b0924802"; |
116 | 139 | } |
117 | 140 | } |
118 | 141 | |
119 | 142 | |
120 | 143 | // Headers which are not seen from normal user agents; only malicious bots |
121 | - if (array_key_exists('X-Aaaaaaaaaaaa', $package['headers_mixed']) || array_key_exists('X-Aaaaaaaaaa', $package['headers_mixed'])) { |
|
144 | + if (array_key_exists('X-Aaaaaaaaaaaa', $package['headers_mixed']) || array_key_exists('X-Aaaaaaaaaa', $package['headers_mixed'])) |
|
145 | + { |
|
122 | 146 | return "b9cc1d86"; |
123 | 147 | } |
124 | 148 | // Proxy-Connection does not exist and should never be seen in the wild |
125 | 149 | // http://lists.w3.org/Archives/Public/ietf-http-wg-old/1999JanApr/0032.html |
126 | 150 | // http://lists.w3.org/Archives/Public/ietf-http-wg-old/1999JanApr/0040.html |
127 | - if ($settings['strict'] && array_key_exists('Proxy-Connection', $package['headers_mixed'])) { |
|
151 | + if ($settings['strict'] && array_key_exists('Proxy-Connection', $package['headers_mixed'])) |
|
152 | + { |
|
128 | 153 | return "b7830251"; |
129 | 154 | } |
130 | 155 | |
131 | - if (array_key_exists('Referer', $package['headers_mixed'])) { |
|
156 | + if (array_key_exists('Referer', $package['headers_mixed'])) |
|
157 | + { |
|
132 | 158 | // Referer, if it exists, must not be blank |
133 | - if (empty($package['headers_mixed']['Referer'])) { |
|
159 | + if (empty($package['headers_mixed']['Referer'])) |
|
160 | + { |
|
134 | 161 | return "69920ee5"; |
135 | 162 | } |
136 | 163 | |
137 | 164 | // Referer, if it exists, must contain a : |
138 | 165 | // While a relative URL is technically valid in Referer, all known |
139 | 166 | // legitimate user-agents send an absolute URL |
140 | - if (strpos($package['headers_mixed']['Referer'], ":") === FALSE) { |
|
167 | + if (strpos($package['headers_mixed']['Referer'], ":") === FALSE) |
|
168 | + { |
|
141 | 169 | return "45b35e30"; |
142 | 170 | } |
143 | 171 | } |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | function bb2_protocol($settings, $package) |
6 | 6 | { |
7 | 7 | // We should never see Expect: for HTTP/1.0 requests |
8 | - if (array_key_exists('Expect', $package['headers_mixed']) && stripos($package['headers_mixed']['Expect'], "100-continue") !== FALSE && !strcmp($package['server_protocol'], "HTTP/1.0")) { |
|
8 | + if (array_key_exists('Expect', $package['headers_mixed']) && stripos($package['headers_mixed']['Expect'], "100-continue") !== false && !strcmp($package['server_protocol'], "HTTP/1.0")) { |
|
9 | 9 | return "a0105122"; |
10 | 10 | } |
11 | 11 | |
12 | 12 | // Is it claiming to be HTTP/1.1? Then it shouldn't do HTTP/1.0 things |
13 | 13 | // Blocks some common corporate proxy servers in strict mode |
14 | 14 | if ($settings['strict'] && !strcmp($package['server_protocol'], "HTTP/1.1")) { |
15 | - if (array_key_exists('Pragma', $package['headers_mixed']) && strpos($package['headers_mixed']['Pragma'], "no-cache") !== FALSE && !array_key_exists('Cache-Control', $package['headers_mixed'])) { |
|
15 | + if (array_key_exists('Pragma', $package['headers_mixed']) && strpos($package['headers_mixed']['Pragma'], "no-cache") !== false && !array_key_exists('Cache-Control', $package['headers_mixed'])) { |
|
16 | 16 | return "41feed15"; |
17 | 17 | } |
18 | 18 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | // First-gen Amazon Kindle is broken; Amazon has been notified 9/24/08 |
28 | 28 | // NOTE: RFC 2965 is obsoleted by RFC 6265. Current software MUST NOT |
29 | 29 | // use Cookie2 or $Version in Cookie. |
30 | - if (@strpos($package['headers_mixed']['Cookie'], '$Version=0') !== FALSE && !array_key_exists('Cookie2', $package['headers_mixed']) && strpos($package['headers_mixed']['User-Agent'], "Kindle/") === FALSE) { |
|
30 | + if (@strpos($package['headers_mixed']['Cookie'], '$Version=0') !== false && !array_key_exists('Cookie2', $package['headers_mixed']) && strpos($package['headers_mixed']['User-Agent'], "Kindle/") === false) { |
|
31 | 31 | return '6c502ff1'; |
32 | 32 | } |
33 | 33 | return false; |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | // Worse yet, some Javascript client-side apps do the same in |
47 | 47 | // blatant violation of the protocol and good sense. |
48 | 48 | // if (strpos($package['request_uri'], "#") !== FALSE || strpos($package['headers_mixed']['Referer'], "#") !== FALSE) { |
49 | - if ($settings['strict'] && strpos($package['request_uri'], "#") !== FALSE) { |
|
49 | + if ($settings['strict'] && strpos($package['request_uri'], "#") !== false) { |
|
50 | 50 | return "dfd9b1ad"; |
51 | 51 | } |
52 | 52 | // A pretty nasty SQL injection attack on IIS servers |
53 | - if (strpos($package['request_uri'], ";DECLARE%20@") !== FALSE) { |
|
53 | + if (strpos($package['request_uri'], ";DECLARE%20@") !== false) { |
|
54 | 54 | return "dfd9b1ad"; |
55 | 55 | } |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // NOTE: this blocks the whois.sc bot. No big loss. |
60 | 60 | // Exceptions: MT (not fixable); LJ (refuses to fix; may be |
61 | 61 | // blocked again in the future); Facebook |
62 | - if ($settings['strict'] && array_key_exists('Range', $package['headers_mixed']) && strpos($package['headers_mixed']['Range'], "=0-") !== FALSE) { |
|
62 | + if ($settings['strict'] && array_key_exists('Range', $package['headers_mixed']) && strpos($package['headers_mixed']['Range'], "=0-") !== false) { |
|
63 | 63 | if (strncmp($ua, "MovableType", 11) && strncmp($ua, "URI::Fetch", 10) && strncmp($ua, "php-openid/", 11) && strncmp($ua, "facebookexternalhit", 19)) { |
64 | 64 | return "7ad04a8a"; |
65 | 65 | } |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | // may be blocked again in the future) |
76 | 76 | if ($settings['strict'] && |
77 | 77 | array_key_exists('via', $package['headers']) && |
78 | - strpos($package['headers']['via'],'Clearswift') === FALSE && |
|
79 | - strpos($ua,'CoralWebPrx') === FALSE) { |
|
78 | + strpos($package['headers']['via'],'Clearswift') === false && |
|
79 | + strpos($ua,'CoralWebPrx') === false) { |
|
80 | 80 | return "9c9e4979"; |
81 | 81 | } |
82 | 82 | |
83 | 83 | // pinappleproxy is used by referrer spammers |
84 | 84 | if (array_key_exists('Via', $package['headers_mixed'])) { |
85 | - if (stripos($package['headers_mixed']['Via'], "pinappleproxy") !== FALSE || stripos($package['headers_mixed']['Via'], "PCNETSERVER") !== FALSE || stripos($package['headers_mixed']['Via'], "Invisiware") !== FALSE) { |
|
85 | + if (stripos($package['headers_mixed']['Via'], "pinappleproxy") !== false || stripos($package['headers_mixed']['Via'], "PCNETSERVER") !== false || stripos($package['headers_mixed']['Via'], "Invisiware") !== false) { |
|
86 | 86 | return "939a6fbb"; |
87 | 87 | } |
88 | 88 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | return "a52f0448"; |
112 | 112 | } |
113 | 113 | // Keep-Alive format in RFC 2068; some bots mangle these headers |
114 | - if (stripos($package['headers_mixed']['Connection'], "Keep-Alive: ") !== FALSE) { |
|
114 | + if (stripos($package['headers_mixed']['Connection'], "Keep-Alive: ") !== false) { |
|
115 | 115 | return "b0924802"; |
116 | 116 | } |
117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // Referer, if it exists, must contain a : |
138 | 138 | // While a relative URL is technically valid in Referer, all known |
139 | 139 | // legitimate user-agents send an absolute URL |
140 | - if (strpos($package['headers_mixed']['Referer'], ":") === FALSE) { |
|
140 | + if (strpos($package['headers_mixed']['Referer'], ":") === false) { |
|
141 | 141 | return "45b35e30"; |
142 | 142 | } |
143 | 143 | } |
@@ -75,8 +75,8 @@ |
||
75 | 75 | // may be blocked again in the future) |
76 | 76 | if ($settings['strict'] && |
77 | 77 | array_key_exists('via', $package['headers']) && |
78 | - strpos($package['headers']['via'],'Clearswift') === FALSE && |
|
79 | - strpos($ua,'CoralWebPrx') === FALSE) { |
|
78 | + strpos($package['headers']['via'], 'Clearswift') === FALSE && |
|
79 | + strpos($ua, 'CoralWebPrx') === FALSE) { |
|
80 | 80 | return "9c9e4979"; |
81 | 81 | } |
82 | 82 |
@@ -1,28 +1,37 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die("I said no cheating!"); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die("I said no cheating!"); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Miscellaneous helper functions. |
4 | 7 | |
5 | 8 | // Quick and dirty check for an IPv6 address |
6 | -function is_ipv6($address) { |
|
9 | +function is_ipv6($address) |
|
10 | +{ |
|
7 | 11 | return (strpos($address, ":")) ? TRUE : FALSE; |
8 | 12 | } |
9 | 13 | |
10 | 14 | // stripos() needed because stripos is only present on PHP 5 |
11 | -if (!function_exists('stripos')) { |
|
12 | - function stripos($haystack,$needle,$offset = 0) { |
|
15 | +if (!function_exists('stripos')) |
|
16 | +{ |
|
17 | + function stripos($haystack,$needle,$offset = 0) |
|
18 | + { |
|
13 | 19 | return(strpos(strtolower($haystack),strtolower($needle),$offset)); |
14 | 20 | } |
15 | 21 | } |
16 | 22 | |
17 | 23 | // str_split() needed because str_split is only present on PHP 5 |
18 | -if (!function_exists('str_split')) { |
|
24 | +if (!function_exists('str_split')) |
|
25 | +{ |
|
19 | 26 | function str_split($string, $split_length=1) |
20 | 27 | { |
21 | - if ($split_length < 1) { |
|
28 | + if ($split_length < 1) |
|
29 | + { |
|
22 | 30 | return false; |
23 | 31 | } |
24 | 32 | |
25 | - for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length) { |
|
33 | + for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length) |
|
34 | + { |
|
26 | 35 | $chunks[] = substr($string, $pos, $split_length); |
27 | 36 | } |
28 | 37 | return $chunks; |
@@ -30,28 +39,39 @@ discard block |
||
30 | 39 | } |
31 | 40 | |
32 | 41 | // Convert a string to mixed-case on word boundaries. |
33 | -function uc_all($string) { |
|
42 | +function uc_all($string) |
|
43 | +{ |
|
34 | 44 | $temp = preg_split('/(\W)/', str_replace("_", "-", $string), -1, PREG_SPLIT_DELIM_CAPTURE); |
35 | - foreach ($temp as $key=>$word) { |
|
45 | + foreach ($temp as $key=>$word) |
|
46 | + { |
|
36 | 47 | $temp[$key] = ucfirst(strtolower($word)); |
37 | 48 | } |
38 | 49 | return join ('', $temp); |
39 | 50 | } |
40 | 51 | |
41 | 52 | // Determine if an IP address resides in a CIDR netblock or netblocks. |
42 | -function match_cidr($addr, $cidr) { |
|
53 | +function match_cidr($addr, $cidr) |
|
54 | +{ |
|
43 | 55 | $output = false; |
44 | 56 | |
45 | - if (is_array($cidr)) { |
|
46 | - foreach ($cidr as $cidrlet) { |
|
47 | - if (match_cidr($addr, $cidrlet)) { |
|
57 | + if (is_array($cidr)) |
|
58 | + { |
|
59 | + foreach ($cidr as $cidrlet) |
|
60 | + { |
|
61 | + if (match_cidr($addr, $cidrlet)) |
|
62 | + { |
|
48 | 63 | $output = true; |
49 | 64 | break; |
50 | 65 | } |
51 | 66 | } |
52 | - } else { |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
53 | 70 | @list($ip, $mask) = explode('/', $cidr); |
54 | - if (!$mask) $mask = 32; |
|
71 | + if (!$mask) |
|
72 | + { |
|
73 | + $mask = 32; |
|
74 | + } |
|
55 | 75 | $mask = pow(2,32) - pow(2, (32 - $mask)); |
56 | 76 | $output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); |
57 | 77 | } |
@@ -59,19 +79,26 @@ discard block |
||
59 | 79 | } |
60 | 80 | |
61 | 81 | // Determine if an IP address is reserved by RFC 1918. |
62 | -function is_rfc1918($addr) { |
|
82 | +function is_rfc1918($addr) |
|
83 | +{ |
|
63 | 84 | return match_cidr($addr, array("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16")); |
64 | 85 | } |
65 | 86 | // Obtain all the HTTP headers. |
66 | 87 | // NB: on PHP-CGI we have to fake it out a bit, since we can't get the REAL |
67 | 88 | // headers. Run PHP as Apache 2.0 module if possible for best results. |
68 | -function bb2_load_headers() { |
|
69 | - if (!is_callable('getallheaders')) { |
|
89 | +function bb2_load_headers() |
|
90 | +{ |
|
91 | + if (!is_callable('getallheaders')) |
|
92 | + { |
|
70 | 93 | $headers = array(); |
71 | 94 | foreach ($_SERVER as $h => $v) |
72 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
95 | + { |
|
96 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
73 | 97 | $headers[str_replace("_", "-", uc_all($hp[1]))] = $v; |
74 | - } else { |
|
98 | + } |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
75 | 102 | $headers = getallheaders(); |
76 | 103 | } |
77 | 104 | return $headers; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | // Quick and dirty check for an IPv6 address |
6 | 6 | function is_ipv6($address) { |
7 | - return (strpos($address, ":")) ? TRUE : FALSE; |
|
7 | + return (strpos($address, ":")) ? true : false; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | // stripos() needed because stripos is only present on PHP 5 |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | |
10 | 10 | // stripos() needed because stripos is only present on PHP 5 |
11 | 11 | if (!function_exists('stripos')) { |
12 | - function stripos($haystack,$needle,$offset = 0) { |
|
13 | - return(strpos(strtolower($haystack),strtolower($needle),$offset)); |
|
12 | + function stripos($haystack, $needle, $offset = 0) { |
|
13 | + return(strpos(strtolower($haystack), strtolower($needle), $offset)); |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | 17 | // str_split() needed because str_split is only present on PHP 5 |
18 | 18 | if (!function_exists('str_split')) { |
19 | - function str_split($string, $split_length=1) |
|
19 | + function str_split($string, $split_length = 1) |
|
20 | 20 | { |
21 | 21 | if ($split_length < 1) { |
22 | 22 | return false; |
23 | 23 | } |
24 | 24 | |
25 | - for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length) { |
|
25 | + for ($pos = 0, $chunks = array(); $pos < strlen($string); $pos += $split_length) { |
|
26 | 26 | $chunks[] = substr($string, $pos, $split_length); |
27 | 27 | } |
28 | 28 | return $chunks; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | foreach ($temp as $key=>$word) { |
36 | 36 | $temp[$key] = ucfirst(strtolower($word)); |
37 | 37 | } |
38 | - return join ('', $temp); |
|
38 | + return join('', $temp); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Determine if an IP address resides in a CIDR netblock or netblocks. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } else { |
53 | 53 | @list($ip, $mask) = explode('/', $cidr); |
54 | 54 | if (!$mask) $mask = 32; |
55 | - $mask = pow(2,32) - pow(2, (32 - $mask)); |
|
55 | + $mask = pow(2, 32) - pow(2, (32 - $mask)); |
|
56 | 56 | $output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); |
57 | 57 | } |
58 | 58 | return $output; |
@@ -1,6 +1,10 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | -function bb2_blacklist($package) { |
|
6 | +function bb2_blacklist($package) |
|
7 | +{ |
|
4 | 8 | |
5 | 9 | // Blacklisted user agents |
6 | 10 | // These user agent strings occur at the beginning of the line. |
@@ -166,27 +170,35 @@ discard block |
||
166 | 170 | @$ua = $package['headers_mixed']['User-Agent']; |
167 | 171 | @$uri = $package['request_uri']; |
168 | 172 | |
169 | - foreach ($bb2_spambots_0 as $spambot) { |
|
173 | + foreach ($bb2_spambots_0 as $spambot) |
|
174 | + { |
|
170 | 175 | $pos = strpos($ua, $spambot); |
171 | - if ($pos !== FALSE && $pos == 0) { |
|
176 | + if ($pos !== FALSE && $pos == 0) |
|
177 | + { |
|
172 | 178 | return "17f4e8c8"; |
173 | 179 | } |
174 | 180 | } |
175 | 181 | |
176 | - foreach ($bb2_spambots as $spambot) { |
|
177 | - if (strpos($ua, $spambot) !== FALSE) { |
|
182 | + foreach ($bb2_spambots as $spambot) |
|
183 | + { |
|
184 | + if (strpos($ua, $spambot) !== FALSE) |
|
185 | + { |
|
178 | 186 | return "17f4e8c8"; |
179 | 187 | } |
180 | 188 | } |
181 | 189 | |
182 | - foreach ($bb2_spambots_regex as $spambot) { |
|
183 | - if (preg_match($spambot, $ua)) { |
|
190 | + foreach ($bb2_spambots_regex as $spambot) |
|
191 | + { |
|
192 | + if (preg_match($spambot, $ua)) |
|
193 | + { |
|
184 | 194 | return "17f4e8c8"; |
185 | 195 | } |
186 | 196 | } |
187 | 197 | |
188 | - foreach ($bb2_spambots_url as $spambot) { |
|
189 | - if (stripos($uri, $spambot) !== FALSE) { |
|
198 | + foreach ($bb2_spambots_url as $spambot) |
|
199 | + { |
|
200 | + if (stripos($uri, $spambot) !== FALSE) |
|
201 | + { |
|
190 | 202 | return "96c0bd29"; |
191 | 203 | } |
192 | 204 | } |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | |
169 | 169 | foreach ($bb2_spambots_0 as $spambot) { |
170 | 170 | $pos = strpos($ua, $spambot); |
171 | - if ($pos !== FALSE && $pos == 0) { |
|
171 | + if ($pos !== false && $pos == 0) { |
|
172 | 172 | return "17f4e8c8"; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | foreach ($bb2_spambots as $spambot) { |
177 | - if (strpos($ua, $spambot) !== FALSE) { |
|
177 | + if (strpos($ua, $spambot) !== false) { |
|
178 | 178 | return "17f4e8c8"; |
179 | 179 | } |
180 | 180 | } |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | foreach ($bb2_spambots_url as $spambot) { |
189 | - if (stripos($uri, $spambot) !== FALSE) { |
|
189 | + if (stripos($uri, $spambot) !== false) { |
|
190 | 190 | return "96c0bd29"; |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - return FALSE; |
|
194 | + return false; |
|
195 | 195 | } |
@@ -5,160 +5,160 @@ |
||
5 | 5 | // Blacklisted user agents |
6 | 6 | // These user agent strings occur at the beginning of the line. |
7 | 7 | $bb2_spambots_0 = array( |
8 | - "-", // brute force password attempts, malicious botnet |
|
9 | - "8484 Boston Project", // video poker/porn spam |
|
10 | - "ArchiveTeam", // ignores robots.txt and hammers server |
|
11 | - "adwords", // referrer spam |
|
12 | - "autoemailspider", // spam harvester |
|
13 | - "blogsearchbot-martin", // from honeypot |
|
14 | - "BrowserEmulator/", // open proxy software |
|
15 | - "CherryPicker", // spam harvester |
|
16 | - "core-project/", // FrontPage extension exploits |
|
17 | - "Diamond", // delivers spyware/adware |
|
18 | - "Digger", // spam harvester |
|
19 | - "ecollector", // spam harvester |
|
20 | - "EmailCollector", // spam harvester |
|
21 | - "Email Siphon", // spam harvester |
|
22 | - "EmailSiphon", // spam harvester |
|
23 | - "Forum Poster", // forum spambot |
|
24 | - "grub crawler", // misc comment/email spam |
|
25 | - "HttpProxy", // misc comment/email spam |
|
26 | - "Internet Explorer", // XMLRPC exploits seen |
|
27 | - "ISC Systems iRc", // spam harvester |
|
28 | - "Jakarta Commons", // customised spambots |
|
29 | - "Java 1.", // unidentified robots |
|
30 | - "Java/1.", // unidentified robots |
|
31 | - "libwww-perl", // unidentified robots |
|
32 | - "LWP", // unidentified robots |
|
33 | - "lwp", // unidentified robots |
|
34 | - "Microsoft Internet Explorer/", // too old; assumed robot |
|
35 | - "Microsoft URL", // unidentified robots |
|
36 | - "Missigua", // spam harvester |
|
37 | - "MJ12bot/v1.0.8", // malicious botnet |
|
38 | - "Morfeus", // vulnerability scanner |
|
39 | - "Movable Type", // customised spambots |
|
8 | + "-", // brute force password attempts, malicious botnet |
|
9 | + "8484 Boston Project", // video poker/porn spam |
|
10 | + "ArchiveTeam", // ignores robots.txt and hammers server |
|
11 | + "adwords", // referrer spam |
|
12 | + "autoemailspider", // spam harvester |
|
13 | + "blogsearchbot-martin", // from honeypot |
|
14 | + "BrowserEmulator/", // open proxy software |
|
15 | + "CherryPicker", // spam harvester |
|
16 | + "core-project/", // FrontPage extension exploits |
|
17 | + "Diamond", // delivers spyware/adware |
|
18 | + "Digger", // spam harvester |
|
19 | + "ecollector", // spam harvester |
|
20 | + "EmailCollector", // spam harvester |
|
21 | + "Email Siphon", // spam harvester |
|
22 | + "EmailSiphon", // spam harvester |
|
23 | + "Forum Poster", // forum spambot |
|
24 | + "grub crawler", // misc comment/email spam |
|
25 | + "HttpProxy", // misc comment/email spam |
|
26 | + "Internet Explorer", // XMLRPC exploits seen |
|
27 | + "ISC Systems iRc", // spam harvester |
|
28 | + "Jakarta Commons", // customised spambots |
|
29 | + "Java 1.", // unidentified robots |
|
30 | + "Java/1.", // unidentified robots |
|
31 | + "libwww-perl", // unidentified robots |
|
32 | + "LWP", // unidentified robots |
|
33 | + "lwp", // unidentified robots |
|
34 | + "Microsoft Internet Explorer/", // too old; assumed robot |
|
35 | + "Microsoft URL", // unidentified robots |
|
36 | + "Missigua", // spam harvester |
|
37 | + "MJ12bot/v1.0.8", // malicious botnet |
|
38 | + "Morfeus", // vulnerability scanner |
|
39 | + "Movable Type", // customised spambots |
|
40 | 40 | // msnbot is using this fake user agent string now |
41 | 41 | //"Mozilla ", // malicious software |
42 | - "Mozilla/0", // malicious software |
|
43 | - "Mozilla/1", // malicious software |
|
44 | - "Mozilla/2", // malicious software |
|
45 | - "Mozilla/3", // malicious software |
|
46 | - "Mozilla/4.0(", // from honeypot |
|
47 | - "Mozilla/4.0+(compatible;+", // suspicious harvester |
|
48 | - "Mozilla/4.0 (Hydra)", // brute force tool |
|
49 | - "MSIE", // malicious software |
|
50 | - "MVAClient", // automated hacking attempts |
|
51 | - "Nessus", // vulnerability scanner |
|
52 | - "NutchCVS", // unidentified robots |
|
53 | - "Nutscrape/", // misc comment spam |
|
54 | - "OmniExplorer", // spam harvester |
|
55 | - "Opera/9.64(", // comment spam bot |
|
56 | - "PMAFind", // vulnerability scanner |
|
57 | - "psycheclone", // spam harvester |
|
58 | - "PussyCat ", // misc comment spam |
|
59 | - "PycURL", // misc comment spam |
|
60 | - "Python-urllib", // commonly abused |
|
61 | - "revolt", // vulnerability scanner |
|
42 | + "Mozilla/0", // malicious software |
|
43 | + "Mozilla/1", // malicious software |
|
44 | + "Mozilla/2", // malicious software |
|
45 | + "Mozilla/3", // malicious software |
|
46 | + "Mozilla/4.0(", // from honeypot |
|
47 | + "Mozilla/4.0+(compatible;+", // suspicious harvester |
|
48 | + "Mozilla/4.0 (Hydra)", // brute force tool |
|
49 | + "MSIE", // malicious software |
|
50 | + "MVAClient", // automated hacking attempts |
|
51 | + "Nessus", // vulnerability scanner |
|
52 | + "NutchCVS", // unidentified robots |
|
53 | + "Nutscrape/", // misc comment spam |
|
54 | + "OmniExplorer", // spam harvester |
|
55 | + "Opera/9.64(", // comment spam bot |
|
56 | + "PMAFind", // vulnerability scanner |
|
57 | + "psycheclone", // spam harvester |
|
58 | + "PussyCat ", // misc comment spam |
|
59 | + "PycURL", // misc comment spam |
|
60 | + "Python-urllib", // commonly abused |
|
61 | + "revolt", // vulnerability scanner |
|
62 | 62 | // WP 2.5 now has Flash; FIXME |
63 | 63 | // "Shockwave Flash", // spam harvester |
64 | - "sqlmap/", // SQL injection |
|
65 | - "Super Happy Fun ", // spam harvester |
|
66 | - "TrackBack/", // trackback spam |
|
67 | - "user", // suspicious harvester |
|
68 | - "User Agent: ", // spam harvester |
|
69 | - "User-Agent: ", // spam harvester |
|
70 | - "w3af", // vulnerability scanner |
|
71 | - "WebSite-X Suite", // misc comment spam |
|
72 | - "Winnie Poh", // Automated Coppermine hacks |
|
73 | - "Wordpress", // malicious software |
|
74 | - "\"", // malicious software |
|
64 | + "sqlmap/", // SQL injection |
|
65 | + "Super Happy Fun ", // spam harvester |
|
66 | + "TrackBack/", // trackback spam |
|
67 | + "user", // suspicious harvester |
|
68 | + "User Agent: ", // spam harvester |
|
69 | + "User-Agent: ", // spam harvester |
|
70 | + "w3af", // vulnerability scanner |
|
71 | + "WebSite-X Suite", // misc comment spam |
|
72 | + "Winnie Poh", // Automated Coppermine hacks |
|
73 | + "Wordpress", // malicious software |
|
74 | + "\"", // malicious software |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | // These user agent strings occur anywhere within the line. |
78 | 78 | $bb2_spambots = array( |
79 | - "\r", // A really dumb bot |
|
80 | - "<sc", // XSS exploit attempts |
|
81 | - "; Widows ", // misc comment/email spam |
|
82 | - ": ;", // shellshock |
|
83 | - ":;", // shellshock |
|
84 | - "a href=", // referrer spam |
|
85 | - "ArchiveBot", // ignores robots.txt and hammers server |
|
86 | - "Bad Behavior Test", // Add this to your user-agent to test BB |
|
87 | - "compatible ; MSIE", // misc comment/email spam |
|
88 | - "compatible-", // misc comment/email spam |
|
89 | - "DTS Agent", // misc comment/email spam |
|
90 | - "Email Extractor", // spam harvester |
|
91 | - "Firebird/", // too old; assumed robot |
|
92 | - "Gecko/2525", // revisit this in 500 years |
|
93 | - "grub-client", // search engine ignores robots.txt |
|
94 | - "hanzoweb", // very badly behaved crawler |
|
95 | - "Havij", // SQL injection tool |
|
96 | - "Indy Library", // misc comment/email spam |
|
97 | - "Ming Mong", // brute force tool |
|
98 | - "MSIE 7.0; Windows NT 5.2", // Cyveillance |
|
99 | - "Murzillo compatible", // comment spam bot |
|
100 | - ".NET CLR 1)", // free poker, etc. |
|
101 | - ".NET CLR1", // spam harvester |
|
102 | - "Netsparker", // vulnerability scanner |
|
103 | - "Nikto/", // vulnerability scanner |
|
104 | - "Perman Surfer", // old and very broken harvester |
|
105 | - "POE-Component-Client", // free poker, etc. |
|
106 | - "Teh Forest Lobster", // brute force tool |
|
107 | - "Turing Machine", // www.anonymizer.com abuse |
|
108 | - "Ubuntu/9.25", // comment spam bot |
|
109 | - "unspecified.mail", // stealth harvesters |
|
110 | - "User-agent: ", // spam harvester/splogger |
|
111 | - "WebaltBot", // spam harvester |
|
112 | - "WISEbot", // spam harvester |
|
113 | - "WISEnutbot", // spam harvester |
|
114 | - "Win95", // too old; assumed robot |
|
115 | - "Win98", // too old; assumed robot |
|
116 | - "WinME", // too old; assumed robot |
|
117 | - "Win 9x 4.90", // too old; assumed robot |
|
118 | - "Windows 3", // too old; assumed robot |
|
119 | - "Windows 95", // too old; assumed robot |
|
120 | - "Windows 98", // too old; assumed robot |
|
121 | - "Windows NT 4", // too old; assumed robot |
|
122 | - "Windows NT;", // too old; assumed robot |
|
79 | + "\r", // A really dumb bot |
|
80 | + "<sc", // XSS exploit attempts |
|
81 | + "; Widows ", // misc comment/email spam |
|
82 | + ": ;", // shellshock |
|
83 | + ":;", // shellshock |
|
84 | + "a href=", // referrer spam |
|
85 | + "ArchiveBot", // ignores robots.txt and hammers server |
|
86 | + "Bad Behavior Test", // Add this to your user-agent to test BB |
|
87 | + "compatible ; MSIE", // misc comment/email spam |
|
88 | + "compatible-", // misc comment/email spam |
|
89 | + "DTS Agent", // misc comment/email spam |
|
90 | + "Email Extractor", // spam harvester |
|
91 | + "Firebird/", // too old; assumed robot |
|
92 | + "Gecko/2525", // revisit this in 500 years |
|
93 | + "grub-client", // search engine ignores robots.txt |
|
94 | + "hanzoweb", // very badly behaved crawler |
|
95 | + "Havij", // SQL injection tool |
|
96 | + "Indy Library", // misc comment/email spam |
|
97 | + "Ming Mong", // brute force tool |
|
98 | + "MSIE 7.0; Windows NT 5.2", // Cyveillance |
|
99 | + "Murzillo compatible", // comment spam bot |
|
100 | + ".NET CLR 1)", // free poker, etc. |
|
101 | + ".NET CLR1", // spam harvester |
|
102 | + "Netsparker", // vulnerability scanner |
|
103 | + "Nikto/", // vulnerability scanner |
|
104 | + "Perman Surfer", // old and very broken harvester |
|
105 | + "POE-Component-Client", // free poker, etc. |
|
106 | + "Teh Forest Lobster", // brute force tool |
|
107 | + "Turing Machine", // www.anonymizer.com abuse |
|
108 | + "Ubuntu/9.25", // comment spam bot |
|
109 | + "unspecified.mail", // stealth harvesters |
|
110 | + "User-agent: ", // spam harvester/splogger |
|
111 | + "WebaltBot", // spam harvester |
|
112 | + "WISEbot", // spam harvester |
|
113 | + "WISEnutbot", // spam harvester |
|
114 | + "Win95", // too old; assumed robot |
|
115 | + "Win98", // too old; assumed robot |
|
116 | + "WinME", // too old; assumed robot |
|
117 | + "Win 9x 4.90", // too old; assumed robot |
|
118 | + "Windows 3", // too old; assumed robot |
|
119 | + "Windows 95", // too old; assumed robot |
|
120 | + "Windows 98", // too old; assumed robot |
|
121 | + "Windows NT 4", // too old; assumed robot |
|
122 | + "Windows NT;", // too old; assumed robot |
|
123 | 123 | #"Windows NT 4.0;)", // wikispam bot |
124 | - "Windows NT 5.0;)", // wikispam bot |
|
125 | - "Windows NT 5.1;)", // wikispam bot |
|
126 | - "Windows XP 5", // spam harvester |
|
127 | - "WordPress/4.01", // pingback spam |
|
128 | - "Xedant Human Emulator",// spammer script engine |
|
129 | - "ZmEu", // exploit scanner |
|
130 | - "\\\\)", // spam harvester |
|
124 | + "Windows NT 5.0;)", // wikispam bot |
|
125 | + "Windows NT 5.1;)", // wikispam bot |
|
126 | + "Windows XP 5", // spam harvester |
|
127 | + "WordPress/4.01", // pingback spam |
|
128 | + "Xedant Human Emulator", // spammer script engine |
|
129 | + "ZmEu", // exploit scanner |
|
130 | + "\\\\)", // spam harvester |
|
131 | 131 | ); |
132 | 132 | |
133 | 133 | // These are regular expression matches. |
134 | 134 | $bb2_spambots_regex = array( |
135 | - "/^[A-Z]{10}$/", // misc email spam |
|
135 | + "/^[A-Z]{10}$/", // misc email spam |
|
136 | 136 | "/[bcdfghjklmnpqrstvwxz ]{8,}/", |
137 | 137 | // "/(;\){1,2}$/", // misc spammers/harvesters |
138 | - "/MSIE.*Windows XP/", // misc comment spam |
|
139 | - "/MSIE [2345]/", // too old; assumed robot |
|
138 | + "/MSIE.*Windows XP/", // misc comment spam |
|
139 | + "/MSIE [2345]/", // too old; assumed robot |
|
140 | 140 | ); |
141 | 141 | |
142 | 142 | // Blacklisted URL strings |
143 | 143 | // These strings are considered case-insensitive. |
144 | 144 | $bb2_spambots_url = array( |
145 | - "0x31303235343830303536", // Havij |
|
146 | - "../", // path traversal |
|
147 | - "..\\", // path traversal |
|
148 | - "%60information_schema%60", // SQL injection probe |
|
149 | - "+%2F*%21", // SQL injection probe |
|
150 | - "%27--", // SQL injection |
|
151 | - "%27 --", // SQL injection |
|
152 | - "%27%23", // SQL injection |
|
153 | - "%27 %23", // SQL injection |
|
154 | - "benchmark%28", // SQL injection probe |
|
155 | - "insert+into+", // SQL injection |
|
156 | - "r3dm0v3", // SQL injection probe |
|
157 | - "select+1+from", // SQL injection probe |
|
158 | - "union+all+select", // SQL injection probe |
|
159 | - "union+select", // SQL injection probe |
|
160 | - "waitfor+delay+", // SQL injection probe |
|
161 | - "w00tw00t", // vulnerability scanner |
|
145 | + "0x31303235343830303536", // Havij |
|
146 | + "../", // path traversal |
|
147 | + "..\\", // path traversal |
|
148 | + "%60information_schema%60", // SQL injection probe |
|
149 | + "+%2F*%21", // SQL injection probe |
|
150 | + "%27--", // SQL injection |
|
151 | + "%27 --", // SQL injection |
|
152 | + "%27%23", // SQL injection |
|
153 | + "%27 %23", // SQL injection |
|
154 | + "benchmark%28", // SQL injection probe |
|
155 | + "insert+into+", // SQL injection |
|
156 | + "r3dm0v3", // SQL injection probe |
|
157 | + "select+1+from", // SQL injection probe |
|
158 | + "union+all+select", // SQL injection probe |
|
159 | + "union+select", // SQL injection probe |
|
160 | + "waitfor+delay+", // SQL injection probe |
|
161 | + "w00tw00t", // vulnerability scanner |
|
162 | 162 | ); |
163 | 163 | |
164 | 164 | // Do not edit below this line. |
@@ -1,4 +1,7 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Functions called when a request has been denied |
4 | 7 | // This part can be gawd-awful slow, doesn't matter :) |
@@ -7,14 +10,18 @@ discard block |
||
7 | 10 | |
8 | 11 | function bb2_housekeeping($settings, $package) |
9 | 12 | { |
10 | - if (!$settings['logging']) return; |
|
13 | + if (!$settings['logging']) |
|
14 | + { |
|
15 | + return; |
|
16 | + } |
|
11 | 17 | |
12 | 18 | // FIXME Yes, the interval's hard coded (again) for now. |
13 | 19 | $query = "DELETE FROM `" . $settings['log_table'] . "` WHERE `date` < DATE_SUB('" . bb2_db_date() . "', INTERVAL 7 DAY)"; |
14 | 20 | bb2_db_query($query); |
15 | 21 | |
16 | 22 | // Waste a bunch more of the spammer's time, sometimes. |
17 | - if (rand(1,1000) == 1) { |
|
23 | + if (rand(1,1000) == 1) |
|
24 | + { |
|
18 | 25 | $query = "OPTIMIZE TABLE `" . $settings['log_table'] . "`"; |
19 | 26 | bb2_db_query($query); |
20 | 27 | } |
@@ -23,14 +30,19 @@ discard block |
||
23 | 30 | function bb2_display_denial($settings, $package, $key, $previous_key = false) |
24 | 31 | { |
25 | 32 | define('DONOTCACHEPAGE', true); // WP Super Cache |
26 | - if (!$previous_key) $previous_key = $key; |
|
27 | - if ($key == "e87553e1") { |
|
33 | + if (!$previous_key) |
|
34 | + { |
|
35 | + $previous_key = $key; |
|
36 | + } |
|
37 | + if ($key == "e87553e1") |
|
38 | + { |
|
28 | 39 | // FIXME: lookup the real key |
29 | 40 | } |
30 | 41 | // Create support key |
31 | 42 | $ip = explode(".", $package['ip']); |
32 | 43 | $ip_hex = ""; |
33 | - foreach ($ip as $octet) { |
|
44 | + foreach ($ip as $octet) |
|
45 | + { |
|
34 | 46 | $ip_hex .= str_pad(dechex($octet), 2, 0, STR_PAD_LEFT); |
35 | 47 | } |
36 | 48 | $support_key = implode("-", str_split("$ip_hex$key", 4)); |
@@ -40,7 +52,11 @@ discard block |
||
40 | 52 | header("HTTP/1.1 " . $response['response'] . " Bad Behavior"); |
41 | 53 | header("Status: " . $response['response'] . " Bad Behavior"); |
42 | 54 | $request_uri = $_SERVER["REQUEST_URI"]; |
43 | - if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
55 | + if (!$request_uri) |
|
56 | + { |
|
57 | + $request_uri = $_SERVER['SCRIPT_NAME']; |
|
58 | + } |
|
59 | + # IIS |
|
44 | 60 | ?> |
45 | 61 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
46 | 62 | <!--< html xmlns="http://www.w3.org/1999/xhtml">--> |
@@ -60,6 +76,9 @@ discard block |
||
60 | 76 | |
61 | 77 | function bb2_log_denial($settings, $package, $key, $previous_key=false) |
62 | 78 | { |
63 | - if (!$settings['logging']) return; |
|
79 | + if (!$settings['logging']) |
|
80 | + { |
|
81 | + return; |
|
82 | + } |
|
64 | 83 | bb2_db_query(bb2_insert($settings, $package, $key)); |
65 | 84 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | bb2_db_query($query); |
15 | 15 | |
16 | 16 | // Waste a bunch more of the spammer's time, sometimes. |
17 | - if (rand(1,1000) == 1) { |
|
17 | + if (rand(1, 1000) == 1) { |
|
18 | 18 | $query = "OPTIMIZE TABLE `" . $settings['log_table'] . "`"; |
19 | 19 | bb2_db_query($query); |
20 | 20 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | function bb2_display_denial($settings, $package, $key, $previous_key = false) |
24 | 24 | { |
25 | - define('DONOTCACHEPAGE', true); // WP Super Cache |
|
25 | + define('DONOTCACHEPAGE', true); // WP Super Cache |
|
26 | 26 | if (!$previous_key) $previous_key = $key; |
27 | 27 | if ($key == "e87553e1") { |
28 | 28 | // FIXME: lookup the real key |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | header("HTTP/1.1 " . $response['response'] . " Bad Behavior"); |
41 | 41 | header("Status: " . $response['response'] . " Bad Behavior"); |
42 | 42 | $request_uri = $_SERVER["REQUEST_URI"]; |
43 | - if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
43 | + if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
44 | 44 | ?> |
45 | 45 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
46 | 46 | <!--< html xmlns="http://www.w3.org/1999/xhtml">--> |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | <?php |
59 | 59 | } |
60 | 60 | |
61 | -function bb2_log_denial($settings, $package, $key, $previous_key=false) |
|
61 | +function bb2_log_denial($settings, $package, $key, $previous_key = false) |
|
62 | 62 | { |
63 | 63 | if (!$settings['logging']) return; |
64 | 64 | bb2_db_query(bb2_insert($settings, $package, $key)); |
@@ -1,10 +1,15 @@ |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | function bb2_movabletype($package) |
4 | 7 | { |
5 | 8 | // Is it a trackback? |
6 | - if (strcasecmp($package['request_method'], "POST")) { |
|
7 | - if (strcmp($package['headers_mixed']['Range'], "bytes=0-99999")) { |
|
9 | + if (strcasecmp($package['request_method'], "POST")) |
|
10 | + { |
|
11 | + if (strcmp($package['headers_mixed']['Range'], "bytes=0-99999")) |
|
12 | + { |
|
8 | 13 | return "7d12528e"; |
9 | 14 | } |
10 | 15 | } |
@@ -1,11 +1,18 @@ discard block |
||
1 | -<?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
|
1 | +<?php if (!defined('BB2_CORE')) |
|
2 | +{ |
|
3 | + die('I said no cheating!'); |
|
4 | +} |
|
2 | 5 | |
3 | 6 | // Look up address on various blackhole lists. |
4 | 7 | // These should not be used for GET requests under any circumstances! |
5 | 8 | // FIXME: Note that this code is no longer in use |
6 | -function bb2_blackhole($package) { |
|
9 | +function bb2_blackhole($package) |
|
10 | +{ |
|
7 | 11 | // Can't use IPv6 addresses yet |
8 | - if (@is_ipv6($package['ip'])) return false; |
|
12 | + if (@is_ipv6($package['ip'])) |
|
13 | + { |
|
14 | + return false; |
|
15 | + } |
|
9 | 16 | |
10 | 17 | // Workaround for "MySQL server has gone away" |
11 | 18 | bb2_db_query("SET @@session.wait_timeout = 90"); |
@@ -29,12 +36,15 @@ discard block |
||
29 | 36 | // Check the blackhole lists |
30 | 37 | $ip = $package['ip']; |
31 | 38 | $find = implode('.', array_reverse(explode('.', $ip))); |
32 | - foreach ($bb2_blackhole_lists as $dnsbl) { |
|
39 | + foreach ($bb2_blackhole_lists as $dnsbl) |
|
40 | + { |
|
33 | 41 | $result = gethostbynamel($find . "." . $dnsbl . "."); |
34 | - if (!empty($result)) { |
|
42 | + if (!empty($result)) |
|
43 | + { |
|
35 | 44 | // Got a match and it isn't on the exception list |
36 | 45 | $result = @array_diff($result, $bb2_blackhole_exceptions[$dnsbl]); |
37 | - if (!empty($result)) { |
|
46 | + if (!empty($result)) |
|
47 | + { |
|
38 | 48 | return '136673cd'; |
39 | 49 | } |
40 | 50 | } |
@@ -42,24 +52,34 @@ discard block |
||
42 | 52 | return false; |
43 | 53 | } |
44 | 54 | |
45 | -function bb2_httpbl($settings, $package) { |
|
55 | +function bb2_httpbl($settings, $package) |
|
56 | +{ |
|
46 | 57 | // Can't use IPv6 addresses yet |
47 | - if (@is_ipv6($package['ip'])) return false; |
|
58 | + if (@is_ipv6($package['ip'])) |
|
59 | + { |
|
60 | + return false; |
|
61 | + } |
|
48 | 62 | |
49 | - if (@!$settings['httpbl_key']) return false; |
|
63 | + if (@!$settings['httpbl_key']) |
|
64 | + { |
|
65 | + return false; |
|
66 | + } |
|
50 | 67 | |
51 | 68 | // Workaround for "MySQL server has gone away" |
52 | 69 | bb2_db_query("SET @@session.wait_timeout = 90"); |
53 | 70 | |
54 | 71 | $find = implode('.', array_reverse(explode('.', $package['ip']))); |
55 | 72 | $result = gethostbynamel($settings['httpbl_key'].".${find}.dnsbl.httpbl.org."); |
56 | - if (!empty($result)) { |
|
73 | + if (!empty($result)) |
|
74 | + { |
|
57 | 75 | $ip = explode('.', $result[0]); |
58 | - if ($ip[0] == 127 && ($ip[3] & 7) && $ip[2] >= $settings['httpbl_threat'] && $ip[1] <= $settings['httpbl_maxage']) { |
|
76 | + if ($ip[0] == 127 && ($ip[3] & 7) && $ip[2] >= $settings['httpbl_threat'] && $ip[1] <= $settings['httpbl_maxage']) |
|
77 | + { |
|
59 | 78 | return '2b021b1f'; |
60 | 79 | } |
61 | 80 | // Check if search engine |
62 | - if ($ip[3] == 0) { |
|
81 | + if ($ip[3] == 0) |
|
82 | + { |
|
63 | 83 | return 1; |
64 | 84 | } |
65 | 85 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | // Only conservative lists |
14 | 14 | $bb2_blackhole_lists = array( |
15 | - "sbl-xbl.spamhaus.org", // All around nasties |
|
15 | + "sbl-xbl.spamhaus.org", // All around nasties |
|
16 | 16 | // "dnsbl.sorbs.net", // Old useless data. |
17 | 17 | // "list.dsbl.org", // Old useless data. |
18 | 18 | // "dnsbl.ioerror.us", // Bad Behavior Blackhole |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | // Things that shouldn't be blocked, from aggregate lists |
22 | 22 | $bb2_blackhole_exceptions = array( |
23 | - "sbl-xbl.spamhaus.org" => array("127.0.0.4"), // CBL is problematic |
|
24 | - "dnsbl.sorbs.net" => array("127.0.0.10",), // Dynamic IPs only |
|
23 | + "sbl-xbl.spamhaus.org" => array("127.0.0.4"), // CBL is problematic |
|
24 | + "dnsbl.sorbs.net" => array("127.0.0.10",), // Dynamic IPs only |
|
25 | 25 | "list.dsbl.org" => array(), |
26 | 26 | "dnsbl.ioerror.us" => array(), |
27 | 27 | ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | bb2_db_query("SET @@session.wait_timeout = 90"); |
53 | 53 | |
54 | 54 | $find = implode('.', array_reverse(explode('.', $package['ip']))); |
55 | - $result = gethostbynamel($settings['httpbl_key'].".${find}.dnsbl.httpbl.org."); |
|
55 | + $result = gethostbynamel($settings['httpbl_key'] . ".${find}.dnsbl.httpbl.org."); |
|
56 | 56 | if (!empty($result)) { |
57 | 57 | $ip = explode('.', $result[0]); |
58 | 58 | if ($ip[0] == 127 && ($ip[3] & 7) && $ip[2] >= $settings['httpbl_threat'] && $ip[1] <= $settings['httpbl_maxage']) { |