├── LICENSE ├── README.md ├── Tor Memory Parsers ├── README.md ├── TorMemory_BrowserActivity.py ├── TorMemory_BrowserRequests.py ├── TorMemory_BrowserSessionData.py ├── TorMemory_HTTPRequests.py └── TorMemory_SocksRequests.py └── Win 11 - Tor Browser Bookmarks ├── ReadMe.md ├── TorBrowser_Bookmarks.py └── requirements.txt /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 | 635 | Copyright (C) 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 | Copyright (C) 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 | # DarkWeb_Forensics 2 | A series of python scripts to extract information from Dark Web Applications 3 | -------------------------------------------------------------------------------- /Tor Memory Parsers/README.md: -------------------------------------------------------------------------------- 1 | Scripts to Parse Tor Browser Activity from Windows Memory 2 | -------------------------------------------------------------------------------- /Tor Memory Parsers/TorMemory_BrowserActivity.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import mmap 4 | import re 5 | import time 6 | import csv 7 | 8 | # Pre-compile patterns for efficiency 9 | patterns = [ 10 | b'\x01\x00\x00\x00\xF8\x00\x00\x00', 11 | b'\x01\x00\x00\x00\xF8\x01\x00\x00', 12 | b'\x01\x00\x00\x00\xF8\x03\x00\x00', 13 | b'\x02\x00\x00\x00\xF8\x01\x00\x00', 14 | b'\x02\x00\x00\x00\xF8\x00\x00\x00', 15 | b'\x02\x00\x00\x00\xF8\x03\x00\x00', 16 | b'\x03\x00\x00\x00\xF8\x01\x00\x00', 17 | b'\x03\x00\x00\x00\xF8\x00\x00\x00', 18 | b'\x04\x00\x00\x00\xF8\x00\x00\x00', 19 | b'\x05\x00\x00\x00\xF8\x00\x00\x00', 20 | ] 21 | pattern_re = re.compile(b'|'.join(re.escape(p) for p in patterns)) # Join patterns into one regex 22 | 23 | def process_match(match_offset, memory_data, csv_writer): 24 | """Processes pattern match within memory dump and writes relevant data to CSV.""" 25 | try: 26 | matched_prefix = memory_data[match_offset:match_offset + 8] 27 | except IndexError: 28 | return 29 | 30 | index = match_offset + 8 31 | 32 | if matched_prefix: 33 | extracted_data = "" 34 | entry_type = "Potential Browser Activity" 35 | 36 | first_byte = memory_data[index:index+1] 37 | utf16_attempt = False 38 | 39 | if first_byte not in (b'\x00', b'\x08', b'\xFF', b'\xD0', b'\x2E', b'\x4F'): 40 | http_data_start = index 41 | termination_pattern = re.compile(rb'\x00\x0E|\x00\xE5|\x00\x00') 42 | match = termination_pattern.search(memory_data[http_data_start:]) 43 | if not match: 44 | return 45 | http_data_end = http_data_start + match.start() 46 | 47 | try: 48 | extracted_data = ''.join( 49 | c for c in memory_data[http_data_start:http_data_end].decode('utf-8', errors='ignore').strip() 50 | if c.isprintable() 51 | ) 52 | except UnicodeDecodeError: 53 | try: 54 | extracted_data = ''.join( 55 | c for c in memory_data[http_data_start:http_data_end].decode('utf-16', errors='ignore').replace(' ', '').strip() 56 | if c.isprintable() 57 | ) 58 | utf16_attempt = True 59 | except UnicodeDecodeError: 60 | extracted_data = f"[Non-printable: {memory_data[http_data_start:http_data_end].hex()}]" 61 | 62 | # Skip writing if no printable data is found** 63 | if not extracted_data.strip(): 64 | return 65 | 66 | index = http_data_end + 2 67 | print(f"[+] Potential Browser Activity identified at offset: {index}") 68 | 69 | # Write Extracted Data to CSV** 70 | csv_writer.writerow([match_offset, entry_type, extracted_data]) 71 | 72 | def extract_browser_activity(dump_file_path, output_csv_path): 73 | """Reads the entire file using mmap and processes matches sequentially.""" 74 | start_time = time.time() 75 | print(f"Processing started at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\n") 76 | 77 | with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: 78 | csv_writer = csv.writer(csv_file) 79 | csv_writer.writerow(["Offset", "Type", "Extracted Data"]) 80 | 81 | with open(dump_file_path, 'rb') as dump_file: 82 | with mmap.mmap(dump_file.fileno(), 0, access=mmap.ACCESS_READ) as memory_data: 83 | match_offsets = sorted(match.start() for match in pattern_re.finditer(memory_data)) 84 | 85 | for offset in match_offsets: 86 | process_match(offset, memory_data, csv_writer) 87 | 88 | end_time = time.time() 89 | print(f"\nProcessing completed at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}") 90 | elapsed_time = end_time - start_time 91 | hours, remainder = divmod(elapsed_time, 3600) 92 | minutes, seconds = divmod(remainder, 60) 93 | print(f"Total execution time: {int(hours):02d}:{int(minutes):02d}:{seconds:.2f}") 94 | 95 | if __name__ == '__main__': 96 | parser = argparse.ArgumentParser(description='Extract Potential Tor Browser activity from Memory.') 97 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the memory dump file.') 98 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output CSV file.') 99 | 100 | args = parser.parse_args() 101 | 102 | print(r""" 103 | _____ _ ______ _ 104 | / ____| | | | ____| (_) 105 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 106 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 107 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 108 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 109 | | | __/ | 110 | |_| |___/ 111 | 112 | Tor Browser Memory Parser - Potential Browser Activity 113 | Version: 1.0 Feb, 2025 114 | Author: Spyder Forensics Training 115 | Website: www.spyderforensics.com 116 | Course: Host-Based Dark Web Forensics 117 | """) 118 | 119 | if not os.path.isfile(args.input): 120 | print("The specified memory dump file does not exist.") 121 | else: 122 | extract_browser_activity(args.input, args.output) 123 | -------------------------------------------------------------------------------- /Tor Memory Parsers/TorMemory_BrowserRequests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import mmap 4 | import re 5 | import time 6 | import csv 7 | 8 | # Pre-compile patterns for efficiency 9 | patterns = [ 10 | b'\x02\x00\x00\x00\xF8\x01\x00\x00\x4F\x5E', 11 | b'\x02\x00\x00\x00\xF8\x00\x00\x00\x4F\x5E', 12 | b'\x02\x00\x00\x00\xF8\x03\x00\x00\x4F\x5E', 13 | ] 14 | pattern_re = re.compile(b'|'.join(re.escape(p) for p in patterns)) # Join patterns into one regex 15 | 16 | def process_match(match_offset, memory_data, csv_writer): 17 | """Processes pattern match within memory dump and writes to CSV only if required fields exist.""" 18 | try: 19 | matched_prefix = memory_data[match_offset:match_offset + 9] 20 | except IndexError: 21 | return 22 | 23 | index = match_offset + 9 24 | 25 | if matched_prefix: 26 | private_browsing_id = "" 27 | first_party_domain = "" 28 | requested_resource = "" 29 | entry_type = "Browser Request" 30 | 31 | # Extract Private Browsing ID (Required) 32 | private_start = memory_data.find(b'privateBrowsingId=', index) 33 | if private_start == -1 or private_start > index + 100: 34 | return 35 | 36 | private_id_start = private_start + len(b'privateBrowsingId=') 37 | private_browsing_id_byte = memory_data[private_id_start:private_id_start+1] 38 | 39 | try: 40 | private_browsing_id = private_browsing_id_byte.decode('utf-8') 41 | if not private_browsing_id.isprintable(): 42 | private_browsing_id = f"[Non-printable: {private_browsing_id_byte.hex()}]" 43 | except UnicodeDecodeError: 44 | private_browsing_id = f"[Non-printable: {private_browsing_id_byte.hex()}]" 45 | 46 | index = private_id_start + 1 47 | 48 | # Extract First Party Domain (Required) 49 | first_party_start = memory_data.find(b'firstPartyDomain=', index) 50 | if first_party_start == -1: 51 | return 52 | 53 | first_party_start += len(b'firstPartyDomain=') 54 | first_party_end = memory_data.find(b'\x2C', first_party_start) 55 | if first_party_end == -1: 56 | return 57 | 58 | first_party_domain = memory_data[first_party_start:first_party_end].decode(errors='ignore').strip() 59 | index = first_party_end + 1 60 | 61 | # Extract Requested Resource (Optional) 62 | requested_resource_start = memory_data.find(b'\x70\x2C\x3A', index) 63 | if requested_resource_start != -1: 64 | requested_resource_start += 3 65 | requested_resource_end = memory_data.find(b'\x00', requested_resource_start) 66 | if requested_resource_end != -1: 67 | requested_resource = memory_data[requested_resource_start:requested_resource_end].decode(errors='ignore').strip() 68 | index = requested_resource_end + 1 69 | 70 | # Set Type as "Partially Recovered" if only required fields are found 71 | if requested_resource == "": 72 | entry_type = "Partially Carved Browser Request" 73 | 74 | print(f"[+] {entry_type} Identified at offset {match_offset}") 75 | 76 | # Write Extracted Data to CSV 77 | csv_writer.writerow([ 78 | match_offset, entry_type, private_browsing_id, 79 | first_party_domain, requested_resource 80 | ]) 81 | 82 | def extract_socks5_traffic(dump_file_path, output_csv_path): 83 | """Reads the entire file using mmap and processes matches sequentially.""" 84 | start_time = time.time() 85 | print(f"Processing started at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\n") 86 | 87 | with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: 88 | csv_writer = csv.writer(csv_file) 89 | csv_writer.writerow(["Offset", "Type", "Private Browsing ID", "First Party Domain", "Request"]) 90 | 91 | with open(dump_file_path, 'rb') as dump_file: 92 | with mmap.mmap(dump_file.fileno(), 0, access=mmap.ACCESS_READ) as memory_data: 93 | match_offsets = sorted(match.start() for match in pattern_re.finditer(memory_data)) 94 | 95 | for offset in match_offsets: 96 | process_match(offset, memory_data, csv_writer) 97 | 98 | end_time = time.time() 99 | print(f"\nProcessing completed at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}") 100 | elapsed_time = end_time - start_time 101 | hours, remainder = divmod(elapsed_time, 3600) 102 | minutes, seconds = divmod(remainder, 60) 103 | print(f"Total execution time: {int(hours):02d}:{int(minutes):02d}:{seconds:.2f}") 104 | 105 | if __name__ == '__main__': 106 | parser = argparse.ArgumentParser(description='Extract Tor Browser Requests from Memory.') 107 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the memory dump file.') 108 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output CSV file.') 109 | 110 | args = parser.parse_args() 111 | 112 | print(r""" 113 | _____ _ ______ _ 114 | / ____| | | | ____| (_) 115 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 116 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 117 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 118 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 119 | | | __/ | 120 | |_| |___/ 121 | 122 | Tor Browser Memory Parser - Browser Requests 123 | Version: 1.0 Feb, 2025 124 | Author: Spyder Forensics Training 125 | Website: www.spyderforensics.com 126 | Course: Host-Based Dark Web Forensics 127 | """) 128 | 129 | if not os.path.isfile(args.input): 130 | print("The specified memory dump file does not exist.") 131 | else: 132 | extract_socks5_traffic(args.input, args.output) 133 | -------------------------------------------------------------------------------- /Tor Memory Parsers/TorMemory_BrowserSessionData.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import mmap 4 | import re 5 | import time 6 | import csv 7 | import base64 8 | 9 | # Pre-compile the pattern for efficiency 10 | patterns = [ 11 | b'\xFF\xFF\x66\x69\x72\x65\x66\x6F\x78\x2D\x70\x72\x69\x76\x61\x74\x65\x00' 12 | ] 13 | pattern_re = re.compile(b'|'.join(re.escape(p) for p in patterns)) 14 | 15 | 16 | def is_valid_base64(s): 17 | """Check if a string is a valid Base64 encoded string.""" 18 | try: 19 | base64.b64decode(s, validate=True) 20 | return True 21 | except (base64.binascii.Error, ValueError): 22 | return False 23 | 24 | 25 | def extract_base64_icon(favicon_url, index, extracted_icons_folder): 26 | """Extract base64-encoded favicons and save them to a folder.""" 27 | 28 | if not favicon_url.startswith('data:image'): 29 | return None # Not a Base64 image 30 | 31 | try: 32 | # Extract Base64 data part 33 | base64_data = favicon_url.split(',', 1)[1].strip() 34 | 35 | # Ensure only valid Base64 characters remain 36 | base64_data = re.sub(r'[^A-Za-z0-9+/=]', '', base64_data) 37 | 38 | # Validate Base64 data before decoding 39 | if not is_valid_base64(base64_data): 40 | print(f"[-] Invalid Base64 favicon at offset {index}, skipping extraction.") 41 | return None 42 | 43 | # Decode Base64 data 44 | image_data = base64.b64decode(base64_data) 45 | 46 | # Determine file extension 47 | file_extension = 'ico' if 'image/x-icon' in favicon_url else 'png' 48 | 49 | # Ensure output folder exists 50 | os.makedirs(extracted_icons_folder, exist_ok=True) 51 | 52 | # Name the file as the starting offset for the favicon data 53 | output_filename = f"{index}_favicon.{file_extension}" 54 | icon_output = os.path.join(extracted_icons_folder, output_filename) 55 | 56 | # Save image data to file 57 | with open(icon_output, 'wb') as image_file: 58 | image_file.write(image_data) 59 | 60 | print(f"[+] Favicon Extracted: {icon_output}") 61 | return output_filename, icon_output 62 | 63 | except (base64.binascii.Error, OSError, IndexError, ValueError) as e: 64 | print(f"[-] Error decoding Base64 Favicon at offset {index}: {e}") 65 | return None 66 | 67 | def process_match(match_offset, memory_data, csv_writer, extracted_icons_folder): 68 | """Manually walks the memory data to extract Browser Tab Session Data.""" 69 | try: 70 | matched_prefix = memory_data[match_offset:match_offset + 26] 71 | except IndexError: 72 | return 73 | 74 | index = match_offset + 26 # Move past matched pattern 75 | 76 | # Locate 'url' 77 | url_marker = memory_data.find(b'url', index, index + 15) 78 | if url_marker == -1: 79 | return # Skip if 'url' is not found 80 | 81 | index = url_marker + 3 82 | 83 | # Initialize extracted fields 84 | url = "" 85 | title = "Title Not Present" 86 | favicon_url = "FavIconURL Not Present" 87 | 88 | # Extract URL 89 | url_start_marker = memory_data.find(b'\xFF\xFF', index, index + 16) 90 | if url_start_marker != -1: 91 | index = url_start_marker + 2 92 | url_end = memory_data.find(b'\x00\x00', index, index + 2000) 93 | if url_end != -1: 94 | try: 95 | url = memory_data[index:url_end].decode(errors='ignore').strip() 96 | except UnicodeDecodeError: 97 | url = "Decoding Error" 98 | index = url_end + 2 99 | 100 | # Extract Title 101 | title_marker = memory_data.find(b'title', index, index + 50) 102 | if title_marker != -1: 103 | index = title_marker + 5 104 | title_start_marker = memory_data.find(b'\xFF\xFF', index, index + 16) # Find FF FF within 16 bytes 105 | if title_start_marker != -1: 106 | index = title_start_marker + 2 107 | title_end = memory_data.find(b'\x00\x00', index, index + 2000) # End marker for Title 108 | if title_end != -1: 109 | try: 110 | title = memory_data[index:title_end].decode(errors="ignore").strip() 111 | except UnicodeDecodeError: 112 | title = "Decoding Error" 113 | index = title_end + 2 114 | 115 | # Extract FavIconURL 116 | favicon_marker = memory_data.find(b'favIconUrl', index, index + 50) # Search for FavIcon URL 117 | if favicon_marker != -1: 118 | index = favicon_marker + 10 # Move past 'favIconUrl' 119 | favicon_start_marker = memory_data.find(b'\xFF\xFF', index, index + 24) # Search for `FF FF` 120 | if favicon_start_marker != -1: 121 | index = favicon_start_marker + 2 # Move past `FF FF` 122 | 123 | # Detect encoding (UTF-16 if 2nd byte is 0x00, otherwise assume UTF-8) 124 | is_utf16 = memory_data[index + 1] == 0x00 125 | 126 | # Find the end of the URL dynamically 127 | favicon_end = index 128 | if is_utf16: 129 | # UTF-16: Stop at first odd-byte that is NOT `0x00` 130 | while favicon_end + 1 < len(memory_data): 131 | if favicon_end % 2 != 0 and memory_data[favicon_end] != 0x00: 132 | break 133 | favicon_end += 1 134 | else: 135 | # UTF-8: Stop at first non-printable character 136 | while favicon_end < len(memory_data): 137 | if memory_data[favicon_end] < 0x20: # Stop at first non-printable byte 138 | break 139 | favicon_end += 1 140 | 141 | # Extract and decode the favicon URL** 142 | if favicon_end > index: 143 | try: 144 | raw_favicon_bytes = memory_data[index:favicon_end] 145 | 146 | # Decode based on detected encoding 147 | if is_utf16: 148 | favicon_url = raw_favicon_bytes.decode("utf-16-le", errors="ignore").strip() 149 | else: 150 | favicon_url = raw_favicon_bytes.decode("utf-8", errors="ignore").strip() 151 | 152 | except UnicodeDecodeError: 153 | favicon_url = "Decoding Error" 154 | 155 | index = favicon_end # Move index past extracted data 156 | 157 | # Check if the extracted URL is Base64 and extract the icon 158 | extract_base64_icon(favicon_url, match_offset, extracted_icons_folder) 159 | 160 | print(f"[+] Extracted Browser Tab Session Data at offset {match_offset}") 161 | 162 | # Write extracted data to CSV 163 | csv_writer.writerow([ 164 | match_offset, "Browser Tab Session Data", url, title, favicon_url 165 | ]) 166 | 167 | 168 | def extract_tabdata(dump_file_path, output_folder): 169 | """Reads the memory dump and extracts Browser Tab Session Data.""" 170 | start_time = time.time() 171 | print(f"Processing started at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\n") 172 | 173 | # Create the main output folder based on user input 174 | os.makedirs(output_folder, exist_ok=True) 175 | 176 | # Define CSV file path inside the output folder 177 | output_csv_path = os.path.join(output_folder, f"{os.path.basename(output_folder)}.csv") 178 | 179 | # Create Favicon output folder inside the main output folder 180 | extracted_icons_folder = os.path.join(output_folder, "Extracted FavIcons") 181 | os.makedirs(extracted_icons_folder, exist_ok=True) 182 | 183 | with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: 184 | csv_writer = csv.writer(csv_file) 185 | csv_writer.writerow(["Offset", "Type", "URL", "Title", "FavIcon URL"]) 186 | 187 | with open(dump_file_path, 'rb') as dump_file: 188 | with mmap.mmap(dump_file.fileno(), 0, access=mmap.ACCESS_READ) as memory_data: 189 | match_offsets = sorted(match.start() for match in pattern_re.finditer(memory_data)) 190 | 191 | for offset in match_offsets: 192 | process_match(offset, memory_data, csv_writer, extracted_icons_folder) 193 | end_time = time.time() 194 | print(f"\nProcessing completed at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}") 195 | elapsed_time = end_time - start_time 196 | hours, remainder = divmod(elapsed_time, 3600) 197 | minutes, seconds = divmod(remainder, 60) 198 | print(f"Total execution time: {int(hours):02d}:{int(minutes):02d}:{seconds:.2f}") 199 | 200 | print(f"\nResults saved to: {output_csv_path}") 201 | 202 | if __name__ == '__main__': 203 | parser = argparse.ArgumentParser(description='Extract Browser Tab Session Data from a Memory Dump') 204 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the memory dump file.') 205 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output folder.') 206 | 207 | args = parser.parse_args() 208 | 209 | print(r""" 210 | _____ _ ______ _ 211 | / ____| | | | ____| (_) 212 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 213 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 214 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 215 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 216 | | | __/ | 217 | |_| |___/ 218 | 219 | Tor Browser Memory Parser - Browser Tab Session Data 220 | Version: 1.0 Feb, 2025 221 | Author: Spyder Forensics Training 222 | Website: www.spyderforensics.com 223 | Course: Host-Based Dark Web Forensics 224 | """) 225 | 226 | extract_tabdata(args.input, args.output) 227 | -------------------------------------------------------------------------------- /Tor Memory Parsers/TorMemory_HTTPRequests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import mmap 4 | import re 5 | import time 6 | import csv 7 | import struct 8 | import datetime 9 | 10 | # Pre-compile the pattern for efficiency 11 | patterns = [ 12 | b'\xFF\xFF\x72\x65\x71\x75\x65\x73\x74\x49\x64' 13 | ] 14 | pattern_re = re.compile(b'|'.join(re.escape(p) for p in patterns)) 15 | 16 | def process_match(match_offset, memory_data, csv_writer): 17 | """Manually walks the memory data to extract HTTP request metadata""" 18 | try: 19 | matched_prefix = memory_data[match_offset:match_offset + 26] 20 | except IndexError: 21 | return 22 | 23 | index = match_offset + 26 24 | 25 | 26 | request_id = "Unknown" 27 | url = "Unknown" 28 | origin_url = "Unknown" 29 | document_url = "Unknown" 30 | method = "Unknown" 31 | request_type = "Unknown" 32 | 33 | # Extract Request ID 34 | try: 35 | request_id = memory_data[index:index+8].decode('utf-8', errors='ignore') 36 | except UnicodeDecodeError: 37 | request_id = "Decoding Error" 38 | index += 8 39 | 40 | # Extract URL 41 | url_marker = memory_data.find(b'\xFF\xFF', index, index + 8) 42 | if url_marker != -1 and memory_data[url_marker + 2:url_marker + 5] == b'url': 43 | url_start = memory_data.find(b'\xFF\xFF', url_marker + 5, url_marker + 20) 44 | if url_start != -1: 45 | index = url_start + 2 46 | url_end = memory_data.find(b'\x00\x00', index, index + 2000) 47 | if url_end != -1: 48 | try: 49 | url = memory_data[index:url_end].decode(errors='ignore').strip() 50 | except UnicodeDecodeError: 51 | url = "Decoding Error" 52 | index = url_end + 2 53 | 54 | # Extract Origin URL 55 | originURL_marker = memory_data.find(b'\xFF\xFF', index, index + 50) 56 | if originURL_marker != -1 and memory_data[originURL_marker + 2:originURL_marker + 11] == b'originUrl': 57 | originURL_start = memory_data.find(b'\xFF\xFF', originURL_marker + 12, originURL_marker + 62) 58 | if originURL_start != -1: 59 | index = originURL_start + 2 60 | originURL_end = memory_data.find(b'\x00\x00', index, index + 2000) 61 | if originURL_end != -1: 62 | try: 63 | origin_url = memory_data[index:originURL_end].decode(errors='ignore').strip() 64 | except UnicodeDecodeError: 65 | origin_url = "Decoding Error" 66 | index = originURL_end + 2 67 | 68 | # Extract Document URL 69 | documentURL_marker = memory_data.find(b'\xFF\xFF', index, index + 50) 70 | if documentURL_marker != -1 and memory_data[documentURL_marker + 2:documentURL_marker + 13] == b'documentUrl': 71 | documentURL_start = memory_data.find(b'\xFF\xFF', documentURL_marker + 12, documentURL_marker + 62) 72 | if documentURL_start != -1: 73 | index = documentURL_start + 2 74 | documentURL_end = memory_data.find(b'\x00\x00', index, index + 2000) 75 | if documentURL_end != -1: 76 | try: 77 | document_url = memory_data[index:documentURL_end].decode(errors='ignore').strip() 78 | except UnicodeDecodeError: 79 | document_url = "Decoding Error" 80 | index = documentURL_end + 2 81 | 82 | # Extract Method 83 | method_marker = memory_data.find(b'\xFF\xFF', index, index + 50) 84 | if method_marker != -1 and memory_data[method_marker + 2:method_marker + 8] == b'method': 85 | method_start = memory_data.find(b'\xFF\xFF', method_marker + 8, method_marker + 58) 86 | if method_start != -1: 87 | index = method_start + 2 88 | method_end = memory_data.find(b'\x00\x00', index, index + 2000) 89 | if method_end != -1: 90 | try: 91 | method = memory_data[index:method_end].decode(errors='ignore').strip() 92 | except UnicodeDecodeError: 93 | method = "Decoding Error" 94 | index = method_end + 2 95 | 96 | # Extract Type 97 | type_marker = memory_data.find(b'\xFF\xFF', index, index + 50) 98 | if type_marker != -1 and memory_data[type_marker + 2:type_marker + 6] == b'type': 99 | type_start = memory_data.find(b'\xFF\xFF', type_marker + 6, type_marker + 56) 100 | if type_start != -1: 101 | index = type_start + 2 102 | type_end = memory_data.find(b'\x00\x00', index, index + 2000) 103 | if type_end != -1: 104 | try: 105 | request_type = memory_data[index:type_end].decode(errors='ignore').strip() 106 | except UnicodeDecodeError: 107 | request_type = "Decoding Error" 108 | index = type_end + 2 109 | 110 | 111 | print(f"[+] Extracted URL Information from HTTP Request at offset {match_offset}") 112 | 113 | # Write extracted data to CSV 114 | csv_writer.writerow([ 115 | match_offset, "HTTP Request", method, request_id, url, origin_url, document_url, request_type, 116 | ]) 117 | 118 | def extract_http_requests(dump_file_path, output_csv_path): 119 | """Reads the memory dump and extracts HTTP request metadata.""" 120 | start_time = time.time() 121 | print(f"Processing started at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\n") 122 | 123 | with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: 124 | csv_writer = csv.writer(csv_file) 125 | csv_writer.writerow(["Offset", "Type", "Method", "Request ID", "URL", "Origin URL", "Document URL", "Resource Type"]) 126 | 127 | with open(dump_file_path, 'rb') as dump_file: 128 | with mmap.mmap(dump_file.fileno(), 0, access=mmap.ACCESS_READ) as memory_data: 129 | match_offsets = sorted(match.start() for match in pattern_re.finditer(memory_data)) 130 | 131 | for offset in match_offsets: 132 | process_match(offset, memory_data, csv_writer) 133 | 134 | end_time = time.time() 135 | print(f"\nProcessing completed at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}") 136 | elapsed_time = end_time - start_time 137 | hours, remainder = divmod(elapsed_time, 3600) 138 | minutes, seconds = divmod(remainder, 60) 139 | print(f"Total execution time: {int(hours):02d}:{int(minutes):02d}:{seconds:.2f}") 140 | 141 | if __name__ == '__main__': 142 | parser = argparse.ArgumentParser(description='Extract URL information from HTTP Requests from a Memory Dump') 143 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the memory dump file.') 144 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output CSV file.') 145 | 146 | args = parser.parse_args() 147 | print(r""" 148 | _____ _ ______ _ 149 | / ____| | | | ____| (_) 150 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 151 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 152 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 153 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 154 | | | __/ | 155 | |_| |___/ 156 | 157 | Tor Browser Memory Parser - HTTP Requests 158 | Version: 1.0 Feb, 2025 159 | Author: Spyder Forensics Training 160 | Website: www.spyderforensics.com 161 | Course: Host-Based Dark Web Forensics 162 | """) 163 | 164 | if not os.path.isfile(args.input): 165 | print("The specified memory dump file does not exist.") 166 | else: 167 | extract_http_requests(args.input, args.output) 168 | 169 | -------------------------------------------------------------------------------- /Tor Memory Parsers/TorMemory_SocksRequests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import mmap 4 | import re 5 | import time 6 | import csv 7 | 8 | # Pre-compile patterns for efficiency 9 | patterns = [ 10 | b'\x01\x00\x00\x00\xF8\x00\x00\x00\x2E', 11 | b'\x01\x00\x00\x00\xF8\x01\x00\x00\x2E', 12 | b'\x02\x00\x00\x00\xF8\x01\x00\x00\x2E', 13 | b'\x02\x00\x00\x00\xF8\x00\x00\x00\x2E', 14 | ] 15 | pattern_re = re.compile(b'|'.join(re.escape(p) for p in patterns)) # Join patterns into one regex 16 | 17 | def process_match(match_offset, memory_data, csv_writer): 18 | """Processes pattern match within memory dump""" 19 | try: 20 | matched_prefix = memory_data[match_offset:match_offset + 9] 21 | except IndexError: 22 | return 23 | 24 | index = match_offset + 9 25 | 26 | if matched_prefix: 27 | tls_metadata = "" 28 | url = "" 29 | socks_info = "" 30 | second_url = "" 31 | private_browsing_id = "" 32 | first_party_domain = "" 33 | 34 | def stop_extraction(): 35 | print (f"[+] Partially Carved SOCKS5 Traffic Identified at offset {match_offset}") 36 | return match_offset, "Partially Carved SOCKS5 Browser Request", tls_metadata, url, socks_info, second_url, private_browsing_id, first_party_domain 37 | 38 | # Extract TLS metadata (Required) 39 | tls_metadata_start = memory_data.find(b'[tlsflags', index) 40 | if tls_metadata_start != -1 and tls_metadata_start <= match_offset + 50: 41 | tls_metadata_end = memory_data.find(b']', tls_metadata_start) 42 | if tls_metadata_end != -1: 43 | tls_metadata = memory_data[tls_metadata_start:tls_metadata_end+1].decode(errors='ignore').strip() 44 | tls_metadata = tls_metadata.replace("[tlsflags", "").replace("]", "").strip() 45 | index = tls_metadata_end + 1 46 | 47 | # Extract Requested URL (Required) 48 | url_start = index 49 | url_end = memory_data.find(b'(socks', index) 50 | if url_end != -1: 51 | url = memory_data[url_start:url_end].decode(errors='ignore').strip() 52 | index = url_end + len(b'(socks:') 53 | 54 | # Ensure Required Fields Are Present 55 | if tls_metadata == "" or url == "": 56 | return # Skip incomplete entries if any required field is missing 57 | 58 | # Extract SOCKS info 59 | socks_info_end = memory_data.find(b')', index) 60 | if socks_info_end != -1: 61 | if socks_info_end - index > 20: 62 | csv_writer.writerow(stop_extraction()) 63 | return 64 | socks_info = memory_data[index:socks_info_end].decode(errors='ignore').strip() 65 | index = socks_info_end + 1 # Move past closing bracket 66 | 67 | 68 | # Extract Second URL 69 | second_url_start = memory_data.find(b'[', index) 70 | if second_url_start != -1: 71 | second_url_start += 1 72 | second_url_end = memory_data.find(b':0:', second_url_start) 73 | if second_url_end != -1 and second_url_end <= index + 65: 74 | second_url = memory_data[second_url_start:second_url_end].decode(errors='ignore').strip() 75 | index = second_url_end + 3 76 | else: 77 | csv_writer.writerow(stop_extraction()) 78 | return 79 | 80 | # Extract Private Browsing ID 81 | private_start = memory_data.find(b'privateBrowsingId=', index) 82 | if private_start != -1 and private_start <= index + 200: 83 | private_id_start = private_start + len(b'privateBrowsingId=') 84 | private_browsing_id_byte = memory_data[private_id_start:private_id_start+1] 85 | try: 86 | private_browsing_id = private_browsing_id_byte.decode('utf-8') 87 | if not private_browsing_id.isprintable(): 88 | private_browsing_id = f"[Non-printable: {private_browsing_id_byte.hex()}]" 89 | except UnicodeDecodeError: 90 | private_browsing_id = f"[Non-printable: {private_browsing_id_byte.hex()}]" 91 | index = private_id_start + 1 92 | else: 93 | csv_writer.writerow(stop_extraction()) 94 | return 95 | 96 | # Extract First Party Domain 97 | first_party_start = memory_data.find(b'firstPartyDomain=', index) 98 | if first_party_start != -1: 99 | first_party_start += len(b'firstPartyDomain=') 100 | first_party_end = memory_data.find(b'\x00', first_party_start) 101 | if first_party_end != -1: 102 | first_party_domain = memory_data[first_party_start:first_party_end].decode(errors='ignore').strip() 103 | index = first_party_end + 1 104 | else: 105 | csv_writer.writerow(stop_extraction()) 106 | return 107 | 108 | print(f"[+] SOCKS5 Traffic Identified at offset {match_offset}") 109 | 110 | # **Write Extracted Data to CSV** 111 | csv_writer.writerow([ 112 | match_offset, "SOCKS5 Browser Request", tls_metadata, url, 113 | socks_info, second_url, private_browsing_id, first_party_domain 114 | ]) 115 | 116 | def extract_socks5_traffic(dump_file_path, output_csv_path): 117 | """Reads the entire file using mmap""" 118 | start_time = time.time() 119 | print(f"Processing started at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\n") 120 | 121 | with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: 122 | csv_writer = csv.writer(csv_file) 123 | csv_writer.writerow([ 124 | "Offset", "Type", "TLS Flags", "Requested Connection", 125 | "SOCKS Info", "Session Connection", "Private Browsing ID", "First Party Domain" 126 | ]) 127 | 128 | with open(dump_file_path, 'rb') as dump_file: 129 | with mmap.mmap(dump_file.fileno(), 0, access=mmap.ACCESS_READ) as memory_data: 130 | match_offsets = sorted(match.start() for match in pattern_re.finditer(memory_data)) 131 | 132 | for offset in match_offsets: 133 | process_match(offset, memory_data, csv_writer) 134 | 135 | end_time = time.time() 136 | print(f"\nProcessing completed at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}") 137 | elapsed_time = end_time - start_time 138 | hours, remainder = divmod(elapsed_time, 3600) 139 | minutes, seconds = divmod(remainder, 60) 140 | print(f"Total execution time: {int(hours):02d}:{int(minutes):02d}:{seconds:.2f}") 141 | 142 | if __name__ == '__main__': 143 | parser = argparse.ArgumentParser(description='Extract Tor SOCKS5 Requests from a Memory Dump') 144 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the memory dump file.') 145 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output CSV file.') 146 | 147 | args = parser.parse_args() 148 | 149 | print(r""" 150 | _____ _ ______ _ 151 | / ____| | | | ____| (_) 152 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 153 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 154 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 155 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 156 | | | __/ | 157 | |_| |___/ 158 | 159 | Tor Browser Memory Parser - SOCKS5 Requests 160 | Version: 1.0 Feb, 2025 161 | Author: Spyder Forensics Training 162 | Website: www.spyderforensics.com 163 | Course: Host-Based Dark Web Forensics 164 | """) 165 | 166 | if not os.path.isfile(args.input): 167 | print("The specified memory dump file does not exist.") 168 | else: 169 | extract_socks5_traffic(args.input, args.output) 170 | -------------------------------------------------------------------------------- /Win 11 - Tor Browser Bookmarks/ReadMe.md: -------------------------------------------------------------------------------- 1 | Install Requirements: pip install -r requirements.txt 2 | 3 | Usage: TorBrowser_Bookmarks_Beta.py -i [Tor Browser Profile Folder] -o [Output_Path] 4 | 5 | Example: TorBrowser_Bookmarks_Beta.py -i -i MarkTorBrowserExport\profile.default -o "Mark Bookmark Data" 6 | -------------------------------------------------------------------------------- /Win 11 - Tor Browser Bookmarks/TorBrowser_Bookmarks.py: -------------------------------------------------------------------------------- 1 | #This python script will extract user bookmarks for the Tor Browser. 2 | # 3 | # 4 | #Copyright(C) 2024 Spyder Forensics LLC (www.spyderforensics.com) 5 | # 6 | #This program is free software: you can redistribute it and/or modify 7 | #it under the terms of the GNU General Public License as published by 8 | #the Free Software Foundation, either version 3 of the License, or 9 | #(at your option) any later version. 10 | # 11 | #This program is distributed in the hope that it will be useful, 12 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | #GNU General Public License for more details. 15 | # 16 | #You can view the GNU General Public License at . 17 | # 18 | # Version History: 19 | # v beta 2024-10-25 20 | # v 1.0 2024-11-14 21 | 22 | import sys 23 | import lz4.block 24 | import json 25 | import argparse 26 | import logging 27 | import re 28 | import sqlite3 29 | from datetime import datetime, timezone 30 | import openpyxl 31 | import base64 32 | import os 33 | from pathlib import Path 34 | 35 | logger = None 36 | 37 | def setup_logger(filename): 38 | """Sets up the logging""" 39 | logger = logging.getLogger(__name__) 40 | logger.setLevel(logging.INFO) 41 | file_handler = logging.FileHandler(filename, encoding='utf-8') 42 | file_handler.setLevel(logging.INFO) 43 | formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S %Z (UTC %z)') 44 | file_handler.setFormatter(formatter) 45 | logger.addHandler(file_handler) 46 | return logger 47 | 48 | def is_mozlz4_file(file_path): 49 | """Check if the file is a valid MOZLZ4 file by reading the header.""" 50 | with open(file_path, 'rb') as f: 51 | header = f.read(8) # Read the first 8 bytes 52 | return header == b'mozLz40\0' 53 | 54 | def decompress_mozlz4(input_file): 55 | """Decompress the MOZLZ4 file and return JSON data.""" 56 | try: 57 | with open(input_file, 'rb') as f: 58 | data = f.read() 59 | print(f" - Decompressing Backup...") 60 | logger.info(f"Decompressing Backup") 61 | if data[:8] != b'mozLz40\0': 62 | raise ValueError('Invalid MOZLZ4 header') 63 | logger.error(f"{input_file}: Invalid MOZLZ4 header") 64 | else: 65 | print(f" - Decompression Successfully Completed") 66 | logger.info(f"Decompression Successfully Completed") 67 | decompressed_data = lz4.block.decompress(data[8:]) 68 | return json.loads(decompressed_data) 69 | except (ValueError, lz4.block.LZ4BlockError, json.JSONDecodeError) as e: 70 | print(f"Error decompressing file: {e}") 71 | logger.error(f"{input_file}: Error decompressing file: {e}") 72 | return None 73 | 74 | def extract_base64_icon(bookmark_iconuri, bookmark_title, icons_folder, filename): 75 | """Extract base64-encoded icons and save them to a folder.""" 76 | if bookmark_iconuri.startswith('data:image'): 77 | file_extension = 'ico' if 'image/x-icon' in bookmark_iconuri else 'png' 78 | base64_data = bookmark_iconuri.split(',')[1] 79 | try: 80 | # Decode the Base64 data 81 | image_data = base64.b64decode(base64_data) 82 | # Sanitize the title to create a valid filename 83 | sanitized_title = re.sub(r'[\ufeff<>:"/\\|?*]', '', bookmark_title) 84 | sanitized_title = re.sub(r'[:]', '_', sanitized_title) 85 | # Create a subfolder based on the filename 86 | subfolder_path = os.path.join(icons_folder, filename) 87 | create_output_directory(subfolder_path) 88 | output_filename = f"{sanitized_title.replace(' ', '_')}_icon.{file_extension}" 89 | icon_output = os.path.join(subfolder_path, output_filename) 90 | # Save the image data to the file 91 | with open(icon_output, 'wb') as image_file: 92 | image_file.write(image_data) 93 | logger.info(f"Favicon Extracted - {output_filename}") 94 | return output_filename, icon_output 95 | except (base64.binascii.Error, OSError) as e: 96 | print(f"Error decoding Base64 data for {bookmark_title}: {e}") 97 | logger.error(f"Error decoding Base64 data for {bookmark_title}: {e}") 98 | return None 99 | return None 100 | 101 | def convert_unix_timestamp(microseconds): 102 | """Convert Unix timestamp in microseconds to a human-readable date.""" 103 | seconds = microseconds / 1_000_000 104 | return datetime.fromtimestamp(seconds, timezone.utc).strftime('%Y-%m-%d %H:%M:%S') 105 | 106 | def extract_root_info(json_data, folders_found_count): 107 | """Extract root information from the JSON data.""" 108 | rootfolderid = json_data.get('id') 109 | rootfolder = json_data.get('root') 110 | folder_type = 'folder' # Returning for excel output 111 | rootcreated = convert_unix_timestamp(json_data.get('dateAdded', None)) 112 | rootlastmod = convert_unix_timestamp(json_data.get('lastModified', None)) 113 | folders_found_count += 1 # Increment the folder count 114 | return rootfolderid, rootfolder, rootcreated, rootlastmod, folders_found_count 115 | 116 | def extract_folder_info(folder, parent_folder_name=None): 117 | """Extract folder information from the folder JSON object, including the parent folder.""" 118 | folder_id = folder.get('id') 119 | folder_type = 'Folder' 120 | folder_name = folder.get('title') 121 | folder_description = '' 122 | folder_url = '' 123 | folder_added = convert_unix_timestamp(folder.get('dateAdded')) 124 | folder_modified = convert_unix_timestamp(folder.get('lastModified')) 125 | parent_name = parent_folder_name or 'PlacesRoot' 126 | return folder_id, folder_type, parent_name, folder_name, folder_description, folder_url, folder_added, folder_modified 127 | 128 | def extract_separator_info(separator, current_folder_name, filename): 129 | """Extract separator information from the separator JSON object.""" 130 | separator_id = separator.get('id') 131 | separator_type = 'Visual Separator' 132 | folder_name = current_folder_name 133 | separator_title = separator.get('title') 134 | separator_description = '' 135 | separator_url = '' 136 | separator_added = convert_unix_timestamp(separator.get('dateAdded')) 137 | separator_modified = convert_unix_timestamp(separator.get('lastModified')) 138 | return separator_id, separator_type, folder_name, separator_title, separator_description, separator_url, separator_added, separator_modified 139 | 140 | def extract_json_data(json_data, icons_folder, filename): 141 | """Extract bookmark information from the JSON data.""" 142 | print(f" - Extracting Information from JSON File") 143 | logger.info(f"Extracting Information from JSON File") 144 | folder_info = [] 145 | bookmark_info = [] 146 | separator_info = [] 147 | favicon_info = [] 148 | summary_info = [] 149 | favicons_found_count = 0 150 | folders_found_count = 0 151 | bookmarks_found_count = 0 152 | separators_found_count = 0 153 | 154 | rootfolderid, rootfolder, rootcreated, rootlastmod, folders_found_count = extract_root_info(json_data, folders_found_count) 155 | folder_info.append((rootfolderid, 'Folder', '', rootfolder, '', '', rootcreated, rootlastmod)) 156 | 157 | def extract_from_folder(folder, parent_folder_name=None): 158 | nonlocal folders_found_count, bookmarks_found_count, favicons_found_count, separators_found_count 159 | 160 | folder_id, folder_type, parent_name, folder_name, folder_description, folder_url, folder_added, folder_modified = extract_folder_info( 161 | folder, parent_folder_name 162 | ) 163 | 164 | folders_found_count += 1 165 | folder_info.append((folder_id, folder_type, parent_name, folder_name, folder_description, folder_url, folder_added, folder_modified)) 166 | 167 | current_folder_name = folder_name or parent_folder_name or 'Unnamed Folder' 168 | 169 | for child in folder.get('children', []): 170 | child_type = child.get('type') 171 | if child_type == 'text/x-moz-place': 172 | bookmark_data = extract_bookmark_info(child, current_folder_name, filename) 173 | bookmark_info.append(bookmark_data) 174 | bookmarks_found_count += 1 175 | 176 | favicon_data = extract_favicon_info(child, current_folder_name, icons_folder, filename) 177 | if favicon_data: 178 | favicon_info.append(favicon_data[:-1]) 179 | favicons_found_count += 1 180 | 181 | elif child_type == 'text/x-moz-place-separator': 182 | separator_data = extract_separator_info(child, current_folder_name, filename) 183 | separator_info.append(separator_data) 184 | separators_found_count += 1 185 | 186 | elif child_type == 'text/x-moz-place-container': 187 | extract_from_folder(child, current_folder_name) 188 | 189 | for folder in json_data.get('children', []): 190 | extract_from_folder(folder) 191 | 192 | print(f" - {folders_found_count} Bookmark Folder(s) Found") 193 | logger.info(f"{folders_found_count} Bookmark Folder(s) Found") 194 | print(f" - {separators_found_count} Visual Separator(s) Found") 195 | logger.info(f"{separators_found_count} Visual Separator(s) Found") 196 | print(f" - {bookmarks_found_count} Bookmark(s) Found") 197 | logger.info(f"{bookmarks_found_count} Bookmark(s) Found") 198 | print(f" - {favicons_found_count} Bookmark Favicon(s) Found") 199 | logger.info(f"{favicons_found_count} Bookmark Favicon(s) Found") 200 | summary_info.append((folders_found_count, separators_found_count, bookmarks_found_count, favicons_found_count)) 201 | logger.info(f"Finished Extracting Information from JSON File") 202 | if favicons_found_count > 0: 203 | print(f" - Bookmark Favicons Exported to: {icons_folder}") 204 | logger.info(f"Bookmark Favicons Exported to: {icons_folder}") 205 | return summary_info, folder_info, bookmark_info, separator_info, favicon_info 206 | 207 | def extract_bookmark_info(bookmark, folder_name, filename): 208 | """Extract bookmark information and check for favicon.""" 209 | bookmark_id = bookmark.get('id') 210 | bookmark_type = 'Bookmark' 211 | bookmark_title = bookmark.get('title', 'Unnamed Bookmark') 212 | bookmark_uri = bookmark.get('uri', '') 213 | bookmark_description = bookmark.get('description', '') 214 | bookmark_iconuri = bookmark.get('iconuri', '') 215 | bookmark_added = convert_unix_timestamp(bookmark.get('dateAdded', 'unknown')) 216 | bookmark_modified = convert_unix_timestamp(bookmark.get('lastModified', 'unknown')) 217 | return ( 218 | bookmark_id, bookmark_type, folder_name, bookmark_title, 219 | bookmark_uri, bookmark_description, bookmark_added, 220 | bookmark_modified 221 | ) 222 | 223 | def extract_favicon_info(favicon, folder_name, icons_folder, filename): 224 | """Extract favicon information from the bookmark JSON object.""" 225 | favicon_id = favicon.get('id') 226 | favicon_title = favicon.get('title', 'Unnamed Bookmark') 227 | favicon_uri = favicon.get('uri', '') 228 | favicon_iconuri = favicon.get('iconuri', '') 229 | 230 | icon_filename, icon_path = extract_base64_icon(favicon_iconuri, favicon_title, icons_folder, filename) or (None, None) 231 | has_favicon = icon_path is not None 232 | 233 | if has_favicon: 234 | return ( 235 | favicon_id, favicon_title, favicon_uri, icon_filename, icon_path, has_favicon 236 | ) 237 | return None 238 | 239 | def create_output_directory(output_folder): 240 | """Create the output directory if it doesn't exist.""" 241 | if not os.path.exists(output_folder): 242 | os.makedirs(output_folder) 243 | elif not os.path.isdir(output_folder): 244 | logger.error(f"{output_folder} exists but is not a directory") 245 | raise NotADirectoryError(f"{output_folder} exists but is not a directory") 246 | 247 | def extract_backup_date_from_filename(filename): 248 | """Extract the date from the Bookmarkbackup filename.""" 249 | date_match = re.search(r'(\d{4}-\d{2}-\d{2})', filename) 250 | print(f" - Backup Date Extracted from filename") 251 | logger.info(f"Backup Date Extracted from filename") 252 | return date_match.group(0) if date_match else 'Unknown' 253 | 254 | def write_info_to_sheet(summary_info, folder_info, bookmark_info, separator_info, favicon_info, bookmarks_sheet, favicon_sheet, filename, extractionsummary_sheet): 255 | """Write extracted information to the Excel sheets""" 256 | logger.info(f"Writing Extracted Information to Spreadsheet") 257 | def sanitize_data(data): 258 | """Ensures data contains only valid Excel-compatible values""" 259 | return [str(item) if isinstance(item, (tuple, list)) else item for item in data] 260 | combined_info = [] 261 | if folder_info: 262 | for folder in folder_info: 263 | combined_info.append([filename, *folder]) 264 | if bookmark_info: 265 | for bookmark in bookmark_info: 266 | combined_info.append([filename, *bookmark]) 267 | if separator_info: 268 | for separator in separator_info: 269 | combined_info.append([filename, *separator]) 270 | combined_info.sort(key=lambda x: x[1] if len(x) > 1 else "") 271 | if combined_info: 272 | for row in combined_info: 273 | bookmarks_sheet.append(row) 274 | if summary_info: 275 | for summary in summary_info: 276 | extractionsummary_sheet.append([filename, *summary]) 277 | if favicon_info: 278 | for favicon in favicon_info: 279 | sanitized_favicon = sanitize_data(favicon) 280 | favicon_sheet.append([filename, *sanitized_favicon]) 281 | 282 | def save_decompressed_json(decompressed_folder, filename, json_data): 283 | """Save the decompressed JSON file.""" 284 | decompressed_backups_folder = os.path.join(decompressed_folder, "Decompressed Backups") 285 | create_output_directory(decompressed_backups_folder) 286 | output_json_path = os.path.join(decompressed_backups_folder, filename.replace('.jsonlz4', '.json')) 287 | with open(output_json_path, 'w') as json_file: 288 | json.dump(json_data, json_file, indent=4) 289 | print(f" - Decompressed JSON File Exported to: {output_json_path}") 290 | logger.info(f"Decompressed JSON File Exported to: {output_json_path}") 291 | 292 | def process_single_backup(file_path, filename, decompressed_folder, favicon_sheet, bookmarks_sheet, backup_summary_sheet, icons_folder, missing_recordids, deleted_sheet, extractionsummary_sheet, sqlite_bookmarks): 293 | """Process a single MOZLZ4 backup file.""" 294 | print(f"\n- Bookmark Backup Name: {filename}") 295 | logger.info(f"Processing: {filename}") 296 | 297 | if is_mozlz4_file(file_path): 298 | json_data = decompress_mozlz4(file_path) 299 | if json_data: 300 | summary_info, folder_info, bookmark_info, separator_info, favicon_info = extract_json_data(json_data, icons_folder, filename) 301 | backup_date = extract_backup_date_from_filename(filename) 302 | write_info_to_sheet(summary_info, folder_info, bookmark_info, separator_info, favicon_info, bookmarks_sheet, favicon_sheet, filename, extractionsummary_sheet) 303 | backup_summary_sheet.append([filename, backup_date]) 304 | save_decompressed_json(decompressed_folder, filename, json_data) 305 | find_missing_records_in_data(filename, folder_info, bookmark_info, separator_info, missing_recordids, deleted_sheet) 306 | find_overwritten_records_in_data(filename, folder_info, bookmark_info, separator_info, deleted_sheet, sqlite_bookmarks) 307 | logger.info(f"Finished Processing: {filename}") 308 | else: 309 | print(f"- Failed to process JSON data for {filename}") 310 | logger.error(f"Failed to Process JSON data for {filename}") 311 | else: 312 | print(f"- Invalid MOZLZ4 file: {filename}") 313 | logger.error(f"Invalid MOZLZ4 file: {filename}") 314 | 315 | def find_missing_records_in_data(filename, folder_info, bookmark_info, separator_info, missing_recordids, deleted_sheet): 316 | """Find IDs in the bookmark backups that are missing from places.sqlite or have different URLs.""" 317 | print(f' - Attempting to Find Missing IDs in the Backup...') 318 | logger.info(f"Attempting to Find Missing IDs in the Backup") 319 | folder_ids = {folder[0]: (folder, folder[1]) for folder in folder_info} 320 | bookmark_ids = {bookmark[0]: (bookmark, bookmark[1]) for bookmark in bookmark_info} 321 | separator_ids = {separator[0]: (separator, separator[1]) for separator in separator_info} 322 | combined_ids = {**folder_ids, **bookmark_ids, **separator_ids} 323 | missing_entries = [id_ for id_ in missing_recordids if id_ in combined_ids] 324 | if missing_entries: 325 | for id_ in missing_entries: 326 | original_data, entry_type = combined_ids[id_] 327 | print(f" - Missing Entry Found: ID: {id_}, Type: {entry_type}, Title: {original_data[3]}") 328 | logger.info(f"Missing Entry Found: ID: {id_}, Type: {entry_type}, Title: {original_data[3]}") 329 | deleted_sheet.append([filename, *original_data]) 330 | else: 331 | print(" - No Missing IDs Identified") 332 | logger.info(f"No Missing IDs Identified") 333 | 334 | def find_overwritten_records_in_data(filename, folder_info, bookmark_info, separator_info, deleted_sheet, sqlite_bookmarks): 335 | """Identify entries (bookmarks, folders, separators) with the same ID but different type, title, or URL in places.sqlite and the backup.""" 336 | print(f' - Attempting to Find Reused IDs in the Backup...') 337 | logger.info(f"Attempting to Find Reused IDs in the Backup") 338 | backup_entries = {} 339 | for entry in bookmark_info: 340 | backup_entries[entry[0]] = { 341 | "type": entry[1], 342 | "parent_folder": entry[2], 343 | "title": entry[3], 344 | "description": entry[5], 345 | "url": entry[4], 346 | "added_date": entry[6], 347 | "modified_date": entry[7] 348 | } 349 | for entry in folder_info: 350 | backup_entries[entry[0]] = { 351 | "type": entry[1], 352 | "parent_folder": entry[2], 353 | "title": entry[3], 354 | "description": None, # Folders don't have descriptions 355 | "url": None, # Folders don't have URLs 356 | "added_date": entry[6], 357 | "modified_date": entry[7] 358 | } 359 | for entry in separator_info: 360 | backup_entries[entry[0]] = { 361 | "type": entry[1], 362 | "parent_folder": entry[2], 363 | "title": entry[3], 364 | "description": None, # Separators don't have descriptions 365 | "url": None, # Separators don't have URLs 366 | "added_date": entry[6], 367 | "modified_date": entry[7] 368 | } 369 | # Flag to track if any reused IDs with differences are found 370 | reused_ids_found = False 371 | # Compare each entry in the backup with the corresponding entry in sqlite_bookmarks 372 | for entry_id, backup_data in backup_entries.items(): 373 | sqlite_data = sqlite_bookmarks.get(entry_id) 374 | if sqlite_data: 375 | changes = [] 376 | # Compare only type, and url fields 377 | if sqlite_data["type"] != backup_data["type"]: 378 | changes.append(f"Backup Type: {backup_data['type']}, Backup Title: {backup_data['title']} -> Current Type: {sqlite_data['type']}, Current Title: {sqlite_data.get('title', 'N/A')}") 379 | if sqlite_data.get("url") != backup_data["url"]: 380 | changes.append(f"Backup Type: {backup_data['type']}, Backup Title: {backup_data['title']} -> Current Type: {sqlite_data['type']}, Current Title: {sqlite_data.get('title', 'N/A')}") 381 | # Log changes if any discrepancies were found 382 | if changes: 383 | reused_ids_found = True # Set the flag to True if any changes are found 384 | print(f" - ID {entry_id} has been reused: {', '.join(changes)}") 385 | logger.info(f"ID {entry_id} has been reused: {', '.join(changes)}") 386 | deleted_sheet.append([ 387 | filename, 388 | entry_id, 389 | backup_data["type"], 390 | backup_data["parent_folder"], 391 | backup_data["title"], 392 | backup_data["url"] if backup_data["url"] else "N/A", 393 | backup_data["description"], 394 | backup_data["added_date"], 395 | backup_data["modified_date"], 396 | ]) 397 | if not reused_ids_found: 398 | print(f" - No Reused IDs Identified") 399 | logger.info(f"No Reused IDs Identified") 400 | 401 | def process_bookmark_backups(bookmarks_backup_folder, output_folder, bookmarks_sheet, favicon_sheet, backup_summary_sheet, icons_folder, missing_recordids, deleted_sheet, extractionsummary_sheet, sqlite_bookmarks): 402 | """Process all MOZLZ4 bookmark backups and export to JSON and Excel.""" 403 | create_output_directory(output_folder) 404 | 405 | for filename in os.listdir(bookmarks_backup_folder): 406 | if filename.endswith('.jsonlz4'): 407 | file_path = os.path.join(bookmarks_backup_folder, filename) 408 | process_single_backup(file_path, filename, output_folder, favicon_sheet, bookmarks_sheet, backup_summary_sheet, icons_folder, missing_recordids, deleted_sheet, extractionsummary_sheet, sqlite_bookmarks) 409 | 410 | def process_sqlite_database(places_path, favicon_path, bookmarks_sheet, favicon_sheet, icons_folder, placesfilename, faviconsfilename, active_sheet, extractionsummary_sheet): 411 | """Process the SQLite databases and write results to Excel sheets.""" 412 | try: 413 | with sqlite3.connect(f"file:{places_path}?mode=ro", uri=True) as conn: 414 | cursor = conn.cursor() 415 | cursor.execute("PRAGMA query_only = 1;") #Extra safe guard to ensure no writes to database 416 | print(f"- Opening places.sqlite (Read-Only)") 417 | logger.info(f"Opening places.sqlite (Read-Only)") 418 | bookmark_query = """ 419 | SELECT 420 | child.id, 421 | CASE child.type 422 | WHEN 1 THEN 'Bookmark' 423 | WHEN 2 THEN 'Folder' 424 | WHEN 3 THEN 'Visual Separator' 425 | ELSE child.type 426 | END AS 'Type', 427 | CASE 428 | WHEN child.parent = 1 THEN 'PlacesRoot' 429 | ELSE parent.title 430 | END AS parent_folder, 431 | CASE 432 | WHEN child.id = 1 THEN 'PlacesRoot' 433 | ELSE child.title 434 | END AS Title, 435 | moz_places.url, 436 | moz_places.description, 437 | DATETIME((child.dateAdded / 1000000), 'unixepoch') AS 'Date Added (UTC)', 438 | DATETIME((child.lastModified / 1000000), 'unixepoch') AS 'Date Last Modified (UTC)' 439 | FROM moz_bookmarks AS child 440 | LEFT JOIN moz_places ON child.fk = moz_places.id 441 | LEFT JOIN moz_bookmarks AS parent ON child.parent = parent.id; 442 | """ 443 | cursor.execute(bookmark_query) 444 | logger.info(f"Executing Query to Extract Bookmark Information") 445 | bookmark_rows = cursor.fetchall() 446 | logger.info(f"Writing Extracted Information to Spreadsheet") 447 | for row in bookmark_rows: 448 | bookmarks_sheet.append([placesfilename, *row]) 449 | for row in bookmark_rows: 450 | active_sheet.append([placesfilename, *row]) 451 | type_queries = { 452 | "Bookmark Folder(s)": 2, 453 | "Visual Separator(s)": 3, 454 | "Bookmark(s)": 1 455 | } 456 | folders_found_count = 0 457 | separators_found_count = 0 458 | bookmarks_found_count = 0 459 | for label, type_value in type_queries.items(): 460 | cursor.execute("SELECT id FROM moz_bookmarks WHERE type = ?", (type_value,)) 461 | rows = cursor.fetchall() 462 | count = len(rows) 463 | print(f" - {count} {label} Found") 464 | logger.info(f"{count} {label} Found") 465 | if label == "Bookmark Folder(s)": 466 | folders_found_count = count 467 | elif label == "Visual Separator(s)": 468 | separators_found_count = count 469 | elif label == "Bookmark(s)": 470 | bookmarks_found_count = count 471 | extractionsummary_sheet.append([placesfilename, folders_found_count, separators_found_count, bookmarks_found_count, 'N/A']) 472 | if Path(favicon_path).exists(): 473 | cursor.execute(f"ATTACH DATABASE 'file:{favicon_path}?mode=ro' AS favicons_db;") 474 | cursor.execute("PRAGMA favicons_db.query_only = 1;") #Extra safe guard to ensure no writes to database 475 | print(f"- Attached favicons.sqlite (Read-Only)") 476 | logger.info(f"Attached favicons.sqlite (Read-Only)") 477 | favicon_query = """ 478 | SELECT 479 | moz_bookmarks.id, 480 | favicons_db.moz_icons.id, 481 | moz_bookmarks.title, 482 | moz_places.url, 483 | favicons_db.moz_icons.data 484 | FROM moz_bookmarks 485 | LEFT JOIN moz_places ON moz_bookmarks.fk = moz_places.id 486 | LEFT JOIN favicons_db.moz_pages_w_icons 487 | ON moz_places.url_hash = favicons_db.moz_pages_w_icons.page_url_hash 488 | LEFT JOIN favicons_db.moz_icons_to_pages 489 | ON favicons_db.moz_icons_to_pages.page_id = favicons_db.moz_pages_w_icons.id 490 | LEFT JOIN favicons_db.moz_icons 491 | ON favicons_db.moz_icons.id = favicons_db.moz_icons_to_pages.icon_id 492 | WHERE favicons_db.moz_icons.data IS NOT NULL; 493 | """ 494 | cursor.execute(favicon_query) 495 | logger.info(f"Executing Query to Extract Bookmark Favicons") 496 | favicon_rows = cursor.fetchall() 497 | favicons_count = len(favicon_rows) 498 | print(f" - {favicons_count} Bookmark Favicon(s) Found") 499 | logger.info(f"{favicons_count} Bookmark Favicon(s) Found") 500 | favicons_folder = Path(icons_folder) / 'faviconsdb' 501 | favicons_folder.mkdir(parents=True, exist_ok=True) 502 | for index, (bookmark_id, favicon_id, title, url, favicon_data) in enumerate(favicon_rows): 503 | sanitized_title = re.sub(r'[<>:"/\\|?*]', '', title) if title else f"favicon_{index + 1}" 504 | file_extension = 'ico' if favicon_data[:4] == b'\x00\x00\x01\x00' else 'png' 505 | output_filename = f"{sanitized_title}_{favicon_id}.{file_extension}" 506 | icon_output_path = favicons_folder / output_filename 507 | try: 508 | with open(icon_output_path, 'wb') as icon_file: 509 | icon_file.write(favicon_data) 510 | logger.info(f"Favicon Extracted - {output_filename}") 511 | except OSError as e: 512 | print(f"Error saving favicon {bookmark_id}: {e}") 513 | logger.error(f"Error saving favicon {bookmark_id}: {e}") 514 | favicon_sheet.append([faviconsfilename, bookmark_id, title, url, output_filename, str(favicons_folder)]) 515 | logger.info(f"Writing Extracted Information to Spreadsheet") 516 | extractionsummary_sheet.append([faviconsfilename, 'N/A', 'N/A', 'N/A', favicons_count]) 517 | unassociatedfavicon_query = """ 518 | SELECT 519 | favicons_db.moz_icons.id, 520 | favicons_db.moz_icons.icon_url, 521 | favicons_db.moz_icons.data 522 | FROM favicons_db.moz_icons 523 | LEFT JOIN favicons_db.moz_icons_to_pages 524 | ON favicons_db.moz_icons.id = favicons_db.moz_icons_to_pages.icon_id 525 | LEFT JOIN favicons_db.moz_pages_w_icons 526 | ON favicons_db.moz_icons_to_pages.page_id = favicons_db.moz_pages_w_icons.id 527 | LEFT JOIN moz_places 528 | ON favicons_db.moz_pages_w_icons.page_url_hash = moz_places.url_hash 529 | LEFT JOIN moz_bookmarks 530 | ON moz_places.id = moz_bookmarks.fk 531 | WHERE moz_bookmarks.id IS NULL; 532 | """ 533 | cursor.execute(unassociatedfavicon_query) 534 | logger.info(f"Executing Query to Extract Favicons not associated with Bookmarks") 535 | unassociatedfavicon_rows = cursor.fetchall() 536 | unassociatedfavicons_count = len(unassociatedfavicon_rows) 537 | print(f" - {unassociatedfavicons_count} Unassociated Bookmark Favicon(s) Extracted") 538 | logger.info(f"{unassociatedfavicons_count} Unassociated Bookmark Favicon(s) Extracted") 539 | unassociatedfavicons_folder = Path(icons_folder) / 'faviconsdb - unassociated' 540 | unassociatedfavicons_folder.mkdir(parents=True, exist_ok=True) 541 | for index, (favicon_id, icon_url, favicon_data) in enumerate(unassociatedfavicon_rows): 542 | unassociated_filename = 'unassociatedfavicon' 543 | file_extension = ( 544 | 'ico' if favicon_data[:4] == b'\x00\x00\x01\x00' 545 | else 'svg' if favicon_data[:4] == b'\x3c\x73\x76\x67' 546 | else 'png' 547 | ) 548 | output_filename = f"{unassociated_filename}_{favicon_id}.{file_extension}" 549 | icon_output_path = unassociatedfavicons_folder / output_filename 550 | try: 551 | with open(icon_output_path, 'wb') as icon_file: 552 | icon_file.write(favicon_data) 553 | logger.info(f"Unassociated Favicon Extracted - {output_filename}") 554 | except OSError as e: 555 | print(f"Error saving favicon {favicon_id}: {e}") 556 | logger.error(f"Error saving favicon {favicon_id}: {e}") 557 | favicon_sheet.append([f"{faviconsfilename} (Unassociated)", "", "", icon_url, output_filename, str(unassociatedfavicons_folder)]) 558 | logger.info(f"Writing Extracted Information to Spreadsheet") 559 | extractionsummary_sheet.append([f"{faviconsfilename} (Unassociated)", 'N/A', 'N/A', 'N/A', unassociatedfavicons_count]) 560 | else: 561 | print(f" - Favicons.sqlite not found at: {favicon_path}") 562 | logger.error(f"Favicons.sqlite not found at: {favicon_path}") 563 | print("\nPerforming Analysis to Identify Missing IDs in places.sqlite...") 564 | logger.info(f"Performing Analysis to Identify Missing IDs in places.sqlite") 565 | cursor.execute("SELECT id FROM moz_bookmarks") 566 | logger.info(f"Executing Query to extract ID Values from Moz_bookmarks table") 567 | record_ids = {id_[0] for id_ in cursor.fetchall()} 568 | if not record_ids: 569 | print("No Missing IDs Identified") 570 | logger.info("No Missing IDs Identified") 571 | return 572 | min_id, max_id = min(record_ids), max(record_ids) 573 | complete_set = set(range(min_id, max_id + 1)) 574 | missing_ids = complete_set - record_ids 575 | if missing_ids: 576 | print(f" - Missing IDs: {sorted(missing_ids)}") 577 | logger.info(f"Missing IDs: {sorted(missing_ids)}") 578 | else: 579 | print("\n- No Missing IDs Identified") 580 | logger.info(f"No Missing IDs Identified") 581 | #This is used for comparing SQLite data with the Backup Data 582 | sqlite_bookmarks = {} 583 | cursor.execute(""" 584 | SELECT moz_bookmarks.id, 585 | CASE moz_bookmarks.type 586 | WHEN 1 THEN 'Bookmark' 587 | WHEN 2 THEN 'Folder' 588 | WHEN 3 THEN 'Visual Separator' 589 | ELSE moz_bookmarks.type 590 | END AS 'Type', 591 | moz_bookmarks.title, 592 | moz_places.url 593 | FROM moz_bookmarks 594 | LEFT JOIN moz_places ON moz_bookmarks.fk = moz_places.id 595 | """) 596 | for row in cursor.fetchall(): 597 | bookmark_id, item_type, title, url = row 598 | sqlite_bookmarks[bookmark_id] = { 599 | "type": item_type, 600 | "title": title, 601 | "url": url 602 | } 603 | return missing_ids, sqlite_bookmarks 604 | except sqlite3.Error as e: 605 | print(f"SQLite error: {e}") 606 | logger.error(f"SQLite error: {e}") 607 | 608 | def write_excel(workbook): 609 | """Set up the headers in the Excel workbook.""" 610 | logger.info(f"Creating the excel file to save Bookmark Information") 611 | extractionsummary_sheet = workbook.active 612 | extractionsummary_sheet.title = "Extraction Summary" 613 | backup_summary_sheet = workbook.create_sheet("Bookmark Backup Information") 614 | active_sheet = workbook.create_sheet("Active Data") 615 | deleted_sheet = workbook.create_sheet("Deleted Data") 616 | bookmarks_sheet = workbook.create_sheet("All Bookmark Info") 617 | favicon_sheet = workbook.create_sheet("Bookmark Favicons") 618 | 619 | extractionsummary_sheet.append([ 620 | 'Filename', 'Bookmark Folders Found', 'Visual Separators Found', 621 | 'Bookmarks Found', 'Favicons Found']) 622 | backup_summary_sheet.append(['Backup Name', 'Backup Date']) 623 | active_sheet.append([ 624 | 'File', 'Record ID', 'Type', 'Parent Folder', 'Title', 625 | 'URI', 'Description', 'Date Added (UTC)', 'Date Last Modified (UTC)' 626 | ]) 627 | deleted_sheet.append([ 628 | 'File', 'Record ID', 'Type', 'Parent Folder', 'Title', 629 | 'URI', 'Description', 'Date Added (UTC)', 'Date Last Modified (UTC)' 630 | ]) 631 | bookmarks_sheet.append([ 632 | 'File', 'Record ID', 'Type', 'Parent Folder', 'Title', 633 | 'URI', 'Description', 'Date Added (UTC)', 'Date Last Modified (UTC)' 634 | ]) 635 | favicon_sheet.append([ 636 | 'File', 'Record ID', 'Title', 'URL', 'Export Filename', 'Export Location' 637 | ]) 638 | 639 | return { 640 | 'Extraction Summary': extractionsummary_sheet, 641 | 'Bookmark Backup Information': backup_summary_sheet, 642 | 'Active Data': active_sheet, 643 | 'Deleted Data': deleted_sheet, 644 | 'All Bookmark Info': bookmarks_sheet, 645 | 'Bookmark Favicons': favicon_sheet 646 | } 647 | 648 | def count_backup_files(bookmarks_backup_folder): 649 | """Count the number of bookmark backup files in the bookmarkbackups folder.""" 650 | backup_files = [f for f in os.listdir(bookmarks_backup_folder) if os.path.isfile(os.path.join(bookmarks_backup_folder, f))] 651 | print(f" - {len(backup_files)} Bookmark Backup File(s) Found") 652 | logger.info(f"{len(backup_files)} Bookmark Backup File(s) Found") 653 | return len(backup_files) 654 | 655 | def main(): 656 | # Set up argument parsing 657 | parser = argparse.ArgumentParser( 658 | description='Extract Bookmark Information from places.sqlite, favicons.sqlite, and Mozlz4 compressed Bookmark Backups for Tor Browser' 659 | ) 660 | parser.add_argument('-i', '--input', required=True, help='Input Tor Browser profile folder') 661 | parser.add_argument('-o', '--output', required=True, help='Output folder for decompressed JSON files, Favicons, and Extraction Report') 662 | args = parser.parse_args() 663 | print(r""" 664 | _____ _ ______ _ 665 | / ____| | | | ____| (_) 666 | | (___ _ __ _ _ __| | ___ _ __ | |__ ___ _ __ ___ _ __ ___ _ ___ ___ 667 | \___ \| '_ \| | | |/ _` |/ _ \ '__| | __/ _ \| '__/ _ \ '_ \/ __| |/ __/ __| 668 | ____) | |_) | |_| | (_| | __/ | | | | (_) | | | __/ | | \__ \ | (__\__ \ 669 | |_____/| .__/ \__, |\__,_|\___|_| |_| \___/|_| \___|_| |_|___/_|\___|___/ 670 | | | __/ | 671 | |_| |___/ 672 | 673 | Tor Browser Bookmark Extractor 674 | Version: 1.0 Nov, 2024 675 | Author: Spyder Forensics Training 676 | Website: www.spyderforensics.com 677 | Course: Host-Based Dark Web Forensics 678 | """) 679 | places_path = os.path.join(args.input, 'places.sqlite') 680 | favicon_path = os.path.join(args.input, 'favicons.sqlite') 681 | os.makedirs(args.output, exist_ok=True) 682 | log_file_path = os.path.join(args.output, "TorBookmarksExtraction.log") 683 | global logger 684 | logger = setup_logger(log_file_path) 685 | # Check if places.sqlite exists before proceeding 686 | if not os.path.exists(places_path): 687 | print(f"Error: places.sqlite not found at {places_path}. Please ensure the input is the Tor Browser profile folder") 688 | logger.error(f"places.sqlite not found at {places_path}. Please ensure the input is the Tor Browser profile folder") 689 | sys.exit(1) 690 | icons_folder = os.path.join(args.output, 'Bookmark Favicons') 691 | decompressed_folder = os.path.join(args.output, 'Decompressed Backups') 692 | logger.info(f"Creating folders in the Output Directory") 693 | create_output_directory(icons_folder) 694 | create_output_directory(decompressed_folder) 695 | workbook = openpyxl.Workbook() 696 | sheets = write_excel(workbook) 697 | extractionsummary_sheet = sheets['Extraction Summary'] 698 | missing_recordids = [] 699 | sqlite_bookmarks = {} 700 | print(f"Extracting Bookmark Information from SQLite Databases...\n") 701 | logger.info(f"Extracting Bookmark Information from SQLite Databases") 702 | # Process places.sqlite and favicons.sqlite 703 | missing_recordids, sqlite_bookmarks = process_sqlite_database( 704 | places_path=places_path, 705 | favicon_path=favicon_path, 706 | active_sheet=sheets['Active Data'], 707 | bookmarks_sheet=sheets['All Bookmark Info'], 708 | favicon_sheet=sheets['Bookmark Favicons'], 709 | icons_folder=icons_folder, 710 | placesfilename=os.path.basename(places_path), 711 | faviconsfilename=os.path.basename(favicon_path), 712 | extractionsummary_sheet=sheets['Extraction Summary'] 713 | ) 714 | logger.info(f"Finished Extracting Bookmark Information from SQLite Databases") 715 | # Process bookmark backups 716 | bookmarks_backup_folder = os.path.join(args.input, 'bookmarkbackups') 717 | print(f"\nExtracting Bookmark Information from BookmarkBackups Folder...\n") 718 | logger.info(f"Extracting Bookmark Information from BookmarkBackups Folder") 719 | if os.path.exists(bookmarks_backup_folder): 720 | print(f"- Analyzing BookmarkBackups Folder at: {bookmarks_backup_folder}") 721 | logger.info(f"Analyzing BookmarkBackups Folder at: {bookmarks_backup_folder}") 722 | count_backup_files(bookmarks_backup_folder) 723 | process_bookmark_backups( 724 | extractionsummary_sheet=sheets['Extraction Summary'], 725 | bookmarks_backup_folder=bookmarks_backup_folder, 726 | output_folder=args.output, 727 | bookmarks_sheet=sheets['All Bookmark Info'], 728 | favicon_sheet=sheets['Bookmark Favicons'], 729 | backup_summary_sheet=sheets['Bookmark Backup Information'], 730 | icons_folder=icons_folder, 731 | missing_recordids=missing_recordids, 732 | deleted_sheet=sheets['Deleted Data'], 733 | sqlite_bookmarks=sqlite_bookmarks 734 | ) 735 | else: 736 | print(f"- No bookmark backups found at: {bookmarks_backup_folder}") 737 | logger.info(f"No bookmark backups found at: {bookmarks_backup_folder}") 738 | # Save the workbook 739 | excel_output_path = os.path.join(args.output, 'TOR_Bookmarks_Extraction.xlsx') 740 | workbook.save(excel_output_path) 741 | print(f"\nTor Bookmark Information Saved: {excel_output_path}") 742 | logger.info(f"Tor Bookmark Information Saved: {excel_output_path}") 743 | 744 | if __name__ == "__main__": 745 | main() 746 | -------------------------------------------------------------------------------- /Win 11 - Tor Browser Bookmarks/requirements.txt: -------------------------------------------------------------------------------- 1 | lz4 2 | openpyxl 3 | --------------------------------------------------------------------------------