![]() |
|
Small Network Scanner - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Python (https://sinister.ly/Forum-Python) +--- Thread: Small Network Scanner (/Thread-Small-Network-Scanner) |
Small Network Scanner - Ex094 - 08-17-2013 I though that instead of using others made tools to find out hosts which are online in a given IP range, I should rather make my own with python. Remember that I've made this only for Linux, you'll have to modify it to be able to use it with Windows
Here's the code: Code: //Coded By Ex094
//Python 3
import subprocess, locale, socket
encoding = locale.getdefaultlocale()[1]
def ping(host):
response = subprocess.Popen(["/bin/ping", "-c1", "-w10", host], stdout=subprocess.PIPE).stdout.read()
if 'Unreachable' in response.decode(encoding):
return '%s is Offline' % host
else:
return '%s is Alive' % host
def scan(get, start, end):
for n in range(start, end):
ip = get + '.' + str(n)
print(ping(ip))
rand = input('Please input your IP: ')
ip_start = int(input('Enter Start Range: '))
ip_end = int(input('Enter Range End: '))
scan(rand[:7], ip_start, ip_end)Uses Subprocess to work with Linux built-in Ping. It takes your IP and range as input then scans the IP's in that range using the ping module whether they are online or offline. Here's an image of it's working: ![]() Sample Input: Code: Please Input your IP: 192.168.1.1
Enter Start Range: 10
Enter Range End: 20Scan speed is slow but works for the purpose and I quite like it Hope you guys too Will be updating it though! RE: Small Network Scanner - ZingzGone - 09-11-2013 how dose a network scanner help? im new and id like to learn
RE: Small Network Scanner - x_h0rr0r_x - 09-11-2013 It looks useful.I will do some testing and report back..Nice share! RE: Small Network Scanner - Mst0P - 09-16-2013 Great! Thanks for sharing. I would love to see your updates. RE: Small Network Scanner - Daxda - 09-19-2013 Thanks for the share of the source! Just started out with python will digg through it
|