Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

portscanner in python help


ghost's Avatar
0 0

My code doesnt work lol, I think i'm forgetting somethign :S

import socket
# gathering info
host = raw_input( "What is the IP? " )
port0 = raw_input( "What is the starting port? " )
port1 = raw_input( "What is the finishing port? " )
output = raw_input( "What shall the output file be called? " )
# checking ports
port = port0
while port <= port1:
# creating the socket
   s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
   s.connect((host, port))
   s.send()
   data = s.recv(1) # read only one byte
   if (data > 0):
          z.open( output + ".txt", "a" )
          z.wrtie( port + "open" )
          z.close()
          s.close()
          port = port + "1"
   else :
          z.open( output + ".txt", "a" )
          z.write( port + "closed" )
          z.close()
          s.close()
          port = port + "1"

ghost's Avatar
0 0

Fixed it the correct code is available at the open source section in programming