How to Make a Python host checker for Linux
You are going to need:
– Python 3.4
– Internet Connection
– Computer with Windows or Linux
If you haven't got installed Python yet, download it from the following link:
https://www.python.org/downloads/
Why Linux just?
We never prescribe utilizing third gathering libraries, be that as it may, without them you cant regularly ping on Windows. Like, on the off chance that you utilize ping charge on Linux, you get 1 if the host is up, and different numbers on the off chance that it is down. That implies, on Linux, when the ping target is not pinged effectively, the ping returns 1 (operation finished effectively), in another case, it gives you the mistake number. On Windows, this is more confounded. In the event that you ping with ping order, you get operation finished effectively, regardless of the possibility that the host is up or down. Howewer, I don't consider any you really utilize Windows for hacking.
Setting up
Before beginning, please associate with the web, and in the event that you would have another PCs up, that would be really decent. Get your neighborhood IPv4 location, think what ports would you like to output.
Coding How to Make a Python host checker for Linux
Coding is the easy part. Begin from importing sys and socket, then, write the following code:
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
Code should look like this (comments are cut, do not worry):
So, that is pretty easy. The end perimeters in th ping command supresses the commands output. So, save the file, run it from terminal and test this out!
– Python 3.4
– Internet Connection
– Computer with Windows or Linux
If you haven't got installed Python yet, download it from the following link:
https://www.python.org/downloads/
Why Linux just?
We never prescribe utilizing third gathering libraries, be that as it may, without them you cant regularly ping on Windows. Like, on the off chance that you utilize ping charge on Linux, you get 1 if the host is up, and different numbers on the off chance that it is down. That implies, on Linux, when the ping target is not pinged effectively, the ping returns 1 (operation finished effectively), in another case, it gives you the mistake number. On Windows, this is more confounded. In the event that you ping with ping order, you get operation finished effectively, regardless of the possibility that the host is up or down. Howewer, I don't consider any you really utilize Windows for hacking.
Setting up
Before beginning, please associate with the web, and in the event that you would have another PCs up, that would be really decent. Get your neighborhood IPv4 location, think what ports would you like to output.
Coding How to Make a Python host checker for Linux
Coding is the easy part. Begin from importing sys and socket, then, write the following code:
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
Code should look like this (comments are cut, do not worry):
So, that is pretty easy. The end perimeters in th ping command supresses the commands output. So, save the file, run it from terminal and test this out!
No comments: