It's simpel!

You only have to make a program there Connact to target to se if the port are open! you kan use a for command:

a = some input (start)
b = some input (end)

for(i = a; i <= b; i++)
{
If()
blah
else
blah
}

There you can scan the ranke the user type!