martes, 9 de diciembre de 2014

Python Script: Probably useless but functional IPv6 Network scanner

Below is the code of what is probably useless but a functional IPv6 host scanner written in Python using threading.

To perform a regular (brute force) network scans in an IPv6 Network is almost impossible and it can take over 5.000 years to finish.

This project was purely academic and I just wanted to learn about threading in Python.

This software is not recommended for general usage.....

This  script  will call the OS to actually perform the ping

This software receives two parameters:
a) Prefix to scan in the format 2001:db8::/64 (subnet, not host)
b) Number of simultaneous processes it can run (MAXPINGS)

One more time it was purely academic stuff but hopefully it can make your day

Finally, AFAIK nmap does not yet support IPv6 network scan.

The code was written in python3:

--- cut here ---


import threading
import sys
import ipaddress
import subprocess
import time

CURRENTPINGS=0 # Number of simultaneous ping at a time

  CMD="ping6 -c 3 "+str(IPv6ADDRESS) + " 2> /dev/null > /dev/null"
  return_code =, shell=True)
  if return_code == 0:  #If ping was succesful
    print (IPv6ADDRESS," is alive")


def main():
  if len(sys.argv) != 3: #Validate how many parameters we are receiving
    print("  Not enough or too many parameter")
    print("  Usage: ./ IPv6Prefix/lenght MAXPINGS")
    print("  Example: ./ 2001:db8::/64 20")
    print("  Prefix lenght can be between 64-128")
    print("  MAXPINGS corresponds to how many pings will be running at the same time")


  for addr in ipaddress.IPv6Network(sys.argv[1]):  #Let's loop for each address in the Block

    while CURRENTPINGS >= MAXPINGS: # With this while we make it possible to run max simultaneous pings
      time.sleep(1)  # Let's wait one second before proceeding
      #print ("Interrumping...., CURRENTPINGS > MAXPINGS") #Uncomment this line just for debugging



No hay comentarios:

Publicar un comentario

¿Algo adicional que quieras mencionar? ¿Algun consejo?, ¿truco? Gracias!

BGP Multipath tradicional y AS Multipath Relax en una red IPv6

En el video se describe, explica y muestra paso a paso como es el comportamiento por defecto en una red BGP, luego con el BGP Multipath trad...