Facebook
From Jittery Ostrich, 4 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 209
  1. import os
  2. import time
  3.  
  4.  
  5. #Menu (choose)
  6. os.system("cls")
  7. print()
  8. print("====================")
  9. print("LAN SCANNING BY PING")
  10. print("====================")
  11. print()
  12. print("1) Whole LAN scanning")
  13. print("2) One host scanning")
  14. print("3) Settings")
  15. print("0) Exit")
  16. choose = int(input("Enter [1], [2], [3] or [0]:  "))
  17.  
  18.  
  19. #Whole LAN scanning
  20. if choose==1:
  21.  
  22.         print()
  23.         inp = open("C:/Users/Adam/Desktop/ping/new.txt", "r")
  24.         tnp = open("C:/Users/Adam/Desktop/ping/new2.txt", "r")
  25.         break_line = "-"
  26.         print(break_line * 56)
  27.  
  28.         activehosts = []
  29.         unactivehosts = []
  30.  
  31.         for one_line in inp.readlines():
  32.                 one_line = one_line.rstrip()
  33.                 response = os.system("ping " + one_line + " -n 1")
  34.                 if response==0:
  35.                         activehosts.append(one_line)
  36.                         print("Host {} is active".format(one_line))                    
  37.                 elif response==1:
  38.                         unactivehosts.append(one_line)
  39.                         print("Host {} is unactive or unreachable".format(one_line))
  40.                 print(break_line * 56)
  41.                 time.sleep(1)
  42.  
  43.         for one_name in tnp.readlines():
  44.                 one_name = one_name.rstrip()
  45.        
  46.         print()
  47.         print("Active hosts:")
  48.         for x in activehosts:
  49.                 print(x)
  50.         print()
  51.         print("Unactive or unreachable hosts: ")
  52.         for x in unactivehosts:
  53.                 print(x)
  54.         inp.close
  55.  
  56.  
  57. #One host scanning
  58. elif choose==2:
  59.  
  60.         print()
  61.         server_ip = input("Enter server's ip:  ")
  62.         response = os.system("ping " + server_ip + " -n 1")
  63.         print()
  64.         if response==0:
  65.                 print("Host {} is active ".format(server_ip))
  66.         else:
  67.                 print("Host {} is unactive or unreachable".format(server_ip))  
  68.  
  69.  
  70. #Settings
  71. elif choose==3:
  72.  
  73.         print()
  74.         print("1) Show ip board file")
  75.         print("2) Edit ip board file")
  76.         print("0) Exit")
  77.         a = int(input("Enter [1], [2] or [0]:  "))
  78.         if a==1:
  79.                 print()
  80.                 filename = 'C:/Users/Adam/Desktop/ping/new.txt'
  81.                 inp = open("C:/Users/Adam/Desktop/ping/new.txt", "r")
  82.                 lc = 0
  83.                 for one_line in inp.readlines() :
  84.                         lc += 1
  85.                         one_line = one_line.rstrip()
  86.                         print("{}) {}".format(lc, one_line))
  87.                         time.sleep(0.5)
  88.                 inp.close
  89.         elif a==2:
  90.                 filename = 'C:/Users/Adam/Desktop/ping/new.txt'
  91.                 os.startfile(filename)
  92.         elif a==3:
  93.                 exit()
  94.  
  95.  
  96. #Exit option
  97. elif choose==0:
  98.  
  99.         exit()
  100.  
  101. #Afrer complete above code
  102. print()
  103. restart = int(input("Enter [1] to restart the program or [0] to exit it:  "))
  104. if restart == 1:
  105.         os.system("cls")
  106.         os.system("python C:/Users/Adam/Desktop/ping/file.py")
  107. else:
  108.         exit()
  109.  
  110.