Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from uploader import Uploader as VUploader
- from threading import Thread
- from socket import *
- import tempfile
- import os
- from subprocess import call
- class UppinoPy(Thread):
- def __init__(self, ip, port, sock):
- Thread.__init__(self)
- self.ip = ip
- self.port = port
- self.sock = sock
- def run(self):
- data = b""
- buf = "dummy"
- while len(buf):
- buf = self.sock.recv(2048)
- data += buf
- v = VUploader('/dev/ttymxc3', data)
- v.upload()
- class UppinoC(Thread):
- def __init__(self, ip, port, sock):
- Thread.__init__(self)
- self.ip = ip
- self.port = port
- self.sock = sock
- def run(self):
- data = b""
- buf = "dummy"
- while len(buf):
- buf = self.sock.recv(2048)
- data += buf
- (handle, path) = tempfile.mkstemp()
- os.write(handle, data)
- os.close(handle)
- print(path)
- os.system("bash ./uppa.sh " + path)
- class ProxyPy(Thread):
- def __init__(self, port=1234):
- Thread.__init__(self)
- self.sock = socket(AF_INET, SOCK_STREAM)
- self.sock.bind(("0.0.0.0", port))
- self.sock.listen(1)
- def run(self):
- while True:
- (sock, (ip, port)) = self.sock.accept()
- UppinoPy(ip, port, sock).start()
- class ProxyC(Thread):
- def __init__(self, port=23456):
- Thread.__init__(self)
- self.sock = socket(AF_INET, SOCK_STREAM)
- print(self.sock)
- self.sock.bind(("0.0.0.0", port))
- self.sock.listen(1)
- def run(self):
- while True:
- (sock, (ip, port)) = self.sock.accept()
- UppinoC(ip, port, sock).start()
- if __name__ == '__main__':
- py = ProxyPy()
- c = ProxyC()
- py.start()
- c.start()
- py.join()
- c.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement