Created
August 20, 2016 14:05
-
-
Save vivosmith/4c1b5b4fff23a2232be7bb64b95be3e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
s = socket.socket() | |
host = socket.gethostname() | |
port = 1231 | |
s.connect((host, port)) | |
print (s.recv(1024)) | |
filename=input('Choose the file') | |
filez=''.join(filename) | |
s.send(filez.encode()) | |
j = open(filez,"wb+") | |
l = s.recv(1024) | |
while(l): | |
j.read(l) | |
j.write(l) | |
l = s.recv(1024) | |
j.close() | |
s.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
from os import listdir | |
import os | |
import random | |
invite=random.randint(1,100000) | |
key=random.randint(1,1000000) | |
combinedkey=str(key) + str(invite) + "\n" | |
keyfile=open('keylist.txt', 'a') | |
keyfile.write(combinedkey) | |
keyfile.close() | |
commondirectory='/home/communaldump/' | |
files=os.listdir(commondirectory) | |
filelist=''.join(files) | |
s=socket.socket() | |
host=socket.gethostname() | |
port=1231 | |
s.bind((host,port)) | |
s.listen(5) | |
while True: | |
conn,addr=s.accept() | |
print 'got connection from' | |
print "%s" % (addr,) | |
conn.send('Thank you for connecting') | |
conn.send("\n") | |
conn.send(filelist) | |
data = conn.recv(1024) | |
print "%s" % data | |
sdata=commondirectory+data | |
f=open(sdata,"rb+") | |
l=f.read() | |
while (l): | |
l=f.read() | |
conn.sendall(l) | |
f.close() | |
conn.close() | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment