Skip to content

Commit 8bb740f

Browse files
committed
DDos defense
1 parent 07d1778 commit 8bb740f

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

dy1.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
conf=input('Please enter an IP number more than how many connections will be blocked:')
2+
data = ''
3+
with open('/usr/local/ddos/ddos.conf', 'r+') as f:
4+
for line in f.readlines():
5+
if (line.find('NO_OF_CONNECTIONS') == 0):
6+
line = 'NO_OF_CONNECTIONS={}'.format(conf) + '\n'
7+
data += line
8+
9+
with open('/usr/local/ddos/ddos.conf', 'r+') as f:
10+
f.writelines(data)

dy2.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
lv=raw_input('Use APF or iptables to seal IP. It is recommended to use iptables to change the value of APF_BAN to 0:')
2+
data=''
3+
with open('/usr/local/ddos/ddos.conf','r+') as f:
4+
for line in f.readlines():
5+
if(line.find('APF_BAN')==0):
6+
line='APF_BAN={}'.format(lv)+'\n'
7+
data+=line
8+
9+
with open('/usr/local/ddos/ddos.conf','r+') as f:
10+
f.writelines(data)

dy3.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
live=raw_input('Please enter your mailbox, so that you can tell you the IP that has been sealed:')
2+
data=''
3+
with open('/usr/local/ddos/ddos.conf','r+')as f:
4+
for line in f.readlines():
5+
if(line.find('EMAIL_TO')==0):
6+
line='EMAIL_TO={}'.format(live)
7+
data+=line
8+
9+
with open('/usr/local/ddos/ddos.conf','r+')as f:
10+
f.writelines(data)

fyddos.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import os
2+
import time
3+
def fyddos():
4+
IGNORE_IP_LIST = "/usr/local/ddos/ignore.ip.list"
5+
PGOPDIR="/usr/local/ddos/ddos.conf"
6+
PROG = "/usr/local/ddos/ddos.sh"
7+
if os.path.exists(PROG):
8+
print '[+]The execution file exists to continue the program.'
9+
else:
10+
print '[-]The execution file does not exist, the closing procedure.'
11+
exit()
12+
if os.path.exists(PGOPDIR):
13+
print '[+]The configuration file exists to start the execution of the program.'
14+
else:
15+
print '[-]There is no exit procedure for the configuration file.'
16+
exit()
17+
if os.path.exists(IGNORE_IP_LIST):
18+
print '[+]The IP white list file exists to continue the program.'
19+
else:
20+
print '[-]IP white list file does not exist, end the program.'
21+
exit()
22+
23+
time.sleep(1)
24+
print '[+]Start configuring the IP white list.'
25+
IPlist=raw_input('Please enter your white list IP, and if not, enter q to enter the next step:')
26+
if IPlist=='q':
27+
try:
28+
import dy1
29+
except Exception , g:
30+
print '[-]Catch the error cause:',g
31+
print '[+]It has been added to it.'
32+
time.sleep(3)
33+
try:
34+
import dy2
35+
except Exception , r:
36+
print '[-]Catch the error cause:',r
37+
time.sleep(3)
38+
try:
39+
import dy3
40+
except Exception , p:
41+
print '[-]Catch the error cause:',p
42+
print '[+]Query information,Please input: netstat -ntu | awk ''{print $5}'' | cut -d: -f1 | sort | uniq-c | sort -n command view.'
43+
isd=os.system('ddos')
44+
sda=os.system('service iptables status')
45+
print isd
46+
print sda
47+
48+
else:
49+
list=open('/usr/local/ddos/ignore.ip.list','w')
50+
list.write(IPlist+"\n")
51+
print '[+]It has been added to it:',IPlist
52+
time.sleep(3)
53+
try:
54+
import dy1
55+
except Exception , w:
56+
print('[-]Catch the error cause:',w)
57+
time.sleep(3)
58+
try:
59+
import dy2
60+
except Exception , d:
61+
print '[-]Catch the error cause:',d
62+
time.sleep(3)
63+
try:
64+
import dy3
65+
except Exception ,z:
66+
print '[-]Catch the error cause:',z
67+
print '[+]Query information,Please input: netstat -ntu | awk ''{print $5}'' | cut -d: -f1 | sort | uniq-c | sort -n command view.'
68+
isds = os.system('ddos')
69+
sdas= os.system('service iptables status')
70+
print isds
71+
print sdas
72+
73+
fyddos()

install.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
def main():
3+
try:
4+
g=os.system('git clone https://github.com/snail007/ddos-defalte.git')
5+
print g
6+
except:
7+
print'[-]You didn t install git'
8+
try:
9+
s=os.system('tar zxfv ddos-defalte.tar.gz')
10+
print s
11+
except:
12+
print '[-]Youd didan t install tar'
13+
v=os.system('cd ddos-defalte')
14+
print v
15+
dsd=os.system('./install.sh')
16+
print dsd
17+
if __name__ == '__main__':
18+
main()

0 commit comments

Comments
 (0)