Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions volatility3/framework/symbols/windows/extensions/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,77 @@ def get_string(self) -> interfaces.objects.ObjectInterface:
encoding="utf16",
)

class tagCLIP(objects.StructType):
"""A class for clipboard format entries (one per clipboard item)"""

# TODO: Extend clipboard format mapping if needed.
CF_FORMATS = {
1: "CF_TEXT",
2: "CF_BITMAP",
3: "CF_METAFILEPICT",
7: "CF_OEMTEXT",
8: "CF_DIB",
13: "CF_UNICODETEXT",
14: "CF_ENHMETAFILE",
15: "CF_HDROP",
16: "CF_LOCALE",
17: "CF_DIBV5",
}

def get_format_name(self) -> str:
"""Returns the clipboard format as a human-readable string"""
try:
fmt_val = int(self.fmt)
return self.CF_FORMATS.get(fmt_val, f"CF_UNKNOWN({fmt_val:#x})")
except exceptions.InvalidAddressException:
return "CF_UNKNOWN"

class tagCLIPDATA(objects.StructType):
"""A class for clipboard data objects stored in Windows memory"""

def get_data(self) -> Optional[bytes]:
"""Returns the raw clipboard data as bytes"""

# TODO: Verify abData consistency; future Windows may change tagCLIPDATA layout.
try:
size = int(self.cbData)

# TODO: Improve clipboard size validation if needed.
MAX_CLIPBOARD_SIZE = 50 * 1024 * 1024 # 50 MiB
if size == 0 or size > MAX_CLIPBOARD_SIZE:
return None

layer = self._context.layers[self.vol.layer_name]
return layer.read(self.abData.vol.offset, size, pad=True)

except exceptions.InvalidAddressException:
return None

def get_text(self, fmt: str) -> Optional[str]:
"""Returns clipboard data as readable text if format is text-based"""
data = self.get_data()

if data is None:
return None

# TODO: Extend support for more clipboard formats as needed.

if fmt == "CF_UNICODETEXT":
return data.decode("utf-16-le", errors="replace").rstrip("\x00")
elif fmt in ("CF_TEXT", "CF_OEMTEXT"):
return data.decode("latin-1", errors="replace").rstrip("\x00")

elif fmt == "CF_HDROP":
# File paths stored as null-separated UTF-16 list
return data.decode("utf-16-le", errors="replace").rstrip("\x00")
return None

