Advertisement
Guest User

Untitled

a guest
May 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. # Travis Gayle
  3. import os
  4. import socket
  5. import sys
  6. import time
  7.  
  8. # Constants
  9.  
  10. ADDRESS = 'xavier.h4x0r.space'
  11. PROGRAM = os.path.basename(sys.argv[0])
  12.  
  13. CONNECT = False
  14.  
  15. while not CONNECT:
  16. # Echo Client
  17. for P in xrange(9700,9799):
  18. client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  19.  
  20. try:
  21. client.connect((ADDRESS, P)) # Connect to server with ADDRESS and PORT
  22. CONNECT = True
  23. print "Port {}: ACCEPTED!".format(P)
  24. break
  25.  
  26. except socket.error:
  27. print "Port {}: REJECTED!".format(P)
  28. #except KeyboardInterrupt:
  29. # print "KeyboardInterrupt detected!"
  30. # sys.exit(1)
  31.  
  32. stream = client.makefile('w+') # Create file object from socket
  33. data = sys.stdin.readline()
  34.  
  35.  
  36. while data:
  37. # Send STDIN to Server
  38. stream.write(data)
  39. stream.flush()
  40.  
  41. # Read from Server to STDOUT
  42. data = stream.readline()
  43. sys.stdout.write(data)
  44.  
  45. # Read from STDIN
  46. data = sys.stdin.readline()
  47.  
  48. # If I were a unix utility I would be pwd because the command is cool and I would always know where I am.
  49.  
  50. # My favorite part of the course was the times where I felt like I was actually learning.
  51.  
  52. # My least favorite part was the last week where everything seemed like it fell apart and all happened at once.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement