Guest User

Untitled

a guest
Jul 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. from twisted.internet import reactor, defer
  2. from connectiontester import testConnect
  3.  
  4. def handleAllResults(allResults, ports):
  5. for port, results in zip(ports, allResults):
  6. success, result = results
  7. if success:
  8. print "Connected to port %i" % port
  9. reactor.stop()
  10.  
  11. import sys
  12. host = sys.argv[1]
  13. ports = range(1, 201)
  14. testers = [testConnect(host, port) for port in ports]
  15. defer.DeferredList(testers, consumeErrors=True).addCallback(
  16. handleAllResults, ports)
  17. reactor.run()
  18.  
  19. # $ python portscan.py localhost
  20. #Connected to port 21
  21. #Connected to port 22
  22. #Connected to port 25
  23. #Connected to port 80
  24. #Connected to port 81
  25. #Connected to port 111
  26. #Connected to port 139
  27. #Connected to port 143
Add Comment
Please, Sign In to add comment