SQL Injection Forum | Hacking & Exploit Tutorial - SQLiWiki
How to Make a Python host checker for Linux - Printable Version

+- SQL Injection Forum | Hacking & Exploit Tutorial - SQLiWiki (http://forum.sqliwiki.com)
+-- Forum: Other Programming Hacking And Tutorial (http://forum.sqliwiki.com/forumdisplay.php?fid=15)
+--- Forum: Programming Tutorial (http://forum.sqliwiki.com/forumdisplay.php?fid=17)
+--- Thread: How to Make a Python host checker for Linux (/showthread.php?tid=62)



How to Make a Python host checker for Linux - Erfan_Sami - 10-28-2015

Hello*** Cool Cool Cool Cool Cool Python up/down host checker - that works on Linux only.

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 only?
We never recommend using 3rd party libraries, but, without them you cant normally ping on Windows. Like, if you use ping command on Linux, you get 1 if the host is up, and other numbers if it is down. That means, on Linux, when the ping target is not pinged successfully, the ping returns 1 (operation completed successfully), in another case, it gives you the error number. On Windows, this is more complicated. If you ping with ping command, you get operation completed successfully, even if the host is up or down.

Setting up
Before starting, please connect to the internet, and if you would have another computers up, that would be pretty nice. Get your local IPv4 address, think what ports do you want to scan.

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:
Code:
import os # Importing main libs
Code:
import sys
Code:
start = "" # Setting up variables
Code:
range1 = 0
Code:
range2 = 0
 
Code:
for carg in sys.argv: # Checking for arguments
Code:
    if carg == "-s":
Code:
        argnum = sys.argv.index(carg)
Code:
        argnum += 1
Code:
        start = sys.argv[argnum]
Code:
    elif carg == "-r1":
Code:
        argnum = sys.argv.index(carg)
Code:
        argnum += 1
Code:
        range1r = sys.argv[argnum]
Code:
        range1 = int(range1r)
Code:
    elif carg == "-r2":
Code:
        argnum = sys.argv.index(carg)
Code:
        argnum += 1
Code:
        range2r = sys.argv[argnum]
Code:
        range2 = int(range2r)
 
Code:
print ("[*] Host Scanner launched!") # Informs user about initialize
[*]
 

Code:
if start == "": # Checks if all the information is provided



Code:
    print ("[E] No host provided")



Code:
elif range1 == 0:



Code:
    print ("[E] No range1 provided")



Code:
elif range2 == 0:



Code:
    print ("[E] No range2 provided")



Code:
else:



Code:
    if range1 > range2:



Code:
        count = range1 - range2



Code:
    elif range1 < range2:



Code:
        count = range2 - range1



Code:
    for ccount in range(range1, range2): # Counts the IP range to ping



Code:
            target = start + "***" + str(ccount)



Code:
            response = os.system("ping " + target + " 2>&1 >/dev/null") # Sets response to ping



Code:
            if response == 0: # Reads response, checks if it is 0



Code:
                err = 0 # sets err to 0



Code:
            else:



Code:
                err = 1 # sets err to 1



Code:
            if err == 0: # when err is equal to 0



Code:
                print ("[+] " + target + " is up!") # Informs user about hosts that are up


[*]


***/X_F1R3


RE: How to Make a Python host checker for Linux - BD_Inj3ct0r - 10-28-2015

Big Grin nice


RE: How to Make a Python host checker for Linux - Erfan_Sami - 10-28-2015

Thnx Big Grin Big Grin Big Grin


RE: How to Make a Python host checker for Linux - higgs_boson - 12-18-2015

Good one


RE: How to Make a Python host checker for Linux - jameslee - 02-08-2016

It is an amazing as well as informative forum post that have a lot of great things to know. Education give you a skill to help others in their difficulty. If someone is in trouble and are unable to choose a right way or take a right decision then you can also help others through your knowledge. Its your social responsibility to help others in any difficulty and help in taking right decisions. This simple programming idea is really helpful for those who search for Make a Python host checker for Linux



RE: How to Make a Python host checker for Linux - edinaclark11 - 02-03-2017

I composed a Python script which does some decent stuff. It peruses a few contributions from an exceed expectations document and stores the outcomes in another exceed expectations record by getting help from Can Someone Do My Essay for Me Cheap and My arrangement is: I can make an electronic shape from which can be utilized to include the python program. I can make the code however how to run my program on a mutual facilitating stage? I am utilizing modules like xlrd, xlwt, by SQLite, by zipcode and so forth.


RE: How to Make a Python host checker for Linux - Andrewstrauss - 06-22-2017

It is an astonishing and in addition instructive gathering post that have a considerable measure of extraordinary things to know. Training give you an ability to help other people in their trouble. On the off chance that somebody is stuck in an unfortunate situation and can't pick a correct way or take a correct choice then you can likewise help other people through your insight. Essay Writing Services


RE: How to Make a Python host checker for Linux - daisyfaith18 - 02-08-2018

It is an amazing and moreover informational social event post that have a significant measure of uncommon things to know. Preparing give you a capacity to help other individuals in a bad position. In case someone is stuck in a grievous circumstance and can't pick a right way or take a right decision then you can moreover help other individuals through your knowledge. coursework writing


RE: How to Make a Python host checker for Linux - christinana - 02-09-2018

Hi, if you want to make a Python host checker for Linux then use this code:
Code:
import os #Importing main libs
Code:
import sys
Code:
start = "" # Setting up variables
Code:
range1 = 0
Code:
range2 = 0
 
Code:
for carg in sys.argv: # Checking for arguments
Code:
    if carg == "-s":
Code:
        argnum = sys.argv.index(carg)
Code:
        argnum += 1
Code:
        start = sys.argv[argnum]
Code:
    elif carg == "-r1":
argnum = sys.argv.index(carg)[align=justify][code]        argnum += 1
[/align]
Code:
        range1r = sys.argv[argnum]
Code:
        range1 = int(range1r)
Code:
    elif carg == "-r2":
Code:
        argnum = sys.argv.index(carg)
Code:
        argnum += 1
Code:
        range2r = sys.argv[argnum]
Code:
        range2 = int(range2r)
 
Code:
print ("[*] Host Scanner launched!") # Informs user about initialize
[*][*][*]
[*][*][*]

 

Code:
if start == "": # Checks if all the information is provided

Code:
    print ("[E] No host provided")


Code:
elif range1 == 0:


Code:
    print ("[E] No range1 provided")

Code:
elif range2 == 0:

Code:
    print ("[E] No range2 provided")

Code:
else:


Code:
    if range1 > range2:


Code:
        count = range1 - range2

Code:
    elif range1 < range2:

Code:
        count = range2 - range1

Code:
    for ccount in range(range1, range2): # Counts the IP range to ping

Code:
            target = start + "***" + str(ccount)


Code:
            response = os.system("ping " + target + " 2>&1 >/dev/null") # Sets response to ping


Code:
            if response == 0: # Reads response, checks if it is 0

Code:
                err = 0 # sets err to 0

Code:
            else:

Code:
                err = 1 # sets err to 1

Code:
            if err == 0: # when err is equal to 0

Code:
                print ("[+] " + target + " is up!") # Informs user about hosts that are up

Code should look like this (comments are cut, do not worry)


Wish u luck Smile

[/code]