![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
On my spare time 2 years back I decided to write a IP scanner program... this never got off it's feet really, but I did get it to work (somewhat)... I'd say it's best for Windows since it's the only platform I acctually tested it on. It's really buggy, and yah... if you want to scan IP ranges, don't use this! Heh
#Beegie_B's IP Scanner v0.4 BETA #Scans IP's to see if they are online #Now Supports Ranges #If you want to copy this program and distribute it please give reference to me. #This program can be used freely by anyone import os from os import mkdir, rmdir, remove, chdir from time import time, ctime from socket import * print """ This is the BETA version of my IP scanner. Minor bugs were found in the scanner when used on Windows XP. Please report all bugs and improvement codes to: webmaster@bastardshandbook.com. I need some people who can test this on Linux, Unix, and Mac for me. Creator: Beegie_B Date: Mar 2, 2004 Version: 0.4 BETA Tested On: Windows XP Changes Since v0.3 BETA: run change() to view ================================================================= Run man() for help on use of the IP scanner. """ def ipScan(ipStart, ipEnd, r): #r = range logWrite = "txt_logs/%s.txt" %(str(ctime(time())[0:10])) #This will make the log title the Date x = 3 logHold = [] for s in r: hold = [ipStart[0],ipStart[1],ipStart[2],ipStart[3]] #This will hold theorgiginal IP while int(ipStart[x]) <= int(ipEnd[x]) and int(ipStart[3]) <= int(ipEnd[3]): s = ipStart ipStart = ".".join(ipStart) scn = os.system("ping " + ipStart + " -w .1 -n 1") #-w = timeout, -n = number of scans if scn >= 0 and scn < 1: print ipStart,": Online" logHold.append(ipStart + "\t" + gethostbyaddr(ipStart)[0] + "\tOnline") elif scn >= 1: print ipStart,": Offline" logHold.append(ipStart + "\t" + gethostbyaddr(ipStart)[0] + "\tOffline") #gethostbyaddr gets host name by putting in the IP address ipStart = s s = ipStart[3] s = int(s) s = s + 1 s = str(s) ipStart[3] = s p = 0 for k in hold: #Resets the original IP for further scanning ipStart[p] = hold[p] p = p + 1 x = x-1 n = int(ipStart[x]) + 1 ipStart[x] = str(n) #str() converts to string, int() converts to integer logInfoHeader = "IP Address\tHost Name\t\t\tStatus" logInfo = "\n".join(logHold) #Joins all the log info into a string logInfo = "Scan Date: " + str(ctime(time())) + "\n\n" + logInfoHeader + "\n\n" + logInfo + "\n\n" try: #Will make a logs directory mkdir("logs") chdir("logs") mkdir("txt_logs") w = open(logWrite, "ar").write(logInfo) #Writes Log and saves as log.txt except OSError: #If the directory is made it will bypass making one try: chdir("logs") mkdir("txt_logs") w = open(logWrite, "ar").write(logInfo) #Writes Log and saves as log.txt except OSError: w = open(logWrite, "ar").write(logInfo) #Writes Log and saves as log.txt def scanIP(): ipStart = raw_input("IP Start: ") ipEnd = raw_input("IP End: ") ipStart = ipStart + "." ipEnd = ipEnd + "." h = x = 0 rangeStart = [] rangeEnd = [] rangeDiff = [] while len(rangeStart) < 4: #Grabs the IP address numbers without the "." for ipStart while ipStart[x] != ".": x = x+1 rangeStart.append(ipStart[h:x]) x = x+1 h = x h = x = 0 while len(rangeEnd) < 4: #Grabs the IP address numbers without the "." for ipEnd while ipEnd[x] != ".": x = x+1 rangeEnd.append(ipEnd[h:x]) x = x+1 h = x x = 0 for s in rangeStart: #Finds the range p = int(rangeStart[x]) o = int(rangeEnd[x]) rangeDiff.append(o-p) if rangeDiff[x] < 0: print "Invalid Range, Try Again" s = 4 x = x+1 if s == 4: pass else: ipScan(rangeStart, rangeEnd, rangeDiff) #Does the IP scan def man(): print """ To run use the command scanIP() The IP scanner is only tested on Windows XP but I belive it should work on different OS's also. When running the program make sure not to close the window that gets oppend. Like I said, the scanner is only tested on Windows XP and CMD will automatically close by itself. """ def change(): print """ Changes since v0.3 BETA are: 1. Now automatically logs the scan 2. Hostname info is included in the log NOTE: An HTML View of the log will be added in the next version """ Have fun lookin at it Beeg |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Hey, isn't this the same as this->this?
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#3 |
|
Programmer
|
Nope, Ones a IP Range Scanner, and the Other is a Port Scanner
Beeg |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
Ah, i guess that's what i get for full not reading the threads.....heh
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#5 |
|
Programmer
|
hehe, it happens to the best of us
![]() Beeg |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|