|
| 1 | +name: Windows.Forensics.OneNoteHunt |
| 2 | +author: Andy Swift |
| 3 | +description: | |
| 4 | + Hunt OneNote files, search ASCII and UTF-16LE content, |
| 5 | + detect embedded image signatures, report keyword hits, |
| 6 | + and optionally upload files. |
| 7 | + Note: the BMP signature uses a 10-byte header pattern to reduce false positives. |
| 8 | +
|
| 9 | +type: CLIENT |
| 10 | + |
| 11 | +parameters: |
| 12 | +- name: TargetGlob |
| 13 | + description: Locations to search |
| 14 | + default: C:\Users\**\*.one |
| 15 | + |
| 16 | +- name: SearchRegexAscii |
| 17 | + type: regex |
| 18 | + default: (?i)powershell|password|key|private|username|pass|user|administration|admin|administrator|root |
| 19 | + |
| 20 | +- name: SearchRegexUtf16 |
| 21 | + type: regex |
| 22 | + default: (?i)p\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00|u\x00s\x00e\x00r\x00n\x00a\x00m\x00e\x00|r\x00o\x00o\x00t\x00|a\x00d\x00m\x00i\x00n\x00|k\x00e\x00y\x00|p\x00r\x00i\x00v\x00a\x00t\x00e\x00 |
| 23 | + |
| 24 | +- name: MaxRegexReadBytes |
| 25 | + type: int64 |
| 26 | + default: 52428800 |
| 27 | + |
| 28 | +- name: MaxFileSize |
| 29 | + type: int64 |
| 30 | + default: 104857600 |
| 31 | + |
| 32 | +- name: UploadOriginal |
| 33 | + type: bool |
| 34 | + default: false |
| 35 | + |
| 36 | +- name: IncludeNoHitFiles |
| 37 | + type: bool |
| 38 | + default: true |
| 39 | + |
| 40 | +sources: |
| 41 | + |
| 42 | +- name: FileSummary |
| 43 | + precondition: |
| 44 | + SELECT OS FROM info() |
| 45 | + WHERE OS='windows' |
| 46 | + |
| 47 | + query: | |
| 48 | +
|
| 49 | + LET OneNoteMagic <= unhex(string='e4525c7b8cd8a74daeb15378d02996d3') |
| 50 | +
|
| 51 | + LET ImageRule = ''' |
| 52 | + rule embedded_images { |
| 53 | + strings: |
| 54 | + $png={89 50 4E 47 0D 0A 1A 0A} |
| 55 | + $jpg={FF D8 FF} |
| 56 | + $gif1="GIF87a" |
| 57 | + $gif2="GIF89a" |
| 58 | + $bmp={42 4D ?? ?? ?? ?? 00 00 00 00} |
| 59 | + $tif1={49 49 2A 00} |
| 60 | + $tif2={4D 4D 00 2A} |
| 61 | + $webp="WEBP" |
| 62 | + condition: |
| 63 | + any of them |
| 64 | + } |
| 65 | + ''' |
| 66 | +
|
| 67 | + LET CombinedRegex = SearchRegexAscii + '|' + SearchRegexUtf16 |
| 68 | +
|
| 69 | + LET onenote_files = SELECT OSPath, Name, Size, Mtime, Btime, Ctime, Atime, |
| 70 | + read_file(filename=OSPath, length=MaxRegexReadBytes) =~ CombinedRegex AS RegexMatched |
| 71 | + FROM glob(globs=TargetGlob) |
| 72 | + WHERE NOT IsDir |
| 73 | + AND Size <= MaxFileSize |
| 74 | + AND read_file(filename=OSPath, length=16) = OneNoteMagic |
| 75 | +
|
| 76 | + LET checked_files = SELECT *, |
| 77 | + len(list={ |
| 78 | + SELECT String.Name |
| 79 | + FROM yara(files=OSPath, rules=ImageRule, number=1) |
| 80 | + }) AS ImageSignatureCount |
| 81 | + FROM onenote_files |
| 82 | + WHERE IncludeNoHitFiles OR RegexMatched |
| 83 | +
|
| 84 | + SELECT *, |
| 85 | + ImageSignatureCount > 0 AS ImageSignaturesFound, |
| 86 | + hash(path=OSPath).SHA256 AS SHA256, |
| 87 | + UploadOriginal && upload(file=OSPath) AS OneNoteUpload |
| 88 | + FROM checked_files |
| 89 | + WHERE IncludeNoHitFiles OR RegexMatched OR ImageSignatureCount > 0 |
| 90 | +
|
| 91 | +
|
| 92 | +- name: ImageSignatureHits |
| 93 | + precondition: |
| 94 | + SELECT OS FROM info() |
| 95 | + WHERE OS='windows' |
| 96 | + |
| 97 | + query: | |
| 98 | +
|
| 99 | + LET ImageRule = ''' |
| 100 | + rule embedded_images { |
| 101 | + strings: |
| 102 | + $png={89 50 4E 47 0D 0A 1A 0A} |
| 103 | + $jpg={FF D8 FF} |
| 104 | + $gif1="GIF87a" |
| 105 | + $gif2="GIF89a" |
| 106 | + $bmp={42 4D ?? ?? ?? ?? 00 00 00 00} |
| 107 | + $tif1={49 49 2A 00} |
| 108 | + $tif2={4D 4D 00 2A} |
| 109 | + $webp="WEBP" |
| 110 | + condition: |
| 111 | + any of them |
| 112 | + } |
| 113 | + ''' |
| 114 | +
|
| 115 | + LET OneNoteMagic <= unhex(string='e4525c7b8cd8a74daeb15378d02996d3') |
| 116 | +
|
| 117 | + LET onenote_files = SELECT OSPath, Name, Size |
| 118 | + FROM glob(globs=TargetGlob) |
| 119 | + WHERE NOT IsDir |
| 120 | + AND Size <= MaxFileSize |
| 121 | + AND read_file(filename=OSPath, length=16) = OneNoteMagic |
| 122 | +
|
| 123 | + SELECT |
| 124 | + OSPath, |
| 125 | + Name, |
| 126 | + Size, |
| 127 | + String.Name AS ImageSignature, |
| 128 | + String.Offset AS ImageOffset |
| 129 | +
|
| 130 | + FROM foreach( |
| 131 | + row=onenote_files, |
| 132 | +
|
| 133 | + query={ |
| 134 | + SELECT |
| 135 | + OSPath, |
| 136 | + Name, |
| 137 | + Size, |
| 138 | + String |
| 139 | + FROM yara( |
| 140 | + files=OSPath, |
| 141 | + rules=ImageRule, |
| 142 | + number=9999 |
| 143 | + ) |
| 144 | + }) |
| 145 | +
|
| 146 | +
|
| 147 | +- name: KeywordHits |
| 148 | + precondition: |
| 149 | + SELECT OS FROM info() |
| 150 | + WHERE OS='windows' |
| 151 | + |
| 152 | + query: | |
| 153 | +
|
| 154 | + LET KeywordRule=''' |
| 155 | + rule keyword_hits { |
| 156 | + strings: |
| 157 | + $powershell="powershell" nocase wide ascii |
| 158 | + $password="password" nocase wide ascii |
| 159 | + $username="username" nocase wide ascii |
| 160 | + $pass="pass" nocase wide ascii |
| 161 | + $user="user" nocase wide ascii |
| 162 | + $admin="admin" nocase wide ascii |
| 163 | + $administrator="administrator" nocase wide ascii |
| 164 | + $root="root" nocase wide ascii |
| 165 | + $private="private" nocase wide ascii |
| 166 | + $key="key" nocase wide ascii |
| 167 | + condition: |
| 168 | + any of them |
| 169 | + } |
| 170 | + ''' |
| 171 | +
|
| 172 | + LET OneNoteMagic <= unhex(string='e4525c7b8cd8a74daeb15378d02996d3') |
| 173 | +
|
| 174 | + LET onenote_files = SELECT OSPath, Name, Size |
| 175 | + FROM glob(globs=TargetGlob) |
| 176 | + WHERE NOT IsDir |
| 177 | + AND Size <= MaxFileSize |
| 178 | + AND read_file(filename=OSPath, length=16) = OneNoteMagic |
| 179 | +
|
| 180 | + SELECT |
| 181 | + OSPath, |
| 182 | + Name, |
| 183 | + Size, |
| 184 | + String.Name AS MatchedKeyword, |
| 185 | + String.Offset AS MatchOffset |
| 186 | +
|
| 187 | + FROM foreach( |
| 188 | + row=onenote_files, |
| 189 | +
|
| 190 | + query={ |
| 191 | + SELECT |
| 192 | + OSPath, |
| 193 | + Name, |
| 194 | + Size, |
| 195 | + String |
| 196 | + FROM yara( |
| 197 | + files=OSPath, |
| 198 | + rules=KeywordRule, |
| 199 | + number=9999 |
| 200 | + ) |
| 201 | + }) |
0 commit comments