1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of SHIELDFY Web Application Firewall Detector. |
4
|
|
|
* (c) 2016 SHIELDFY, All rights reserved. |
5
|
|
|
* |
6
|
|
|
* The code provided was developed by Matthias "Nihylum" Kaschubowski |
7
|
|
|
* |
8
|
|
|
* The applied license is stored at the root directory of this package. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
// dependencies |
12
|
|
|
require __DIR__.'/../src/Exception/InvalidUrlException.php'; |
13
|
|
|
require __DIR__.'/../src/FirewallInterface.php'; |
14
|
|
|
|
15
|
|
|
// firewalls |
16
|
|
|
require __DIR__.'/../src/Firewall/CloudFlare.php'; |
17
|
|
|
require __DIR__.'/../src/Firewall/Incapsula.php'; |
18
|
|
|
require __DIR__.'/../src/Firewall/ModSecurity.php'; |
19
|
|
|
require __DIR__.'/../src/Firewall/Shieldfy.php'; |
20
|
|
|
|
21
|
|
|
// detector |
22
|
|
|
require __DIR__.'/../src/Detector.php'; |
23
|
|
|
|
24
|
|
|
// configuration |
25
|
|
|
|
26
|
|
|
$firewalls = [ |
27
|
|
|
new \Shieldfy\Firewall\CloudFlare(), |
28
|
|
|
new \Shieldfy\Firewall\Incapsula(), |
29
|
|
|
new \Shieldfy\Firewall\ModSecurity(), |
|
|
|
|
30
|
|
|
new \Shieldfy\Firewall\Shieldfy(), |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
// bootstrap |
34
|
|
|
|
35
|
|
|
set_exception_handler(function (Exception $exception) { |
36
|
|
|
$output = [ |
37
|
|
|
'', |
38
|
|
|
sprintf('%s:', get_class($exception)), |
39
|
|
|
$exception->getMessage(), |
40
|
|
|
'', |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
echo PHP_EOL.implode(PHP_EOL, $output).PHP_EOL; |
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
$detector = new \Shieldfy\Detector(...$firewalls); |
47
|
|
|
|
48
|
|
|
echo <<<ASCIIART |
49
|
|
|
|`-._/\_.-`| |
50
|
|
|
| || | Web |
51
|
|
|
|___o()o___| Application |
52
|
|
|
|__((<>))__| Firewall |
53
|
|
|
\ o\/o / Detector |
54
|
|
|
\ || / |
55
|
|
|
\ || / by Shieldfy.com |
56
|
|
|
'.||.' |
57
|
|
|
`` |
58
|
|
|
(c) 2016 Shieldfy Security Team |
59
|
|
|
(c) 2016 Matthias "Nihylum" Kaschubowski |
60
|
|
|
ASCIIART; |
61
|
|
|
|
62
|
|
|
if (! isset($argv[1]) || (isset($argv[1]) && $argv[1] === 'help')) { |
63
|
|
|
$help = [ |
64
|
|
|
'', |
65
|
|
|
'Usage:', |
66
|
|
|
'', |
67
|
|
|
'php waf-detector.php http://example.com', |
68
|
|
|
'', |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
echo PHP_EOL.implode(PHP_EOL, $help).PHP_EOL; |
72
|
|
|
} else { |
73
|
|
|
echo PHP_EOL.PHP_EOL.'Checking: '.$argv[1].PHP_EOL; |
74
|
|
|
|
75
|
|
|
foreach ($detector->detect($argv[1]) as $firewall => $result) { |
76
|
|
|
echo PHP_EOL."- {$firewall} ... ".($result ? 'enabled' : 'disabled'); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
echo PHP_EOL.PHP_EOL; |
80
|
|
|
} |
81
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.