├── .gitignore ├── LICENSE ├── README.md ├── ham.conf ├── hamburglar.py ├── requirements.txt ├── rules ├── apple.yar ├── audio.yar ├── compressed.yar ├── crypto.yar ├── executables.yar ├── gif.yar ├── gps.yar ├── jpeg.yar ├── mem_dumps.yar ├── office.yar ├── pdf.yar ├── png.yar ├── skype.yar ├── sqlite.yar ├── vcard.yar ├── vector.yar ├── video.yar ├── vmware.yar └── win_reg.yar └── utils └── magic_sig_scraper.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | *.swp 3 | *.json 4 | test/ 5 | env/ 6 | __pychache__/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## The Hamburglar 2 | 3 |

4 | 5 |

6 | 7 | 8 | ## Setup 9 | 10 | There are 2 versions of hamburglar, full and lite. The main branch is the full version, and hamburglar lite is on a separate branch. 11 | 12 | **Hamburglar** 13 | 14 | Full fledged scraping tool for artifact retrieval from multiple sources. There are some dependencies, so install them first: 15 | 16 | `pip3 install -r requirements.txt` 17 | 18 | Hamburglar also has the option of checking against file signatures during a hexdump. It will get skipped if not set up. To get it working, you will need to first create the database and a user: 19 | 20 | ```sql 21 | CREATE DATABASE 22 | CREATE USER 'hamman'@'localhost' IDENTIFIED BY 'deadbeef'; 23 | GRANT ALL PRIVILEGES ON fileSign.signatures TO 'hamman'@'localhost'; 24 | ``` 25 | 26 | Then, run magic_sig_scraper. This can be run on a cronjob to regularly update it, or just run it once: 27 | 28 | `python3 magic_sig_scraper.py` 29 | 30 | **Hamburglar Lite** 31 | 32 | Multithreaded and recursive directory scraping script. Stores useful information with the filepath and finding. Hamburglar lite will never require external packages, and will always remain as a single script. Setup is as simple as requesting the file and using it: 33 | 34 | `wget https://raw.githubusercontent.com/needmorecowbell/Hamburglar/hamburglar-lite/hamburglar-lite.py` 35 | 36 | This is designed to be quickly downloaded and executed on a machine. 37 | 38 | 39 | ## Operation 40 | 41 | ``` 42 | usage: hamburglar.py [-h] [-g] [-x] [-v] [-w] [-i] [-o FILE] [-y YARA] path 43 | 44 | positional arguments: 45 | path path to directory, url, or file, depending on flag 46 | used 47 | 48 | optional arguments: 49 | -h, --help show this help message and exit 50 | -g, --git sets hamburglar into git mode 51 | -x, --hexdump give hexdump of file 52 | -v, --verbose increase output verbosity 53 | -w, --web sets Hamburgler to web request mode, enter url as path 54 | -i, --ioc uses iocextract to parse contents 55 | -o FILE, --out FILE write results to FILE 56 | -y YARA, --yara YARA use yara ruleset for checking 57 | ``` 58 | 59 | 60 | **Directory Traversal** 61 | 62 | - `python3 hamburglar.py ~/Directory/` 63 | - This will recursively scan for files in the given directory, then analyzes each file for a variety of findings using regex filters 64 | 65 | **Single File Analysis** 66 | 67 | - `python3 hamburglar.py ~/Directory/file.txt` 68 | - This will recursively scan for files in the given directory, then analyzes each file for a variety of findings using regex filters 69 | 70 | **YARA Rule Based Analysis** 71 | - `python3 hamburglar.py -y rules/ ~/Directory` 72 | - This will compile the yara rule files in the rules directory and then check them against every item in Directory. 73 | 74 | **Git Scraping Mode** 75 | 76 | - `python3 hamburglar.py -g https://www.github.com/needmorecowbell/Hamburglar` 77 | - Adding `-y ` will allow the repo to be scraped using yara rules 78 | 79 | **Web Request Mode** 80 | 81 | - `python3 hamburglar.py -w https://google.com` 82 | - Adding a `-w` to hamburgler.py tells the script to handle the path as a url. 83 | - Currently this does not spider the page, it just analyzes the requested html content 84 | 85 | **IOC Extraction** 86 | - `python3 hamburglar.py -w -i https://pastebin.com/SYisR95m` 87 | - Adding a `-i` will use iocextract to extract any ioc's from the requested url 88 | 89 | **Hex Dump Mode** 90 | 91 | - `python3 hamburglar.py -x ~/file-to-dump` 92 | - This just does a hex dump and nothing more right now -- could be piped into a file 93 | - This will eventually be used for binary analysis 94 | 95 | **Tips** 96 | 97 | - Adding `-v` will set the script into verbose mode, and `-h` will show details of available arguments 98 | - Adding `-o FILENAME` will set the results filename, this is especially useful in scripting situations where you might want multiple results tables (ie github repo spidering) 99 | 100 | ## Settings 101 | 102 | - `whitelistOn`: turns on or off whitelist checking 103 | - `maxWorkers`: number of worker threads to run concurrently when reading file stack 104 | - `whitelist`: list of files or directories to exclusively scan for (if whitelistOn=True) 105 | - `blacklist`: list of files, extensions, or directories to block in scan 106 | - `regexList`: dictionary of regex filters with filter type as the key 107 | 108 | ## The Hamburglar can find 109 | 110 | - ipv4 addresses (public and local) 111 | - emails 112 | - private keys 113 | - urls 114 | - ioc's (using iocextract) 115 | - cryptocurrency addresses 116 | - anything you can imagine using regex filters and yara rules 117 | 118 | ## Example output: 119 | 120 | ```json 121 | { 122 | "/home/adam/Dev/test/email.txt": { 123 | "emails": "{'testingtesting@gmail.com'}" 124 | }, 125 | "/home/adam/Dev/test/email2.txt": { 126 | "emails": "{'loall@gmail.com'}" 127 | }, 128 | "/home/adam/Dev/test/ips.txt": { 129 | "ipv4": "{'10.0.11.2', '192.168.1.1'}" 130 | }, 131 | "/home/adam/Dev/test/test2/email.txt": { 132 | "emails": "{'ntested4@gmail.com', 'ntested@gmail.com'}" 133 | }, 134 | "/home/adam/Dev/test/test2/ips.txt": { 135 | "ipv4": "{'10.0.11.2', '192.168.1.1'}" 136 | }, 137 | "/home/adam/Dev/test/test2/links.txt": { 138 | "site": "{'http://login.web.com'}" 139 | } 140 | } 141 | ``` 142 | ## Contributions ## 143 | 144 | - Please contribute! If there's an error let me know -- even better if you can fix it :) 145 | 146 | - A big thank you to anyone who has helped: 147 | 148 | - [adi928](https://github.com/adi928) 149 | - [jaeger-2601](https://github.com/jaeger-2601) 150 | - [tijko](https://github.com/tijko) 151 | - [joanbono](https://github.com/joanbono) and [Xumeiquer](https://github.com/Xumeiquer) for the rules from [yara-forensics](https://github.com/Xumeiquer/yara-forensics) 152 | 153 | -------------------------------------------------------------------------------- /ham.conf: -------------------------------------------------------------------------------- 1 | [mySql] 2 | user = hamman 3 | password = deadbeef 4 | -------------------------------------------------------------------------------- /hamburglar.py: -------------------------------------------------------------------------------- 1 | import re 2 | import os 3 | import sys 4 | import threading 5 | import json 6 | from urllib.request import urlopen 7 | import argparse 8 | import sqlalchemy as db 9 | import configparser 10 | import yara 11 | import iocextract 12 | import os 13 | from newspaper import Article 14 | 15 | 16 | whitelistOn = False # Set True to filter by whitelist 17 | 18 | maxWorkers = 20 # Max workers for reading and sniffing each file 19 | 20 | # Add to whitelist to ONLY sniff certain files or directories 21 | whitelist = [".txt", ".html", ".md"] 22 | 23 | 24 | # Add to blacklist to block files and directories 25 | blacklist = [ 26 | ".git/objects/", 27 | ".git/index", 28 | "/node_modules/", 29 | "vendor/gems/", 30 | ".iso", 31 | ".bundle", 32 | ".png", 33 | ".jpg", 34 | ".crt", 35 | ".exe", 36 | ".gif", 37 | ".mp4", 38 | ".mp3" 39 | ] 40 | 41 | # Regex dictionary, comment out a line to stop checking for entry, and add a line for new filters 42 | regexList = { 43 | "AWS API Key": "AKIA[0-9A-Z]{16}", 44 | # "bitcoin-address" : "[13][a-km-zA-HJ-NP-Z1-9]{25,34}" , 45 | "bitcoin-cash-address": "(?:^[13][a-km-zA-HJ-NP-Z1-9]{33})", 46 | "bitcoin-uri": "bitcoin:([13][a-km-zA-HJ-NP-Z1-9]{25,34})", 47 | "bitcoin-xpub-key": "(xpub[a-km-zA-HJ-NP-Z1-9]{100,108})(\\?c=\\d*&h=bip\\d{2,3})?", 48 | "dash-address": "(?:^X[1-9A-HJ-NP-Za-km-z]{33})", 49 | "dogecoin-address": "(?:^D{1}[5-9A-HJ-NP-U]{1}[1-9A-HJ-NP-Za-km-z]{32})", 50 | "email": "[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", 51 | "ethereum-address": "(?:^0x[a-fA-F0-9]{40})", 52 | "Facebook Oauth": "[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].*['|\"][0-9a-f]{32}['|\"]", 53 | "Generic Secret": "[s|S][e|E][c|C][r|R][e|E][t|T].*['|\"][0-9a-zA-Z]{32,45}['|\"]", 54 | "GitHub": "[g|G][i|I][t|T][h|H][u|U][b|B].*[['|\"]0-9a-zA-Z]{35,40}['|\"]", 55 | "Google Oauth": "(\"client_secret\":\"[a-zA-Z0-9-_]{24}\")", 56 | "Heroku API Key": "[h|H][e|E][r|R][o|O][k|K][u|U].*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}", 57 | "ipv4": "[0-9]+(?:\.[0-9]+){3}", 58 | "litecoin-address": "(?:^[LM3][a-km-zA-HJ-NP-Z1-9]{26,33})", 59 | "monero-address": "(?:^4[0-9AB][1-9A-HJ-NP-Za-km-z]{93})", 60 | "neo-address": "(?:^A[0-9a-zA-Z]{33})", 61 | "PGP private key block": "-----BEGIN PGP PRIVATE KEY BLOCK-----", 62 | "phone": "\(?\\b[2-9][0-9]{2}\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}\\b", 63 | "ripple-address": "(?:^r[0-9a-zA-Z]{33})", 64 | "RSA private key": "-----BEGIN RSA PRIVATE KEY-----", 65 | "site": "https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+", 66 | "Slack Token": "(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})", 67 | "SSH (DSA) private key": "-----BEGIN DSA PRIVATE KEY-----", 68 | "SSH (EC) private key": "-----BEGIN EC PRIVATE KEY-----", 69 | "SSH (OPENSSH) private key": "-----BEGIN OPENSSH PRIVATE KEY-----", 70 | "Twitter Oauth": "[t|T][w|W][i|I][t|T][t|T][e|E][r|R].*['|\"][0-9a-zA-Z]{35,44}['|\"]" 71 | } 72 | 73 | 74 | parser = argparse.ArgumentParser() 75 | parser.add_argument("-g", "--git", action="store_true", 76 | help="sets hamburglar into git mode") 77 | parser.add_argument("-x", "--hexdump", action="store_true", 78 | help="give hexdump of file") 79 | parser.add_argument("-v", "--verbose", help="increase output verbosity", 80 | action="store_true") 81 | 82 | parser.add_argument("-w", "--web", help="sets Hamburgler to web request mode, enter url as path", 83 | action="store_true") 84 | parser.add_argument( 85 | "-i", "--ioc", help="uses iocextract to parse contents", action="store_true") 86 | parser.add_argument("-o", "--out", dest="output", 87 | help="write results to FILE", metavar="FILE") 88 | 89 | parser.add_argument("-y", "--yara", dest="yara", 90 | help="use yara ruleset for checking") 91 | 92 | parser.add_argument( 93 | "path", help="path to directory, url, or file, depending on flag used") 94 | 95 | args = parser.parse_args() 96 | 97 | # Get Path Argument (file url or directory) 98 | passedPath = args.path 99 | 100 | if args.output is None: 101 | if args.git: 102 | outputFilename = args.path[args.path.rfind("/")+1:]+".json" 103 | else: 104 | outputFilename = os.path.basename(args.path)+"_hamburgled.json" 105 | else: 106 | outputFilename = args.output 107 | 108 | 109 | # only use unique filepaths(should be unique anyways, just redundant) 110 | filestack = set() 111 | requestStack = set() 112 | 113 | cumulativeFindings = {} 114 | 115 | 116 | def webScan(): 117 | """ Scans the url given in the path, then adds to request stack (eventually this may be a spider)""" 118 | requestStack.add(passedPath) 119 | 120 | 121 | def scan(): 122 | """ scans the directory for files and adds them to the filestack """ 123 | # check for directory 124 | if(os.path.isfile(passedPath)): 125 | # we just have a single file, so add it to the stack 126 | print("[+] single file passed") 127 | filestack.add(passedPath) 128 | return 129 | # iterate through every file in given directory 130 | for root, _, files in os.walk(passedPath): 131 | for entry in files: # get all files from root directory 132 | filepath = os.path.join(root, entry) 133 | if(whitelistOn and _iswhitelisted(filepath)): 134 | print("[+] whitelist finding: "+str(filepath)) 135 | filestack.add(filepath) 136 | elif _isfiltered(filepath): 137 | # if whitelist is off, check blacklist 138 | if(args.verbose): 139 | print("[-] "+filepath+" blacklisted, not scanning") 140 | else: 141 | # lastly, if it is not blacklisted, lets add the file to the stack 142 | try: 143 | print("[+] adding:"+str(filepath)+" (" + 144 | str(os.stat(filepath).st_size >> 10)+"kb) to stack") 145 | filestack.add(filepath) 146 | except Exception as e: 147 | print("[-] read error: "+str(e)) 148 | 149 | 150 | def _isfiltered(filepath): 151 | """ checks if the file is blacklisted """ 152 | for filtered in blacklist: 153 | if (filtered in filepath): 154 | return True 155 | return False 156 | 157 | 158 | def _iswhitelisted(filepath): 159 | """ checks if the file given is whitelisted """ 160 | for filtered in whitelist: 161 | if (filtered in filepath): 162 | return True 163 | return False 164 | 165 | 166 | def _url_read(): 167 | """ opens the urls in requestStack, makes request, and if something matches the regex, add it to the cumulativeFindings """ 168 | 169 | while(requestStack): # while there are still requests to be made 170 | url = requestStack.pop() 171 | if(args.verbose): 172 | print("[+] left on stack: "+str(len(requestStack))) 173 | 174 | try: 175 | # with urlopen(url) as response: 176 | article = Article(url) 177 | article.download() 178 | article.parse() 179 | # html = response.read() 180 | # data= str(html).rstrip("\r\n") 181 | results = _sniff_text(article.text) 182 | 183 | if(len(results.items()) > 0): 184 | totalResults = sum(map(len, results.values())) 185 | print("[+] "+url+" -- "+str(totalResults)+" result(s) found.") 186 | cumulativeFindings.update({url: results}) 187 | 188 | except Exception as e: 189 | print("Url Worker Error: "+str(e)) 190 | 191 | 192 | def _file_read(): 193 | """ opens the files in filestack, reads them , and if something is found in the file that matches the regex, adds them to cumalativeFindings""" 194 | while(filestack): # while there are still items on the stack/worker pool... 195 | filepath = filestack.pop() 196 | if(args.verbose): 197 | print("[+] left on stack: "+str(len(filestack))) 198 | try: 199 | with open(filepath, "r") as scanfile: # open file on stack that needs sniffed 200 | 201 | # turn file to string and clean it of newlines 202 | filestring = str(scanfile.read()).rstrip('\r\n') 203 | # get dictionary of results from regex search 204 | results = _sniff_text(filestring) 205 | 206 | # if we found something in the file, add it to the findings report 207 | if (len(results.items()) > 0): 208 | totalResults = len(results.items()) 209 | print("[+] "+filepath+" -- " + 210 | str(totalResults)+" result(s) found.") 211 | cumulativeFindings.update({filepath: results}) 212 | 213 | except Exception as e: 214 | print("[-] "+filepath+": can't be read: "+str(e)) 215 | 216 | 217 | def _sniff_text(text): 218 | """ checks every regex for findings, and return a dictionary of all findings """ 219 | results = {} 220 | if(args.ioc): 221 | print("") 222 | urls = list(iocextract.extract_urls(text)) 223 | ips = list(iocextract.extract_ips(text)) 224 | emails = list(iocextract.extract_emails(text)) 225 | hashes = list(iocextract.extract_hashes(text)) 226 | rules = list(iocextract.extract_yara_rules(text)) 227 | if(urls): 228 | results.update({"urls": urls}) 229 | if(ips): 230 | results.update({"ips": ips}) 231 | if(emails): 232 | results.update({"emails": emails}) 233 | if(hashes): 234 | results.update({"hashes": hashes}) 235 | if(rules): 236 | results.update({"rules": rules}) 237 | 238 | else: 239 | for key, value in regexList.items(): 240 | findings = set(re.findall(value, text)) 241 | if findings: 242 | results.update({key: findings}) 243 | return results 244 | 245 | 246 | def displayCumulative(): 247 | """ Displays finding report """ 248 | print(json.dumps(dict(cumulativeFindings), 249 | default=lambda x: str(x), sort_keys=True, indent=4)) 250 | 251 | 252 | def _write_to_file(fname): 253 | """ writes report to json file """ 254 | print("[+] writing to " + outputFilename + "...") 255 | with open(fname, 'w') as file: 256 | file.write(json.dumps(dict(cumulativeFindings), 257 | default=lambda x: str(x), sort_keys=True, indent=4)) 258 | 259 | 260 | def get_offset(offsets): 261 | formatted_offset = [] 262 | if offsets is None: 263 | return formatted_offset 264 | 265 | for offset in offsets.split(): 266 | if re.search('0[xX][0-9a-fA-F]+', offset): 267 | if len(offset) <= 6: 268 | formatted_offset.append(int(offset, 16)) 269 | else: 270 | formatted_offset.append(int(offset[0:6], 16)) 271 | formatted_offset.append(int(offset[6:12], 16)) 272 | else: 273 | return [0] 274 | return formatted_offset 275 | 276 | 277 | def convert_to_regex(hex): 278 | hex = "".join(hex.split()) 279 | hex = re.sub('\?+', '(.?)', hex) 280 | hex_list = hex.split('(.?)') 281 | hex_complete = "" 282 | for hex_str in hex_list: 283 | for i in range(0, len(hex_str)): 284 | i = i * 2 285 | hex_complete += " " + hex_str[i:i + 2] 286 | hex_complete += "(.+)" 287 | hex_complete = " ".join(hex_complete.split()) 288 | return hex_complete[:-4] 289 | 290 | 291 | def compare_signature(): 292 | print("[+] Attempting to identify by magic") 293 | try: 294 | config = configparser.ConfigParser() 295 | config.read('ham.conf') 296 | sql_user = config['mySql']['user'] 297 | sql_pass = config['mySql']['password'] 298 | conn_String = 'mysql+pymysql://' + sql_user + \ 299 | ':' + sql_pass + '@localhost/fileSign' 300 | db_engine = db.create_engine(conn_String) 301 | conn = db_engine.connect() 302 | signatures = conn.execute("SELECT * FROM signatures").fetchall() 303 | 304 | with open(args.path, "rb") as target: 305 | fileHeader = target.read() 306 | s1 = " ".join([f"{i:02x}" for i in fileHeader]) 307 | 308 | for signs in signatures: 309 | sig_list = signs[1].split('\n') 310 | for sigs in sig_list: 311 | if sigs == "": 312 | continue 313 | sigs_regex = convert_to_regex(sigs).strip() 314 | offset = get_offset(signs[3]) 315 | for offs in offset: 316 | if re.match(sigs_regex, s1[offs:len(sigs) + offs]): 317 | print("File format --> ", signs[4]) 318 | except Exception as e: 319 | print("[-] File Signature table not set up properly") 320 | 321 | 322 | def hexDump(): 323 | try: 324 | with open(args.path, "rb") as f: 325 | n = 0 326 | b = f.read(16) 327 | outputFilename = os.path.basename(f.name)+".hexdump" 328 | print("[+] writing to " + outputFilename + "...") 329 | with open(outputFilename, 'w') as file: 330 | while b: 331 | s1 = " ".join([f"{i:02x}" for i in b]) 332 | s1 = s1[0:23] + " " + s1[23:] 333 | s2 = "".join( 334 | [chr(i) if 32 <= i <= 127 else "." for i in b]) 335 | 336 | file.write(f"{n*16:08x} {s1:<48} |{s2}|\n") 337 | 338 | n += 1 339 | b = f.read(16) 340 | 341 | except Exception as e: 342 | print(__file__, ": ", type(e).__name__, 343 | " - ", e, sep="", file=sys.stderr) 344 | 345 | 346 | def isMatch(rule, target_path): 347 | # rule = compiled yara rules 348 | m = rule.match(target_path) 349 | if m: 350 | return True 351 | else: 352 | return False 353 | 354 | 355 | def compileRules(rule_path): 356 | ruleSet = [] 357 | for root, sub, files in os.walk(rule_path): 358 | for file in files: 359 | rule = yara.compile(os.path.join(root, file)) 360 | ruleSet.append(rule) 361 | return ruleSet 362 | 363 | 364 | def scanTargetDirectory(target_path, ruleSet): 365 | result = [] 366 | for root, sub, files in os.walk(target_path): 367 | for file in files: # check each file for rules 368 | for rule in ruleSet: 369 | if(isMatch(rule, os.path.join(root, file))): 370 | matches = rule.match(os.path.join(root, file)) 371 | if(matches): 372 | for match in matches: 373 | print("\t\tYARA MATCH: " + 374 | os.path.join(root, file)+"\t"+match.rule) 375 | result.append( 376 | {os.path.join(root, file): match.rule}) 377 | 378 | return result 379 | 380 | 381 | def _startWorkers(): 382 | # set scantype based of url or directory/file traverseal 383 | workerType = _url_read if args.web else _file_read 384 | 385 | workers = [] # workers to handle filestack 386 | for x in range(maxWorkers): # start up file reading worker threads 387 | t = threading.Thread(target=workerType) 388 | t.start() 389 | workers.append(t) 390 | 391 | for worker in workers: # join all workers to conclude scan 392 | worker.join() 393 | 394 | 395 | def scanGitRepo(target_path, ruleSet=None, yara=False): 396 | 397 | result = [] 398 | 399 | # Clone the repo 400 | print("Cloning Repo Cloned") 401 | os.system("git clone "+target_path+" tmp") 402 | os.chdir("tmp") 403 | os.system("git log -p >> tmp_git_log") 404 | os.system("mv tmp_git_log ..") 405 | os.chdir("..") 406 | 407 | # Git Diff results 408 | if(yara): 409 | for root, sub, files in os.walk("tmp"): 410 | for file in files: # check each file for rules 411 | for rule in ruleSet: 412 | 413 | if(isMatch(rule, os.path.join(root, file))): 414 | matches = rule.match(os.path.join(root, file)) 415 | if(matches): 416 | for match in matches: 417 | print("\t\tYARA MATCH: " + 418 | os.path.join(root, file)+"\t"+match.rule) 419 | result.append( 420 | {os.path.join(root, file): match.rule}) 421 | 422 | if(isMatch(rule, "tmp_git_log")): 423 | matches = rule.match("tmp_git_log") 424 | if(matches): 425 | for match in matches: 426 | print("\t\tYARA MATCH: Git Log \t"+match.rule) 427 | 428 | else: 429 | 430 | # iterate through every file in repo 431 | for root, sub, files in os.walk("tmp"): 432 | for entry in files: # get all files from root directory 433 | filepath = os.path.join(root, entry) 434 | if(whitelistOn and _iswhitelisted(filepath)): 435 | print("[+] whitelist finding: "+str(filepath)) 436 | filestack.add(filepath) 437 | elif _isfiltered(filepath): 438 | # if whitelist is off, check blacklist 439 | if(args.verbose): 440 | print("[-] "+filepath+" blacklisted, not scanning") 441 | else: 442 | # lastly, if it is not blacklisted, lets add the file to the stack 443 | try: 444 | print("[+] adding:"+str(filepath)+" (" + 445 | str(os.stat(filepath).st_size >> 10)+"kb) to stack") 446 | filestack.add(filepath) 447 | except Exception as e: 448 | print("[-] read error: "+str(e)) 449 | 450 | print("[+] adding: tmp_git_log" + 451 | " ("+str(os.stat("tmp_git_log").st_size >> 10)+"kb) to stack") 452 | filestack.add("tmp_git_log") 453 | _startWorkers() 454 | 455 | # Remove the repository and log 456 | os.system("rm tmp -rf && rm tmp_git_log") 457 | 458 | return result 459 | 460 | 461 | if __name__ == "__main__": 462 | 463 | print("[+] scanning...") 464 | if(args.hexdump): 465 | compare_signature() 466 | hexDump() 467 | exit() 468 | 469 | if(args.web): 470 | webScan() 471 | _startWorkers() 472 | _write_to_file(outputFilename) 473 | elif(args.yara is not None): 474 | 475 | rule_path = args.yara 476 | print("Loading rules") 477 | rules = compileRules(rule_path) 478 | print("Scanning Directory ...") 479 | 480 | if(args.git): 481 | rule_path = args.yara 482 | print("Loading rules") 483 | rules = compileRules(rule_path) 484 | print("Scanning Directory...") 485 | cumulativeFindings = scanGitRepo(args.path, rules, yara=True) 486 | else: 487 | cumulativeFindings = scanTargetDirectory(args.path, rules) 488 | 489 | print("[+] writing to " + outputFilename + "...") 490 | with open(outputFilename, 'w') as f: 491 | json.dump({args.path: cumulativeFindings}, 492 | f, sort_keys=True, indent=4) 493 | 494 | elif(args.git): 495 | print("Scanning Repository") 496 | scanGitRepo(args.path) 497 | print("[+] scan complete") 498 | _write_to_file(outputFilename) 499 | 500 | else: 501 | scan() 502 | _startWorkers() 503 | print("[+] scan complete") 504 | _write_to_file(outputFilename) 505 | 506 | print("[+] The Hamburglar has finished snooping") 507 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.7.1 2 | certifi==2019.6.16 3 | cffi==1.13.2 4 | chardet==3.0.4 5 | cryptography==2.8 6 | cssselect==1.0.3 7 | feedfinder2==0.0.4 8 | feedparser==5.2.1 9 | idna==2.8 10 | iocextract==1.13.1 11 | jieba3k==0.35.1 12 | lxml==4.3.4 13 | newspaper3k==0.2.8 14 | nltk==3.4.5 15 | numpy==1.17.4 16 | pandas==0.25.3 17 | Pillow==6.2.0 18 | pycparser==2.19 19 | PyMySQL==0.9.3 20 | python-dateutil==2.8.0 21 | pytz==2019.3 22 | PyYAML==5.1.1 23 | regex==2019.6.8 24 | requests==2.22.0 25 | requests-file==1.4.3 26 | six==1.12.0 27 | soupsieve==1.9.1 28 | SQLAlchemy==1.3.5 29 | tinysegmenter==0.3 30 | tldextract==2.2.1 31 | urllib3==1.25.3 32 | yara-python==3.11.0 33 | -------------------------------------------------------------------------------- /rules/apple.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | rule plist: PLIST 10 | { 11 | meta: 12 | author = "Joan Bono" 13 | 14 | strings: 15 | $a = { 62 70 6c 69 73 74 30 30 } 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule apple_bom: CAR 22 | { 23 | meta: 24 | author = "Joan Bono" 25 | 26 | strings: 27 | $a = { 42 4f 4d 53 74 6f 72 65 } 28 | 29 | condition: 30 | $a at 0 31 | } 32 | 33 | rule apple_nib: NIB 34 | { 35 | meta: 36 | author = "Joan Bono" 37 | 38 | strings: 39 | $a = { 4e 49 42 41 72 63 68 69 76 65 01 } 40 | 41 | condition: 42 | $a at 0 43 | } 44 | 45 | rule apple_dylib: DYLIB 46 | { 47 | meta: 48 | author = "Joan Bono" 49 | 50 | strings: 51 | $a = { cf fa ed fe 0c 00 00 01 } 52 | 53 | condition: 54 | $a at 0 55 | } 56 | 57 | rule apple_sinf: SINF 58 | { 59 | meta: 60 | author = "Joan Bono" 61 | 62 | strings: 63 | $a = { 00 00 04 20 73 69 6e 66 } 64 | 65 | condition: 66 | $a at 0 67 | } 68 | 69 | rule apple_supf: SUPF 70 | { 71 | meta: 72 | author = "Joan Bono" 73 | 74 | strings: 75 | $a = { 03 34 30 35 00 00 07 a8 } 76 | 77 | condition: 78 | $a at 0 79 | } 80 | 81 | rule apple_supp: SUPP 82 | { 83 | meta: 84 | author = "Joan Bono" 85 | 86 | strings: 87 | $a = { 01 34 30 35 2b 8d 5c 4c 24 18 d2 5f } 88 | 89 | condition: 90 | $a at 0 91 | } 92 | 93 | -------------------------------------------------------------------------------- /rules/audio.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | - Rafa Bono <@rafa_bono> 8 | */ 9 | 10 | rule ogg: OGG 11 | { 12 | meta: 13 | author = "Jaume Martin" 14 | file_info = "Ogg Vorbis Codec" 15 | 16 | strings: 17 | $a = {4F 67 67 53 00 02 00 00 00 00 00 00 00 00} 18 | 19 | condition: 20 | $a at 0 21 | } 22 | 23 | rule aac: AAC 24 | { 25 | meta: 26 | author = "Rafa Bono" 27 | file_info = "Advanced Audio Coding" 28 | 29 | strings: 30 | $a = {41 41 43 00 01 00} 31 | 32 | condition: 33 | $a at 0 34 | } 35 | 36 | rule au: AU 37 | { 38 | meta: 39 | author = "Rafa Bono" 40 | file_info = "Audacity Audio" 41 | 42 | strings: 43 | $a = {64 6E 73 2E} 44 | 45 | condition: 46 | $a at 0 47 | } 48 | 49 | rule next_au_format: AU 50 | { 51 | meta: 52 | author = "Rafa Bono" 53 | file_info = "NeXT Audio Format" 54 | 55 | strings: 56 | $a = {2E 73 6E 64 00 00 00} 57 | 58 | condition: 59 | $a at 0 60 | } 61 | 62 | rule aax: AAX 63 | { 64 | meta: 65 | author = "Rafa Bono" 66 | file_info = "Audible Enhanced Audio" 67 | 68 | strings: 69 | $a = {00 00 00 24 66 74 79 70 61 61 78 20 00 00 00 01} 70 | 71 | condition: 72 | $a at 0 73 | } 74 | 75 | rule act: ACT 76 | { 77 | meta: 78 | author = "Rafa Bono" 79 | file_info = "Cartooners Actor" 80 | 81 | strings: 82 | $a = {00 10 46 00 00 00 77 07 85 0C} 83 | 84 | condition: 85 | $a at 0 86 | } 87 | 88 | rule aiff: AIFF 89 | { 90 | meta: 91 | author = "Rafa Bono" 92 | file_info = "Audio Interchange File Format" 93 | 94 | strings: 95 | $a = {46 4F 52 4D} 96 | 97 | condition: 98 | $a at 0 99 | } 100 | 101 | rule amr: AMR 102 | { 103 | meta: 104 | author = "Rafa Bono" 105 | file_info = "Adaptive Multi Rate Encoded Audio" 106 | 107 | strings: 108 | $a = {23 21 41 4D 52 0A} 109 | 110 | condition: 111 | $a at 0 112 | } 113 | 114 | rule ape: APE 115 | { 116 | meta: 117 | author = "Rafa Bono" 118 | file_info = "Monkey's Audio" 119 | 120 | strings: 121 | $a = {4D 41 43 20} 122 | 123 | condition: 124 | $a at 0 125 | } 126 | 127 | rule awb: AWB 128 | { 129 | meta: 130 | author = "Rafa Bono" 131 | file_info = "Adaptive Multi-Rate Wideband ACELP codec" 132 | 133 | strings: 134 | $a = {23 21 41 4D 52 2D 57 42} 135 | 136 | condition: 137 | $a at 0 138 | } 139 | 140 | rule dss: DSS 141 | { 142 | meta: 143 | author = "Rafa Bono" 144 | file_info = "Digital Sound Studio module" 145 | 146 | strings: 147 | $a = {4D 4D 55 32} 148 | 149 | condition: 150 | $a at 0 151 | } 152 | 153 | rule dss_v2: DSS 154 | { 155 | meta: 156 | author = "Rafa Bono" 157 | file_info = "Digital Speech Standard audio (v2)" 158 | 159 | strings: 160 | $a = {02 64 73 73} 161 | 162 | condition: 163 | $a at 0 164 | } 165 | 166 | rule dss_v3: DSS 167 | { 168 | meta: 169 | author = "Rafa Bono" 170 | file_info = "Digital Speech Standard audio (v3)" 171 | 172 | strings: 173 | $a = {03 64 73 73} 174 | 175 | condition: 176 | $a at 0 177 | } 178 | 179 | rule dream_station_1_module: DSS 180 | { 181 | meta: 182 | author = "Rafa Bono" 183 | file_info = "Dream Station 1.0 module" 184 | 185 | strings: 186 | $a = {44 53 46 6D 74 31 0D 0A} 187 | 188 | condition: 189 | $a at 0 190 | } 191 | 192 | rule dvf: DVF 193 | { 194 | meta: 195 | author = "Rafa Bono" 196 | file_info = "Sony Compressed Voice File" 197 | 198 | strings: 199 | $a = {4D 53 5F 56 4F 49 43 45} 200 | 201 | condition: 202 | $a at 0 203 | } 204 | 205 | rule flac: FLAC 206 | { 207 | meta: 208 | author = "Rafa Bono" 209 | file_info = "Free Lossless Audio Codec" 210 | 211 | strings: 212 | $a = {66 4C 61 43} 213 | 214 | condition: 215 | $a at 0 216 | } 217 | 218 | rule gsm: GSM 219 | { 220 | meta: 221 | author = "Rafa Bono" 222 | file_info = "US Robotics GSM audio" 223 | 224 | strings: 225 | $a = {52 49 46 46} 226 | 227 | condition: 228 | $a at 0 229 | } 230 | 231 | rule m4a: M4A 232 | { 233 | meta: 234 | author = "Rafa Bono" 235 | file_info = "Apple Lossless Audio Codec" 236 | 237 | strings: 238 | $a = {00 00 00 20 66 74 79 70 4D 34 41 20 00 00 00 00} 239 | 240 | condition: 241 | $a at 0 242 | } 243 | 244 | rule mmf: MMF 245 | { 246 | meta: 247 | author = "Rafa Bono" 248 | file_info = "Yamaha SMAF Synthetic music Mobile Application Format" 249 | 250 | strings: 251 | $a = {4D 4D 4D 44} 252 | 253 | condition: 254 | $a at 0 255 | } 256 | 257 | rule mp3: MP3 258 | { 259 | meta: 260 | author = "Rafa Bono" 261 | file_info = "MP3 Audio" 262 | 263 | strings: 264 | $a = {49 44 33} 265 | 266 | condition: 267 | $a at 0 268 | } 269 | 270 | rule mp3_album_wrap: MP3 271 | { 272 | meta: 273 | author = "Rafa Bono" 274 | file_info = "MP3 AlbumWrap archive" 275 | 276 | strings: 277 | $a = {49 44 33 03 00 00 00 00 0A 23 54 49 54 32 00 00} 278 | 279 | condition: 280 | $a at 0 281 | } 282 | 283 | rule mp3_gogo_encoded: MP3 284 | { 285 | meta: 286 | author = "Rafa Bono" 287 | file_info = "GoGo encoded MP3 audio" 288 | 289 | strings: 290 | $a = {FF FB 90} 291 | $b = {49 44 33 } 292 | 293 | condition: 294 | $a at 0 or $b at 0 295 | } 296 | 297 | rule mp3_hd: MP3 298 | { 299 | meta: 300 | author = "Rafa Bono" 301 | file_info = "MP3 HD audio" 302 | 303 | strings: 304 | $a = {49 44 33 03 00 00 00} 305 | 306 | condition: 307 | $a at 0 308 | } 309 | 310 | rule mpc_gen: MPC 311 | { 312 | meta: 313 | author = "Rafa Bono" 314 | file_info = "Musepack encoded audio (generic)" 315 | 316 | strings: 317 | $a = {4D 50 2B} 318 | 319 | condition: 320 | $a at 0 321 | } 322 | 323 | rule mpc_sv7: MPC 324 | { 325 | meta: 326 | author = "Rafa Bono" 327 | file_info = "Musepack encoded audio (SV7)" 328 | 329 | strings: 330 | $a = {4D 50 2B 07} 331 | 332 | condition: 333 | $a at 0 334 | } 335 | 336 | rule mpc_sv8: MPC 337 | { 338 | meta: 339 | author = "Rafa Bono" 340 | file_info = "Musepack encoded audio (SV8)" 341 | 342 | strings: 343 | $a = {4D 50 43 4B 53 48 0F} 344 | 345 | condition: 346 | $a at 0 347 | } 348 | 349 | rule msv: MSV 350 | { 351 | meta: 352 | author = "Rafa Bono" 353 | file_info = "Sony Compressed Voice File" 354 | 355 | strings: 356 | $a = {4D 53 5F 56 4F 49 43 45} 357 | 358 | condition: 359 | $a at 0 360 | } 361 | 362 | rule opus: OPUS 363 | { 364 | meta: 365 | author = "Rafa Bono" 366 | file_info = "Opus compressed audio" 367 | 368 | strings: 369 | $a = {4F 67 67 53} 370 | 371 | condition: 372 | $a at 0 373 | } 374 | 375 | rule ra: RA 376 | { 377 | meta: 378 | author = "Rafa Bono" 379 | file_info = "Real Audio" 380 | 381 | strings: 382 | $a = {2E 72 61 FD 00} 383 | $b = {2E 52 4D 46 00 00 00 12 00} 384 | 385 | condition: 386 | $a at 0 or $b at 0 387 | } 388 | 389 | rule raw: RAW 390 | { 391 | meta: 392 | author = "Rafa Bono" 393 | file_info = "Rdos Raw OPL Capture music" 394 | 395 | strings: 396 | $a = {52 41 57 41 44 41 54 41} 397 | 398 | condition: 399 | $a at 0 400 | } 401 | 402 | rule tta: TTA 403 | { 404 | meta: 405 | author = "Rafa Bono" 406 | file_info = "TTA lossless compressed audio" 407 | 408 | strings: 409 | $a = {54 54 41} 410 | 411 | condition: 412 | $a at 0 413 | } 414 | 415 | rule vox_magica_voxel: VOX 416 | { 417 | meta: 418 | author = "Rafa Bono" 419 | file_info = "MagicaVoxel file format" 420 | 421 | strings: 422 | $a = {56 4F 58 20} 423 | 424 | condition: 425 | $a at 0 426 | } 427 | 428 | rule vox_voxware: VOX 429 | { 430 | meta: 431 | author = "Rafa Bono" 432 | file_info = "VoxWare MetaVoice encoded audio" 433 | 434 | strings: 435 | $a = {52 49 46 46} 436 | 437 | condition: 438 | $a at 0 439 | } 440 | -------------------------------------------------------------------------------- /rules/compressed.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule _7z: _7z 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {37 7A BC AF 27 1C} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule rar: rar 22 | { 23 | meta: 24 | author = "Jaume martin" 25 | 26 | strings: 27 | $a = {52 61 72 21 1A 07 00} 28 | $b = {52 61 72 21 1A 07 01 00} 29 | 30 | condition: 31 | $a at 0 or $b at 0 32 | } 33 | 34 | rule tar: tar 35 | { 36 | meta: 37 | author = "Jaume martin" 38 | 39 | strings: 40 | $a = {75 73 74 61 72 00 30 30} 41 | $b = {75 73 74 61 72 20 20 00} 42 | 43 | condition: 44 | $a at 0 or $b at 0 45 | } 46 | 47 | rule gzip: gzip 48 | { 49 | meta: 50 | author = "Jaume martin" 51 | 52 | strings: 53 | $a = {1F 8B} 54 | $b = {1F 8B} 55 | 56 | condition: 57 | $a at 0 or $b at 0 58 | } 59 | -------------------------------------------------------------------------------- /rules/crypto.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on dump files, like raw dd image. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule pgp_wde: PGP WDE 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | description = "PGP Whole Disk Encryption" 14 | strings: 15 | $a = {50 47 50 64 4D 41 49 4E} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule pgp_skr: PGP SKR 22 | { 23 | meta: 24 | author = "Jaume Martin" 25 | description = "Private keyring" 26 | strings: 27 | $a = {95 00} 28 | $b = {95 01} 29 | 30 | condition: 31 | $a at 0 or $b at 0 32 | } 33 | 34 | rule pgp_pkr: PGP PKR 35 | { 36 | meta: 37 | author = "Jaume Martin" 38 | description = "Public keyring" 39 | strings: 40 | $a = {99 01} 41 | 42 | condition: 43 | $a at 0 44 | } 45 | 46 | rule x509: DER x509 47 | { 48 | meta: 49 | author = "Jaume Martin" 50 | 51 | strings: 52 | $a = {30 82} 53 | 54 | condition: 55 | $a at 0 56 | } 57 | -------------------------------------------------------------------------------- /rules/executables.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | rule exe: EXE 10 | { 11 | meta: 12 | author = "Joan Bono" 13 | 14 | strings: 15 | $a = { 4D 5A } 16 | $b = "!This program cannot be run in DOS mode." 17 | 18 | condition: 19 | $a at 0 and for all of ($b): (@ > @a) 20 | } 21 | 22 | rule elf64: ELF64 23 | { 24 | meta: 25 | author = "Joan Bono" 26 | 27 | strings: 28 | $a = { 7F 45 4C 46 } 29 | $b = "linux_amd64" 30 | $c = "linux-x86-64" 31 | 32 | condition: 33 | $a at 0 and ($b or $c) 34 | } 35 | 36 | -------------------------------------------------------------------------------- /rules/gif.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | rule gif_bitmap: GIF 10 | { 11 | meta: 12 | author = "Joan Bono" 13 | 14 | strings: 15 | $a = { 47 49 46 } 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule gif87a_bitmap: GIF 22 | { 23 | meta: 24 | author = "Joan Bono" 25 | 26 | strings: 27 | $a = { 47 49 46 38 37 61 } 28 | 29 | condition: 30 | $a at 0 31 | } 32 | 33 | rule gif89a_bitmap: GIF 34 | { 35 | meta: 36 | author = "Joan Bono" 37 | 38 | strings: 39 | $a = { 47 49 46 38 39 61 } 40 | 41 | condition: 42 | $a at 0 43 | } -------------------------------------------------------------------------------- /rules/gps.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule gps: GPS GPX 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {3C 67 70 78 20 76 65 72 73 69 6F 6E 3D 22 31 2E 31} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | -------------------------------------------------------------------------------- /rules/jpeg.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule jpeg: JFIF JPE JPEG JPG 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {FF D8 FF E0 ?? ?? 4A 46 49 46 00} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule jpg_with_EXIF: JPG 22 | { 23 | meta: 24 | author = "Jaume Martin" 25 | 26 | strings: 27 | $a = {FF D8 FF E1 ?? ?? 45 78 69 66 00} 28 | 29 | condition: 30 | $a at 0 31 | } 32 | 33 | rule jpeg_with_Canon_EOS: JPEG 34 | { 35 | meta: 36 | author = "Jaume Martin" 37 | 38 | strings: 39 | $a = {FF D8 FF E2 ?? ?? 53 50 49 46 46 00} 40 | 41 | condition: 42 | $a at 0 43 | } 44 | 45 | 46 | rule jpeg_with_Samsung_D500: JPEG 47 | { 48 | meta: 49 | author = "Jaume Martin" 50 | 51 | strings: 52 | $a = {FF D8 FF E3 ?? ?? 53 50 49 46 46 00} 53 | 54 | condition: 55 | $a at 0 56 | } 57 | 58 | rule jpg_with_SPIFF: JPG 59 | { 60 | meta: 61 | author = "Jaume Martin" 62 | 63 | strings: 64 | $a = {FF D8 FF E8 ?? ?? 53 50 49 46 46 00} 65 | 66 | condition: 67 | $a at 0 68 | } 69 | 70 | rule jpeg_2000: JPEG2000 71 | { 72 | meta: 73 | author = "Jaume Martin" 74 | 75 | strings: 76 | $a = {00 00 00 0C 6A 50 20 20 0D 0A} 77 | 78 | condition: 79 | $a at 0 80 | } 81 | -------------------------------------------------------------------------------- /rules/mem_dumps.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule win_64_mem_dump: DMP 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | file_info = "Windows 64-bit memory dump" 14 | 15 | strings: 16 | $a = {50 41 47 45 44 55 36 34} 17 | 18 | condition: 19 | $a at 0 20 | } 21 | 22 | rule win_32_mem_dump: DMP 23 | { 24 | meta: 25 | author = "Jaume Martin" 26 | file_info = "Windows 32-bit memory dump" 27 | 28 | strings: 29 | $a = {50 41 47 45 44 55 4D 50} 30 | 31 | condition: 32 | $a at 0 33 | } 34 | -------------------------------------------------------------------------------- /rules/office.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | - Joan Bono <@joan_bono> 8 | */ 9 | 10 | rule doc: DOC 11 | { 12 | meta: 13 | author = "Jaume Martin" 14 | 15 | strings: 16 | $a = {CF 11 E0 A1 B1 1A E1 00} 17 | 18 | condition: 19 | $a at 0 20 | } 21 | 22 | rule excel_2007: XLSX 23 | { 24 | meta: 25 | author = "Joan Bono" 26 | 27 | strings: 28 | $a = { 50 4b 03 04 } 29 | 30 | condition: 31 | $a at 0 32 | } 33 | 34 | rule excel_2003: XLS 35 | { 36 | meta: 37 | author = "Joan Bono" 38 | 39 | strings: 40 | $a = { D0 CF 11 E0 A1 B1 1A E1 00 } 41 | 42 | condition: 43 | $a at 0 44 | } 45 | 46 | rule excel_XML: XLS 47 | { 48 | meta: 49 | author = "Joan Bono" 50 | 51 | strings: 52 | $a = { 3C 3F 78 6D 6C 20 76 } 53 | 54 | condition: 55 | $a at 0 56 | } 57 | 58 | rule excel_OS2worksheet: XLS 59 | { 60 | meta: 61 | author = "Joan Bono" 62 | 63 | strings: 64 | $a = { 09 00 04 00 06 00 } 65 | 66 | condition: 67 | $a at 0 68 | } 69 | 70 | rule excel_OrthoTrack: XLS 71 | { 72 | meta: 73 | author = "Joan Bono" 74 | 75 | strings: 76 | $a = { 56 65 72 73 69 6F 6E 09 } 77 | 78 | condition: 79 | $a at 0 80 | } 81 | 82 | -------------------------------------------------------------------------------- /rules/pdf.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule pdf: PDF 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {25 50 44 46} 16 | $b = {0A 25 25 45 4F 46 (??|0A)} 17 | $c = {0D 0A 25 25 45 4F 46 0D 0A} 18 | $d = {0D 25 25 45 4F 46 0D} 19 | 20 | condition: 21 | $a at 0 and for any of ($b, $c, $d): (@ > @a) 22 | } 23 | -------------------------------------------------------------------------------- /rules/png.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | 10 | rule png: PNG 11 | { 12 | meta: 13 | author = "Joan Bono" 14 | 15 | strings: 16 | $a = { 89 50 4E 47 0D 0A 1A 0A } 17 | $b = { 49 48 44 52 } 18 | $c = { 49 44 41 54 } 19 | $d = { 49 45 4E 44 } 20 | 21 | condition: 22 | $a at 0 and for any of ($b, $c): (@ > @a) and $d 23 | } 24 | 25 | rule mng: PNG 26 | { 27 | meta: 28 | author = "Joan Bono" 29 | 30 | strings: 31 | $a = { 8A 4D 4E 47 0D 0A 1A 0A } 32 | $b = { 49 45 4E 44 } 33 | 34 | condition: 35 | $a at 0 and $b 36 | } 37 | 38 | rule jng: PNG 39 | { 40 | meta: 41 | author = "Joan Bono" 42 | 43 | strings: 44 | $a = { 8B 4A 4E 47 0D 0A 1A 0A } 45 | $b = { 49 45 4E 44 } 46 | 47 | condition: 48 | $a at 0 and $b 49 | } 50 | -------------------------------------------------------------------------------- /rules/skype.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule skype_user_data: SKYPE 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {6C 33 33 6C} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | -------------------------------------------------------------------------------- /rules/sqlite.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | - Joan Bono <@joan_bono> 8 | */ 9 | 10 | rule sqlite: SQLITE 11 | { 12 | meta: 13 | author = "Jaume Martin" 14 | 15 | strings: 16 | $a = {53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00} 17 | 18 | condition: 19 | $a at 0 20 | } 21 | 22 | rule windows_thumbnail: WTBDB 23 | { 24 | meta: 25 | author = "Joan Bono" 26 | 27 | strings: 28 | $a = { D0 CF 11 E0 A1 B1 1A E1 } 29 | 30 | condition: 31 | $a at 0 32 | } 33 | 34 | rule quartus_database: QRDB 35 | { 36 | meta: 37 | author = "Joan Bono" 38 | 39 | strings: 40 | $a = { 51 75 61 72 74 75 73 5F 56 65 72 73 69 6F 6E 20 } 41 | 42 | condition: 43 | $a at 0 44 | } 45 | -------------------------------------------------------------------------------- /rules/vcard.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule vcard: vCard 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {42 45 47 49 4E 3A 56 43 41 52 44 0D 0A} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | -------------------------------------------------------------------------------- /rules/vector.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | rule ai: AI 10 | { 11 | meta: 12 | author = "Joan Bono" 13 | file_info = "Adobe Illustrator" 14 | 15 | strings: 16 | $a = {25 21 50 53 2D} 17 | 18 | condition: 19 | $a at 0 20 | } 21 | 22 | rule ai_compressed: AI 23 | { 24 | meta: 25 | author = "Joan Bono" 26 | file_info = "Adobe Illustrator Comrpessed" 27 | 28 | strings: 29 | $a = {41 69 02} 30 | 31 | condition: 32 | $a at 0 33 | } 34 | 35 | rule corel_draw_graohic: CDR 36 | { 37 | meta: 38 | author = "Joan Bono" 39 | file_info = "Corel Draw Document" 40 | 41 | strings: 42 | $a = {52 49 46 46} 43 | 44 | condition: 45 | $a at 0 46 | } 47 | 48 | rule corel_draw_compressed: CDR 49 | { 50 | meta: 51 | author = "Joan Bono" 52 | file_info = "Corel Draw Document Compressed" 53 | 54 | strings: 55 | $a = {50 4B 03 04} 56 | 57 | condition: 58 | $a at 0 59 | } 60 | 61 | rule gem: GEM 62 | { 63 | meta: 64 | author = "Joan Bono" 65 | file_info = "Graphics Environment Manager" 66 | 67 | strings: 68 | $a = {FF FF 18} 69 | 70 | condition: 71 | $a at 0 72 | } 73 | 74 | rule hpgl: HPGL 75 | { 76 | meta: 77 | author = "Joan Bono" 78 | file_info = "HP Graphics Language" 79 | 80 | strings: 81 | $a = {49 4E 3B} 82 | 83 | condition: 84 | $a at 0 85 | } 86 | 87 | rule hvif: HVIF 88 | { 89 | meta: 90 | author = "Joan Bono" 91 | file_info = "Haiku Vector Icon Format" 92 | 93 | strings: 94 | $a = {6E 63 69 66} 95 | 96 | condition: 97 | $a at 0 98 | } 99 | 100 | rule odg: ODG 101 | { 102 | meta: 103 | author = "Joan Bono" 104 | file_info = "Open Document Graphics document" 105 | 106 | strings: 107 | $a = {50 4B 03 04} 108 | 109 | condition: 110 | $a at 0 111 | } 112 | 113 | rule povray: POVRAY 114 | { 115 | meta: 116 | author = "Joan Bono" 117 | file_info = "Persistence of Vision State File" 118 | 119 | strings: 120 | $a = {50 4F 56 2D 52 61 79 20 52 65 6E 64 65 72 20 53} 121 | 122 | condition: 123 | $a at 0 124 | } 125 | 126 | rule pgml: PGML 127 | { 128 | meta: 129 | author = "Joan Bono" 130 | file_info = "Precission Graphics Markup Language" 131 | 132 | strings: 133 | $a = {3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31} 134 | 135 | condition: 136 | $a at 0 137 | } 138 | 139 | rule pgf: PGF 140 | { 141 | meta: 142 | author = "Joan Bono" 143 | file_info = "Progressive Graphics File bitmap" 144 | 145 | strings: 146 | $a = {50 47 46 01 10 00} 147 | 148 | condition: 149 | $a at 0 150 | } 151 | 152 | rule gis: GIS 153 | { 154 | meta: 155 | author = "Joan Bono" 156 | file_info = "Erdas bitmap" 157 | 158 | strings: 159 | $a = {48 45 41 44 37 34 00 00 03 00 00 00 00 00 00 00} 160 | 161 | condition: 162 | $a at 0 163 | } 164 | 165 | rule rip: RIP 166 | { 167 | meta: 168 | author = "Joan Bono" 169 | file_info = "Rocky Interlace Picture" 170 | 171 | strings: 172 | $a = {52 49 50} 173 | 174 | condition: 175 | $a at 0 176 | } 177 | 178 | rule wmf: WMF 179 | { 180 | meta: 181 | author = "Joan Bono" 182 | file_info = "Windows Metafile" 183 | 184 | strings: 185 | $a = {01 00 09 00} 186 | $b = {D7 CD C6 9A 00 00} 187 | 188 | condition: 189 | $a at 0 or $b at 0 190 | } 191 | 192 | rule xar: XAR 193 | { 194 | meta: 195 | author = "Joan Bono" 196 | file_info = "Xara vector drawing" 197 | 198 | strings: 199 | $a = {58 41 52 41 A3 A3 0D} 200 | 201 | condition: 202 | $a at 0 203 | } 204 | 205 | rule amf: AMF 206 | { 207 | meta: 208 | author = "Joan Bono" 209 | file_info = "Additive Manufacturing File Format" 210 | 211 | strings: 212 | $a = {3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31} 213 | 214 | condition: 215 | $a at 0 216 | } 217 | 218 | rule blend: BLEND 219 | { 220 | meta: 221 | author = "Joan Bono" 222 | file_info = "Blender 3D File" 223 | 224 | strings: 225 | $a = {42 4C 45 4E 44 45 52} 226 | 227 | condition: 228 | $a at 0 229 | } 230 | 231 | rule dgn: DGN 232 | { 233 | meta: 234 | author = "Joan Bono" 235 | file_info = "Bentley MicroStation CAD drawing" 236 | 237 | strings: 238 | $a = {D0 CF 11 E0 A1 B1 1A E1 00} 239 | 240 | condition: 241 | $a at 0 242 | } 243 | 244 | rule dwf: DWF 245 | { 246 | meta: 247 | author = "Joan Bono" 248 | file_info = "AutoDesk Design Web Format" 249 | 250 | strings: 251 | $a = {28 44 57 46 20 56} 252 | 253 | condition: 254 | $a at 0 255 | } 256 | 257 | rule dwg: DWG 258 | { 259 | meta: 260 | author = "Joan Bono" 261 | file_info = "AutoDesk AutoCAD Drawing" 262 | 263 | strings: 264 | $a = {41 43 31 30 31 35} /* 2000-2002 */ 265 | $b = {41 43 31 30 31 38} /* 2004-2006 */ 266 | $c = {41 43 31 30 32 31} /* 2007-2009 */ 267 | $d = {41 43 31 30 32 34} /* 2010-2012 */ 268 | $e = {41 43 31 30 32 37} /* 2013-2016 */ 269 | $f = {4D 43 30 2E 30} /* AutoCAD R1.0 */ 270 | $g = {41 43 31 2E 32} /* AutoCAD R1.2 */ 271 | $h = {41 43 31 2E 34 30} /* AutoCAD R1.40 */ 272 | $i = {41 43 31 30 30 36} /* AutoCAD R10 */ 273 | $j = {41 43 31 30 30 39} /* AutoCAD R11-12 */ 274 | $k = {41 43 31 30 31 30} /* AutoCAD R13 (sub 10) */ 275 | $l = {41 43 31 30 31 31} /* AutoCAD R13 (sub 11) */ 276 | $m = {41 43 31 30 31 32} /* AutoCAD R13 */ 277 | $n = {41 43 31 30 31 33} /* AutoCAD R13 */ 278 | 279 | condition: 280 | for any of ($*) : ( $ at 0 ) 281 | } 282 | 283 | rule dxf: DXF 284 | { 285 | meta: 286 | author = "Joan Bono" 287 | file_info = "AutoDesk AutoCAD Exchange Format" 288 | 289 | strings: 290 | $a = {41 75 74 6F 43 41 44 20 42 69 6E 61 72 79 20 44} 291 | 292 | condition: 293 | $a at 0 294 | } 295 | 296 | rule hsf: HSF 297 | { 298 | meta: 299 | author = "Joan Bono" 300 | file_info = "HOOPS 3D Stream Format" 301 | 302 | strings: 303 | $a = {3B 3B 20 48 53 46 20 56} 304 | 305 | condition: 306 | $a at 0 307 | } 308 | 309 | rule jt: JT 310 | { 311 | meta: 312 | author = "Joan Bono" 313 | file_info = "JT 3D Visualization format" 314 | 315 | strings: 316 | $a = {56 65 72 73 69 6F 6E 20} 317 | 318 | condition: 319 | $a at 0 320 | } 321 | 322 | rule ma: MA 323 | { 324 | meta: 325 | author = "Joan Bono" 326 | file_info = "Maya ASCII Format" 327 | 328 | strings: 329 | $a = {2F 2F 4D 61 79 61 20 41 53 43 49 49} 330 | 331 | condition: 332 | $a at 0 333 | } 334 | 335 | rule mb: MB 336 | { 337 | meta: 338 | author = "Joan Bono" 339 | file_info = "Maya Binary Scene" 340 | 341 | strings: 342 | $a = {46 4F 52 34} 343 | 344 | condition: 345 | $a at 0 346 | } 347 | 348 | rule obg: OBJ 349 | { 350 | meta: 351 | author = "Joan Bono" 352 | file_info = "AliaslWavefront File Format" 353 | 354 | strings: 355 | $a = {23 20 4D 61 78 32 4F 62 6A 20 56 65 72 73 69 6F} /* 3D Max */ 356 | $b = {23 57 61 76 65 66 72 6F 6E 74 20 4F 42 4A 20 66} /* Hexagon */ 357 | $c = {41 43 4D 54 00 00} /* X-CAD Modifier */ 358 | $d = {23 20 42 6C 65 6E 64 65 72} /* Blender 3D */ 359 | 360 | condition: 361 | for any of ($*) : ( $ at 0 ) 362 | } 363 | 364 | rule prc: PRC 365 | { 366 | meta: 367 | author = "Joan Bono" 368 | file_info = "Picture Gear Bitmap" 369 | 370 | strings: 371 | $a = {42 69 74 6D 61 70} 372 | 373 | condition: 374 | $a at 0 375 | } 376 | 377 | rule skp: SKP 378 | { 379 | meta: 380 | author = "Joan Bono" 381 | file_info = "Google SketchUp" 382 | 383 | strings: 384 | $a = {FF FE FF 0E 53 00 6B 00 65 00 74 00 63 00 68 00} 385 | 386 | condition: 387 | $a at 0 388 | } 389 | 390 | rule stl: STL 391 | { 392 | meta: 393 | author = "Joan Bono" 394 | file_info = "STereoLithography" 395 | 396 | strings: 397 | $a = {61 6C 69 62 72 65 20 73 74 6C 20 62 69 6E 61 72} /* Alibre */ 398 | $b = {53 54 4C 42 20 41 54 46 20} /* ATF */ 399 | $c = {41 75 74 6F 43 41 44 20 73 6F 6C 69 64 00} /* AutoCAD */ 400 | $d = {45 78 70 6F 72 74 65 64 20 66 72 6F 6D 20} /* Blender 3D */ 401 | $e = {53 54 4C 20 4F 75 74 70 75 74 20 66 72 6F 6D 20} /* Geomagic Studio */ 402 | $f = {53 54 4C 42 20 41 53 4D 20} /* Inventor */ 403 | $g = {53 54 4C 20 46 69 6C 65 20 63 72 65 61 74 65 64} /* netfabb */ 404 | $h = {52 68 69 6E 6F 63 65 72 6F 73 20 42 69 6E 61 72} /* Rhinoceros */ 405 | $i = {62 69 6E 61 72 79 20 73 74 6C 20 66 69 6C 65 20} /* STereo Lithography */ 406 | $j = {73 6F 6C 69 64 20} /* STereo Lithography ASCII */ 407 | 408 | condition: 409 | for any of ($*) : ( $ at 0 ) 410 | } 411 | 412 | rule u3d: U3D 413 | { 414 | meta: 415 | author = "Joan Bono" 416 | file_info = "Universal 3D" 417 | 418 | strings: 419 | $a = {55 33 44 00} 420 | 421 | condition: 422 | $a at 0 423 | } 424 | 425 | rule xaml: XAML 426 | { 427 | meta: 428 | author = "Joan Bono" 429 | file_info = "Microsoft Extensible Application Markup Language" 430 | 431 | strings: 432 | $a = {EF BB BF 3C} 433 | 434 | condition: 435 | $a at 0 436 | } 437 | 438 | rule x3d: X3D 439 | { 440 | meta: 441 | author = "Joan Bono" 442 | file_info = "Extensible 3D Vector Graphics" 443 | 444 | strings: 445 | $a = {3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D} 446 | 447 | condition: 448 | $a at 0 449 | } 450 | 451 | rule vector3d: Vector3D 452 | { 453 | meta: 454 | author = "Joan Bono" 455 | file_info = "VersaCAD Drawing" 456 | 457 | strings: 458 | $a = {01 00 32 00 28 00 00 00} 459 | 460 | condition: 461 | $a at 0 462 | } 463 | 464 | rule _3dm: _3DM 465 | { 466 | meta: 467 | author = "Joan Bono" 468 | file_info = "3D Model" 469 | 470 | strings: 471 | $a = {43 61 64 65 6E 74 20 33 44 20 4D 6F 64 65 6C 20} /* Cadent 3D Model */ 472 | $b = {33 44 20 47 65 6F 6D 65 74 72 79 20 46 69 6C 65} /* Rhinoceros 3D Model */ 473 | 474 | condition: 475 | $a at 0 or $b at 0 476 | } 477 | 478 | rule _3dxml: _3DXML 479 | { 480 | meta: 481 | author = "Joan Bono" 482 | file_info = "3D XML Files" 483 | 484 | strings: 485 | $a = {3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31} 486 | 487 | condition: 488 | $a at 0 489 | } 490 | 491 | rule _3dxml_compressed: _3DXML 492 | { 493 | meta: 494 | author = "Joan Bono" 495 | file_info = "3D XML Files Compressed" 496 | 497 | strings: 498 | $a = {50 4B 03 04} 499 | 500 | condition: 501 | $a at 0 502 | } -------------------------------------------------------------------------------- /rules/video.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | - Joan Bono <@joan_bono> 8 | */ 9 | 10 | rule videocd: VCD 11 | { 12 | meta: 13 | author = "Jaume Martin" 14 | 15 | strings: 16 | $a = {45 4E 54 52 59 56 43 44 02 00 00 01 02 00 18 58} 17 | 18 | condition: 19 | $a at 0 20 | } 21 | 22 | rule ogg: OGG 23 | { 24 | meta: 25 | author = "Jaume Martin" 26 | file_info = "Ogg Vorbis Codec" 27 | 28 | strings: 29 | $a = {4F 67 67 53 00 02 00 00 00 00 00 00 00 00} 30 | 31 | condition: 32 | $a at 0 33 | } 34 | 35 | rule avi: AVI 36 | { 37 | meta: 38 | author = "Joan Bono" 39 | 40 | strings: 41 | $a = { 52 49 46 46 } 42 | 43 | condition: 44 | $a at 0 45 | } 46 | 47 | rule mkv: MKV 48 | { 49 | meta: 50 | author = "Joan Bono" 51 | 52 | strings: 53 | $a = { 1A 45 DF A3 } 54 | 55 | condition: 56 | $a at 0 57 | } 58 | 59 | rule flv: FLV 60 | { 61 | meta: 62 | author = "Joan Bono" 63 | 64 | strings: 65 | $a = { 46 4C 56 01 } 66 | 67 | condition: 68 | $a at 0 69 | } 70 | 71 | rule wmv: WMV 72 | { 73 | meta: 74 | author = "Joan Bono" 75 | 76 | strings: 77 | $a = { 30 26 B2 75 8E 66 CF 11 A6 D9 00 AA 00 62 CE 6C } 78 | 79 | condition: 80 | $a at 0 81 | } 82 | 83 | rule mpg2: MPG 84 | { 85 | meta: 86 | author = "Joan Bono" 87 | 88 | strings: 89 | $a = { 00 00 01 BA 44 } 90 | 91 | condition: 92 | $a at 0 93 | } 94 | 95 | rule mpg4: MP4 96 | { 97 | meta: 98 | author = "Joan Bono" 99 | 100 | strings: 101 | $a = { 00 00 00 14 66 74 79 70 69 73 6F 6D 00 00 00 01 } 102 | 103 | condition: 104 | $a at 0 105 | } 106 | 107 | rule mov: MOV 108 | { 109 | meta: 110 | author = "Joan Bono" 111 | 112 | strings: 113 | $a = { 4B 41 4D 76 } 114 | 115 | condition: 116 | $a at 0 117 | } 118 | 119 | rule real_media_stream: RM 120 | { 121 | meta: 122 | author = "Joan Bono" 123 | 124 | strings: 125 | $a = { 2E 52 4D 46 00 00 00 12 00 } 126 | 127 | condition: 128 | $a at 0 129 | } 130 | 131 | rule real_media_variable_bitrate: RMVB 132 | { 133 | meta: 134 | author = "Joan Bono" 135 | 136 | strings: 137 | $a = { 2E 52 4D 46 } 138 | 139 | condition: 140 | $a at 0 141 | } 142 | 143 | rule raw_h264: H264 144 | { 145 | meta: 146 | author = "Joan Bono" 147 | 148 | strings: 149 | $a = { 00 00 00 01 67 64 00 1F AC 34 E2 40 B4 11 7E E1 } 150 | 151 | condition: 152 | $a at 0 153 | } 154 | 155 | rule magic_lantern_video: MLV 156 | { 157 | meta: 158 | author = "Joan Bono" 159 | 160 | strings: 161 | $a = { 4D 4C 56 49 } 162 | 163 | condition: 164 | $a at 0 165 | } 166 | 167 | rule webm: WEBM 168 | { 169 | meta: 170 | author = "Joan Bono" 171 | 172 | strings: 173 | $a = { 1A 45 DF A3 } 174 | 175 | condition: 176 | $a at 0 177 | } 178 | 179 | rule vob: VOB 180 | { 181 | meta: 182 | author = "Joan Bono" 183 | 184 | strings: 185 | $a = { FF FF FF 5D 00 00 00 02 00 01 00 00 00 FC FF 35 } 186 | 187 | condition: 188 | $a at 0 189 | } 190 | 191 | rule dirac: DRC 192 | { 193 | meta: 194 | author = "Joan Bono" 195 | 196 | strings: 197 | $a = { 42 42 43 44 } 198 | 199 | condition: 200 | $a at 0 201 | } 202 | 203 | 204 | rule gif_animated: GIF 205 | { 206 | meta: 207 | author = "Joan Bono" 208 | 209 | strings: 210 | $a = { 47 49 46 38 39 61 } 211 | 212 | condition: 213 | $a at 0 214 | } 215 | 216 | rule anime_music_video: AMV 217 | { 218 | meta: 219 | author = "Joan Bono" 220 | 221 | strings: 222 | $a = { 52 49 46 46 } 223 | 224 | condition: 225 | $a at 0 226 | } 227 | 228 | rule material_exchange_music: MXF 229 | { 230 | meta: 231 | author = "Joan Bono" 232 | 233 | strings: 234 | $a = { 06 0E 2B 34 02 05 01 01 0D 01 02 01 01 02 } 235 | 236 | condition: 237 | $a at 0 238 | } 239 | 240 | rule picasa_material_exchange_music: MXF 241 | { 242 | meta: 243 | author = "Joan Bono" 244 | 245 | strings: 246 | $a = { 3C 43 54 72 61 6E 73 54 69 6D 65 6C 69 6E 65 3E } 247 | 248 | condition: 249 | $a at 0 250 | } 251 | 252 | rule id_software_game_video: ROQ 253 | { 254 | meta: 255 | author = "Joan Bono" 256 | 257 | strings: 258 | $a = { 84 10 FF FF FF FF 1E 00 } 259 | 260 | condition: 261 | $a at 0 262 | } 263 | 264 | rule nullsoft_streaming_video: NSV 265 | { 266 | meta: 267 | author = "Joan Bono" 268 | 269 | strings: 270 | $a = { 4E 53 56 } 271 | 272 | condition: 273 | $a at 0 274 | } 275 | 276 | 277 | -------------------------------------------------------------------------------- /rules/vmware.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Joan Bono <@joan_bono> 7 | */ 8 | 9 | rule vmdk: VMDK 10 | { 11 | meta: 12 | author = "Joan Bono" 13 | 14 | strings: 15 | $a = {4B 44 4D 56} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule vmem: VMEM 22 | { 23 | meta: 24 | author = "Joan Bono" 25 | 26 | strings: 27 | $a = {53 ff 00 f0} 28 | 29 | condition: 30 | $a at 0 31 | } 32 | 33 | rule nvram: NVRAM 34 | { 35 | meta: 36 | author = "Joan Bono" 37 | 38 | strings: 39 | $a = {4D 52 56 4E} 40 | 41 | condition: 42 | $a at 0 43 | } 44 | 45 | rule vmx: VMX 46 | { 47 | meta: 48 | author = "Joan Bono" 49 | 50 | strings: 51 | $a = {2E 65 6E 63 6F 64 69 6E 67 20 3D 20 22} 52 | 53 | condition: 54 | $a at 0 55 | } 56 | 57 | rule vmxf: VMXF 58 | { 59 | meta: 60 | author = "Joan Bono" 61 | 62 | strings: 63 | $a = {3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31} 64 | 65 | condition: 66 | $a at 0 67 | } 68 | 69 | rule vmss: VMSS 70 | { 71 | meta: 72 | author = "Joan Bono" 73 | 74 | strings: 75 | $a = {d2 be d2 be 08 00 00 00 66} 76 | 77 | condition: 78 | $a at 0 79 | } 80 | -------------------------------------------------------------------------------- /rules/win_reg.yar: -------------------------------------------------------------------------------- 1 | /* 2 | Description: This finds the magics on individual files. 3 | Disclaimer: This can though false positives. 4 | 5 | Contributors: 6 | - Jaume Martin <@Xumeiquer> 7 | */ 8 | 9 | rule win_register: REG SUD 10 | { 11 | meta: 12 | author = "Jaume Martin" 13 | 14 | strings: 15 | $a = {52 45 47 45 44 49 54} 16 | 17 | condition: 18 | $a at 0 19 | } 20 | 21 | rule win_hive: REG HIVE 22 | { 23 | meta: 24 | author = "Jaume Martin" 25 | strings: 26 | $a = { 72 65 67 66 } 27 | condition: 28 | $a at 0 29 | } 30 | -------------------------------------------------------------------------------- /utils/magic_sig_scraper.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import lxml.html as lh 3 | import pandas as pd 4 | import sqlalchemy as db 5 | import re 6 | 7 | 8 | # magic_sig_scraper scrapes the dynamic list of magic numbers from wikipedia, storing it in a database. 9 | # this database can then be used to supplement hamburglar.py 10 | # It does not need to be updated very regularly, but you can set this on a cron job 11 | url='https://en.wikipedia.org/wiki/List_of_file_signatures' 12 | 13 | #Create a handle, page, to handle the contents of the website 14 | page = requests.get(url) 15 | 16 | #Store the contents of the website under doc 17 | doc = lh.fromstring(page.content) 18 | 19 | #Parse data that are stored between .. of HTML 20 | tr_elements = doc.xpath('//tr') 21 | 22 | #Create empty list 23 | col = [] 24 | i = 0 25 | 26 | for t in tr_elements[0]: 27 | i += 1 28 | name = t.text_content().strip() 29 | print(i, name) 30 | if name != "": 31 | col.append((name, [])) 32 | 33 | for j in range(1, len(tr_elements)): 34 | T = tr_elements[j] 35 | i = 0 36 | 37 | for t in T.iterchildren(): 38 | data = t.text_content().strip() 39 | 40 | if i > 0: 41 | try: 42 | data = int(data) 43 | except: 44 | pass 45 | 46 | col[i][1].append(data) 47 | 48 | i += 1 49 | 50 | Dict = {title:column for (title, column) in col} 51 | df = pd.DataFrame(dict([(k, pd.Series(v)) for k, v in Dict.items()])) 52 | 53 | engine = db.create_engine('mysql+pymysql://hamman:deadbeef@localhost/fileSign') 54 | conn = engine.connect() 55 | 56 | df.to_sql("signatures", engine, if_exists='replace') 57 | db_string = engine.execute("SELECT `Hex signature` FROM `signatures` WHERE signatures.index=0").fetchall() 58 | 59 | print(db_string) --------------------------------------------------------------------------------