Advertisement
Advertisement
| 04.11.2008 at 07:34AM PDT, ID: 23315202 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: |
#!/usr/bin/python import asyncore, socket host = "(first 3 octets of an ip address)" port = # a port goes here class http_client(asyncore.dispatcher): def __init__(self, host, port): asyncore.dispatcher.__init__(self) self.host = host self.port = port self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.setblocking(0) self.settimeout(3) print "Connecting to "+str(self.host)+" on port "+str(self.port) try: self.connect((self.host, self.port)) except: self.close() def handle_connect(self): print str(self.host)+" on port "+str(self.port)+" OPEN" self.close() def handle_close(self): self.close() def handle_read(self): self.close() def writable(self): self.close() def handle_write(self): self.close() digit = 1 while digit < 255: zhost = str(host)+'.'+str(digit) c = http_client(zhost, port) try: asyncore.loop() except: pass digit += 1 |