We are coding Python Host Checker that will test if host is up/or down, and it works on Linux only.
We need Working Internet Connection , Linux or Windows Machine and Python 3.4 . Python can be downloaded from https://www.python.org/downloads/
We are using Linux here as on Linux if ping is completed successfully it say 1, else other numbers says error. On Windows even if Pin is not successful the output is Command Completed Successfully. Also for Hacker Linux is Choice due to availability of tools.
CODE :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import os # Importing main libs import sys start = "" # Setting up variables range1 = 0 range2 = 0 for carg in sys.argv: # Checking for arguments if carg == "-s": argnum = sys.argv.index(carg) argnum += 1 start = sys.argv[argnum] elif carg == "-r1": argnum = sys.argv.index(carg) argnum += 1 range1r = sys.argv[argnum] range1 = int(range1r) elif carg == "-r2": argnum = sys.argv.index(carg) argnum += 1 range2r = sys.argv[argnum] range2 = int(range2r) print ("[*] Host Scanner launched!") # Informs user about initialize if start == "": # Checks if all the information is provided print ("[E] No host provided") elif range1 == 0: print ("[E] No range1 provided") elif range2 == 0: print ("[E] No range2 provided") else: if range1 > range2: count = range1 - range2 elif range1 < range2: count = range2 - range1 for ccount in range(range1, range2): # Counts the IP range to ping target = start + "." + str(ccount) response = os.system("ping " + target + " 2>&1 >/dev/null") # Sets response to ping if response == 0: # Reads response, checks if it is 0 err = 0 # sets err to 0 else: err = 1 # sets err to 1 if err == 0: # when err is equal to 0 print ("[+] " + target + " is up!") # Informs user about hosts that are up |
Copy Code above and try running it , Your Own Host Checker. Comment the results or suggesations