[HELP]port scan multi threads

[HELP]port scan multi threads

Postby unname121992 » Thu Jun 06, 2013 7:57 am

Hello all,i'm newbie,i want to write a python script to scan multi IPs with multi ports,but my code is error,please help me
error :
Code: Select all
Exception in thread Thread-2
Traceback (most recent call last):
FIle "C:\Python27\lib\threadiing.py",line 808,in __bootstrap_inner
self.run()
FIle "C:\Python27\lib\threadiing.py",line 761,in run
self.__target(*self.__args,**self.__kwargs)
typeError: connect() take 2 arguments(15 given)



My CODE :
Code: Select all
import socket
import threading
MAX_THREADS = 5

class Scan(threading.Thread):
    def __init__(self):
  threading.Thread.__init__(self)
  self.target_ip = "173.194.69.147-150"
  self.ports = (22,80,445,1433,1521,3389,1,2,3,4,5,6,7,8,9,10)   

 
    def connect(self,IP):
    try:
    # connect to the given host:port
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(2)
    sock.connect((IP, self.ports))   
    print "%s:%d OPEN" % (IP, self.ports)
    sock.close()
    except: pass

    def scan(self):   
  remoteServer_ = self.target_ip.split('-')
  remoteServer__ = remoteServer_[0].split('.')
  try:
    for ip in range(int(remoteServer__[3]),int(remoteServer_[1])+1):
    _ip_ = remoteServer__[0]+"."+remoteServer__[1]+"."+remoteServer__[2]+"."+str(ip)
    print "== IP: "+_ip_+" ==\n"
     # while threading.activeCount() < MAX_THREADS:
    threading.Thread(target=self.connect, args=(_ip_)).start()
     #   self.ports.index += 1 
  except (socket.timeout, socket.error):
    return port, False

if __name__ == '__main__':
    Scan().scan()
    raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.')



Thank
Last edited by unname121992 on Fri Jun 07, 2013 2:31 am, edited 1 time in total.
unname121992
 
Posts: 2
Joined: Thu Jun 06, 2013 7:52 am

Re: [HELP]port scan multi threads

Postby gratuitous_arp » Thu Jun 06, 2013 11:49 am

I don't think anyone here is going to help you write a port scanner. You do know that using scanning information to gain unauthorized access to another organization's network and servers is illegal and can land you in a mess of trouble that you'll regret later in life, right? What do you have against Time Warner?
gratuitous_arp
 
Posts: 6
Joined: Tue Apr 16, 2013 11:10 pm

Re: [HELP]port scan multi threads

Postby unname121992 » Fri Jun 07, 2013 2:36 am

gratuitous_arp wrote:I don't think anyone here is going to help you write a port scanner. You do know that using scanning information to gain unauthorized access to another organization's network and servers is illegal and can land you in a mess of trouble that you'll regret later in life, right? What do you have against Time Warner?


you're thinking too far ! it's only small tools that my teacher want we do
unname121992
 
Posts: 2
Joined: Thu Jun 06, 2013 7:52 am


Return to Networking

Who is online

Users browsing this forum: No registered users and 4 guests