├── LICENSE ├── README.md └── juicy_files.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 DiabloHorn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yara4pentesters 2 | rules to identify files containing juicy information like usernames, passwords etc 3 | 4 | ## requirements 5 | 6 | * YARA 7 | * https://virustotal.github.io/yara/ 8 | 9 | ## searching for files 10 | Remember that depending on the YARA version or operating system that you use, the syntax might vary slightly. 11 | 12 | ### recursive search 13 | 14 | ``` 15 | yara -r juicy_files.txt 16 | ``` 17 | 18 | ### recursive search by tag 19 | 20 | ``` 21 | yara -t -r juicy_files.txt 22 | ``` 23 | 24 | ### recursive search single rule 25 | ``` 26 | yara -i -r juicy_files.txt 27 | ``` 28 | 29 | ## examples 30 | 31 | ``` 32 | ~/Desktop/yara4pentesters$ yara -r juicy_files.txt ../y4p_files 33 | shadow_file ../y4p_files/shadow 34 | hive_file ../y4p_files/mysecurity 35 | hive_file ../y4p_files/mysam 36 | hive_file ../y4p_files/system 37 | hive_file ../y4p_files/mysystem 38 | ntds_file ../y4p_files/ntds.dit 39 | 40 | 41 | ~/Desktop/yara4pentesters$ yara -t linux -r juicy_files.txt ../y4p_files 42 | shadow_file ../y4p_files/shadow 43 | 44 | ~/Desktop/yara4pentesters$ yara -i ntds_file -r juicy_files.txt ../y4p_files 45 | ntds_file ../y4p_files/ntds.dit 46 | ``` 47 | 48 | ## References 49 | 50 | * https://www.cgsecurity.org/wiki/File_Formats_Recovered_By_PhotoRec 51 | -------------------------------------------------------------------------------- /juicy_files.txt: -------------------------------------------------------------------------------- 1 | rule ntds_file : usernames hashed_passwords active_directory windows passwords 2 | { 3 | meta: 4 | author = "DiabloHorn https://diablohorn.com" 5 | description = "find the ntds.dit file" 6 | strings: 7 | $filemagic = {ef cd ab 89} 8 | $content_string = "Admin-Display-Name" nocase wide 9 | $content_string2 = "Address-Entry-Display-Table-MSDOS" nocase wide 10 | $content_string3 = "nTDSDSA-Display" nocase wide 11 | $content_string4 = "MSysObjects" nocase ascii 12 | $content_string5 = "ObjidTable" nocase ascii 13 | condition: 14 | ($filemagic at 4) and (int32(12) == 0 or int32(12) == 1) and all of ($content_*) 15 | } 16 | 17 | rule hive_file : usernames hashed_passwords registry windows passwords 18 | { 19 | meta: 20 | author = "DiabloHorn https://diablohorn.com" 21 | description = "find registry hive files like system/security/sam" 22 | strings: 23 | $filemagic = "regf" 24 | $filemagicbin = "hbin" 25 | $content_string = "ROOT" 26 | condition: 27 | $filemagic at 0 and $filemagicbin at 4096 and $content_string 28 | 29 | } 30 | 31 | rule shadow_file : usernames hashed_passwords linux passwords 32 | { 33 | meta: 34 | author = "DiabloHorn https://diablohorn.com" 35 | description = "find shadow files" 36 | strings: 37 | $rootline = /root:.:\d+?:\d+?:\d+?:\d+?:/ nocase 38 | $hashline = /:\$\d\$/ 39 | $hashtype_md5 = ":$1$" 40 | $hashtype_blowfish = ":$2a$" 41 | $hashtype_blowfish2 = ":$2y$" 42 | $hashtype_sha256 = ":$5$" 43 | $hashtype_sha512 = ":$6$" 44 | condition: 45 | $rootline and $hashline and (1 of ($hashtype_*)) 46 | } 47 | 48 | rule tomcat_file : usernames plain_passwords passwords 49 | { 50 | meta: 51 | author = "DiabloHorn https://diablohorn.com" 52 | description = "find tomcat config file with plaintext passwords" 53 | strings: 54 | $xml_ident = "" nocase 55 | $xml_ident2 = "" nocase 56 | $roles = "= filesize 178 | } 179 | 180 | rule crashdump64_file : memory windows 181 | { 182 | meta: 183 | author = "DiabloHorn https://diablohorn.com" 184 | description = "find memory dump files" 185 | strings: 186 | $header = "PAGE" 187 | $header2 = "DU64" 188 | condition: //might not work due to int32() on filesize, should be int64, but not available 189 | $header at 0 and $header2 at 4 and (uint32(0xf98) == 1 or uint32(0xf98) == 2) and int32(0xfa0) >= filesize 190 | } 191 | 192 | rule vmdk_file : virtualdisk 193 | { 194 | meta: 195 | author = "DiabloHorn https://diablohorn.com" 196 | description = "find vmdk files" 197 | strings: 198 | $filemagic = {4b 44 4d} //KDM 199 | $header = "# Disk DescriptorFile" 200 | $header2 = "version=" 201 | $header3 = "CID=" 202 | $header4 = "parentCID=" 203 | $header5 = "createType=" 204 | $header6 = "# Extent description" 205 | condition: 206 | $filemagic at 0 and (all of ($header*)) 207 | } 208 | 209 | rule gpp_file : passwords plain_password 210 | { 211 | meta: 212 | author = "DiabloHorn https://diablohorn.com" 213 | description = "find gpp files" 214 | strings: 215 | $content1 = "" nocase 221 | condition: 222 | all of them 223 | } 224 | 225 | rule sql_dump : passwords dbdump { 226 | meta: 227 | author = "ydklijnsma https://blog.0x3a.com" 228 | description = "Looks at sql dump file pattern" 229 | 230 | strings: 231 | $dump_header_regex = /-- [a-zA-Z0-9]+\s?SQL\s?[Dd]ump\s?/i 232 | 233 | $dump_string_createtableifexists = "CREATE TABLE IF NOT EXISTS" 234 | $dump_string_droptableifexists = "DROP TABLE IF EXISTS " 235 | $dump_string_createtable = "CREATE TABLE " 236 | 237 | $insert_into = "INSERT INTO " 238 | 239 | condition: 240 | $dump_header_regex at 0 and 241 | (2 of ($dump_string_*)) and 242 | #insert_into >= 1 243 | } 244 | 245 | rule idapro_database { 246 | meta: 247 | author = "ydklijnsma https://blog.0x3a.com/" 248 | description = "Finds IDA pro IDB databases" 249 | 250 | strings: 251 | $magic = { 49 44 41 ?? } 252 | $btree_str = "B-tree" 253 | 254 | condition: 255 | $magic at 0 and $btree_str 256 | 257 | } 258 | --------------------------------------------------------------------------------