-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathipGenerator.py
54 lines (48 loc) · 1.41 KB
/
ipGenerator.py
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
50
51
52
53
54
import random
import string
"""@Javi801
Gives an array of random IP addresses, without the IP 200.7.4.7
Param: total -> (int) numbers of IP addresses in the array.
Seed -> (float) seed for randomize.
ddos -> (boolean) true if the IPs addresses have a prefix ('cause the
attack is DDoS type) or false if not.
Return: ips -> (list(str)) array of IP addresses.
"""
def randomIP(total, Seed, ddos):
random.seed(Seed)
if total>256 and ddos:
('Se creara una botnet con prefijo IP /16')
if total<1:
print('Se intenta generar un numero 0 o negativo de IP')
return ['']
ips=[]
j=random.randint(0,255)
k=random.randint(0,255)
l=random.randint(0,255)
for i in range(total):
ip='200.7.4.7'
while(ip=='200.7.4.7'):
if ddos and total>256:
l=random.randint(0,255)
elif not(ddos):
j=random.randint(0,255)
k=random.randint(0,255)
l=random.randint(0,255)
m=random.randint(0,255)
ip=str(j)+'.'+str(k)+'.'+str(l)+'.'+str(m)
ips+=[ip]
return ips
"""
Check if an ip is valid
Param: ip: String
return: Boolean
"""
def checkValidIp(ip):
values = ip.split(".")
if(len(values) != 4):
return False
else:
for v in values:
if(int(v) < 0 or int(v) > 255):
return False
return True