Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from twisted.internet import reactor, defer
- from connectiontester import testConnect
- def handleAllResults(allResults, ports):
- for port, results in zip(ports, allResults):
- success, result = results
- if success:
- print "Connected to port %i" % port
- reactor.stop()
- import sys
- host = sys.argv[1]
- ports = range(1, 201)
- testers = [testConnect(host, port) for port in ports]
- defer.DeferredList(testers, consumeErrors=True).addCallback(
- handleAllResults, ports)
- reactor.run()
- # $ python portscan.py localhost
- #Connected to port 21
- #Connected to port 22
- #Connected to port 25
- #Connected to port 80
- #Connected to port 81
- #Connected to port 111
- #Connected to port 139
- #Connected to port 143
Add Comment
Please, Sign In to add comment