Advertisement
wandrake

Untitled

Dec 10th, 2014
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. from uploader import Uploader as VUploader
  2. from threading import Thread
  3. from socket import *
  4. import tempfile
  5. import os
  6. from subprocess import call
  7.  
  8. class UppinoPy(Thread):
  9.  
  10.     def __init__(self, ip, port, sock):
  11.         Thread.__init__(self)
  12.         self.ip = ip
  13.         self.port = port
  14.         self.sock = sock
  15.  
  16.     def run(self):
  17.         data = b""
  18.         buf = "dummy"
  19.         while len(buf):
  20.             buf = self.sock.recv(2048)
  21.             data += buf
  22.         v = VUploader('/dev/ttymxc3', data)
  23.         v.upload()
  24.  
  25.  
  26. class UppinoC(Thread):
  27.  
  28.     def __init__(self, ip, port, sock):
  29.         Thread.__init__(self)
  30.         self.ip = ip
  31.         self.port = port
  32.         self.sock = sock
  33.  
  34.     def run(self):
  35.         data = b""
  36.         buf = "dummy"
  37.         while len(buf):
  38.             buf = self.sock.recv(2048)
  39.             data += buf
  40.         (handle, path) = tempfile.mkstemp()
  41.         os.write(handle, data)
  42.         os.close(handle)
  43.         print(path)
  44.         os.system("bash ./uppa.sh " + path)
  45.  
  46.  
  47. class ProxyPy(Thread):
  48.  
  49.     def __init__(self, port=1234):
  50.         Thread.__init__(self)
  51.         self.sock = socket(AF_INET, SOCK_STREAM)
  52.         self.sock.bind(("0.0.0.0", port))
  53.         self.sock.listen(1)
  54.  
  55.     def run(self):
  56.         while True:
  57.             (sock, (ip, port)) = self.sock.accept()
  58.             UppinoPy(ip, port, sock).start()
  59.  
  60. class ProxyC(Thread):
  61.  
  62.     def __init__(self, port=23456):
  63.         Thread.__init__(self)
  64.         self.sock = socket(AF_INET, SOCK_STREAM)
  65.         print(self.sock)
  66.         self.sock.bind(("0.0.0.0", port))
  67.         self.sock.listen(1)
  68.  
  69.     def run(self):
  70.         while True:
  71.             (sock, (ip, port)) = self.sock.accept()
  72.             UppinoC(ip, port, sock).start()
  73.  
  74. if __name__ == '__main__':
  75.     py = ProxyPy()
  76.     c = ProxyC()
  77.  
  78.     py.start()
  79.     c.start()
  80.     py.join()
  81.     c.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement