Collecting IP range

Y

yawgmoth7

Hello, I'm sure that this has been discussed before, but I have a
question. I have written a few port scanners, banner grabbers in the
past and have never found a good way to get a range of IP's.
Obviously, in my opinion the best and simplest way to do somethign
like and simple port scanner is to do something like:

<code>
for ips in range(startip,endip):
<do blah>

Well, since range() won't take a normal IP(Such as 127.0.0.1). and,
you can't take it as 127001(Since socket.connect() won't take that).
What would you suggest as a better way to approach this?

Thanks for all your help.
 
D

David Murmann

yawgmoth7 said:
Hello, I'm sure that this has been discussed before, but I have a
question. I have written a few port scanners, banner grabbers in the
past and have never found a good way to get a range of IP's.
Obviously, in my opinion the best and simplest way to do somethign
like and simple port scanner is to do something like:

<code>
for ips in range(startip,endip):
<do blah>

you might want to take a look at IPy:

http://c0re.23.nu/c0de/IPy/

iterating over ip-address ranges is very easy there:
... print x
...
127.0.0.0
127.0.0.1
127.0.0.2
127.0.0.3
 
D

David Murmann

yawgmoth7 said:
Well, I seem to have a bit of a problem:
Traceback (Most recent call last):

to make this work with "import IPy" you need
to use "ip = IPy.IP('127.0.0.1/30')".
I've tried doing it like:
from IPy import *
And then doing that, but it gives mea different error. Thanks once again

what error are you getting? it works for me...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top