Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 21st, 2004, 5:48 PM   #1
Beegie_B
Programmer
 
Join Date: Nov 2004
Location: Windsor, Ontario, Canada
Posts: 32
Rep Power: 0 Beegie_B is on a distinguished road
Send a message via ICQ to Beegie_B Send a message via MSN to Beegie_B
This was written before my IP scanner, and yet again isn't to fancy or good... But I'm still going to throw it on here for Learning Reasons

#Python Port Scanner
#Orgiginal Idea by K1
#Code and Changes by Beegie_B

from socket import *
print """
  =========================================================================
  start() is to begin port scan, and man() is for a manual on how to use
  the port scanner.
  =========================================================================
  """
  
def scan(ip, min_port, max_port):
    open_ports = []
    print "Scanning...",
    setdefaulttimeout(.31)
    for port in range(min_port, max_port+1):
      #print "Scanning %d:"%port,
      #print port,
      try:
          s = socket(AF_INET, SOCK_STREAM)
          s.connect((ip, port))
          s.close()
          open_ports.append(port)
          #print "Open"
      except:
          pass
          #print "Closed"
    print
    print "Open Ports:", open_ports
    
def start():
  ip = raw_input("IP/Hostname: ")
  min_port = input("Start Port: ")
  max_port = input("End Port: ")
  scan(ip, min_port, max_port)

def man():
  print """
  To use first enter: start() and input the information.

  IP/Hostname: Is the IP address or DNS of the computer you wish to scan.
  eg. IP/Hostname: 112.32.2.42 or IP/Hostname: www.bastardshandbook.com

  Start Port: Is the port you wish to start the scan on.
  eg. Start Port: 21

  End Port: Is the port you wish to end the scan on.
  eg. End Port: 1203
  """

Again, Nothing Fancy...

Beeg
Beegie_B is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC