Thursday, 20 December 2018

ʜᴏᴡ ᴛᴏ ᴍᴀᴋᴇ ᴀ ᴘʏᴛʜᴏɴ ʜᴏsᴛ ᴄʜᴇᴄᴋᴇʀ ғᴏʀ ʟɪɴᴜx

  Today we are going to make 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 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, ʙut, without them you can't 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's down. That means, on Linux, when the ping target is not pinged successfully,The ping return 1 (operation completed successfully), In another case, it gives you error number. On Windows, this is more complicated. If you ping with ping command, you get operation completd successfully, Even if the host is up or down. However, I don't think any of you actually use Windows for hacking.
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 server, Think what ports Do You want to scan.
Coding How to make python host checker for Linux
Coding is the easy part. Begin from Importing sys and socket, Then, write the  Following ᴄode:
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

0 comments:

Post a Comment

Blog Archive

Popular Posts

Powered by Blogger.

Contact Form

Name

Email *

Message *

Blog Archive

Labels

Carding (16) Cracking (2) Education (40) Hacking (35) News (39) technology (23) Tips & Tricks (11) Tips N Tricks (85)

Recent Post

Pages

Comments

Popular Posts

Tags

Carding (16) Cracking (2) Education (40) Hacking (35) News (39) technology (23) Tips & Tricks (11) Tips N Tricks (85)