class_types = {
"tagWINDOWSTATION": tagWINDOWSTATION,
"tagDESKTOP": tagDESKTOP,
"tagWND": tagWND,
"_LARGE_UNICODE_STRING": LARGE_UNICODE_STRING,
# Clipboard plugin extensions
"tagCLIPDATA": tagCLIPDATA,
"tagCLIP": tagCLIP,
}
42 changes: 31 additions & 11 deletions volatility3/framework/symbols/windows/gui/gui-win10-10586-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13653,18 +13653,14 @@
"tagWINDOWSTATION": {
"fields": {
"pClipBase": {
"offset": 96,
"type": {
"kind": "pointer",
"subtype": {
"count": 104,
"subtype": {
"kind": "struct",
"name": "tagCLIP"
},
"kind": "array"
},
"kind": "pointer"
},
"offset": 96
"kind": "struct",
"name": "tagCLIP"
}
}
},
"dwSessionId": {
"type": {
Expand Down Expand Up @@ -18027,6 +18023,30 @@
},
"kind": "struct",
"size": 6
},
"tagCLIPDATA": {
"kind": "struct",
"size": 24,
"fields": {
"cbData": {
"offset": 16,
"type": {
"kind": "base",
"name": "unsigned long"
}
},
"abData": {
"offset": 20,
"type": {
"kind": "array",
"subtype": {
"kind": "base",
"name": "unsigned char"
},
"count": 0
}
}
}
}
},
"base_types": {
Expand Down Expand Up @@ -18790,4 +18810,4 @@
},
"format": "4.0.0"
}
}
}
42 changes: 31 additions & 11 deletions volatility3/framework/symbols/windows/gui/gui-win10-15063-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13653,18 +13653,14 @@
"tagWINDOWSTATION": {
"fields": {
"pClipBase": {
"offset": 96,
"type": {
"kind": "pointer",
"subtype": {
"count": 104,
"subtype": {
"kind": "struct",
"name": "tagCLIP"
},
"kind": "array"
},
"kind": "pointer"
},
"offset": 96
"kind": "struct",
"name": "tagCLIP"
}
}
},
"dwSessionId": {
"type": {
Expand Down Expand Up @@ -18027,6 +18023,30 @@
},
"kind": "struct",
"size": 6
},
"tagCLIPDATA": {
"kind": "struct",
"size": 24,
"fields": {
"cbData": {
"offset": 16,
"type": {
"kind": "base",
"name": "unsigned long"
}
},
"abData": {
"offset": 20,
"type": {
"kind": "array",
"subtype": {
"kind": "base",
"name": "unsigned char"
},
"count": 0
}
}
}
}
},
"base_types": {
Expand Down Expand Up @@ -18790,4 +18810,4 @@
},
"format": "4.0.0"
}
}
}
42 changes: 31 additions & 11 deletions volatility3/framework/symbols/windows/gui/gui-win10-16299-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13653,18 +13653,14 @@
"tagWINDOWSTATION": {
"fields": {
"pClipBase": {
"offset": 96,
"type": {
"kind": "pointer",
"subtype": {
"count": 104,
"subtype": {
"kind": "struct",
"name": "tagCLIP"
},
"kind": "array"
},
"kind": "pointer"
},
"offset": 96
"kind": "struct",
"name": "tagCLIP"
}
}
},
"dwSessionId": {
"type": {
Expand Down Expand Up @@ -18027,6 +18023,30 @@
},
"kind": "struct",
"size": 6
},
"tagCLIPDATA": {
"kind": "struct",
"size": 24,
"fields": {
"cbData": {
"offset": 16,
"type": {
"kind": "base",
"name": "unsigned long"
}
},
"abData": {
"offset": 20,
"type": {
"kind": "array",
"subtype": {
"kind": "base",
"name": "unsigned char"
},
"count": 0
}
}
}
}
},
"base_types": {
Expand Down Expand Up @@ -18790,4 +18810,4 @@
},
"format": "4.0.0"
}
}
}
42 changes: 31 additions & 11 deletions volatility3/framework/symbols/windows/gui/gui-win10-17134-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13696,18 +13696,14 @@
"tagWINDOWSTATION": {
"fields": {
"pClipBase": {
"offset": 96,
"type": {
"kind": "pointer",
"subtype": {
"count": 104,
"subtype": {
"kind": "struct",
"name": "tagCLIP"
},
"kind": "array"
},
"kind": "pointer"
},
"offset": 96
"kind": "struct",
"name": "tagCLIP"
}
}
},
"dwSessionId": {
"type": {
Expand Down Expand Up @@ -18070,6 +18066,30 @@
},
"kind": "struct",
"size": 6
},
"tagCLIPDATA": {
"kind": "struct",
"size": 24,
"fields": {
"cbData": {
"offset": 16,
"type": {
"kind": "base",
"name": "unsigned long"
}
},
"abData": {
"offset": 20,
"type": {
"kind": "array",
"subtype": {
"kind": "base",
"name": "unsigned char"
},
"count": 0
}
}
}
}
},
"base_types": {
Expand Down Expand Up @@ -18833,4 +18853,4 @@
},
"format": "4.0.0"
}
}
}
42 changes: 31 additions & 11 deletions volatility3/framework/symbols/windows/gui/gui-win10-17763-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13696,18 +13696,14 @@
"tagWINDOWSTATION": {
"fields": {
"pClipBase": {
"offset": 96,
"type": {
"kind": "pointer",
"subtype": {
"count": 104,
"subtype": {
"kind": "struct",
"name": "tagCLIP"
},
"kind": "array"
},
"kind": "pointer"
},
"offset": 96
"kind": "struct",
"name": "tagCLIP"
}
}
},
"dwSessionId": {
"type": {
Expand Down Expand Up @@ -18070,6 +18066,30 @@
},
"kind": "struct",
"size": 6
},
"tagCLIPDATA": {
"kind": "struct",
"size": 24,
"fields": {
"cbData": {
"offset": 16,
"type": {
"kind": "base",
"name": "unsigned long"
}
},
"abData": {
"offset": 20,
"type": {
"kind": "array",
"subtype": {
"kind": "base",
"name": "unsigned char"
},
"count": 0
}
}
}
}
},
"base_types": {
Expand Down Expand Up @@ -18833,4 +18853,4 @@
},
"format": "4.0.0"
}
}
}
Loading