Skip to content

Commit b417224

Browse files
authored
Create Windows.Detection.Honeyfile.yaml (#1012)
1 parent f4ff934 commit b417224

File tree

5 files changed

+198
-150
lines changed

5 files changed

+198
-150
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Windows.Detection.Honeyfiles
2+
author: Zane Gittins & Matt Green (@mgreen27).
3+
description: |
4+
This artifact deploys honeyfiles according to the Honeyfiles CSV parameter. It then monitors access to these files using etw. The process tracker must be enabled, we use this to enrich etw events. Honeyfiles created by this artifact are removed at exit.
5+
6+
* TargetPath - Location to create honeyfile.
7+
* Enabled - Only generate the honeyfile if this is set to 'Y'
8+
* MagicBytes - The starting magic bytes of the honeyfile.
9+
* MinSize,MaxSize - The size of the honeyfile will be a random value between MinSize and MaxSize.
10+
11+
type: CLIENT_EVENT
12+
13+
parameters:
14+
- name: Honeyfiles
15+
description: The honeyfiles to generate and monitor.
16+
type: csv
17+
default: |
18+
TargetPath,Enabled,MagicBytes,MinSize,MaxSize
19+
"%USERPROFILE%\Documents\KeePass\KeePass.kdbx",Y,03D9A29A67FB4BB5,10249,20899
20+
"%USERPROFILE%\AppData\Local\KeePass\KeePass.config.xml",Y,3C3F786D6C,512,1024
21+
"%USERPROFILE%\AppData\Local\LastPass\lastpass.conf",Y,3C3F786D6C,512,1024
22+
"%USERPROFILE%\AppData\Roaming\LastPass\loginState.xml",Y,3C3F786D6C,512,1024
23+
"%USERPROFILE%\AppData\Roaming\WinSCP\WinSCP.ini",Y,5B436F6E66696775726174696F6E5D,512,1024
24+
"%USERPROFILE%\.aws\credentials",Y,5B64656661756C745D,512,2048
25+
"%USERPROFILE%\.aws\config",Y,5B64656661756C745D,512,2048
26+
"%USERPROFILE%\.ssh\my_id_rsa",Y,2D2D2D2D2D424547494E205253412050524956415445204B45592D2D2D2D2D,1024,4096
27+
"%USERPROFILE%\.gcloud\credentials.db",Y,53514c69746520666f726d6174203300,512,2048
28+
"%USERPROFILE%\.azure\azureProfile.json",Y,7B0D0A,512,2048
29+
- name: ProcessExceptionsRegex
30+
description: Except these processes from detections when they access honeyfiles.
31+
type: string
32+
default: "SearchProtocolHost.exe|Explorer.exe"
33+
- name: HoneyUserRegex
34+
description: User name regex that will be used to host honeyfiles.
35+
type: string
36+
default: "."
37+
sources:
38+
- precondition:
39+
SELECT OS From info() where OS = 'windows'
40+
41+
query: |
42+
LET RandomChars(size) = SELECT
43+
format(format="%02x", args=rand(range=256)) AS HexByte
44+
FROM range(end=size)
45+
46+
LET check_exist(path) = SELECT
47+
OSPath,
48+
Size,
49+
IsDir,
50+
if(condition=read_file(filename=OSPath)[-7:] =~ 'VRHoney',
51+
then=True,
52+
else=False) AS IsHoneyFile
53+
FROM stat(filename=path)
54+
55+
LET enumerate_path = SELECT
56+
regex_replace(source=TargetPath,
57+
re='''\%USERPROFILE\%''',
58+
replace=Directory) AS TargetPath,
59+
*,
60+
check_exist(path=regex_replace(source=TargetPath,
61+
re='''\%USERPROFILE\%''',
62+
replace=Directory))[0] AS Exists,
63+
MaxSize - rand(range=(MaxSize - MinSize)) - len(
64+
list=unhex(string=MagicBytes)) - 7 AS _PaddingSize
65+
FROM Honeyfiles
66+
67+
LET target_users = SELECT Name,
68+
Directory,
69+
UUID
70+
FROM Artifact.Windows.Sys.Users()
71+
WHERE NOT UUID =~ '''^(S-1-5-18|S-1-5-19|S-1-5-20)$'''
72+
AND Name =~ HoneyUserRegex
73+
74+
LET show_honeyfiles = SELECT TargetPath,
75+
Enabled,
76+
MagicBytes,
77+
MinSize,
78+
MaxSize,
79+
_PaddingSize,
80+
Exists.Size AS Size,
81+
Exists.IsHoneyFile AS IsHoneyFile
82+
FROM foreach(row=target_users, query=enumerate_path)
83+
84+
LET copy_honeyfiles = SELECT
85+
*, if(condition=Enabled =~ "^(Y|YES)$"
86+
AND (NOT Size OR IsHoneyFile),
87+
then=log(message="Creating file %v", dedup=-1, args=TargetPath)
88+
&& copy(dest=TargetPath,
89+
create_directories='y',
90+
accessor='data',
91+
filename=unhex(
92+
string=MagicBytes + join(
93+
array=RandomChars(size=_PaddingSize).HexByte) +
94+
format(format='%x', args='VRHoney'))),
95+
else="File does not exist") AS CreateHoneyFile
96+
FROM show_honeyfiles
97+
98+
LET remove_honeyfiles = SELECT
99+
*, _PaddingSize,
100+
if(condition=IsHoneyFile,
101+
then=log(message="Removing %v", args=TargetPath, dedup=-1)
102+
&& rm(filename=TargetPath),
103+
else="File does not exist") AS RemoveHoneyFile
104+
FROM show_honeyfiles
105+
106+
LET add_honeyfiles = SELECT
107+
TargetPath,
108+
Enabled,
109+
MagicBytes,
110+
MinSize,
111+
MaxSize,
112+
check_exist(path=TargetPath)[0].Size AS Size,
113+
check_exist(path=TargetPath)[0].IsHoneyFile AS IsHoneyFile
114+
FROM copy_honeyfiles
115+
116+
LET _ <= atexit(query={ SELECT * FROM remove_honeyfiles })
117+
118+
LET WatchFiles <= to_dict(item={
119+
SELECT TargetPath AS _key,
120+
IsHoneyFile AS _value
121+
FROM add_honeyfiles
122+
WHERE IsHoneyFile
123+
})
124+
125+
LET Keyword <= 5264
126+
127+
LET CurrentPid <= getpid()
128+
129+
LET TargetEvents = SELECT *
130+
FROM watch_etw(guid='{edd08927-9cc4-4e65-b970-c2560fb5c289}',
131+
description="Microsoft-Windows-Kernel-File",
132+
any=Keyword)
133+
WHERE System.ID = 12
134+
AND System.ProcessID != CurrentPid
135+
136+
LET AuditEvents = SELECT
137+
timestamp(string=System.TimeStamp) AS Timestamp,
138+
get(item=WatchFiles, field=EventData.FileName) AS IsHoneyFile,
139+
*
140+
FROM TargetEvents
141+
WHERE IsHoneyFile != NULL
142+
143+
LET Events = SELECT
144+
Timestamp,
145+
IsHoneyFile,
146+
System.ProcessID AS Pid,
147+
EventData.FileName AS TargetPath,
148+
process_tracker_get(id=System.ProcessID).Data AS ProcInfo,
149+
join(array=process_tracker_callchain(id=System.ProcessID).Data.Name,
150+
sep="->") AS CallChain
151+
FROM AuditEvents
152+
WHERE NOT ProcInfo.Exe =~ ProcessExceptionsRegex
153+
154+
SELECT *
155+
FROM delay(query=Events, delay=5)

content/exchange/artifacts/Windows.KapeFiles.Remapping.yaml

-127
This file was deleted.

scripts/exchange_verify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'''
2727
VELO_CONFIG_FILENAME = "/tmp/velo.config.yaml"
2828
VELO_FILENAME = "/tmp/velociraptor"
29-
VELO_URL = "https://github.com/Velocidex/velociraptor/releases/download/v0.72/velociraptor-v0.72.3-linux-amd64-musl"
29+
VELO_URL = "https://github.com/Velocidex/velociraptor/releases/download/v0.73/velociraptor-v0.73.4-linux-amd64-musl"
3030
EXCHANGE_PATH = os.path.abspath("./content/exchange/artifacts/")
3131
VELO_LOGFILE = "/tmp/velo.log"
3232

static/exchange/data.json

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
[
2+
{
3+
"title": "Linux.Detection.Honeyfiles",
4+
"author": "zaneGittins",
5+
"description": "This artifact deploys honeyfiles according to the Honeyfiles CSV parameter. It then monitors access to these files using eBPF. The process tracker must be enabled, we use this to enrich events. You also must be using Velociraptor >= 0.74 to support eBPF. Honeyfiles created by this artifact are removed at exit.",
6+
"link": "/exchange/artifacts/pages/linux.detection.honeyfiles",
7+
"tags": [],
8+
"author_link": "https://github.com/zaneGittins",
9+
"author_avatar": "https://avatars.githubusercontent.com/u/22203776?v=4",
10+
"date": "2025-03-18"
11+
},
12+
{
13+
"title": "MacOS.Forensics.ASL",
14+
"author": "ydkhatri",
15+
"description": "This artifact parses the ASL (Apple System Log) v2 files located at \n/private/var/log/asl/*.asl\n",
16+
"link": "/exchange/artifacts/pages/macos.forensics.asl",
17+
"tags": [],
18+
"author_link": "https://github.com/ydkhatri",
19+
"author_avatar": "https://avatars.githubusercontent.com/u/13247440?v=4",
20+
"date": "2025-02-19"
21+
},
222
{
323
"title": "Linux.Forensics.Targets",
424
"author": "kidrek",
@@ -236,7 +256,7 @@
236256
{
237257
"title": "Windows.EventLogs.SysmonProcessEnriched.yaml",
238258
"author": "zaneGittins",
239-
"description": "Gather sysmon process creation events from the sysmon operational event log. Enrich with authenticode signature of image and call chain.\nCaches authenticode signature by the hash of the image for ClearCacheSeconds (default, 1hr).\nPrerequisites: Sysmon, and the process tracker.\n",
259+
"description": "Gather sysmon process creation events from the sysmon operational event log. Enrich with authenticode signature of image and call chain.\nCaches authenticode signature by the hash of the image for an hour to reduce number of times it fetches the authenticode signature.\nPrerequisites: Sysmon, and the process tracker artifact.\n",
240260
"link": "/exchange/artifacts/pages/windows.eventlogs.sysmonprocessenriched",
241261
"tags": [],
242262
"author_link": "https://github.com/zaneGittins",
@@ -1882,16 +1902,6 @@
18821902
"author_avatar": "https://avatars.githubusercontent.com/u/13081800?v=4",
18831903
"date": "2022-08-12"
18841904
},
1885-
{
1886-
"title": "Windows.KapeFiles.Remapping",
1887-
"author": "scudette",
1888-
"description": "This artifact automates the rebuilding of remapping rules to be able to easily\npost process the results of the Windows.KapeFiles.Targets.",
1889-
"link": "/exchange/artifacts/pages/windows.kapefiles.remapping",
1890-
"tags": [],
1891-
"author_link": "https://github.com/scudette",
1892-
"author_avatar": "https://avatars.githubusercontent.com/u/3856546?v=4",
1893-
"date": "2022-08-04"
1894-
},
18951905
{
18961906
"title": "Server.Enrichment.MalwareBazaar",
18971907
"author": "weslambert",
@@ -2772,5 +2782,15 @@
27722782
"author_link": "https://github.com/ffh571",
27732783
"author_avatar": "https://avatars.githubusercontent.com/u/48983874?v=4",
27742784
"date": "2021-06-23"
2785+
},
2786+
{
2787+
"title": "Windows.Detection.Honeyfiles",
2788+
"author": "",
2789+
"description": "This artifact deploys honeyfiles according to the Honeyfiles CSV parameter. It then monitors access to these files using etw. The process tracker must be enabled, we use this to enrich etw events. Honeyfiles created by this artifact are removed at exit.",
2790+
"link": "/exchange/artifacts/pages/windows.detection.honeyfile",
2791+
"tags": [],
2792+
"author_link": "",
2793+
"author_avatar": "",
2794+
"date": ""
27752795
}
27762796
]

static/kb/data.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
[
2+
{
3+
"title": "How to setup an SFTP server",
4+
"link": "/knowledge_base/tips/setting_up_sftp",
5+
"tags": [
6+
"deployment"
7+
],
8+
"author": "scudette",
9+
"author_link": "https://github.com/scudette",
10+
"author_avatar": "https://avatars.githubusercontent.com/u/3856546?v=4",
11+
"date": "2025-02-25"
12+
},
213
{
314
"title": "How can I automatically add & update client metadata?",
415
"link": "/knowledge_base/tips/automating_metadata",
@@ -424,16 +435,5 @@
424435
"author_avatar": "https://avatars.githubusercontent.com/u/3856546?v=4",
425436
"author_link": "https://github.com/scudette",
426437
"date": "2022-03-21"
427-
},
428-
{
429-
"title": "How to setup an SFTP server",
430-
"link": "/knowledge_base/tips/setting_up_sftp",
431-
"tags": [
432-
"deployment"
433-
],
434-
"author": "",
435-
"author_link": "",
436-
"author_avatar": "",
437-
"date": ""
438438
}
439439
]

0 commit comments

Comments
 (0)