Advertisement
1337ings

[Python] ICMP-Echo Tester

Nov 4th, 2016
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. ##########################################################
  3. #
  4. # /!\ Module /!\
  5. # pip install dpkt
  6. #
  7. # ____________ _______ ______ __
  8. # / _/ ____/ |/ / __ \ / ____/____/ /_ ____
  9. # / // / / /|_/ / /_/ /_____/ __/ / ___/ __ \/ __ \
  10. # _/ // /___/ / / / ____/_____/ /___/ /__/ / / / /_/ /
  11. # /___/\____/_/ /_/_/ /_____/\___/_/ /_/\____/
  12. #
  13. # /!\ This is for testing for ICMP-echo security /!\
  14. #
  15. #/!\ change "IPYOUWANTTOTEST" to your desired test target /!\
  16. #
  17. ##########################################################
  18. # #
  19. # /!\ C R E D I T S /!\ #
  20. # #
  21. # @codingplanets | Chris Poole #
  22. # #
  23. ##########################################################
  24.  
  25. import dpkt
  26. import socket, random
  27.  
  28. echo = dpkt.icmp.ICMP.Echo()
  29. echo.id = random.randint(0, 0xffff)
  30. echo.seq = random.randint(0, 0xffff)
  31. echo.data = 'hello world'
  32.  
  33. icmp = dpkt.icmp.ICMP()
  34. icmp.type = dpkt.icmp.ICMP_ECHO
  35. icmp.data = echo
  36.  
  37. s = socket.socket(socket.AF_INET, socket.SOCK_RAW, dpkt.ip.IP_PROTO_ICMP)
  38. s.connect(('IPYOUWANTTOTEST', 1)) #CHANGE "IPYOUWANTTOTEST" TO THE IPADDRESS YOU WANT TO TEST
  39. sent = s.send(str(icmp))
  40.  
  41. print 'sent %d bytes' % sent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement