Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- # Travis Gayle
- import os
- import socket
- import sys
- import time
- # Constants
- ADDRESS = 'xavier.h4x0r.space'
- PROGRAM = os.path.basename(sys.argv[0])
- CONNECT = False
- while not CONNECT:
- # Echo Client
- for P in xrange(9700,9799):
- client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- client.connect((ADDRESS, P)) # Connect to server with ADDRESS and PORT
- CONNECT = True
- print "Port {}: ACCEPTED!".format(P)
- break
- except socket.error:
- print "Port {}: REJECTED!".format(P)
- #except KeyboardInterrupt:
- # print "KeyboardInterrupt detected!"
- # sys.exit(1)
- stream = client.makefile('w+') # Create file object from socket
- data = sys.stdin.readline()
- while data:
- # Send STDIN to Server
- stream.write(data)
- stream.flush()
- # Read from Server to STDOUT
- data = stream.readline()
- sys.stdout.write(data)
- # Read from STDIN
- data = sys.stdin.readline()
- # If I were a unix utility I would be pwd because the command is cool and I would always know where I am.
- # My favorite part of the course was the times where I felt like I was actually learning.
- # 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