-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
clipboard1903.sql
184 lines (170 loc) · 9.54 KB
/
clipboard1903.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
Select
ActivityOperation.ETag as 'Etag',
datetime(ActivityOperation.StartTime, 'unixepoch', 'localtime') as 'StartTime',
datetime(ActivityOperation.LastModifiedTime, 'unixepoch', 'localtime') as 'LastModified',
case
when json_extract(ActivityOperation.AppId, '$[0].application') = '308046B0AF4A39CB'
then 'Mozilla Firefox-64bit'
when json_extract(ActivityOperation.AppId, '$[0].application') = 'E7CF176E110C211B'
then 'Mozilla Firefox-32bit'
when json_extract(ActivityOperation.AppId, '$[1].application') = '308046B0AF4A39CB'
then 'Mozilla Firefox-64bit'
when json_extract(ActivityOperation.AppId, '$[1].application') = 'E7CF176E110C211B'
then 'Mozilla Firefox-32bit'
when length (json_extract(ActivityOperation.AppId, '$[1].application')) between 17 and 22
then
replace(replace(replace(replace(replace
(json_extract(ActivityOperation.AppId, '$[0].application'),
'{'||'6D809377-6AF0-444B-8957-A3773F02200E'||'}', '*ProgramFiles (x64)'),
'{'||'7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E'||'}', '*ProgramFiles (x32)'),
'{'||'1AC14E77-02E7-4E5D-B744-2EB1AE5198B7'||'}', '*System' ),
'{'||'F38BF404-1D43-42F2-9305-67DE0B28FC23'||'}', '*Windows'),
'{'||'D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27'||'}', '*System32')
else replace(replace(replace(replace(replace(json_extract(ActivityOperation.AppId,
'$[1].application'),
'{'||'6D809377-6AF0-444B-8957-A3773F02200E'||'}', '*ProgramFiles (x64)' ),
'{'||'7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E'||'}', '*ProgramFiles (x32)'),
'{'||'1AC14E77-02E7-4E5D-B744-2EB1AE5198B7'||'}', '*System' ),
'{'||'F38BF404-1D43-42F2-9305-67DE0B28FC23'||'}', '*Windows'),
'{'||'D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27'||'}', '*System32')
end as 'Application',
case when json_extract(ActivityOperation.ClipboardPayload, '$[0].formatName') = 'Text' then
json_extract(ActivityOperation.ClipboardPayload, '$[0].content') else ' ' end as 'Clip Text(Base64)',
json_extract(ActivityOperation.ClipboardPayload, '$[0].formatName') as 'Format',
json_extract(ActivityOperation.Payload, '$.1[0].content') as 'Payload Content',
json_extract(ActivityOperation.Payload, '$.1[0].formatName') as 'Type',
case ActivityOperation.ActivityType
when 5 then 'Open App/File/Page'
when 6 then 'App In Use/Focus'
when 10 then 'Clipboard'
when 16 then 'Copy/Paste'
else ActivityOperation.ActivityType end as 'Activity_type',
ActivityOperation."Group" as 'Group',
ActivityOperation.GroupAppActivityId as 'GroupAppActivityId',
ActivityOperation.GroupItems as 'GroupItems',
json_extract(ActivityOperation.Payload, '$.clipboardDataId') as 'clipboardDataId',
'{' || substr(hex(Activity_PackageId.ActivityId), 1, 8) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 9, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 13, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 17, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 21, 12) || '}' as 'ActivityId',
case when hex(ActivityOperation.ParentActivityId) = '00000000000000000000000000000000'
then '' else
'{' || substr(hex(ActivityOperation.ParentActivityId), 1, 8) || '-' ||
substr(hex(ActivityOperation.ParentActivityId), 9, 4) || '-' ||
substr(hex(ActivityOperation.ParentActivityId), 13, 4) || '-' ||
substr(hex(ActivityOperation.ParentActivityId), 17, 4) || '-' ||
substr(hex(ActivityOperation.ParentActivityId), 21, 12) || '}' end as 'ParentActivityId',
ActivityOperation.DdsDeviceId as 'DdsDeviceId',
ActivityOperation.PlatformDeviceId as 'Device ID',
cast((ActivityOperation.ExpirationTime - ActivityOperation.LastModifiedTime) as integer) / '86400' as 'Expires In days',
case
when ActivityOperation.OriginalLastModifiedOnClient > 0
then datetime(ActivityOperation.OriginalLastModifiedOnClient, 'unixepoch', 'localtime')
else ' - '
end as 'LastModifiedOnClient',
case
when ActivityOperation.EndTime > 0
then datetime(ActivityOperation.EndTime, 'unixepoch', 'localtime')
else "-"
end as 'EndTime',
case
when ActivityOperation.CreatedInCloud > 0
then datetime(ActivityOperation.CreatedInCloud, 'unixepoch', 'localtime')
else "-"
end as 'CreatedInCloud',
datetime(Activity_PackageId.ExpirationTime, 'unixepoch', 'localtime') as 'Expiration on PackageID',
datetime(ActivityOperation.ExpirationTime, 'unixepoch', 'localtime') as 'Expiration',
'' as 'IsLocalOnly',
ActivityOperation.PackageIdHash as 'PackageIdHash',
ActivityOperation.Payload as 'Payload',
ActivityOperation.ClipboardPayload as 'ClipboardPayload'
from Activity_PackageId
join ActivityOperation on Activity_PackageId.ActivityId = ActivityOperation.Id
where Activity_PackageId.Platform = json_extract(ActivityOperation.AppId, '$[0].platform')
and Activity_PackageId.ActivityId = ActivityOperation.Id and ActivityOperation.ActivityType in (10,16)
union -- Join Activity & ActivityOperation Queries to get results from both Tables
Select
Activity.ETag as 'Etag',
datetime(Activity.StartTime, 'unixepoch', 'localtime') as 'StartTime',
datetime(Activity.LastModifiedTime, 'unixepoch', 'localtime') as 'LastModified',
case
when json_extract(Activity.AppId, '$[0].application') = '308046B0AF4A39CB'
then 'Mozilla Firefox-64bit'
when json_extract(Activity.AppId, '$[0].application') = 'E7CF176E110C211B'
then 'Mozilla Firefox-32bit'
when json_extract(Activity.AppId, '$[1].application') = '308046B0AF4A39CB'
then 'Mozilla Firefox-64bit'
when json_extract(Activity.AppId, '$[1].application') = 'E7CF176E110C211B'
then 'Mozilla Firefox-32bit'
when length (json_extract(Activity.AppId, '$[1].application')) between 17 and 22
then
replace(replace(replace(replace(replace
(json_extract(Activity.AppId, '$[0].application'),
'{'||'6D809377-6AF0-444B-8957-A3773F02200E'||'}', '*ProgramFiles (x64)'),
'{'||'7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E'||'}', '*ProgramFiles (x32)'),
'{'||'1AC14E77-02E7-4E5D-B744-2EB1AE5198B7'||'}', '*System' ),
'{'||'F38BF404-1D43-42F2-9305-67DE0B28FC23'||'}', '*Windows'),
'{'||'D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27'||'}', '*System32')
else replace(replace(replace(replace(replace(json_extract(Activity.AppId,
'$[1].application'),
'{'||'6D809377-6AF0-444B-8957-A3773F02200E'||'}', '*ProgramFiles (x64)' ),
'{'||'7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E'||'}', '*ProgramFiles (x32)'),
'{'||'1AC14E77-02E7-4E5D-B744-2EB1AE5198B7'||'}', '*System' ),
'{'||'F38BF404-1D43-42F2-9305-67DE0B28FC23'||'}', '*Windows'),
'{'||'D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27'||'}', '*System32')
end as 'Application',
case when json_extract(Activity.ClipboardPayload, '$[0].formatName') = 'Text' then
json_extract(Activity.ClipboardPayload, '$[0].content') else ' ' end as 'Clip Text(Base64)',
json_extract(Activity.ClipboardPayload, '$[0].formatName') as 'Format',
json_extract(Activity.Payload, '$.1[0].content') as 'Payload Content',
json_extract(Activity.Payload, '$.1[0].formatName') as 'Type',
case Activity.ActivityType
when 5 then 'Open App/File/Page' when 6 then 'App In Use/Focus'
when 10 then 'Clipboard' when 16 then 'Copy/Paste'
else Activity.ActivityType end as 'Activity_type',
Activity."Group" as 'Group',
Activity.GroupAppActivityId as 'GroupAppActivityId',
Activity.GroupItems as 'GroupItems',
'{' || substr(hex(Activity_PackageId.ActivityId), 1, 8) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 9, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 13, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 17, 4) || '-' ||
substr(hex(Activity_PackageId.ActivityId), 21, 12) || '}' as 'ActivityId',
case when hex(Activity.ParentActivityId) = '00000000000000000000000000000000'
then '' else
'{' || substr(hex(Activity.ParentActivityId), 1, 8) || '-' ||
substr(hex(Activity.ParentActivityId), 9, 4) || '-' ||
substr(hex(Activity.ParentActivityId), 13, 4) || '-' ||
substr(hex(Activity.ParentActivityId), 17, 4) || '-' ||
substr(hex(Activity.ParentActivityId), 21, 12) || '}' end as 'ParentActivityId',
json_extract(Activity.Payload, '$.clipboardDataId') as 'clipboardDataId',
Activity.DdsDeviceId as 'DdsDeviceId',
Activity.PlatformDeviceId as 'Device ID',
cast((Activity.ExpirationTime - Activity.LastModifiedTime) as integer) / '86400' as 'Expires In days',
case
when Activity.OriginalLastModifiedOnClient > 0
then datetime(Activity.OriginalLastModifiedOnClient, 'unixepoch', 'localtime')
else ' - '
end as 'LastModifiedOnClient',
case
when Activity.EndTime > 0
then datetime(Activity.EndTime, 'unixepoch', 'localtime')
else "-"
end as 'EndTime',
case
when Activity.CreatedInCloud > 0
then datetime(Activity.CreatedInCloud, 'unixepoch', 'localtime')
else "-"
end as 'CreatedInCloud',
datetime(Activity_PackageId.ExpirationTime, 'unixepoch', 'localtime') as 'Expiration on PackageID',
datetime(Activity.ExpirationTime, 'unixepoch', 'localtime') as 'Expiration',
case Activity.IsLocalOnly when 0 then 'No' when 1 then 'Yes' else Activity.IsLocalOnly end as 'IsLocalOnly',
Activity.PackageIdHash as 'PackageIdHash',
Activity.Payload as 'Payload',
Activity.ClipboardPayload as 'ClipboardPayload'
from Activity_PackageId
join Activity on Activity_PackageId.ActivityId = Activity.Id
where Activity_PackageId.Platform = json_extract(Activity.AppId, '$[0].platform')
and Activity_PackageId.ActivityId = Activity.Id and Activity.ActivityType in (10,16)
order by Etag desc;