How to create a Python host checker for Linux


Python programming





Hello Today we are going to create "how to create python host checker for linux" python up / down host checker working on linux.





You need:





  • Python 3.4
  • Internet connection
  • Computer with Windows or Linux




If you have not yet installed Python, download it from the following link:





https://www.python.org/downloads/





Why Linux only?





We never recommend using a 3rd party library, but, without them, you cannot normally ping on Windows. For example, if you use the ping command on Linux, you get 1 when the host is found, and another number if it is down. This means that on Linux, when the ping target is not successfully pinged, then ping1 (operation completed successfully), in the other case, it gives you the error number. On Windows, it is more complex. If you ping with the ping command, you get the operation completed successfully, regardless of whether the host is up or down. Hower, I don't think any of you actually use Windows for hacking.





establishment





Before you begin, please connect to the Internet, and if you have another computer, that would be great. Get your local IPv4 address, think about which port you want to scan.





Coding for creating Python host checker for Linux
Coding is the easy part. Start by importing sys and sockets, then, type 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 &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



So, it is very easy. The end perimeter command in the ping command suppresses the output. So, save the file, run it from the terminal and test it!


Comments

Popular

धनतेरस तिथि 2020: इस वर्ष धनतेरस कब है? जानिए शुभ मुहूर्त और पूजा का महत्व

How "Digital India" and "Make in India" Strengthen India's Tech Giant-#StartupIndia

KV Admission Result of Class 1: Kendriya Vidyalaya result will be declared today, check this way

Big Leap In Indigenous Defense Technologies: DRDO Successfully Tests Hypersonic Technology Demonstration Vehicle

GSEB SSC Result 2020 Declared on gseb.org - 60.64% of students pass, check percentile, percentage criteria here

New earthquake hits SW Puerto Rico

Fierce fire, ATM ash, rains at Lucknow Charbagh railway station

When Johnny Depp said he started smoking at age 12, drinking alcohol, and using drugs soon after.

Honda could be a victim of ransomware cyberattack

On World Ocean Day 2020, how is the fashion industry acting?