PHP ddos blocker
Goedemiddag,
Ik ben ddos block script tegen gekomen en dacht dat handig is om als extratje te gebruiken naast hosting firewall. Wat vinden jullie er van zal ik het gebruiken?
Ik ben ddos block script tegen gekomen en dacht dat handig is om als extratje te gebruiken naast hosting firewall. Wat vinden jullie er van zal ik het gebruiken?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
Posted @ http://www.w3tools.info/2011/12/anti-ddos-php-script.html
*/
$ Ad_ddos_query = 10, / / ������number of requests per second to detect DDOS attacks
$ Ad_check_file = 'check.txt'; / / file to write the current state during the monitoring
$ Ad_temp_file = 'all_ip.txt'; / / temporary file
$ Ad_black_file = 'black_ip.txt'; / / will be entered into a zombie machine ip
$ Ad_white_file = 'white_ip.txt'; / / ip logged visitors
$ Ad_dir = 'anti_ddos'; / / directory with scripts
$ Ad_num_query = 0, / / ������current number of requests per second from a file $ check_file
$ Ad_sec_query = 0, / / ������second from a file $ check_file
$ Ad_end_defense = 0, / / ������end while protecting the file $ check_file
$ Ad_sec = date ("s"); / / current second
$ Ad_date = date ("mdHis"); / / current time
$ Ad_defense_time = 10000 / / ddos ������attack detection time in seconds at which stops monitoring
if (! file_exists ("{$ ad_dir} / {$ ad_check_file}") or! file_exists ("{$ ad_dir} / {$ ad_temp_file}") or! file_exists ("{$ ad_dir} / {$ ad_black_file}") or ! file_exists ("{$ ad_dir} / {$ ad_white_file}") or! file_exists ("{$ ad_dir} / anti_ddos.php")) {
die ("Not enough files.");
}
require ("{$ ad_dir} / {$ ad_check_file}");
if ($ ad_end_defense and $ ad_end_defense> $ ad_date) {
require ("{$ ad_dir} / anti_ddos.php");
} Else {
if ($ ad_sec == $ ad_sec_query) {
$ Ad_num_query + +;
} Else {
$ Ad_num_query = '1 ';
}
if ($ ad_num_query> = $ ad_ddos_query) {
$ Ad_file = fopen ("{$ ad_dir} / {$ ad_check_file}", "w");
$ Ad_end_defense = $ ad_date + $ ad_defense_time;
$ Ad_string = '<? Php $ ad_end_defense ='. $ Ad_end_defense. ';?>';
fputs ($ ad_file, $ ad_string);
fclose ($ ad_fp);
} Else {
$ Ad_file = fopen ("{$ ad_dir} / {$ ad_check_file}", "w");
$ Ad_string = '<? Php $ ad_num_query ='. $ Ad_num_query. '; $ Ad_sec_query ='. $ Ad_sec. ';?>';
fputs ($ ad_file, $ ad_string);
fclose ($ ad_fp);
}
}
?>
/*
Posted @ http://www.w3tools.info/2011/12/anti-ddos-php-script.html
*/
$ Ad_ddos_query = 10, / / ������number of requests per second to detect DDOS attacks
$ Ad_check_file = 'check.txt'; / / file to write the current state during the monitoring
$ Ad_temp_file = 'all_ip.txt'; / / temporary file
$ Ad_black_file = 'black_ip.txt'; / / will be entered into a zombie machine ip
$ Ad_white_file = 'white_ip.txt'; / / ip logged visitors
$ Ad_dir = 'anti_ddos'; / / directory with scripts
$ Ad_num_query = 0, / / ������current number of requests per second from a file $ check_file
$ Ad_sec_query = 0, / / ������second from a file $ check_file
$ Ad_end_defense = 0, / / ������end while protecting the file $ check_file
$ Ad_sec = date ("s"); / / current second
$ Ad_date = date ("mdHis"); / / current time
$ Ad_defense_time = 10000 / / ddos ������attack detection time in seconds at which stops monitoring
if (! file_exists ("{$ ad_dir} / {$ ad_check_file}") or! file_exists ("{$ ad_dir} / {$ ad_temp_file}") or! file_exists ("{$ ad_dir} / {$ ad_black_file}") or ! file_exists ("{$ ad_dir} / {$ ad_white_file}") or! file_exists ("{$ ad_dir} / anti_ddos.php")) {
die ("Not enough files.");
}
require ("{$ ad_dir} / {$ ad_check_file}");
if ($ ad_end_defense and $ ad_end_defense> $ ad_date) {
require ("{$ ad_dir} / anti_ddos.php");
} Else {
if ($ ad_sec == $ ad_sec_query) {
$ Ad_num_query + +;
} Else {
$ Ad_num_query = '1 ';
}
if ($ ad_num_query> = $ ad_ddos_query) {
$ Ad_file = fopen ("{$ ad_dir} / {$ ad_check_file}", "w");
$ Ad_end_defense = $ ad_date + $ ad_defense_time;
$ Ad_string = '<? Php $ ad_end_defense ='. $ Ad_end_defense. ';?>';
fputs ($ ad_file, $ ad_string);
fclose ($ ad_fp);
} Else {
$ Ad_file = fopen ("{$ ad_dir} / {$ ad_check_file}", "w");
$ Ad_string = '<? Php $ ad_num_query ='. $ Ad_num_query. '; $ Ad_sec_query ='. $ Ad_sec. ';?>';
fputs ($ ad_file, $ ad_string);
fclose ($ ad_fp);
}
}
?>
Gewijzigd op 18/12/2014 12:42:03 door Johan de wit
Een echte dDOS kan je alleen maar blocken op de firewall. Met PHP gaat het echt niet lukken, want er blijven requests komen op de webserver.
Ik kan dit meer een IP-ban script noemen tegen flooding.
Ik kan dit meer een IP-ban script noemen tegen flooding.
Gewijzigd op 18/12/2014 12:51:53 door - Ariën -
Je kan tenminste voor ingestelde tijd bannen. Dat is ook wat toch?
Johan de wit op 18/12/2014 13:04:05:
Je kan tenminste voor ingestelde tijd bannen. Dat is ook wat toch?
Maar je blijft requests krijgen, en met een redelijk ingezet botnet doe je er niks tegen met dit script. Een gemiddelde dDOS bestaat uit heel veel IP-adressen, en dan ook vaak zelfs gefaked.
Gewijzigd op 18/12/2014 13:07:40 door - Ariën -
Oke, dat is duidelijk. Dank u




