Webhosting in Pakistan
Results 1 to 2 of 2

Thread: How to Make a Python host checker for Linux

  1. #1
    gazzi khan's Avatar
    gazzi khan is offline Senior Member+
    Last Online
    24th March 2018 @ 09:23 PM
    Join Date
    24 Oct 2015
    Location
    Chaand
    Age
    20
    Gender
    Male
    Posts
    75
    Threads
    35
    Credits
    335
    Thanked
    4

    Default How to Make a Python host checker for Linux

    Webhosting in Pakistan
    Hello. Today we are going to make a Python up/down host checker "How to Make a Python host checker for Linux" that works on Linux only.You are going to need:每
    Python 3.4
    每 Internet Connection每
    Computer with Windows or LinuxIf you haven't got installed Python yet, download it from the following link:
    https://www.python.org/downloads/
    You can find some of the Python basics in my first tutorial at
    http://www.hacking-tutorial.com/hack...y-with-python/

    .


    Coding How to Make a Python host checker for Linux.

    .
    Coding is the easy part. Begin from importing sysand socket, then, write the following code:import os # Importing main libsimport sysstart = "" # Setting up variablesrange1 = 0range2 = 0for carg in sys.argv: # Checking for argumentsif carg == "-s":argnum = sys.argv.index(carg)argnum = 1start = sys.argv[argnum]elif carg == "-r1":argnum = sys.argv.index(carg)argnum = 1range1r = sys.argv[argnum]range1 = int(range1r)elif carg == "-r2":argnum = sys.argv.index(carg)argnum = 1range2r = sys.argv[argnum]range2 = int(range2r)print ("[*] Host Scanner launched!") # Informs user about initializeif start == "": # Checks if all the information is providedprint ("[E] No host provided")elif range1 == 0rint ("[E] No range1 provided")elif range2 == 0rint ("[E] No range2 provided")else:if range1 > range2:count = range1 - range2elif range1 < range2:count = range2 - range1for ccount in range(range1, range2): # Counts the IP range to pingtarget = start "." str(ccount)response = os.system("ping " target " 2>&1 >/dev/null") # Sets response to pingif response == 0: # Reads response, checksif it is 0err = 0 # sets err to 0else:err = 1 # sets err to 1if err == 0: # when err is equal to 0print ("[ ] " target " is up!") # Informs user about hosts that are upCode 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!
    Bedard Zamana Keya Janne.

  2. #2
    MrDJROMEO is offline Advance Member
    Last Online
    16th July 2018 @ 05:51 PM
    Join Date
    02 Jun 2015
    Location
    Dunyapur
    Age
    23
    Gender
    Male
    Posts
    2,066
    Threads
    29
    Credits
    15,994
    Thanked
    154

    Default

    Webhosting in Pakistan
    Thanks

Similar Threads

  1. Replies: 49
    Last Post: 25th February 2016, 04:31 PM
  2. Solved How to make Copy CD of Windows Linux CD.
    By Rahmatullah Ktk in forum Solved Problems (IT)
    Replies: 10
    Last Post: 2nd June 2012, 07:11 PM
  3. Linux Xp Ab Microsoft Or Linux Aik Saath
    By Member1 in forum Software Reviews
    Replies: 34
    Last Post: 25th February 2010, 11:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •