Author Topic: Question:Subnet port scanner  (Read 597 times)

0 Members and 1 Guest are viewing this topic.

Offline Clone

  • Peasant
  • *
  • Posts: 50
  • Cookies: 2
  • Always trying to find the value of x
    • View Profile
Question:Subnet port scanner
« on: February 02, 2014, 10:12:35 am »
I need help i started python network prog and wanted to know how you could port scan a hosts in a subnet for open ports.The example of my dried up port scanner,again just a simple one:
Code: (Python) [Select]
import socket as sock
s=sock.socket()
Target_ip=raw_input("Enter target address:")
start=input("Enter starting port:")
end=input("Enter ending port:")
if start>end:
    print"Error:Ending port<start port\n"*5
else:
    print"Scanning ",Target_ip,"..."
    target_ip=sock.gethostbyname(Target_ip)
    try:
        while start<=end:
            r=s.connect_ex((target_ip,start))
            if r==0:
                print"port ",start,":OPEN"
            else:
                print "port ",start,":CLOSED"
                start=start+1
    except:
        print"The following errors might have occured 1.)You are not connected to the network.\n2.)Wrong Address\n"
    else:
        print"End of scan."
        s.close()           
« Last Edit: February 16, 2014, 06:18:11 pm by Clone »
One who walks the line between light and dark, with no ties to either side. No morals or emotions clouding their judgment,able to accomplish tasks and solve problems in the most efficient and logical way.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Question:Subnet port scanner
« Reply #1 on: February 02, 2014, 11:12:54 am »
Good,

You should add shorter timeouts for a connect scan , it will take forever otherwise.
Suggest you take a look at SYN and ACK scanning.
Scapy might offer some help here.

You need help on what?
« Last Edit: February 02, 2014, 11:13:11 am by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline Clone

  • Peasant
  • *
  • Posts: 50
  • Cookies: 2
  • Always trying to find the value of x
    • View Profile
Re: Question:Subnet port scanner
« Reply #2 on: February 02, 2014, 07:24:59 pm »
Thanks I will add shorter timeouts its only a draft i posted.anyway I was thinking in terms of subnets,so how would you port scan a subnet lets say my ip address is "10.0.6.123" and i want to port scan ip "10.0.6.140" how would i script such a port scanner.In other words how do you scan ips in the same subnet.
« Last Edit: February 02, 2014, 07:27:32 pm by Clone »
One who walks the line between light and dark, with no ties to either side. No morals or emotions clouding their judgment,able to accomplish tasks and solve problems in the most efficient and logical way.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Question:Subnet port scanner
« Reply #3 on: February 02, 2014, 07:32:17 pm »
You just let it connect with all the adresses in the subnet.
for I  in range(1,254):
               Do something here
« Last Edit: February 02, 2014, 07:32:24 pm by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline Clone

  • Peasant
  • *
  • Posts: 50
  • Cookies: 2
  • Always trying to find the value of x
    • View Profile
Re: Question:Subnet port scanner
« Reply #4 on: February 02, 2014, 07:38:55 pm »
i see... thanks i really appreciate the advice  :)   
One who walks the line between light and dark, with no ties to either side. No morals or emotions clouding their judgment,able to accomplish tasks and solve problems in the most efficient and logical way.