Created
August 18, 2016 08:02
-
-
Save vivosmith/ff809cc12c97aa14ac987e2f87846981 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()) | |
l = s.recv(1024) | |
has='has' | |
j = open(filez,"wb+") | |
j.read() | |
j.write(l) | |
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() | |
conn.send(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