Hi
I wonder How I can add version detection to port scanning?

from socket import * 

ip = raw_input("Enter IP to scan : ")

start=input("Enter start port number : ")

end=input("Enter end port number : ") 

print "Scanning IP: " , ip
for port in range(start,end):
    s =socket(AF_INET, SOCK_STREAM)

    if(s.connect_ex((ip,port))==0):
        print "Port " , port, "is open"

    s.close()

print "Port scanning completed now."

Recommended Answers

All 2 Replies

What type of Version do you have in mind?

For example, here you see the version of open port

PORT      STATE    SERVICE         VERSION
1/tcp     filtered tcpmux
3/tcp     filtered compressnet
4/tcp     filtered unknown
6/tcp     filtered unknown
7/tcp     filtered echo
9/tcp     filtered discard
13/tcp    filtered daytime
17/tcp    filtered qotd
19/tcp    filtered chargen
21/tcp    open     ftp             Pure-FTPd
22/tcp    filtered ssh
25/tcp    filtered smtp
26/tcp    open     smtp            Exim smtpd 4.80
53/tcp    open     domain
80/tcp    open     http?
110/tcp   open     pop3            Dovecot pop3d
143/tcp   open     imap            Dovecot imapd


root@bt:/pentest/web/nikto# ./nikto.pl -h xxx.com

2222/tcp  open     ssh          OpenSSH 5.3 (protocol 2.0)
3306/tcp  open     mysql        MySQL 5.5.23-55

As you see the version of ssh is OpenSSH 5.3 (protocol 2.0)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.