[
  {
    "path": ".gitmodules",
    "content": "[submodule \"src/source/password-hashing\"]\n\tpath = src/source/password-hashing\n\turl = git@git.defuse.ca:gits/password-hashing.git\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<http://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "src/blocked.html",
    "content": "<html>\n    <head>\n        <title>Error 403: Access Denied</title>\n    </head>\n    <body>\n        <h1>Forbidden</h1>\n    </body>\n    <p>Either you're trying to access something you're not supposed to, or you've been banned.</p>\n    <p>If you think you've been banned, email havoc@defuse.ca to appeal.</p>\n\n    <!--\n     This stuff is here to make sure internet explorer displays this message.\n     This stuff is here to make sure internet explorer displays this message.\n     This stuff is here to make sure internet explorer displays this message.\n     This stuff is here to make sure internet explorer displays this message.\n     -->\n</html>\n"
  },
  {
    "path": "src/css/main.css",
    "content": "/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of CrackStation.\n * \n * CrackStation is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n * \n * CrackStation is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n * \n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\n/* Some parts of this style sheet come from http://grc.com/ */\n\n/* CSS Sticky footer from: http://www.cssstickyfooter.com/using-sticky-footer-code.html */\n\n/* TAGS {{{1 */\n\nhtml {\n    height: 100%;\n    width: 100%;\n}\n\nbody {\n\twidth:100%; \n\theight:100%;\n\tcolor:black;\n\tfont-size:10pt;\n\tfont-family: verdana, tahoma, arial, helvetica, sans-serif, \"MS Sans Serif\";\n    background-color: white;\n}\n\n/*Opera Fix (css sticky footer) */\nbody:before {\n\tcontent:\"\";\n\theight:100%;\n\tfloat:left;\n\twidth:0;\n\tmargin-top:-32767px;/\n}\n\nbody, img, button, iframe, ul, li, hr  { \n\tmargin:0; padding:0; border:0; \n}\n\ntable { \n\tmargin:0;\n\tpadding:0;\n\ttext-align:left;\n\tfont-size:10pt; \n}\n\ntextarea {\n    resize: none;\n}\n\n/* GLOBAL (All Pages) Styles {{{1 */\n#wrap {\n    min-height: 100%;\n    width: 100%;\n    min-width: 900px; /* Must be big enough to fit content and it's p+m */\n}\n\n#sm {\n    text-align: center;\n    position: absolute;\n    top: 62px;\n    right: 30px;\n    font-size: 16pt;\n    font-weight: bold;\n    font-family: Arial, Helvetica, sans-serif;\n}\n\n#sm a {\n    color: white;\n    text-decoration: none;\n}\n\n#sm a:hover {\n    color: #00FFFF;\n}\n\n#twitterlogo {\n    vertical-align: middle;\n    margin-right: 2px;\n    padding-bottom: 2px;\n}\n\n#homediv {\n\ttext-align: center; \n\tcolor: white;\n}\n\n#homediv h2 {\n\tmargin-top: 30px;\n}\n\n#homediv li {\n\tfont-size: 20px;\n\tmargin-top: 10px;\n}\n\n.homelink {\n\tcolor: white;\n\ttext-decoration: none;\n}\n\n.homeul {\n\ttext-align: left;\n\twidth: 420px;\n\tmargin: 0 auto;\n}\n\n#content {\n\ttext-align: left;\n\tmargin: 0 auto; \n\twidth: 80%; \n\tmax-width: 1000px; \n\tmin-width: 800px;\n\tmargin-top:5px;\n\tbackground-color:white;\n\tpadding-left: 30px;\n\tpadding-right:30px;\n\n\tpadding-top:5px;\n\n    /*overflow: auto;*/\n    padding-bottom: 140px; /* total #footer height + desired padding */\n\n}\n\n#contenthome {\n\tmargin-top:20px;\n}\n\n#contenthome li {\n    margin-bottom: 5px;\n}\n\n\n#content h1 {\n\twidth:100%;\n\tpadding-bottom:5px;\n\ttext-align: center;\n\tpadding-top: 0;\n\tmargin-top:0;\n\tborder-bottom: solid #000000 5px; /*#333333*/\n    font-size: 25px;\n    font-family: \"Times New Roman\", \"Times\", serif;\n    font-weight: normal;\n}\n\n#content h2 {\n\tfont-size: 16pt;\n    border-bottom: solid 1px #AAAAAA;\n    font-family: \"Times New Roman\", \"Times\", serif;\n    font-weight: normal;\n}\n\n#content h3 {\n\tfont-size: 13pt;\n}\n\n#content h4 {\n\tfont-size: 10pt;\n}\n\n.majorlink {\n\tcolor:white;\n\ttext-decoration: none;\n\tfont-size: 16px;\n}\n\na:hover {\n\tcolor:#FF0000;\n}\n\n#undergrad {\n\tbackground-image: url('/images/undergrad.png');\n\theight: 10px;\n\tmargin-top: 1px;\n\twidth: 100%;\n}\n\n#latest a:link {\n\tcolor: red;\n}\n\n#latest a:hover {\n\tcolor: white;\n}\n\n#latest a:visited {\n\tcolor: red;\n}\n\nul {\n    padding-left:40px;\n}\n\n.linkblock {\n    margin: 0 auto;\n    background:#ddffff;\n    border: solid #66ccdd 2px;\n}\n\n.linkblockheader {\n    margin-top:20px;\n    text-align:center;\n}\n\n.linkblock td {\n    padding-right:5px;\n    text-decoration:underline;\n}\n\n/* These DO NOT affect the PASTEBIN page! */\n.div1 {\n\tbackground-color: #d4d4d4 ;\n\tword-wrap: break-word;\n}\n\n.div0 {\n\tword-wrap: break-word;\n}\n\n#footerborder {\n    background-image: url('images/undergrad-inverted.png');\n    height: 10px;\n}\n\n#footerwrapper {\n    position: relative;\n    margin-top: -105px; /* #footer total height (padding too) + 10px footerborder */\n    clear: both;\n    width: 100%;\n    min-width: 900px;\n}\n\n/* Hide the footer while printing */\n@media print {\n    #footerwrapper {\n        display:none;\n    }\n}\n\n\n#footer {\n    background-color: black;\n    /*border-top: solid #202020 1px;*/\n    padding-top: 5px;\n    padding-bottom: 10px;\n    padding-left: 10px;\n    padding-right: 10px;\n    margin: 0;\n    color: white;\n    height: 80px;\n}\n\n#footer a {\n    color: #CCCCCC;\n}\n\n#footer a:hover {\n    color: red;\n}\n\n.codeskillbox {\n\tbackground-color: white;\n\tcolor: black;\n\tfont-size: 40px;\n\ttext-align: center;\n\tborder: solid black 1px;\n\tmargin: 0 auto;\n\tmargin-bottom: 30px;\n\twidth: 750px;\n}\n\n.codeskillheader {\n\tbackground-color: #000;\n\tcolor: white;\n\ttext-align: center;\n\tpadding: 5px;\n\tfont-size: 20px;\n\tborder-bottom: solid black 1px;\n}\n\n.honestywarebox {\n    background-color: #aadaff;\n    border: solid black 1px;\n    padding: 10px;\n}\n\n.honestywarebox h2 {\n    text-align: center;\n    border-style: none !important;\n    padding: 0;\n    margin: 0;\n}\n\n.code {\n    padding: 10px; \n    font-family: monospace;\n    color: #c0c0c0;\n    background-color: #000000;\n    border-radius: 15px;\n    box-shadow: 6px 6px 4px 2px #888 ;\n    background-image: url('/images/code-top.png');\n    background-repeat: repeat-x;\n}\n\n.codehl {\n    font-weight: bold;\n}\n\n.badcode {\n    background-image: url('/images/grid-red.gif') !important;\n}\n/* PPHOS {{{1 */\n/* ============ PPHOS ================= */\n\n.hosval {\n    border: solid 1px gray;\n}\n\n.nopaddingatall {\n\tpadding: 0;\n\tmargin: 0;\n}\n\n.pphostbl {\n    width: 100%;\n    border-collapse:collapse;\n}\n\n.pphostbl th {\n    padding: 5px;\n    background-color: black;\n    color:white;\n    border: solid 1px gray;\n}\n\n.alt {\n    background-color: #e5e5e5;\n}\n\n\n/* PASSWORD BLOCKS {{{1 */\n/* ========== PASSWORD BLOCKS ========= */\n\n.blocksection h2 {\n    border-bottom: solid black 1px;\n    padding: 0;\n    margin: 0;\n    margin-bottom: 15px;\n    text-align: center;\n}\n\n.blocksection {\n    width: 700px;\n    margin: 0 auto;\n    border: solid black 3px;\n    margin-bottom: 20px;\n    background-color: #FFFFFF;\n}\n\n#blockfactory {\n\n}\n\n#blocksorter {\n\n}\n\n#passwordpractice {\n\n}\n\n#passwordsecurity {\n\n}\n\n.selectedBlock {\n    border: solid black 3px;\n    padding: 3px;\n    margin: 3px;\n    position: relative;\n    display: inline-block;\n    width: auto;\n}\n\n.unselectedBlock {\n    border: solid black 1px;\n    padding: 3px;\n    margin: 3px;\n    position: relative;\n    display: inline-block;\n    width: auto;\n}\n\n.typefactory {\n    padding: 10px;\n    border-top: solid black 1px;\n    border-bottom: solid black 1px;\n    display: none;\n    background-color: #DDDDDD;\n}\n\n#customfactory {\n    display:none;\n}\n\n#paddingfactory {\n    display:none;\n}\n\n#blockpreview {\n    text-align: center;\n    font-size: 15px;\n    margin: 20px;\n    display: none;\n}\n\n#blockview {\n    text-align: center;\n}\n\n.ftlink {\n    padding-left: 10px;\n    padding-right: 10px;\n    padding-top: 5px;\n    padding-bottom: 5px;\n    text-decoration: underline;\n    cursor: pointer;\n    display: inline-block;\n}\n\n.starblock {\n    display: inline;\n}\n\n.ftlink:hover {\n    color: #0000CC;\n}\n\n#ftheader {\n    text-align: center; \n    font-weight: bold;\n}\n\n.fakelink {\n    text-decoration: underline;\n    color: blue;\n}\n\n.restable {\n    width: 500px;\n    margin: 0 auto;\n    font-size: 12pt;\n    border-collapse: collapse;\n    text-align: center;\n    margin-top: 20px;\n    margin-bottom: 20px;\n}\n\n.restable td {\n    border: solid #000000 1px;\n    margin: 0;\n}\n\n.res1 {\n    background-color: #90EE90;\n}\n\n.res2 {\n    background-color: #FFFFE0;\n}\n\n.res3 {\n    background-color: #D87093;\n}\n\n.wldl {\n    color: black;\n    text-decoration: none;\n}\n\n.wldl2 {\n    color: black;\n    text-decoration: none;\n    font-size: 16pt;\n}\n\n.wldl2:hover {\n    color: green;\n}\n\n.wldl:hover {\n    color: green;\n}\n"
  },
  {
    "path": "src/css/mainmenu2.css",
    "content": "/*==============================================================================\n\n\tNOTE: I've made a lot of modifications to this file for this website.\n    You'll probably\twant to get a fresh copy from...\n\t            \n                http://www.grc.com/menu2/invitro.htm\n\n\tGRC multi-level script-free pure-CSS menuing system stylesheet.\n   This code is hereby placed into the public domain by its author\n   Steve Gibson. It may be freely used for any purpose whatsoever.\n\n\tComputed Geometries:\twith a default 12px font, 1.0em == 12px and\n\t1px == 0.08333em.\n\tThus, our 98px wide Freeware & Research buttons are 8.166666em wide.\n\n                      PUBLIC DOMAIN CONTRIBUTION NOTICE\t\t\t\t\t\t\t \n   This work has been explicitly placed into the Public Domain for the\n\tbenefit of anyone who may find it useful for any purpose whatsoever.\n\t\n==============================================================================*/\n\n.headerlink {\n\tpadding-right:15px;\n}\n\n.downimg {\n\tcolor: #990000;\n    padding: 0;\n    margin: 0;\n    padding-left: 15px;\n    padding-top: 6px;\n}\n\n\n /*================= STYLES FOR THE GRC MASTHEAD & CONTROLS ==================*/\n\n.menuminwidth0 {             /* for all browsers (non-IE) that obey min-width */\n\tposition:relative;\n\tborder:0;\n\tmargin:0;\n\tpadding:0;\n\twidth:100%;\n\theight:119px;/* 36px masthead height + 18px button height + 1px lower border*/\n\tmin-width:800px;\n}\n\n/* suppress our whole menu when not an interactive mode (when printing, etc.) */\n@media print, projection { .menuminwidth0 { d\\isplay:none; } }\n\n* html .menuminwidth1 { /* this allows IE5/6 to simulate min-width capability */\n\tposition:relative;  /* we can simulate a minimum width by creating a large */\n\tfloat:left;          /* border in this first div, then placing our content */\n\theight: 1px;          /* into a second nested div (see 2nd nested div next */\n\tborder-left:800px solid #fff;    /* CSS box-model borders are a fixed size */\n}\n\n* html .menuminwidth2 {    /* used to simulate min-width capability for IE5/6 */\n\tposition:relative;\n\tmargin-left:-800px;\n\theight: 1px;\n}\n\n#masthead {\n\tposition:relative;      /* position our child objects relative to this div */\n\tfloat:left;\n\tvertical-align:top;\t         /* protect from super-large user text sizing */\n\tborder:0;\n\tmargin:0;\n\tpadding:0;\n\twidth:100%;                                  /* grey-fill the entire width */\n\theight:100px;                 /* set the overall height above the menu-bar */\n\n\tbackground:#000;\n\tbackground-image: url('/images/crackstation_header.png');\n\tbackground-repeat: no-repeat;\n\tcolor:white;\n}\n\n#mastheadlogo {\n\tfloat:left;\n\tvertical-align:top;\n\tborder:0;\n\tpadding:0;\n\tmargin: 28px 0 0 15px;\n}\n\n\n /*========================= TOP OF THE MENU CASCADE =========================*/\n\n.menu {\n\tposition:relative;        /* establish a menu-relative positioning context */\n\tfloat:left;                                     /* play nicely with others */\n\tmargin:0;\n\tpadding:0;\n\tborder:0;\n\theight:22px;                                  /* the menu's overall height */\n\twidth:100%;         /* we always want our menu to fill the available space */\n\t/*background:#232323;*/\n\tbackground:black;\n\tbackground-image: url('/images/navbg.png');\n\tbackground-repeat: repeat-x;\n\tfont-family: Verdana, Helvetica, Arial, sans-serif;\n\tfont-size:14px;         /* this (and also below) sets the menu's font size */ /*FIREXWARE EDIT: was 12*/\n\tborder-bottom:1px solid black;        /* give us a black border underneath */\n}\n\n.menu img {\n\tvertical-align: top;      /* prevent images from being pushed down by text */\n}\n\n.menu ul {\n\tpadding-left:5px;\n\tmargin:0;\n\tlist-style-type:none;          /* we don't want to view the list as a list */\n\tline-height:1.5em;           /* globally set the menu's item spacing. note */\n}                               /* this must be 1.0 or 1.5 or 2.0 for Mozilla */\n\n.menu li {\n\tfloat:left;    /* this creates the side-by-side array of top-level buttons */\n\tposition:relative;    /* create local positioning contexts for each button */\n\tmargin:0;\n}\n\n.menu ul li table {\n\tmargin:-1px 0;              /* IE5 needs -1px top and bottom table margins */\n\tm\\argin:0;               /* re-zero the table margins for everyone but IE5 */\n\tborder-collapse:collapse;      /* IE5 needs this for the sub-menus to work */\n\tfont-size:12px;        /* this sets the base font size for our entire menu */\n}\n\n.drop {\n\tdisplay:block;\n\tpadding:0px 0.33em;\t       /* this sets the l/r margins for our menu item */\n\tmargin:0;\n\ttext-align:right;   /* this right alignment goes with the float:left below */\n\tcursor:pointer;      /* IE tries to switch back to an I-beam, don't let it */\n\tcursor:hand;           /* IE5 only knows about \"hand\", so set it both ways */\n}\n\n.drop span {        /* this simultaneously left and right aligns the text and */\n\tfloat:left;       /* the >> in the drop-down menus which link to sub-menus */\n}\n\n.rightmenu {\n\tposition:relative;  /* establish a local positioning context for YAH label */\n\tfloat:right;                  /* and right-align it at the top of our page */\n}\n\n#research {            /* this rightmost \"Research\" button must be positioned */\n\tposition:absolute;       /* absolutely so that the YAH (you are here) text */\n\ttop:0px;               /* label will slide underneath it under Opera v8.54 */\n\tleft:364px;    /* which has a z-order sequencing bug with abs-pos elements */\n}\n\n#other {                  /* this rightmost \"Other\" button must be positioned */\n\tposition:absolute;       /* absolutely so that the YAH (you are here) text */\n\ttop:0px;               /* label will slide underneath it under Opera v8.54 */\n\tleft:462px;    /* which has a z-order sequencing bug with abs-pos elements */\n}\n\n/*======================== TOP LEVEL MENU DEFINITIONS ========================*/\n\n.menu ul li ul {\n\tdisplay:none;                  /* initially hide the entire list hierarchy */\n\tpadding:1px;                               /* this is our box border width */\n}\n\n.menu ul li a,\n.menu ul li a:visited {                    /* unselected top-level menu items */\n\tdisplay:block;\n\tfloat:left;\n\ttext-decoration:none;\n\tcolor:white;\n\theight:18px;\n}\n\n.menu ul li:hover a,\n.menu ul li a:hover {                        /* selected top-level menu items */\n\t/*border-bottom:1px solid white;*/    /* these 2 lines create the push-in illusion */\n\theight:16px;\n    color: #FFAAAA;\n}\n\n/*======================== 2ND LEVEL MENU DEFINITIONS ========================*/\n\n.menu ul li:hover ul,\n.menu ul li a:hover ul {                           /* 2nd level drop-down box */\n\tdisplay:block;\n\tposition:absolute;\n\tmargin:0;\n\ttop:18px;              /* place us just up underneath the top-level images */\n\tleft:-1px;       /* left-align our drop-down to the previous button border */\n\theight:auto;      /* the drop-down height will be determiend by line count */\n\twidth:13.5em;\n\tcolor:black;                        /* this sets the unselected-text color */\n\tbackground:black;         /* this sets our menu's effective \"border\" color */\n\tborder: solid #404040 1px;\n}\n\n.menu ul li:hover ul.leftbutton,\n.menu ul li a:hover ul.leftbutton {/* our first dropdown should not be skewed */\n\tleft:0px;\n}\n\n.menu ul li:hover ul.skinny,\n.menu ul li a:hover ul.skinny {             /* 2nd level skinny drop-down box */\n\twidth:8.08333em;   /* with a 12px default font, this is 97px width (97/12) */\n}\n\n.menu ul.rightmenu li:hover ul,\n.menu ul.rightmenu li a:hover ul {    /* 2nd level neighborhood drop-down box */\n\tleft:auto;\n\tright:0;         /* nudge the right menu right to line up under the border */\n\twidth:400px;      /* with a 12px default font, this is 228px width (228/12) */\n}\n\n* html .menu ul.rightmenu li a:hover ul {         /* IE5/6 needs a tweak here */\n\tright:-1px;\n}\n\n.menu ul li:hover ul li a,\n.menu ul li a:hover ul li a {                   /* 2nd level unselected items */\n\tborder:0;\n\tmargin:0;\n\tpadding:0;\n\theight:auto;\n\tcolor:#FFFFFF;               /* this sets the unselected drop-down text color */\n\t/*background:#444444;*/      /* this sets the drop-down menu background color */\n\tbackground:black;\n\twidth:13.5em;\n}\n\n.menu ul li:hover ul li:hover a,\n.menu ul li a:hover ul li a:hover {                /* 2nd level selected item */\n\tcolor: #FFAAAA;\n\tbackground:black;\n}\n\n.menu ul li:hover ul.skinny li a,\n.menu ul li a:hover ul.skinny li a,\n.menu ul li:hover ul.skinny li a:hover,\n.menu ul li a:hover ul.skinny li a:hover {     /* 2nd level un+selected items */\n\twidth:8.08333em;\n}\n\n/*======================== 3RD LEVEL MENU DEFINITIONS ========================*/\n\n.menu ul li:hover ul li ul,\n.menu ul li a:hover ul li a ul {             /* hide inactive 3rd-level menus */\n\tvisibility:hidden;\n}\n     \n.menu ul li:hover ul li:hover ul,\n.menu ul li a:hover ul li a:hover ul {             /* 3rd level drop-down box */\n\tvisibility:visible;\n\tposition:absolute;\n\tmargin-top:-1px;\t      /* bring the top edge of the 3rd level menu up one */\n\ttop:0;\n\t/*left:8.08333em;*/ /*CHANGE BY FIREXWARE: use super wide always*/\n\tleft:13.5em;\n\twidth:14em;\n}\n\n.menu ul li:hover ul li:hover ul li a,\n.menu ul li a:hover ul li a:hover ul li a {     /* 3rd level unselected items */\n\twidth:14em;\n\tbackground:#444444;\n\tbackground:black;\n\tcolor:white;\n}\n\n.menu ul li:hover ul li:hover ul li a:hover,\n.menu ul li a:hover ul li a:hover ul li a:hover {    /* level3 selected items */\n\twidth:14em;\n\tcolor: #FFAAAA;\n\tbackground:black;\n}\n\n#text {           /* the Mac's standard Safari browser will not see this code */\n\theight:1.215em;#           /* ...  but every other browser will and should */\n} /* Safari barfs on the illegal pound sign (#) after the rule's property val */\n\n\n.darr {\n\tcolor: #990000;\n}\n"
  },
  {
    "path": "src/css/style.css",
    "content": "/*\r\n * CrackStation, a web-based hash cracking website.\r\n * Copyright (C) 2013  Taylor Hornby\r\n * \r\n * This file is part of CrackStation.\r\n * \r\n * CrackStation is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU Affero General Public License as\r\n * published by the Free Software Foundation, either version 3 of the\r\n * License, or (at your option) any later version.\r\n * \r\n * CrackStation is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n * GNU Affero General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU Affero General Public License\r\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n */\r\n\r\n/* Custom stuff */\r\n\r\nul, ol {\r\n    margin-left: 30px;\r\n}\r\n\r\n.crackresults {\r\n    margin-top: 10px;\r\n}\r\n\r\n.results\r\n{\r\n\twidth: 100%;\r\n}\r\n\r\n.results th\r\n{\r\n    text-align: center;\r\n}\r\n\r\n.results td\r\n{\r\n\ttext-align:left;\r\n}\r\n\r\n\r\n.fail\r\n{\r\n    background-color: #FF0000;\r\n}\r\n\r\n.results td\r\n{\r\n\tpadding:5px;\r\n    font-family: monospace;\r\n    border: solid black 1px;\r\n}\r\n\r\n.suc\r\n{\r\n\tbackground-color: #00FF00;\r\n}\r\n\r\n.part\r\n{\r\n    background-color: #FFFF00;\r\n}\r\n\r\n.ic{\r\n    color:#000000;\r\n    font-family: monospace;\r\n}\r\n\r\n.sca {\r\n    display: block;\r\n    height: 100%;\r\n    width: 100%;\r\n}\r\n\r\n.shortcuts{\r\n    width:100%;\r\n    color: #000000;\r\n}\r\n\r\n.shortcuts td {\r\n    background-color: #F0F0F0;\r\n    border: solid 1px black;\r\n    padding: 5px;\r\n    font-weight: bold;\r\n    color: #000000;\r\n}\r\n\r\n.shortcuts td a{\r\n    font-weight:normal;\r\n    text-decoration: none;\r\n    color: #000000;\r\n}\r\n\r\n.shortcuts td a:visited {\r\n    color: #000000;\r\n}\r\n.shortcuts td:hover {\r\n    background-color: #DDDDDD;\r\n}\r\n\r\n#rnglist {\r\n    margin: 0 auto;\r\n}\r\n\r\n#rnglist td {\r\n    border: solid 1px #AAAAAA;\r\n    padding: 10px;\r\n}\r\n\r\n.passcrack{\r\n    padding: 10px; \r\n    font-family: monospace;\r\n    color: #c0c0c0;\r\n    background-color: #000000;\r\n    border-radius: 15px;\r\n    box-shadow: 6px 6px 4px 2px #888 ;\r\n    background-image: url('/images/code-top.png');\r\n    background-repeat: repeat-x;\r\n}\r\n\r\n.downloaddiv {\r\n    padding: 10px;\r\n    font-size: 16pt;\r\n    text-align: center;\r\n}\r\n\r\n.downloadlink {\r\n    color: black;\r\n    padding: 5px;\r\n}\r\n"
  },
  {
    "path": "src/index.php",
    "content": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of CrackStation.\n * \n * CrackStation is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n * \n * CrackStation is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n * \n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\n// Standardize the times & dates to UTC because people don't live in the same timezone as the server.\ndate_default_timezone_set(\"UTC\"); \n\n// HSTS header (force HTTPS)\nif(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' &&\n    $_SERVER['HTTP_HOST'] != \"localhost\" && \n    $_SERVER['HTTP_HOST'] != \"192.168.1.102\")\n{\n    header('Strict-Transport-Security: max-age=31536000; includeSubDomains; preload'); /* one year */\n}\n\n//Strengthen the server's CSPRNG\n$entropy = implode(gettimeofday()) . implode($_SERVER) . implode($_GET) . implode($_POST) . implode($_COOKIE) . implode($_ENV) . microtime() . mt_rand() . mt_rand();\nfile_put_contents(\"/dev/urandom\", $entropy);\n\nrequire_once('libs/URLParse.php'); \nrequire_once('libs/phpcount.php');\n\n$name = URLParse::ProcessURL();\nPHPCount::AddHit($name, $_SERVER['REMOTE_ADDR']);\n\n// Prevent pages from being displayed in iframes. Not supported by all browsers.\nheader('X-Frame-Options: SAMEORIGIN'); \n\nheader('Content-Type: text/html; charset=utf-8');\n?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<head>\n<title><?php \n            $title = URLParse::getPageTitle($name);\n            echo htmlspecialchars($title, ENT_QUOTES);\n?></title>\n<meta name=\"description\" content=\"<?php \n            $metd = URLParse::getPageMetaDescription($name);\n            echo htmlspecialchars($metd, ENT_QUOTES);\n?>\" />\n<meta name=\"keywords\" content=\"<?php \n            $metk = URLParse::getPageMetaKeywords($name);\n            echo htmlspecialchars($metk, ENT_QUOTES);\n?>\" />\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"google-site-verification\" content=\"AeVohZfbCxeMLV4i1tKOdEgAOxhl8JgvNEpi11neLLk\" />\n<meta name=\"google-site-verification\" content=\"bJfNsQVzNQLRCAQiZD0kUNF-gFYS16YnaCZDJEX-dLk\" />\n<link rel=\"stylesheet\" media=\"all\" type=\"text/css\" href=\"/css/mainmenu2.css\" />\n<link rel=\"stylesheet\" media=\"all\" type=\"text/css\" href=\"/css/main.css\" />\n<link rel=\"stylesheet\" media=\"all\" type=\"text/css\" href=\"/css/style.css\" />\n<?php\n    if ($name === \"\") {\n    ?>\n        <script src='https://www.google.com/recaptcha/api.js'></script>\n    <?\n    }\n?>\n<!--[if !IE 7]>\n\t<style type=\"text/css\">\n\t\t#wrap {display:table;height:100%}\n\t</style>\n<![endif]-->\n</head>\n<body <?php if( $name == \"\" ) echo 'style=\"background:white;\" '; ?> >\n<div id=\"wrap\">\n\n<!-- This menuing system was made by Steve Gibson at GRC.COM \n            see more at http://www.grc.com/menudemo.htm -->\n\n<div class=\"menuminwidth0\"><div class=\"menuminwidth1\"><div class=\"menuminwidth2\">\n<div id=\"masthead\">\n    <div style=\"font-size:30px;\"><img src=\"/images/1by1.gif\" alt=\"CrackStation\" /></div>\n    <div id=\"sm\">\n        <a href=\"https://defuse.ca/\" title=\"Defuse Security\">Defuse.ca</a>\n        &nbsp;&middot;&nbsp;\n        <a href=\"https://twitter.com/defusesec\" title=\"Follow @DefuseSec on twitter!\">\n            <img id=\"twitterlogo\" src=\"/images/twitter.png\" alt=\"Follow me on twitter!\" height=\"25\" width=\"30\" />\n            Twitter\n        </a>\n    </div>\n</div>\n\n<div class=\"menu\">\n\n<ul>\n    <li class=\"headerlink\" ><a href=\"/\">CrackStation<img class=\"downimg\" src=\"/images/downarrow.gif\" alt=\"&#9660;\"/><!--[if gt IE 6]><!--></a><!--<![endif]--><!--[if lt IE 7]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><![endif]-->\n        <ul class=\"leftbutton\">\n            <li><a href=\"/\">&nbsp;Free Hash Cracker</a></li>\n            <li><a href=\"crackstation-wordlist-password-cracking-dictionary.htm\">&nbsp;Wordlist Download</a></li>\n            <li><a href=\"/about-us.htm\">&nbsp;About Us</a></li>\n            <li><a href=\"/contact-us.htm\">&nbsp;Contact Us</a></li>\n            <li><a href=\"/legal-privacy.htm\">&nbsp;ToS &amp; Privacy Policy</a></li>\n        </ul>\n        <!--[if lte IE 6]></td></tr></table></a><![endif]-->\n    </li>\n</ul>\n\n\n<ul>\n    <li class=\"headerlink\" ><a href=\"/hashing-security.htm\">Password Hashing Security<img class=\"downimg\" src=\"/images/downarrow.gif\" alt=\"&#9660;\"/><!--[if gt IE 6]><!--></a><!--<![endif]--><!--[if lt IE 7]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><![endif]-->\n        <!--[if lte IE 6]></td></tr></table></a><![endif]-->\n    </li>\n</ul>\n\n<ul>\n    <li class=\"headerlink\" ><a href=\"https://defuse.ca/\">Defuse Security<img class=\"downimg\" src=\"/images/downarrow.gif\" alt=\"&#9660;\"/><!--[if gt IE 6]><!--></a><!--<![endif]--><!--[if lt IE 7]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><![endif]-->\n        <!--[if lte IE 6]></td></tr></table></a><![endif]-->\n    </li>\n</ul>\n\n</div> <!-- close \"menu\" div -->\n<hr style=\"display:none\" />\n</div></div></div> <!-- close the \"minwidth\" wrappers -->\n<!-- End of menu -->\n\n<!--[if !IE]>-->\n<div id=\"undergrad\"></div>\n<!--<![endif]-->\n\n<!--[If gt IE 6]>\n<div id=\"undergrad\"></div>\n<![endif]-->\n\n<div id=\"content\">\n<?php\n    $included = URLParse::IncludePageContents();\n?>\n</div>\n\n</div> <!-- Wrap -->\n    <div id=\"footerwrapper\">\n    <div id=\"footerborder\"></div>\n    <div id=\"footer\">\n    <?php\n        $last_modified = htmlspecialchars(\n                                date(\"F j, Y, g:ia e\", filemtime($included)),\n                                ENT_QUOTES\n                                );\n        $unique =  PHPCount::GetHits($name, true);\n        $hits = PHPCount::GetHits($name);\n        $total = PHPCount::GetTotalHits();\n        $totalu = PHPCount::GetTotalHits(true);\n    ?>\n    <table>\n        <tr>\n            <th>Last Modified: &nbsp;&nbsp;</th>\n            <td><?php echo $last_modified;?></td>\n        </tr>\n        <tr>\n            <th>Page Hits:</th>\n            <td><?php echo $hits; ?></td>\n        </tr>\n        <tr>\n            <th>Unique Hits:</th>\n            <td><?php echo $unique; ?></td>\n        </tr>\n    </table>\n<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/deed.en_US\"><img alt=\"Creative Commons License\" style=\"border-width:0; vertical-align: bottom;\" src=\"/images/cc-by-sa.png\" /></a>\n<a href=\"https://defuse.ca/\">Defuse Security</a> | \n    <a href=\"https://z.cash/\">Zcash</a> |\n    <a href=\"https://defuse.ca/pastebin.htm\">Secure Pastebin</a> | \n    <a href=\"https://github.com/defuse/crackstation\">Source Code</a>\n    </div> <!-- end footer -->\n    </div> <!-- footerwrapper -->\n<!-- Piwik -->\n<script type=\"text/javascript\">\n  var _paq = _paq || [];\n  _paq.push([\"setDoNotTrack\", true]);\n  _paq.push([\"trackPageView\"]);\n  _paq.push([\"enableLinkTracking\"]);\n\n  (function() {\n    var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://defuse.ca/piwik/\";\n    _paq.push([\"setTrackerUrl\", u+\"piwik.php\"]);\n    _paq.push([\"setSiteId\", \"2\"]);\n    var d=document, g=d.createElement(\"script\"), s=d.getElementsByTagName(\"script\")[0]; g.type=\"text/javascript\";\n    g.defer=true; g.async=true; g.src=u+\"piwik.js\"; s.parentNode.insertBefore(g,s);\n  })();\n</script>\n<noscript>\n<img src=\"https://defuse.ca/piwik/piwik.php?idsite=2&amp;rec=1\" style=\"border:0\" alt=\"\" />\n</noscript>\n<!-- End Piwik Code -->\n\n<!--[if !(lt IE 8)]><!-->\n   <script type=\"text/javascript\">\n     (function(){var e=document.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=document.location.protocol+\"//d1agz031tafz8n.cloudfront.net/thedaywefightback.js/widget.min.js\";var t=document.getElementsByTagName(\"script\")[0];t.parentNode.insertBefore(e,t)})()\n   </script>\n<!--<![endif]-->\n</body>\n</html>\n"
  },
  {
    "path": "src/libs/CrackHashes.php",
    "content": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of CrackStation.\n * \n * CrackStation is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n * \n * CrackStation is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n * \n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nrequire_once(getenv(\"CRACKSTATION_DEPENDS_DIR\") . \"/crackstation-hashdb/LookupTable.php\");\n\nfunction CrackHashes($hashes)\n{\n\techo \"<table class=\\\"results\\\">\";\n\techo \"<tr><th>Hash</th><th>Type</th><th>Result</th></tr>\";\n\n    foreach($hashes as $hash) {\n        $supported_lookups = array(\n            array(\n                'index' => 'lm.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'LM',\n            ),\n            array(\n                'index' => 'ntlm.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'NTLM',\n            ),\n            array(\n                'index' => 'mysql4.1+.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'MySQL4.1+',\n            ),\n            /* md5(md5) must come before actual md5, since the hash might be in\n               the wordlist. */\n            array(\n                'index' => 'md5md5.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'md5(md5)',\n            ),\n            array(\n                'index' => 'md5.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'md5',\n            ),\n            array(\n                'index' => 'sha1.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'sha1',\n            ),\n            array(\n                'index' => 'md2.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'md2',\n            ),\n            array(\n                'index' => 'md4.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'md4',\n            ),\n            array(\n                'index' => 'sha256.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'sha256',\n            ),\n            array(\n                'index' => 'sha224.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'sha224',\n            ),\n            array(\n                'index' => 'sha384.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'sha384',\n            ),\n            array(\n                'index' => 'sha512.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'sha512',\n            ),\n            array(\n                'index' => 'whirlpool.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'whirlpool',\n            ),\n            array(\n                'index' => 'ripemd160.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'ripemd160',\n            ),\n            array(\n                'index' => 'qubesv3.1.idx',\n                'dict' => 'REALUNIQ.lst',\n                'alg' => 'QubesV3.1BackupDefaults',\n            ),\n            /* Big ones. */\n            array(\n                'index' => 'md5-huge.idx',\n                'dict' => 'HUGELIST.lst',\n                'alg' => 'md5',\n            ),\n            array(\n                'index' => 'sha1-huge.idx',\n                'dict' => 'HUGELIST.lst',\n                'alg' => 'sha1',\n            ),\n        );\n\n        $html_escaped_hash = htmlentities(\n            wordwrap($hash, 64, \"\\n\", true),\n            ENT_QUOTES\n        );\n        $html_escaped_hash = str_replace(\"\\n\", \"<br />\\n\", $html_escaped_hash);\n\n        /* Try to crack the hash with every lookup table, collecting all of the\n            results. */\n        $results = array();\n        foreach($supported_lookups as $lookup) {\n\n            $index_path = getenv(\"CRACKSTATION_DEPENDS_DIR\") . \"/cracking/\" . $lookup['index'];\n            $dict_path = getenv(\"CRACKSTATION_DEPENDS_DIR\") . \"/cracking/\" . $lookup['dict'];\n\n            $lut = new LookupTable($index_path, $dict_path, $lookup['alg']);\n\n            try {\n                $results = array_merge($results, $lut->crack($hash));\n                /* Exit early.\n                   This does two things. Firstly, it avoids duplication between\n                   md5.idx/md5-huge.idx and sha1.idx/sha1-huge.idx. Secondly, it\n                   speeds things up since for example if we've already cracked\n                   it as an md5 hash it's very unlikely to also be a sha1 hash.\n                */\n                foreach ($results as $result) {\n                    if ($result->isFullMatch()) {\n                        break 2;\n                    }\n                }\n            } catch (HashFormatException $ex) {\n                echo \"<tr class=\\\"fail\\\"><td>$html_escaped_hash</td><td>Unknown</td><td>Unrecognized hash format.</td></tr>\";\n                /* WARNING: Curently a throw of HashFormatException for one\n                   algorithm means it will throw for *all* algorithms. That may\n                   not remain to be the case. */\n                goto nexthash;\n            }\n        }\n\n        /* Show all of the results for this hash. */\n        if (count($results) == 0) {\n            echo \"<tr class=\\\"fail\\\"><td>$html_escaped_hash</td><td>Unknown</td><td>Not found.</td></tr>\";\n        } else {\n            foreach ($results as $result) {\n                if ($result->isFullMatch()) {\n                    $tr_class = \"suc\";\n                } else {\n                    $tr_class = \"part\";\n                }\n                echo \"<tr class=\\\"$tr_class\\\">\";\n                echo \"<td>$html_escaped_hash</td>\";\n                $html_escaped_alg = htmlentities($result->getAlgorithmName(), ENT_QUOTES);\n                echo \"<td>$html_escaped_alg</td>\";\n                $html_escaped_plaintext = htmlentities($result->getPlaintext(), ENT_QUOTES);\n                echo \"<td>$html_escaped_plaintext</td>\";\n                echo \"</tr>\";\n            }\n        }\n\nnexthash:\n    }\n\n    echo \"</table>\";\n    echo '<p style=\"font-size: 8pt;\"><strong>Color Codes:</strong> <span style=\"background-color: #00FF00;\">Green:</span> Exact match, <span style=\"background-color: #FFFF00;\">Yellow:</span> Partial match, <span style=\"background-color: #FF0000;\">Red:</span> Not found.</p>';\n}\n?>\n"
  },
  {
    "path": "src/libs/URLParse.php",
    "content": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of CrackStation.\n * \n * CrackStation is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n * \n * CrackStation is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n * \n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\n/*\n *      Defuse Cyber-Security's Secure & Lightweight CMS in PHP for Linux.\n *      Setup & Usage Instructions: https://defuse.ca/helloworld-cms.htm\n */\n\n/*\n * The purpose of this class is to process the current request URL to \n * determine which page is to be displayed to the user, or to which URL\n * the user should be redirected. Once the user has been redirected to\n * the correct URL, and the desired page is determined, the page contents\n * can be loaded from a file into a dynamically generated web page.\n *\n * The URL parsing is split into four processes:\n * 1. First, the hostname (domain name) the request was made to is verified \n *    against a list of \"accepted hosts.\" If the hostname doesn't match any of\n *    these accepted hosts, the user is redirected to the same URL on the\n *    \"master host.\" The accepted hosts and master host variables can be set\n *     by modifying the $ACCEPTED_HOSTS and $MASTER_HOST variables respectively.\n * 2. Second, an HTTPS connection is enforced if $FORCE_HTTPS is set to true.\n *    If $FORCE_HTTPS === true and the current connection is not secure, the\n *    user is redirected to a secure (https) URL.\n * 3. The desired page is determined from the URL (see below). If this page\n *    is really an alias for another page, the user is redirected to the proper\n *    page.\n * 4. If the user did not request the page using the cannonical filename,\n *    they are redirected to the cannonical URL for the page (see below).\n *\n * How the desired page is determined from the URL:\n *\n * Every page has a name, and there are two valid URLs for each page name.\n * For a page named \"foobar\", the following are valid URLs for the page:\n *      1. http://example.com/foobar\n *      2. http://example.com/foobar.htm\n * (2) is the cannonical URL for the page. So if the user were to type (1) into\n * their browser, they would be redirected to (2). The URL without the .htm\n * extension is recognized as a convienience so the URL can be spoken without\n * explicitly pronouncing the \"dot h-t-m.\"\n *\n * Names can also contain forward slashes, allowing virtual directories to be\n * created. For example, the page name \"foo/bar\" is valid, with the following\n * URLs:\n *      1. http://example.com/foo/bar\n *      2. http://example.com/foo/bar.htm\n * With (2) being the cannonical form.\n * There is a special case of these names where no \".htm\" extension is allowed.\n * For example, the name \"\" (meaning the homepage) is accessible though:\n *          http://example.com/\n * but NOT through:\n *          http://example.com/.htm\n * The same applies to names ending in \"/\", e.g. \"foo/\" is accessible through:\n *          http://example.com/foo/\n * but NOT through:\n *          http://example.com/foo/.htm\n * Note that a page named \"foo/\" and \"foo\" can exist simultaneously, but since\n * it is common to ommit the trailing \"/\" when typing the URL, this practice\n * is strongly discouraged. If the name \"foo/\" exists and the user omits the \n * trailing \"/\", they will be redirected to the \"foo/\" URL. But if \"foo/\" and\n * \"foo\" both exist, they will be redirected to \"foo.htm\".\n */\n\n// Keys used for definining page data arrays\ndefine('P_FILE', 0); // File content (suffix to $ROOT_FOLDER)\ndefine('P_TITL', 1); // <title>text</title>\ndefine('P_METD', 2); // META tag description\ndefine('P_METK', 3); // META tag keywords\ndefine('P_RDIR', 4); // Redirect URL (has precidence)\n\nclass URLParse\n{\n    private static $ROOT_FOLDER = \"pages/\";\n    private static $MASTER_HOST = \"crackstation.net\";\n    private static $ACCEPTED_HOSTS = array(\n                                            \"crackstation.h.defuse.ca\",\n                                            \"crackstation:20443\"\n                                            );\n    private static $FORCE_HTTPS = true;\n    private static $DEFAULT_TITLE = \"CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.\";\n    private static $DEFAULT_META_DESC = \"Crackstation is the most effective hash cracking service. We crack: MD5, SHA1, SHA2, WPA, and much more...\";\n    private static $DEFAULT_META_KEYWORDS = \"md5 cracking, sha1 cracking, hash cracking, password cracking\";\n\n    private static $PAGE_INFO = array(\n            \"\" =>           array(\n                P_FILE => \"home.php\",\n                ),\n            // Handles /index and /index.htm\n            \"index\" =>      array(\n                P_RDIR => \"\",\n                ),\n            \"index.html\" =>  array(\n                P_RDIR => \"\",\n                ),\n            \"index.php\" =>  array(\n                P_RDIR => \"\",\n                ),\n            \"cracking-services.html\" => array(\n                P_RDIR => \"cracking-services\",\n            ),\n            \"cracking-services\" => array(\n                P_FILE => \"cracking-services.php\",\n                P_TITL => \"CrackStation - Advanced Password Hash Cracking Services\",\n                P_METD => \"Hash and encryption cracking. MD5, LM, WPA, WEP, ANY algorithm. Bulk cracking.\",\n                P_METK => \"password cracking, wpa cracking, bulk cracking, md5 cracking\",\n                ),\n            \"hashing-security.html\" => array(\n                P_RDIR => \"hashing-security\",\n                ),\n            \"hashing-security\" => array(\n                P_FILE => \"hashing-security.php\",\n                P_TITL => \"Secure Salted Password Hashing - How to do it Properly\",\n                P_METD => \"How to hash passwords properly using salt. Why hashes should be salted and how to use salt correctly.\",\n                P_METK => \"salt, salted hashing, secure password hashing, password hashing, proper way to hash passwords\",\n                ),\n            \"hashing-security-draft\" => array(\n                P_FILE => \"hashing-security-draft.php\",\n                P_TITL => \"Secure Salted Password Hashing - How to do it Properly\",\n                P_METD => \"How to hash passwords properly using salt. Why hashes should be salted and how to use salt correctly.\",\n                P_METK => \"salt, salted hashing, secure password hashing, password hashing, proper way to hash passwords\",\n                ),\n            \"downloads\" => array(\n                P_FILE => \"downloads.php\",\n                P_TITL => \"CrackStation Tools & Downloads\",\n                P_METD => \"Free tools & Downloads provided by CrackStation\",\n                P_METK => \"hash tools, hash cracking, password cracking\",\n                ),\n            \"contact-us\" => array(\n                P_FILE => \"contactus.php\",\n                P_TITL => \"CrackStation Contact\",\n                P_METD => \"Instructions for contacting CrackStation\",\n                P_METK => \"crackstation contact\",\n                ),\n            \"about-us\" => array(\n                P_FILE => \"aboutus.php\",\n                P_TITL => \"CrackStation Contact\",\n                P_METD => \"What CrackStation is and why we exist\",\n                P_METK => \"crackstation contact\",\n                ),\n            \"thank-you\" => array(\n                P_FILE => \"thank-you.php\",\n                P_TITL => \"Thanks!\",\n                P_METD => \"Donation Confirmation Page\"\n                ),\n            \"buy-crackstation-wordlist-password-cracking-dictionary\" => array(\n                P_RDIR => \"crackstation-wordlist-password-cracking-dictionary\"\n                ),\n            \"crackstation-wordlist-password-cracking-dictionary\" => array(\n                P_FILE => \"buy-crackstation-wordlist-cracking-dictionary.php\",\n                P_TITL => \"CrackStation's Password Cracking Dictionary (Pay what you want!)\",\n                P_METD => \"Download CrackStation's password cracking wordlist.\",\n                P_METK => \"password cracking wordlist, biggest password cracking wordlist, cracking dictionary\",\n                ),\n            \"how-crackstation-works\" => array(\n                P_FILE => \"how-crackstation-works.php\",\n                P_TITL => \"How CrackStation Works\",\n                P_METD => \"How CrackStation's non-salted hash cracking system works.\",\n                P_METK => \"hash lookup table, binary search, hash cracking\"\n                ),\n            \"legal-privacy.html\" => array(\n                P_RDIR => \"legal-privacy\"\n                ),\n            \"legal-privacy\" => array(\n                P_FILE => \"legal-privacy.php\",\n                P_TITL => \"CrackStation - Legal and Privacy\",\n                P_METD => \"CrackStation.net's privacy policy\",\n                P_METK => \"hash cracking legal, penetration testing, password security\",\n                ),\n            );\n\n    // Page to be displayed for invalid URLs\n    private static $FILE_NOT_FOUND = array(\n                        P_FILE => \"404.php\",\n                        P_TITL => \"File Not Found\",\n                        );\n                        \n\n    private static $to_show;\n\n    public static function ProcessURL()\n    {\n        // Check the host the request was made to, and redirect if necessary.\n        self::checkHost(); \n        // Check the HTTPS status, redirect if necessary.\n        self::checkHTTPS();\n\n        $page_info_key = self::getPageArrayKey();\n        if($page_info_key === false)\n        {\n            self::send404Headers();\n            self::$to_show = self::$FILE_NOT_FOUND;\n            return \"404\";\n        }\n        else\n        {\n            $page_array = self::$PAGE_INFO[$page_info_key];\n            self::checkRedirectRequest($page_array);\n            self::ensureHTMOrSlashExtension($page_array, $page_info_key);\n            self::$to_show = $page_array;\n            return $page_info_key;\n        }\n    }\n\n    public static function getPageTitle($name)\n    {\n        if(array_key_exists($name, self::$PAGE_INFO))\n        {\n            $page_array = self::$PAGE_INFO[$name];\n            if(array_key_exists(P_TITL, $page_array))\n                return $page_array[P_TITL];\n            else\n                return self::$DEFAULT_TITLE;\n        }\n        else\n            return self::$DEFAULT_TITLE;\n    }\n\n    public static function getPageMetaDescription($name)\n    {\n        if(array_key_exists($name, self::$PAGE_INFO))\n        {\n            $page_array = self::$PAGE_INFO[$name];\n            if(array_key_exists(P_METD, $page_array))\n                return $page_array[P_METD];\n            else\n                return self::$DEFAULT_META_DESC;\n        }\n        else\n            return self::$DEFAULT_META_DESC;\n    }\n\n    public static function getPageMetaKeywords($name)\n    {\n        if(array_key_exists($name, self::$PAGE_INFO))\n        {\n            $page_array = self::$PAGE_INFO[$name];\n            if(array_key_exists(P_METK, $page_array))\n                return $page_array[P_METK];\n            else\n                return self::$DEFAULT_META_KEYWORDS;\n        }\n        else\n            return self::$DEFAULT_META_KEYWORDS;\n    }\n\n    // Includes the page contents (ProcessURL must be called first). \n    // Returns the name of the included page.\n    public static function IncludePageContents()\n    {\n        $included = \"\";\n        if(isset(self::$to_show) && array_key_exists(P_FILE, self::$to_show) && \n                        file_exists(self::$ROOT_FOLDER . self::$to_show[P_FILE]))\n        {\n            $included = self::$ROOT_FOLDER . self::$to_show[P_FILE]; \n            include($included);\n        }\n        else\n        {\n            $included = self::$ROOT_FOLDER . self::$FILE_NOT_FOUND[P_FILE]; \n            include($included); \n        }\n        return $included;\n    }\n\n    // Make sure the request is coming to one of the accepted hosts, and if not,\n    // redirect to the master host.\n    private static function checkHost()\n    {\n        $http_host = $_SERVER['HTTP_HOST'];\n        if($http_host != self::$MASTER_HOST && !in_array($http_host, self::$ACCEPTED_HOSTS))\n        {\n            // We anticipate the HTTPS requirement here so that we can avoid a \n            // second redirect from checkHTTPS()\n            // Use https:// protocol if:\n            //          1. $FORCE_HTTPS is true\n            //      or, 2. HTTPS is already in use.\n            if(self::$FORCE_HTTPS || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'))\n                $protocol = \"https://\";\n            else\n                $protocol = \"http://\";\n\n            // Redirect to the master host\n            self::permRedirect($protocol . self::$MASTER_HOST . \"/\" . \n                            self::getUrlFile() . self::getUrlParams());\n        }\n    }\n\n    // If $FORCE_HTTPS is true and HTTPS is not in use, redirect to an HTTPS URL\n    private static function checkHTTPS()\n    {\n        if(self::$FORCE_HTTPS && (empty($_SERVER[\"HTTPS\"]) || $_SERVER['HTTPS'] == 'off'))\n        {\n            self::permRedirect(\"https://\" . $_SERVER['HTTP_HOST'] . \"/\" . \n                            self::getUrlFile() . self::getUrlParams());\n        }\n    }\n\n    // Returns the page name ($PAGE_INFO key) for the currently requested page, or\n    // false if the page requested is not present in $PAGE_INFO.\n    // e.g. if the url is either:\n    //    a) http://example.com/foo.htm\n    // or b) http://example.com/foo\n    // this method will return 'foo', if $PAGE_INFO['foo'] exists.\n    private static function getPageArrayKey()\n    {\n        $page_name = strtolower(self::getUrlFile());\n        $htm_removed = false;\n\n        // Remove the .htm extension if present\n        if(strpos($page_name, \".htm\") === strlen($page_name) - 4)\n        {\n            $page_name = substr($page_name, 0, strlen($page_name) - 4);\n            $htm_removed = true;\n\n            // If the page name ends in a \"/\", it is not valid, e.g:\n            // http://example.com/.htm\n            // http://example.com/foo/.htm\n            if(empty($page_name) || $page_name[strlen($page_name) - 1] == \"/\")\n                return false;\n        }\n\n        // Return the page array if the page exists, otherwise boolean false.\n        if(array_key_exists($page_name, self::$PAGE_INFO))\n        {\n            return $page_name;\n        }\n        elseif(array_key_exists($page_name . \"/\", self::$PAGE_INFO) && !$htm_removed)\n        {\n            return $page_name . \"/\";\n        }\n        else\n        {\n            return false;\n        }\n    }\n\n    // Checks if the P_RDIR index exists in the page array and redirects to\n    // the specified page if so.\n    private static function checkRedirectRequest($page_array)\n    {\n        if(array_key_exists(P_RDIR, $page_array))\n        {\n            $redir = $page_array[P_RDIR];\n\n            // Anticipate the need for .htm extension to avoid a second redirect\n            // All pages that don't end in a / must end in .htm\n            if(!empty($redir) && $redir[strlen($redir) - 1] != \"/\")\n            {\n                $redir .= \".htm\";\n            }\n\n            // Redirect, keeping the URL parameters.\n            self::permRedirect(self::getUrlFront() . $redir . self::getUrlParams());\n        }\n    }\n\n    // Ensures that the current URL ends in .htm, if it is the URL of a normal\n    // page, or ends in \"/\" if it is the URL of a virtual directory root.\n    // http://example.com/?bar => http://example.com/?bar\n    // http://example.com/foo/bar?baz => http://example.com/foo/bar.htm?baz\n    // http://example.com/hello => http://example.com/hello/ (if $proper_name is \"hello/\")\n    private static function ensureHTMOrSlashExtension($page_array, $proper_name)\n    {\n        $file = self::getUrlFile();\n\n        // If the page is a directory (other than the root)...\n        if(!empty($proper_name) && $proper_name[strlen($proper_name) - 1] == \"/\") \n        {\n            if($file[strlen($file) - 1] != \"/\") // ... make sure it ends in \"/\"\n            {\n                // Redirect to the / version, preserving the parameters\n                self::permRedirect(self::getUrlFront() . $file . \"/\" . self::getUrlParams()); \n            }\n        }\n        // Otherwise, if it's a normal page name, it should end in .htm\n        elseif(!empty($file) && strpos($file, \".htm\") != strlen($file) - 4)\n        {\n            // Redirect to the .htm version, preserving the parameters\n            self::permRedirect(self::getUrlFront() . $file . \".htm\" . self::getUrlParams()); \n        }\n    }\n\n    // Returns the URL parameters, if any.\n    // If there are URL parameters, a the parameter string (including \"?\")\n    // will be returned. If there are none, the empty string is returned.\n    private static function getUrlParams()\n    {\n        $url = $_SERVER['REQUEST_URI'];\n        $question = strpos($url, \"?\");\n        if($question !== FALSE)\n            return substr($url, $question);\n        else\n            return \"\";\n    }\n\n    // Returns the file part of the URL. This is everything after (not including)\n    // the first \"/\" after the host name and before (not including) the \"?\" in\n    // front of the URL parameters.\n    // e.g. http://example.com/foo/bar.htm?baz=foo returns \"foo/bar.htm\"\n    private static function getUrlFile()\n    {\n        $url = $_SERVER['REQUEST_URI'];\n        $first_slash = self::getFirstSlashIndex($url);\n        $question = strpos($url, \"?\");\n        if($question === false)\n            return substr($url, $first_slash + 1);\n        else\n            return substr($url, $first_slash + 1, $question - $first_slash - 1);\n    }\n\n    // Returns the protocol and host part of the URL, including the \"/\" after\n    // the host name.\n    private static function getUrlFront()\n    {\n        $url = $_SERVER['REQUEST_URI'];\n        $first_slash = self::getFirstSlashIndex($url);\n        return substr($url, 0, $first_slash + 1);\n    }\n\n    // Returns the index of the slash after the hostname, or the index of the\n    // last character in the string if there is none.\n    private static function getFirstSlashIndex($url)\n    {\n        $prot_end = strpos($url, \"://\");\n        if($prot_end === false)\n            $prot_end = 0;\n        else\n            $prot_end += 3; // skip over the ://\n\n        // find the first slash after the end of the protocol specifier\n        $first_slash = strpos($url, \"/\", $prot_end);\n\n        // If there is no slash after the protocol specifier, the entire URL\n        // is considered the \"front\" so we return the index of the last element.\n        if($first_slash === false)\n            return strlen($url) - 1;\n        else\n            return $first_slash;\n    }\n\n    // Send a HTTP 301 Moved Permanently redirect and cease script execution.\n    private static function permRedirect($newUrl)\n    {\n        header(\"HTTP/1.1 301 Moved Permanently\");\n        header(\"Location: $newUrl\");\n        die();\n    }\n\n    // Send the HTTP 404 Not Found header\n    private static function send404Headers()\n    {\n        header(\"HTTP/1.0 404 Not Found\");\n        header(\"Status: 404 Not Found\");\n    }\n}\n?>\n"
  },
  {
    "path": "src/libs/phpcount.php",
    "content": "<?php\n// WARNING: HACKED BY ADDING 'cs' PREFIX TO EVERY TABLE NAME.\n/*\n * phpcount.php Ver.1.1- An \"anoymizing\" hit counter.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n*/\n\n/*\n * This PHP Class provides a hit counter that is able to track unique hits\n * without recording the visitor's IP address in the database. It does so by \n * recording the hash of the IP address and page name.\n *\n * By hashing the IP address with page name as salt, you prevent yourself from\n * being able to track a user as they navigate your site. You also prevent \n * yourself from being able to recover anyone's IP address without brute forcing\n * through all of the assigned IP address blocks in use by the internet.\n *\n * Contact: havoc AT defuse.ca\n * WWW:     https://defuse.ca/\n *\n * USAGE:\n *        In your script, use reqire_once() to import this script, then call the\n *        functions like PHPCount::AddHit(...); See each function for help.\n *\n * NOTE: You must set the database credentials in the InitDB method.\n */\n\nrequire_once('/storage/creds.php');\n\nclass PHPCount\n{\n   /*\n    * Defines how many seconds a hit should be rememberd for. This prevents the\n    * database from perpetually increasing in size. Thirty days (the default)\n    * works well. If someone visits a page and comes back in a month, it will be\n    * counted as another unique hit.\n    */\n    const HIT_OLD_AFTER_SECONDS = 2592000; // default: 30 days.\n\n    // Don't count hits from search robots and crawlers.\n    const IGNORE_SEARCH_BOTS = true;\n\n    // Don't count the hit if the browser sends the DNT: 1 header.\n    const HONOR_DO_NOT_TRACK = false;\n\n    private static $IP_IGNORE_LIST = array(\n        '127.0.0.1',\n    );\n\n    private static $DB = false;\n\n    private static function InitDB()\n    {\n        if(self::$DB)\n            return;\n\n        try\n        {\n            // TODO: Set the database login credentials.\n            $creds = Creds::getCredentials(\"df_phpcount\");\n            self::$DB = new PDO(\n                \"mysql:host={$creds[C_HOST]};dbname={$creds[C_DATB]}\",\n                $creds[C_USER], // Username\n                $creds[C_PASS], // Password\n                array(PDO::ATTR_PERSISTENT => true)\n            );\n            self::$DB->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);\n            unset($creds);\n        }\n        catch(Exception $e)\n        {\n            die('Failed to connect to phpcount database');\n        }\n    }\n\n    /*\n     * Adds a hit to a page specified by a unique $pageID string.\n     */\n    public static function AddHit($pageID)\n    {\n        if(self::IGNORE_SEARCH_BOTS && self::IsSearchBot())\n            return false;\n        if(in_array($_SERVER['REMOTE_ADDR'], self::$IP_IGNORE_LIST))\n            return false;\n        if(\n            self::HONOR_DO_NOT_TRACK &&\n            isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == \"1\"\n        ) {\n            return false;\n        }\n\n        self::InitDB();\n\n        self::Cleanup();\n        self::CreateCountsIfNotPresent($pageID);\n        if(self::UniqueHit($pageID))\n        {\n            self::CountHit($pageID, true);\n            self::LogHit($pageID);\n        }\n        self::CountHit($pageID, false);\n\n        return true;\n    }\n    \n    /*\n     * Returns (int) the amount of hits a page has\n     * $pageID - the page identifier\n     * $unique - true if you want unique hit count\n     */\n    public static function GetHits($pageID, $unique = false)\n    {\n        self::InitDB();\n\n        self::CreateCountsIfNotPresent($pageID);\n\n        $q = self::$DB->prepare(\n            'SELECT hitcount FROM cshits\n             WHERE pageid = :pageid AND isunique = :isunique'\n        );\n        $q->bindParam(':pageid', $pageID);\n        $q->bindParam(':isunique', $unique);\n        $q->execute();\n\n        if(($res = $q->fetch()) !== FALSE)\n        {\n            return (int)$res['hitcount'];\n        }\n        else\n        {\n            die(\"Missing hit count from database!\");\n            return false;\n        }\n    }\n    \n    /*\n     * Returns the total amount of hits to the entire website\n     * When $unique is FALSE, it returns the sum of all non-unique hit counts\n     * for every page. When $unique is TRUE, it returns the sum of all unique\n     * hit counts for every page, so the value that's returned IS NOT the \n     * amount of site-wide unique hits, it is the sum of each page's unique\n     * hit count.\n     */\n    public static function GetTotalHits($unique = false)\n    {\n        self::InitDB();\n\n        $q = self::$DB->prepare(\n            'SELECT hitcount FROM cshits WHERE isunique = :isunique'\n        );\n        $q->bindParam(':isunique', $unique);\n        $q->execute();\n        $rows = $q->fetchAll();\n\n        $total = 0;\n        foreach($rows as $row)\n        {\n            $total += (int)$row['hitcount'];\n        }\n        return $total;\n    }\n    \n    /*====================== PRIVATE METHODS =============================*/\n    \n    private static function IsSearchBot()\n    {\n        // Of course, this is not perfect, but it at least catches the major\n        // search engines that index most often.\n        $keywords = array(\n            'bot',\n            'spider',\n            'spyder',\n            'crawlwer',\n            'walker',\n            'search',\n            'yahoo',\n            'holmes',\n            'htdig',\n            'archive',\n            'tineye',\n            'yacy',\n            'yeti',\n        );\n\n        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);\n\n        foreach($keywords as $keyword) \n        {\n            if(strpos($agent, $keyword) !== false)\n                return true;\n        }\n\n        return false;\n    }\n\n    private static function UniqueHit($pageID)\n    {\n        $ids_hash = self::IDHash($pageID);\n\n        $q = self::$DB->prepare(\n            'SELECT time FROM csnodupes WHERE ids_hash = :ids_hash'\n        );\n        $q->bindParam(':ids_hash', $ids_hash);\n        $q->execute();\n\n        if(($res = $q->fetch()) !== false)\n        {\n            if($res['time'] > time() - self::HIT_OLD_AFTER_SECONDS)\n                return false;\n            else\n                return true;\n        }\n        else\n        {\n            return true;\n        }\n    }\n    \n    private static function LogHit($pageID)\n    {\n        $ids_hash = self::IDHash($pageID);\n\n        $q = self::$DB->prepare(\n            'SELECT time FROM csnodupes WHERE ids_hash = :ids_hash'\n        );\n        $q->bindParam(':ids_hash', $ids_hash);\n        $q->execute();\n\n        $curTime = time();\n\n        if(($res = $q->fetch()) !== false)\n        {\n            $s = self::$DB->prepare(\n                'UPDATE csnodupes SET time = :time WHERE ids_hash = :ids_hash'\n            );\n            $s->bindParam(':time', $curTime);\n            $s->bindParam(':ids_hash', $ids_hash);\n            $s->execute();\n        }\n        else\n        {\n            $s = self::$DB->prepare(\n                'INSERT INTO csnodupes (ids_hash, time)\n                 VALUES( :ids_hash, :time )'\n            );\n            $s->bindParam(':time', $curTime);\n            $s->bindParam(':ids_hash', $ids_hash);\n            $s->execute();\n        }\n    }\n    \n    private static function CountHit($pageID, $unique)\n    {\n        $q = self::$DB->prepare(\n            'UPDATE cshits SET hitcount = hitcount + 1 ' .\n            'WHERE pageid = :pageid AND isunique = :isunique'\n        );\n        $q->bindParam(':pageid', $pageID);\n        $unique = $unique ? '1' : '0';\n        $q->bindParam(':isunique', $unique);\n        $q->execute();\n    }\n    \n    private static function IDHash($pageID)\n    {\n        $visitorID = $_SERVER['REMOTE_ADDR'];\n        return hash(\"SHA256\", $pageID . $visitorID);\n    }\n    \n    private static function CreateCountsIfNotPresent($pageID)\n    {\n        // Non-unique\n        $q = self::$DB->prepare(\n            'SELECT pageid FROM cshits WHERE pageid = :pageid AND isunique = 0'\n        );\n        $q->bindParam(':pageid', $pageID);\n        $q->execute();\n\n        if($q->fetch() === false)\n        {\n            $s = self::$DB->prepare(\n                'INSERT INTO cshits (pageid, isunique, hitcount) \n                 VALUES (:pageid, 0, 0)'\n            );\n            $s->bindParam(':pageid', $pageID);\n            $s->execute();\n        }\n\n        // Unique\n        $q = self::$DB->prepare(\n            'SELECT pageid FROM cshits WHERE pageid = :pageid AND isunique = 1'\n        );\n        $q->bindParam(':pageid', $pageID);\n        $q->execute();\n\n        if($q->fetch() === false)\n        {\n            $s = self::$DB->prepare(\n                'INSERT INTO cshits (pageid, isunique, hitcount) \n                 VALUES (:pageid, 1, 0)'\n            );\n            $s->bindParam(':pageid', $pageID);\n            $s->execute();\n        }\n    }\n    \n    private static function Cleanup()\n    {\n        $last_interval = time() - self::HIT_OLD_AFTER_SECONDS;\n\n        $q = self::$DB->prepare(\n            'DELETE FROM csnodupes WHERE time < :time'\n        );\n        $q->bindParam(':time', $last_interval);\n        $q->execute();\n    }\n}\n"
  },
  {
    "path": "src/libs/recaptchalib.php",
    "content": "<?php\n/*\n * This is a PHP library that handles calling reCAPTCHA.\n *    - Documentation and latest version\n *          http://recaptcha.net/plugins/php/\n *    - Get a reCAPTCHA API Key\n *          https://www.google.com/recaptcha/admin/create\n *    - Discussion group\n *          http://groups.google.com/group/recaptcha\n *\n * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net\n * AUTHORS:\n *   Mike Crawford\n *   Ben Maurer\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * The reCAPTCHA server URL's\n */\ndefine(\"RECAPTCHA_API_SERVER\", \"http://www.google.com/recaptcha/api\");\ndefine(\"RECAPTCHA_API_SECURE_SERVER\", \"https://www.google.com/recaptcha/api\");\ndefine(\"RECAPTCHA_VERIFY_SERVER\", \"www.google.com\");\n\n/**\n * Encodes the given data into a query string format\n * @param $data - array of string elements to be encoded\n * @return string - encoded request\n */\nfunction _recaptcha_qsencode ($data) {\n        $req = \"\";\n        foreach ( $data as $key => $value )\n                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';\n\n        // Cut the last '&'\n        $req=substr($req,0,strlen($req)-1);\n        return $req;\n}\n\n\n\n/**\n * Submits an HTTP POST to a reCAPTCHA server\n * @param string $host\n * @param string $path\n * @param array $data\n * @param int port\n * @return array response\n */\nfunction _recaptcha_http_post($host, $path, $data, $port = 80) {\n\n        $req = _recaptcha_qsencode ($data);\n\n        $http_request  = \"POST $path HTTP/1.0\\r\\n\";\n        $http_request .= \"Host: $host\\r\\n\";\n        $http_request .= \"Content-Type: application/x-www-form-urlencoded;\\r\\n\";\n        $http_request .= \"Content-Length: \" . strlen($req) . \"\\r\\n\";\n        $http_request .= \"User-Agent: reCAPTCHA/PHP\\r\\n\";\n        $http_request .= \"\\r\\n\";\n        $http_request .= $req;\n\n        $response = '';\n        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {\n                die ('Could not open socket');\n        }\n\n        fwrite($fs, $http_request);\n\n        while ( !feof($fs) )\n                $response .= fgets($fs, 1160); // One TCP-IP packet\n        fclose($fs);\n        $response = explode(\"\\r\\n\\r\\n\", $response, 2);\n\n        return $response;\n}\n\n\n\n/**\n * Gets the challenge HTML (javascript and non-javascript version).\n * This is called from the browser, and the resulting reCAPTCHA HTML widget\n * is embedded within the HTML form it was called from.\n * @param string $pubkey A public key for reCAPTCHA\n * @param string $error The error given by reCAPTCHA (optional, default is null)\n * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)\n\n * @return string - The HTML to be embedded in the user's form.\n */\nfunction recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)\n{\n\tif ($pubkey == null || $pubkey == '') {\n\t\tdie (\"To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>\");\n\t}\n\t\n\tif ($use_ssl) {\n                $server = RECAPTCHA_API_SECURE_SERVER;\n        } else {\n                $server = RECAPTCHA_API_SERVER;\n        }\n\n        $errorpart = \"\";\n        if ($error) {\n           $errorpart = \"&amp;error=\" . $error;\n        }\n        return '<script type=\"text/javascript\" src=\"'. $server . '/challenge?k=' . $pubkey . $errorpart . '\"></script>\n\n\t<noscript>\n        <div style=\"background-color: white; border: solid black 3px; margin: 20px;\">\n  \t\t<iframe src=\"'. $server . '/noscript?k=' . $pubkey . $errorpart . '\" height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br/>\n  \t\t<textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\"></textarea>\n  \t\t<input type=\"hidden\" name=\"recaptcha_response_field\" value=\"manual_challenge\"/>\n        </div>\n\t</noscript>';\n}\n\n\n\n\n/**\n * A ReCaptchaResponse is returned from recaptcha_check_answer()\n */\nclass ReCaptchaResponse {\n        var $is_valid;\n        var $error;\n}\n\n\n/**\n  * Calls an HTTP POST function to verify if the user's guess was correct\n  * @param string $privkey\n  * @param string $remoteip\n  * @param string $challenge\n  * @param string $response\n  * @param array $extra_params an array of extra variables to post to the server\n  * @return ReCaptchaResponse\n  */\nfunction recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())\n{\n\tif ($privkey == null || $privkey == '') {\n\t\tdie (\"To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>\");\n\t}\n\n\tif ($remoteip == null || $remoteip == '') {\n\t\tdie (\"For security reasons, you must pass the remote ip to reCAPTCHA\");\n\t}\n\n\t\n\t\n        //discard spam submissions\n        if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {\n                $recaptcha_response = new ReCaptchaResponse();\n                $recaptcha_response->is_valid = false;\n                $recaptcha_response->error = 'incorrect-captcha-sol';\n                return $recaptcha_response;\n        }\n\n        $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, \"/recaptcha/api/verify\",\n                                          array (\n                                                 'privatekey' => $privkey,\n                                                 'remoteip' => $remoteip,\n                                                 'challenge' => $challenge,\n                                                 'response' => $response\n                                                 ) + $extra_params\n                                          );\n\n        $answers = explode (\"\\n\", $response [1]);\n        $recaptcha_response = new ReCaptchaResponse();\n\n        if (trim ($answers [0]) == 'true') {\n                $recaptcha_response->is_valid = true;\n        }\n        else {\n                $recaptcha_response->is_valid = false;\n                $recaptcha_response->error = $answers [1];\n        }\n        return $recaptcha_response;\n\n}\n\n/**\n * gets a URL where the user can sign up for reCAPTCHA. If your application\n * has a configuration page where you enter a key, you should provide a link\n * using this function.\n * @param string $domain The domain where the page is hosted\n * @param string $appname The name of your application\n */\nfunction recaptcha_get_signup_url ($domain = null, $appname = null) {\n\treturn \"https://www.google.com/recaptcha/admin/create?\" .  _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));\n}\n\nfunction _recaptcha_aes_pad($val) {\n\t$block_size = 16;\n\t$numpad = $block_size - (strlen ($val) % $block_size);\n\treturn str_pad($val, strlen ($val) + $numpad, chr($numpad));\n}\n\n/* Mailhide related code */\n\nfunction _recaptcha_aes_encrypt($val,$ky) {\n\tif (! function_exists (\"mcrypt_encrypt\")) {\n\t\tdie (\"To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.\");\n\t}\n\t$mode=MCRYPT_MODE_CBC;   \n\t$enc=MCRYPT_RIJNDAEL_128;\n\t$val=_recaptcha_aes_pad($val);\n\treturn mcrypt_encrypt($enc, $ky, $val, $mode, \"\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\");\n}\n\n\nfunction _recaptcha_mailhide_urlbase64 ($x) {\n\treturn strtr(base64_encode ($x), '+/', '-_');\n}\n\n/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */\nfunction recaptcha_mailhide_url($pubkey, $privkey, $email) {\n\tif ($pubkey == '' || $pubkey == null || $privkey == \"\" || $privkey == null) {\n\t\tdie (\"To use reCAPTCHA Mailhide, you have to sign up for a public and private key, \" .\n\t\t     \"you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>\");\n\t}\n\t\n\n\t$ky = pack('H*', $privkey);\n\t$cryptmail = _recaptcha_aes_encrypt ($email, $ky);\n\t\n\treturn \"http://www.google.com/recaptcha/mailhide/d?k=\" . $pubkey . \"&c=\" . _recaptcha_mailhide_urlbase64 ($cryptmail);\n}\n\n/**\n * gets the parts of the email to expose to the user.\n * eg, given johndoe@example,com return [\"john\", \"example.com\"].\n * the email is then displayed as john...@example.com\n */\nfunction _recaptcha_mailhide_email_parts ($email) {\n\t$arr = preg_split(\"/@/\", $email );\n\n\tif (strlen ($arr[0]) <= 4) {\n\t\t$arr[0] = substr ($arr[0], 0, 1);\n\t} else if (strlen ($arr[0]) <= 6) {\n\t\t$arr[0] = substr ($arr[0], 0, 3);\n\t} else {\n\t\t$arr[0] = substr ($arr[0], 0, 4);\n\t}\n\treturn $arr;\n}\n\n/**\n * Gets html to display an email address given a public an private key.\n * to get a key, go to:\n *\n * http://www.google.com/recaptcha/mailhide/apikey\n */\nfunction recaptcha_mailhide_html($pubkey, $privkey, $email) {\n\t$emailparts = _recaptcha_mailhide_email_parts ($email);\n\t$url = recaptcha_mailhide_url ($pubkey, $privkey, $email);\n\t\n\treturn htmlentities($emailparts[0]) . \"<a href='\" . htmlentities ($url) .\n\t\t\"' onclick=\\\"window.open('\" . htmlentities ($url) . \"', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\\\" title=\\\"Reveal this e-mail address\\\">...</a>@\" . htmlentities ($emailparts [1]);\n\n}\n\n\n?>\n"
  },
  {
    "path": "src/pages/404.php",
    "content": "<div style=\"text-align:center;\">\n<span style=\"font-size: 36pt;\">Oops!</span><br />\n<span style=\"font-size: 26pt;\">This page does not exist.</span> <br /><br /><br /><br />\n<img src=\"/images/divzero.png\" /> <br /><br /><br /><br />\n<span style=\"font-size: 14pt; color: #888888;\">(ERROR 404)</span>\n</div>\n"
  },
  {
    "path": "src/pages/aboutus.php",
    "content": "<div class=\"box\">\n<div class=\"padding\">\n<h1>About CrackStation</h1>\n\n<p>\nCrackStation is a security awareness project started by <a href=\"https://defuse.ca/\">Defuse\nSecurity</a>. Its purpose is to raise awareness about insecure password storage in web\napplications, and to provide guidance to implementors of user authentication systems. By making\nlarge hash lookup tables freely available to the public, we make it easier for security researchers\nto demonstrate why password storage solutions, like non-salted hashing, are insecure.\n</p>\n\n<p>\nWhile CrackStation does provide paid services, its goal is not to make a profit. The money is used\nto pay for the hardware required to run CrackStation, and any left-overs go toward other security\nresearch projects (the results of which are released into the public domain). You may support\nCrackStation and other Defuse Security projects by donating using the PayPal donate button\nabove.\n</p>\n\n<p>\nIf you have any questions, comments, or concerns about CrackStation, or would like help implementing\nsecure password storage in an authentication system, please contact us. You can find\nour contact information on the <a href=\"/contact-us.htm\">Contact Information Page</a>.\n</p>\n\n</div>\n</div>\n"
  },
  {
    "path": "src/pages/buy-crackstation-wordlist-cracking-dictionary.php",
    "content": "<h1>CrackStation's Password Cracking Dictionary</h1>\n\n<p>\nI am releasing CrackStation's main password cracking dictionary (1,493,677,782\nwords, 15GB) for download.\n</p>\n\n<h2>What's in the list?</h2>\n\n<p>\nThe list contains every wordlist, dictionary, and password database leak that\nI could find on the internet (and I spent a LOT of time looking). It also\ncontains every word in the Wikipedia databases (pages-articles, retrieved 2010,\nall languages) as well as lots of books from <a\nhref=\"http://www.gutenberg.org/\">Project Gutenberg</a>. It also includes the\npasswords from some low-profile database breaches that were being sold in the\nunderground years ago.\n</p>\n\n<p>\nThe format of the list is a standard text file sorted in non-case-sensitive\nalphabetical order. Lines are separated with a newline \"\\n\" character.\n</p>\n\n<p>\nYou can test the list without downloading it by giving SHA256 hashes to the <a\nhref=\"/\">free hash cracker</a>. Here's a <a\nhref=\"https://defuse.ca/checksums.htm\"> tool for computing hashes easily</a>.\nHere are the results of cracking <a\nhref=\"https://defuse.ca/blog/cracking-linkedin-hashes-with-crackstation\">LinkedIn's</a>\nand <a\nhref=\"https://defuse.ca/blog/cracking-eharmonys-unsalted-hashes-with-crackstation\">\neHarmony's</a> password hash leaks with the list.\n</p>\n\n<p>\nThe list is responsible for\ncracking about 30% of all hashes given to CrackStation's free hash cracker, but\nthat figure should be taken with a grain of salt because some people try hashes\nof really weak passwords just to test the service, and others try to crack their\nhashes with other online hash crackers before finding CrackStation. Using the\nlist, we were able to crack 49.98% of one customer's set of 373,000\nhuman password hashes to motivate their move to a better salting scheme.\n</p>\n\n<h2>Download</h2>\n\n<p>\n<b>Note:</b> To download the torrents, you will need a torrent client like\nTransmission (for Linux and Mac), or uTorrent for Windows.\n</p>\n\n<div style=\"text-align: center;\">\n    <a class=\"wldl\" href=\"/downloads/crackstation.txt.gz.torrent\">\n        <span style=\"font-size: 20pt;\">Torrent (Fast)</span>\n        <br />\n        GZIP-compressed (level 9). 4.2 GiB compressed. 15 GiB uncompressed.\n    </a>\n    <br /><br />\n    <a class=\"wldl\" href=\"/files/crackstation.txt.gz\">\n        <span style=\"font-size: 16pt;\">HTTP Mirror (Slow)</span>\n    </a>\n</div>\n\n<h4>Checksums (crackstation.txt.gz)</h4>\n\n<pre>\nMD5:    4748a72706ff934a17662446862ca4f8\nSHA1:   efa3f5ecbfba03df523418a70871ec59757b6d3f\nSHA256: a6dc17d27d0a34f57c989741acdd485b8aee45a6e9796daf8c9435370dc61612\n</pre>\n\n<a name=\"humanpasswords\"></a>\n<h3>Smaller Wordlist (Human Passwords Only)</h3>\n\n<p>\nI got some requests for a wordlist with just the \"real human\" passwords leaked\nfrom various website databases. This smaller list contains just those passwords.\nThere are about 64 million passwords in this list!\n</p>\n\n<div style=\"text-align: center;\">\n    <a class=\"wldl\" href=\"/downloads/crackstation-human-only.txt.gz.torrent\">\n        <span style=\"font-size: 20pt;\">Torrent (Fast)</span>\n        <br />\n        GZIP-compressed. 247 MiB compressed. 684 MiB uncompressed.\n    </a>\n    <br /><br />\n    <a class=\"wldl\" href=\"/files/crackstation-human-only.txt.gz\">\n        <span style=\"font-size: 16pt;\">HTTP Mirror (Slow)</span>\n    </a>\n    <br />\n</div>\n\n<h4>Checksums (crackstation-human-only.txt.gz)</h4>\n\n<pre>\nMD5:    fbc3ca43230086857aac9b71b588a574\nSHA1:   116c5f60b50e80681842b5716be23951925e5ad3\nSHA256: 201f8815c71a47d39775304aa422a505fc4cca18493cfaf5a76e608a72920267\n</pre>\n\n<h3>Sharing and Licensing</h3>\n\n<div style=\"text-align: center;\">\n<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/deed.en_US\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"/images/cc-by-sa-big.png\" /></a>.\n</div>\n\n<p>\nYou <em>are</em> allowed to share these lists! They are both licensed under\nthe <a href=\"http://creativecommons.org/licenses/by-sa/3.0/deed.en_US\">Creative\nCommons Attribution-ShareAlike 3.0</a> license. If you do share them, I would\nappreciate it if you included a link to this page.\n</p>\n\n"
  },
  {
    "path": "src/pages/contactus.php",
    "content": "<div class=\"box\">\n<div class=\"padding\">\n<h1>Contacting CrackStation</h1>\n\n<p>\nIf you purchased the wordlist and it isn't working for you, or otherwise need\nsupport with the website, or just want to provide feedback, please email me. You\ncan find my contact information\n<a href=\"https://defuse.ca/contact.htm\">here</a>.\n</p>\n\n</div>\n</div>\n"
  },
  {
    "path": "src/pages/downloads.php",
    "content": "<h3>HashDB</h3>\n\n<h3>PHP Cracking Script</h3>\n\n<h3>Waterfall</h3>\n\n<h3>Wordlists</h3>\n\n"
  },
  {
    "path": "src/pages/hashing-security-draft.php",
    "content": "<h1>How to Store Passwords</h1>\n\n<p>\nThis article will walk you through the design of a secure password storage\nsystem. Along the way, we'll encounter many common mistakes, and for each\nmistake, we'll understand why it's a mistake and how to fix it.\n</p>\n\n<div style=\"background-color: #FFCCCC; border: solid red 1px; padding: 10px;\">\n<strong>IMPORTANT WARNING:</strong> If you are thinking of writing your own\npassword hashing code, <strong>please don't!</strong>. It's too easy to screw\nup. No, that cryptography course you took in university doesn't make you exempt\nfrom this warning. This applies to everyone: <strong>DO NOT WRITE YOUR OWN\nCRYPTO!</strong> The problem of storing passwords has already been solved. Use either use either <a\nhref=\"http://www.openwall.com/phpass/\">phpass</a> or the source code given on\nthis page.\n</div>\n\n<p>\nIf for some reason you missed that big red warning note, please go read it now.\nReally, this guide is <b>not</b> meant to walk you through the process of\nwriting your own storage system, it's to explain the reasons why passwords\nshould be stored a certain way.\n</p>\n\n<p>\nWith that in mind, we can begin. To understand password storage, we will start\nwith an insecure system and iteratively improve it until it is secure. At each\niteration, we'll see how an attacker can take advantage of the vulnerability,\nand how we as defenders can make the attacker's job harder.\n</p>\n\n<p>\nFor concreteness, we'll use a standard web site login system as an\nexample. \n</p>\n\n<h2>Weak System #1: Plain Text Storage</h2>\n\n<p>\nThe most obvious way to store passwords is to just put them straight into the\ndatabase without any kind of encryption or hashing. Obviously, this is\na horrible idea, since if an attacker gains access to your database, they will\nhave all of your users' passwords, and you'll be in PR hell trying to win back\nyour users' trust.\n</p>\n\n<p>\nWorse, if attackers know you're storing passwords in plain text, they will\ntarget you, because password databases are valuable and can be sold on the black\nmarket.\n</p>\n\n<p>\nIt's a huge risk, not just to you, but to your users too. It's very common for\npeople to re-use the same password on multiple websites. If your website exposes\na user's password to an attacker, that attacker might be able to use it to log\nin to the user's account on another website. You might be tempted to blame the\nuser for re-using their password, but if you had protected the passwords, the\nuser wouldn't be at risk, so it <em>is</em> partly your responsibility.\n</p>\n\n<p>\nAnother problem you'll have, if you store passwords in plain text, is that when\nyou get hacked, it will be nearly impossible to give your users a secure way to\nreclaim their account, even after you've fixed the vulnerability. Once the\nattacker has all of the passwords, they can log in to any accounts they're\ninterested in, set new passwords, and have permanent access to the accounts.\nProtecting the password database buys you a little bit of time to tell your\nusers that they need to change their password.\n</p>\n\n<h2>Weak System #2: Encryption</h2>\n\n<p>\nThe next obvious step is to encrypt passwords with symmetric encryption. As\nwe'll see, this turns out to be a bad idea.\n</p>\n\n<p>\nSymmetric encryption works by using a random key to encrypt some data. The\nencrypted data is called the ciphertext. To turn the ciphertext back into the\noriginal data, you need to know the key that it was encrypted with. Without the\nkey, you can't decrypt the ciphertext.\n</p>\n\n<p>\nYou might think encrypting passwords would be a good idea. It's not, because\nwhere do you store the key? The server that creates user accounts and verifies\nusernames and passwords has to have access to it. So, chances are, if an\nattacker can get the encrypted password database, they'll be able to get the\nencryption key, and will be able to decrypt all of the passwords.\n</p>\n\n<h2>Weak System #3: Hashing Without Salt</h2>\n\n<p>\nTo move on to a more secure design, we need to realize that to verify\na password, you don't actually need to know the correct password. It is possible\nto compute the \"fingerprint\" of a password, with the following properties:\n</p>\n\n<ul>\n    <li>It's very unlikely for two different passwords to have the same fingerprint.</li>\n    <li>It's hard to \"reverse\" the fingerprint back into the password.</li>\n</ul>\n\n<p>\nThis can be done with a cryptographic hash function like SHA256. These functions\ncompute a fixed-length fingerprint from a variable-length input. They have the\nproperties we want: It's hard to find two inputs that hash to the same value,\nand given an output, it's very difficult to find the input.\n</p>\n\n<p>\nHere are some example SHA256 hashes. You can see that even if the input only\nchanges by one letter, the output looks completely different.\n</p>\n\n<div class=\"passcrack\" style=\"text-align: center;\">\nhash(\"hello\") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />\nhash(\"hbllo\") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366<br />\nhash(\"waltz\") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542<br />\n</div>\n\n<p>\nWe can use a function like this to protect passwords. Instead of storing the\npassword in plain text, or encrypting the password, we can store the hash of the\npassword. Then, when a user logs in, we hash the password they've given us and\ncompare it to the hash that's saved in the database. Because the chance of two\npasswords producing the same hash is extremely low (one of the properties of\na hash function), the chance of someone getting in with the wrong password is\nalso extremely low.\n</p>\n\n<p>\nYou might think we can stop here. In fact, we can't, because storing passwords\nthis way is insecure. \n</p>\n\n<p>\nTo see why, consider what happens when two users have the same password: the\nhashes are the same! An attacker can tell, just by comparing the hashes, which\nusers are using the same password. Clearly this is a vulnerability, since if the\nattacker wants to get in to Alice's account, and sees that Bob has the same\npassword, the attacker can bribe (or torture) Bob for <em>his</em> password to\nget into <em>Alice's</em> account.\n</p>\n\n<p>\nThat's not the only reason. Another reason is that the same password always\nhashes to the same value. There's a one-to-one correspondence between hashes and\npasswords. This means that an attacker can <b>pre-compute</b> huge tables of\nhashes, then search for the hash they want to crack in that table. Because the\nsearch can be done <a href=\"https://en.wikipedia.org/wiki/Binary_search_algorithm\">very quickly</a>, cracking hashes this way is a lot faster than\ntrying to guess the password for each hash.\n</p>\n\n<p>\nTo see how fast it can be, copy and paste these SHA256 hashes into <a href=\"https://crackstation.net/\">CrackStation's Hash Cracker</a>:\n</p>\n\n<div class=\"passcrack\" style=\"text-align: center;\">\nc11083b4b0a7743af748c85d343dfee9fbb8b2576c05f3a7f0d632b0926aadfc<br />\n08eac03b80adc33dc7d8fbe44b7c7b05d3a2c511166bdb43fcb710b03ba919e7<br />\ne4ba5cbd251c98e6cd1c23f126a3b81d8d8328abc95387229850952b3ef9f904<br />\n5206b8b8a996cf5320cb12ca91c7b790fba9f030408efe83ebb83548dc3007bd<br />\n</div>\n\n<p>\nThe result is that all four hashes can be cracked in under a second. This is\nobviously much faster than trying to guess each hash's password one by one.\nUsing this technique, an attacker can crack most of the hashes in your user\naccount database in a matter of minutes.\n</p>\n\n<p>\nThese password cracking databases are very real, and are used by attackers all\nthe time. One special type, called a \"<a href=\"https://en.wikipedia.org/wiki/Rainbow_table\">Rainbow Table</a>\", can fit the MD5 hashes of\nall possible 8 character passwords into a <a\nhref=\"https://www.freerainbowtables.com/en/tables2/\">1049 GB file</a> that can be\ndownloaded from the Internet.\n</p>\n\n<h2>Weak System #4: Hashing With Salt</h2>\n\n<p>\nThe attacks we saw in the previous section were possible because every time the\nsame password was hashed, the result was the same. This let attackers see who\nwas using the same password, and let them build a huge database of hashes that\ncould be quickly searched to find the password for a given hash.\n</p>\n\n<p>\nTo prevent these attacks, we need to make sure that even if two users use the\nsame password, or if one user uses the same password twice, the hash values are\nalways different. This is done by adding some randomness to the hashing process.\n</p>\n\n<p>\nTo hash a password, we use a cryptographically secure pseudo-random number\ngenerator (CSPRNG) to generate a random string, called a <b>salt</b>, which we\nprepend to the password before hashing it. We then save that random number with\nthe hash, since we'll need to verify passwords against the hash.\n</p>\n\n<p>\nHere's what it looks like in pseudocode. The double bar symbol \"A || B\" means\nconcatenate the string A with the string B.\n</p>\n\n<div class=\"passcrack\">\n<pre>\n# When a new account is created, or a user changes their password.\ncreate_hash(PASSWORD):\n    Generate a random string SALT with a CSPRNG.\n    HASH = sha256(SALT || PASSWORD).\n    return (SALT, HASH).\n\n\n# When a user tries to log in.\ncheck_password((SALT, HASH), PASSWORD_GUESS):\n    GUESS_HASH = sha256(SALT || PASSWORD_GUESS).\n    if GUESS_HASH equals HASH:\n        return TRUE.\n    else:\n        return FALSE.\n</pre>\n</div>\n\n<p>\nAssuming the salt is long enough, always generated with a CSPRNG, and no salt is\never used to hash more than one password, the attacks of the previous section\nare no longer possible. The only way to crack these hashes is to test password\nguesses for each hash individually. However, <b>this is still not good enough!</b>\n</p>\n\n<p>\nHash functions like SHA256 were designed to be fast. Good CPUs can compute\nmillions of SHA256 hashes per second, and good GPUs (graphics processors) can\ncompute <a href=\"http://www.zdnet.com/25-gpus-devour-password-hashes-at-up-to-348-billion-per-second-7000008368/\"><b>billions</b> of hashes per second</a>. Customized hardware (FPGAs and\nASICs) can reach even higher speeds. This is exactly the opposite of what we\nwant, since it means an attacker who stole the user account database can crack\nthe hashes a rate of billions of password guesses per second. Not good.\n</p>\n\n<p>\nThis is the last hurdle in the race. Once we pass it, we'll finally arrive at\na secure password storage system.\n</p>\n\n\n<h2>Secure System #1: Slow Hashing</h2>\n\n<p>\nIn the previous section, we added salt to our passwords to prevent\npre-computation attacks. We then saw that hash functions like SHA256 can be\ncomputed extremely quickly by GPUs and custom hardware, letting attackers test\nbillions of passwords per second.\n</p>\n\n<p>\nPassword hashing functions don't need to be that fast. You probably won't be\nhandling millions of authentication requests per second from one server, so\nthere's no reason an authentication server will ever need to compute millions of\nhashes per second. It's alright if the password hashing process is 1,000 times\nor even 1,000,000 times slower than a regular hash function. To make things\nharder for GPUs and custom hardware, <b>we also want the hashing process to need\nlots of memory</b>.\n</p>\n\n<p>\nIt's not enough to add a call to <kbd>sleep()</kbd> or a time-consuming \"no op\"\nloop into the password hashing code. An attacker can remove it and compute\nhashes as fast as they want. Instead, the hashing function has to be truly hard\nto compute. There should be no way to compute it any faster or with less memory.\nMore correctly stated, there should be no way to reduce the overall <kbd>time\n* area</kbd> needed to compute the function, where \"area\" means the size of the\ncircuit you need to compute the hash in a given amount of time.\n</p>\n\n<p>\nWe want the defender's (password authenticator's) implementation of the function\nto be as optimal as possible. This is important, since if the defender is taking\n10x longer to compute the function, the attacker, using a 10x more efficient\nimplementation, has an advantage over the defender. That means these functions\nshould be implemented in native code (assembly language or C/C++), and not in\na scripting language.\n</p>\n\n<p>\nResearchers are still figuring out how to best design these slow hashes. There's\na competition going on right now, called the <a\nhref=\"https://password-hashing.net/\">Password Hashing Competition (PHC)</a>,  to find\nthe best one. It's similar in nature to the <a\nhref=\"https://en.wikipedia.org/wiki/Advanced_Encryption_Standard_process\">competition\nthat selected the AES cipher</a>. Even though the competition hasn't finished\nyet, we already have some slow hash functions that we think are good, and are in\ncommon use. These are: <a href=\"https://www.tarsnap.com/scrypt/scrypt.pdf\">scrypt</a>,\n<a href=\"https://en.wikipedia.org/wiki/Bcrypt\">bcrypt</a>, and\n<a href=\"https://en.wikipedia.org/wiki/PBKDF2\">PBKDF2</a>.\n</p>\n\n<p>\nIf you want to know more about how slow hashes are designed, read the <a\nhref=\"https://www.tarsnap.com/scrypt/scrypt.pdf\">Scrypt paper</a> and the <a\nhref=\"http://eprint.iacr.org/2013/525.pdf\">Catena paper</a>. You should also\njoin and read the <a href=\"https://password-hashing.net/interaction.html\">PHC\nmailing list</a>, since research in this area is evolving quickly! Whatever you\ndo, <b>do not try to design and use your own slow hash function</b>. Stick to\nthe ones that already exist and have been used for a while. Feel free to design\n(and break) your own as a learning exercise, but for crying out loud, don't use\nit.\n</p>\n\n<p>\nSo, if we choose scrypt as our slow hash, we can store passwords securely like\nthis. It's the same as before, except we're using scrypt instead of SHA256.\n</p>\n\n<div class=\"passcrack\">\n<pre>\n# When a new account is created, or a user changes their password.\ncreate_hash(PASSWORD):\n    Generate a random string SALT with a CSPRNG.\n    HASH = scrypt(SALT, PASSWORD).\n    return (SALT, HASH).\n\n\n# When a user tries to log in.\ncheck_password((SALT, HASH), PASSWORD_GUESS):\n    GUESS_HASH = scrypt(SALT, PASSWORD_GUESS).\n    if GUESS_HASH equals HASH:\n        return TRUE.\n    else:\n        return FALSE.\n</pre>\n</div>\n\n<p>\n- want defender to be optimized\n- the functions are parameterized (take time and memory parameters)\n- summarry like \"we've mitigated pre-computation attacks as well as made it\nextremely difficult for GPUs or whatever\"\n</p>\n\n<pre>\n     - Weak passwords can still be found .. intro next section with\n       security-by-obscurity key.\n     - AKA key stretching,\n    - Offloading to the client (sjcl) -- does not remove need for server hashing\n    - Re-read old post since this is missing some stuff that was covered in it\n</pre>\n\n<p>\nEven with the salt and slow hashing, weak passwords can still be cracked.\nIn the next section, we'll see how, with the help of some special hardware, we\ncan protect our hashes so that even the weak ones can't be cracked.\n</p>\n\n<h2>Increasing Security: Hardware Security Modules</h2>\n\n<pre>\n    - Use hardware device with embedded key to do the hashing, so that unless\n      it's physically stolen and tampered with, the passwords are really safe.\n    - Also possible to do w/o custom hardware... just set up dedicated password\n      authentication box that does nothing but hash passwords; no services, etc.\n    - Mandatory for websites with more than 100k users.\n    - Cloud options? (amazon thing)?\n    - Physical options? (yubihsm?)\n</pre>\n\n<h2>Common Mistakes</h2>\n\n<p>\nBe on the lookout for these common password hashing mistakes.\n</p>\n\n<h3>Salt Reuse</h3>\n\n<h3>Short Salts</h3>\n\n<h3>Generating Salts with a Weak Random Number Generator</h3>\n\n<h2>Frequently Asked Questions</h2>\n\n<pre>\n    - Basically the same list of FAQ from the original article except emphasize\n        slow hashing.\n\n     - In \"what to do when\" section... \"don't clutter up the notice message with\nall the crap about salt and hashing and scrypt, they won't understand. Just tell\nthem to change their password if they used it anywhere else etc. But do publish\nthe information about hashing, just don't make it distracting or give a false\nsense of security.\"\n</pre>\n\n<h2>Source Code</h2>\n\n<pre>\n    - Embed the source code here.\n    - Putting the source code way down here might make people miss it, so add\n      prominent links up at the top (not just in the red warning box).\n</pre>\n"
  },
  {
    "path": "src/pages/hashing-security.php",
    "content": "<h1>Salted Password Hashing - Doing it Right</h1>\n\n<p>\nIf you're a web developer, you've probably had to make a user account system.\nThe most important aspect of a user account system is how user passwords are\nprotected. User account databases are hacked frequently, so you absolutely must\ndo something to protect your users' passwords if your website is ever breached.\nThe best way to protect passwords is to employ <b>salted password hashing</b>.\nThis page will explain why it's done the way it is.\n</p>\n\n<p>\nThere are a lot of conflicting ideas and misconceptions on how to do password\nhashing properly, probably due to the abundance of misinformation on the web.\nPassword hashing is one of those things that's so simple, but yet so many people\nget wrong. With this page, I hope to explain not only the correct way to do it,\nbut why it should be done that way.\n</p>\n\n\n<div style=\"background-color: #FFCCCC; border: solid red 1px; padding: 10px;\">\n<strong>IMPORTANT WARNING:</strong> If you are thinking of writing your own\npassword hashing code, <strong>please don't!</strong>. It's too easy to screw\nup. No, that cryptography course you took in university doesn't make you exempt\nfrom this warning. This applies to everyone: <strong>DO NOT WRITE YOUR OWN\nCRYPTO!</strong> The problem of storing passwords has already been solved. Use\neither use either <a href=\"http://www.openwall.com/phpass/\">phpass</a>, the PHP,\nC#, Java, and Ruby implementations in <a\nhref=\"https://github.com/defuse/password-hashing\">defuse/password-hashing</a>,\nor <a\nhref=\"https://download.libsodium.org/doc/password_hashing/index.html\">libsodium</a>.\n</div>\n\n<p>\nIf for some reason you missed that big red warning note, please go read it now.\nReally, this guide is <b>not</b> meant to walk you through the process of\nwriting your own storage system, it's to explain the reasons why passwords\nshould be stored a certain way.\n</p>\n\n<p>You may use the following links to jump to the different sections of this page.</p>\n\n<table class=\"shortcuts\">\n<tbody><tr>\n    <td><a href=\"#normalhashing\" class=\"sca\" title=\"What are hash functions and why are they used?\">1. What is password hashing?</a></td>\n    <td><a href=\"#attacks\" class=\"sca\" title=\"Methods for making hash cracking more efficient\">2. How Hashes are Cracked</a></td>\n\n    <td><a href=\"#salt\" class=\"sca\" title=\"Adding salt to render hash cracking attacks less effective\">3. Adding Salt</a></td>\n</tr>\n<tr>\n    <td><a href=\"#ineffective\" class=\"sca\" title=\"The wrong way to do password hashing\">4. Ineffective Hashing Methods</a></td>\n    <td><a href=\"#properhashing\" class=\"sca\" title=\"The right way to do password hashing, with salt\">5. How to hash properly</a></td>\n    <td><a href=\"#faq\" class=\"sca\" title=\"Frequently asked questions about password hashing and salt\">6. Frequently Asked Questions</a></td>\n</tr>\n</tbody></table>\n\n<a name=\"normalhashing\"></a>\n<h2>What is password hashing?</h2>\n        <div class=\"passcrack\" style=\"text-align: center;\">\n            hash(\"hello\") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />\n            hash(\"hbllo\") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366<br />\n            hash(\"waltz\") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542<br />\n        </div>\n<p>\nHash algorithms are one way functions. They turn any amount of data into\na fixed-length \"fingerprint\" that cannot be reversed. They also have the\nproperty that if the input changes by even a tiny bit, the resulting hash is\ncompletely different (see the example above). This is great for protecting\npasswords, because we want to store passwords in a form that protects them even\nif the password file itself is compromised, but at the same time, we need to be\nable to verify that a user's password is correct.\n</p>\n\n<p>\nThe general workflow for account registration and authentication in a hash-based\naccount system is as follows:\n</p>\n<ol class=\"moveul\">\n    <li>The user creates an account.</li>\n    <li>Their password is hashed and stored in the database. At no point is the plain-text (unencrypted) password ever written to the hard drive.</li>\n\n    <li>When the user attempts to login, the hash of the password they entered is checked against the hash of their real password (retrieved from the database).</li>\n    <li>If the hashes match, the user is granted access. If not, the user is told they entered invalid login credentials.</li>\n    <li>Steps 3 and 4 repeat every time someone tries to login to their account.</li>\n</ol>\n\n<p>\nIn step 4, never tell the user if it was the username or password they got wrong. Always display\na generic message like \"Invalid username or password.\" This prevents attackers from enumerating\nvalid usernames without knowing their passwords.\n</p>\n\n<p>\nIt should be noted that the hash functions used to protect passwords are not the\nsame as the hash functions you may have seen in a data structures course. The\nhash functions used to implement data structures such as hash tables are\ndesigned to be fast, not secure. Only <b>cryptographic hash functions</b> may be\nused to implement password hashing.  Hash functions like SHA256, SHA512, RipeMD,\nand WHIRLPOOL are cryptographic hash functions.\n</p>\n\n<p>\nIt is easy to think that all you have to do is run the password through a\ncryptographic hash function and your users' passwords will be secure. This is\nfar from the truth. There are many ways to recover passwords from plain hashes\nvery quickly. There are several easy-to-implement techniques that make these\n\"attacks\" much less effective. To motivate the need for these techniques,\nconsider this very website. On the front page, you can submit a list of hashes\nto be cracked, and receive results in less than a second. Clearly, simply\nhashing the password does not meet our needs for security.\n</p>\n\n<p>The next section will discuss some of the common attacks used to crack plain password hashes.</p>\n\n<a name=\"attacks\"></a>\n<h2>How Hashes are Cracked</h2>\n<ul class=\"moveul\" >\n<li>\n    <h3>Dictionary and Brute Force Attacks</h3>\n    <table style=\"margin: 0 auto;\">\n    <tbody><tr>\n    <td>\n    <div class=\"passcrack\" title=\"Cracking a hash with a wordlist\">\n        <center>Dictionary Attack</center><br />\n        Trying apple &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: failed<br />\n        Trying blueberry &nbsp;&nbsp;&nbsp;: failed<br />\n        Trying justinbeiber : failed<br />\n        <center>...</center>\n        Trying letmein &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: failed<br />\n\n        <span style=\"color: green;\">Trying s3cr3t &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: success!</span><br />\n    </div>\n    </td>\n    <td>\n    <div class=\"passcrack\" title=\"Cracking a hash by brute force\">\n        <center>Brute Force Attack</center><br />\n        Trying aaaa : failed<br />\n        Trying aaab : failed<br />\n        Trying aaac : failed<br />\n        <center>...</center>\n        Trying acdb : failed<br />\n        <span style=\"color: green;\">Trying acdc : success!</span><br />\n    </div>\n    </td>\n    </tr>\n    </tbody></table>\n    <p>\n    The simplest way to crack a hash is to try to guess the password, hashing each guess, and checking if the guess's hash equals the hash being cracked. If the hashes are equal, the guess is the password.\n    The two most common ways of guessing passwords are <b>dictionary attacks</b> and <b>brute-force attacks</b>.\n    </p>\n\n    <p>\n    A dictionary attack uses a file containing words, phrases, common passwords,\n    and other strings that are likely to be used as a password. Each word in the\n    file is hashed, and its hash is compared to the password hash. If they\n    match, that word is the password. These dictionary files are constructed by\n    extracting words from large bodies of text, and even from real databases of\n    passwords. Further processing is often applied to dictionary files, such as\n    replacing words with their \"leet speak\" equivalents (\"hello\" becomes\n    \"h3110\"), to make them more effective.\n    </p>\n\n    <p>\n    A brute-force attack tries every possible combination of characters up to a\n    given length. These attacks are very computationally expensive, and are\n    usually the least efficient in terms of hashes cracked per processor time,\n    but they will always eventually find the password. Passwords should be long\n    enough that searching through all possible character strings to find it will\n    take too long to be worthwhile.\n    </p>\n\n    <p>\n    There is no way to prevent dictionary attacks or brute force attacks. They\n    can be made less effective, but there isn't a way to prevent them\n    altogether. If your password hashing system is secure, the only way to crack\n    the hashes will be to run a dictionary or brute-force attack on each hash.\n    </p>\n</li>\n\n<li>\n    <h3>Lookup Tables</h3>\n    <center>\n    <div class=\"passcrack\" style=\"text-align: center;\" title=\"Cracking many hashes with a pre-computed lookup table\">\n        <span style=\"color: green;\">Searching: 5f4dcc3b5aa765d61d8327deb882cf99: FOUND: password5</span><br />\n        Searching: 6cbe615c106f422d23669b610b564800: &nbsp;not in database<br />\n        <span style=\"color: green;\">Searching: 630bf032efe4507f2c57b280995925a9: FOUND: letMEin12 </span><br />\n        <span style=\"color: green;\">Searching: 386f43fab5d096a7a66d67c8f213e5ec: FOUND: mcd0nalds</span><br />\n        <span style=\"color: green;\">Searching: d5ec75d5fe70d428685510fae36492d9: FOUND: p@ssw0rd!</span><br />\n    </span>\n    </center>\n\n    <p>\n    Lookup tables are an extremely effective method for cracking many hashes of\n    the same type very quickly. The general idea is to <b>pre-compute</b> the\n    hashes of the passwords in a password dictionary and store them, and their\n    corresponding password, in a lookup table data structure. A good\n    implementation of a lookup table can process hundreds of hash lookups per\n    second, even when they contain many billions of hashes.\n    </p>\n\n    <p>\n    If you want a better idea of how fast lookup tables can be, try cracking the\n    following sha256 hashes with CrackStation's <a href=\"/\">free hash\n    cracker</a>.\n    </p>\n\n    <div class=\"passcrack\" style=\"text-align: center;\" title=\"Example hashes to be cracked\">\n    c11083b4b0a7743af748c85d343dfee9fbb8b2576c05f3a7f0d632b0926aadfc<br />\n    08eac03b80adc33dc7d8fbe44b7c7b05d3a2c511166bdb43fcb710b03ba919e7<br />\n    e4ba5cbd251c98e6cd1c23f126a3b81d8d8328abc95387229850952b3ef9f904<br />\n    5206b8b8a996cf5320cb12ca91c7b790fba9f030408efe83ebb83548dc3007bd<br />\n    </div>\n\n</li>\n\n<li>\n    <h3>Reverse Lookup Tables</h3>\n    <center>\n    <div class=\"passcrack\" style=\"text-align: left;\" title=\"Cracking many hashes with a pre-computed lookup table\">\n        <span style=\"color: green;\">Searching for hash(apple) in users' hash list... &nbsp;&nbsp;&nbsp;&nbsp;: Matches [alice3, 0bob0, charles8]</span><br />\n        <span style=\"color: green;\">Searching for hash(blueberry) in users' hash list... : Matches [usr10101, timmy, john91]</span><br />\n        <span style=\"color: green;\">Searching for hash(letmein) in users' hash list... &nbsp;&nbsp;: Matches [wilson10, dragonslayerX, joe1984]</span><br />\n        <span style=\"color: green;\">Searching for hash(s3cr3t) in users' hash list... &nbsp;&nbsp;&nbsp;: Matches [bruce19, knuth1337, john87]</span><br />\n        <span>Searching for hash(z@29hjja) in users' hash list... &nbsp;: No users used this password</span><br />\n    </span>\n    </center>\n    <p>\n        This attack allows an attacker to apply a dictionary or brute-force attack to many hashes at the same time, without having to pre-compute a lookup table.\n    </p>\n\n    <p>\n    First, the attacker creates a lookup table that maps each password hash from\n    the compromised user account database to a list of users who had that hash.\n    The attacker then hashes each password guess and uses the lookup table to\n    get a list of users whose password was the attacker's guess. This attack is\n    especially effective because it is common for many users to have the same\n    password. \n    </p>\n</li>\n\n<li>\n    <h3>Rainbow Tables</h3>\n    <p>\n    Rainbow tables are a time-memory trade-off technique. They are like lookup\n    tables, except that they sacrifice hash cracking speed to make the lookup\n    tables smaller. Because they are smaller, the solutions to more hashes can\n    be stored in the same amount of space, making them more effective. Rainbow\n    tables that can crack any md5 hash of a password up to 8 characters long <a\n    href=\"http://www.freerainbowtables.com/en/tables2/\">exist</a>.\n    </p>\n</li>\n</ul>\n\n<p>\nNext, we'll look at a technique called salting, which makes it impossible to use\nlookup tables and rainbow tables to crack a hash.\n</p>\n\n<a name=\"salt\"></a>\n<h2>Adding Salt</h2>\n<div class=\"passcrack\" style=\"text-align: center;\" title=\"Salt example\">\n    hash(\"hello\") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />\n    hash(\"hello\" + \"QxLUF1bgIAdeQX\") = 9e209040c863f84a31e719795b2577523954739fe5ed3b58a75cff2127075ed1<br />\n\n    hash(\"hello\" + \"bv5PehSMfV11Cd\") = d1d3ec2e6f20fd420d50e2642992841d8338a314b8ea157c9e18477aaef226ab<br />\n    hash(\"hello\" + \"YYLmfY6IehjZMQ\") = a49670c3c18b9e079b9cfaf51634f563dc8ae3070db2c4a8544305df1b60f007\n</div>\n\n<p>\nLookup tables and rainbow tables only work because each password is hashed the\nexact same way. If two users have the same password, they'll have the same\npassword hashes.  We can prevent these attacks by randomizing each hash, so that\nwhen the same password is hashed twice, the hashes are not the same.\n</p>\n\n<p>\nWe can randomize the hashes by appending or prepending a random string, called a\n<b>salt</b>, to the password before hashing. As shown in the example above, this\nmakes the same password hash into a completely different string every time. To\ncheck if a password is correct, we need the salt, so it is usually stored in the\nuser account database along with the hash, or as part of the hash string itself.\n</p>\n\n<p>\nThe salt does not need to be secret. Just by randomizing the hashes, lookup\ntables, reverse lookup tables, and rainbow tables become ineffective. An\nattacker won't know in advance what the salt will be, so they can't pre-compute\na lookup table or rainbow table. If each user's password is hashed with a\ndifferent salt, the reverse lookup table attack won't work either. \n</p>\n\n<p>\nIn the next section, we'll look at how salt is commonly implemented incorrectly.\n</p>\n\n<a name=\"ineffective\"></a>\n<h2>The <span style=\"color: red;\">WRONG</span> Way: Short Salt &amp; Salt Reuse</h2>\n\n<p>\nThe most common salt implementation errors are reusing the same salt in multiple\nhashes, or using a salt that is too short.\n</p>\n\n<h3>Salt Reuse</h3>\n\n<p>\nA common mistake is to use the same salt in each hash. Either the salt is\nhard-coded into the program, or is generated randomly once. This is ineffective\nbecause if two users have the same password, they'll still have the same hash.\nAn attacker can still use a reverse lookup table attack to run a dictionary\nattack on every hash at the same time. They just have to apply the salt to each\npassword guess before they hash it. If the salt is hard-coded into a popular\nproduct, lookup tables and rainbow tables can be built for that salt, to make it\neasier to crack hashes generated by the product.\n</p>\n\n<p>\nA new random salt must be generated each time a user creates an account or changes their password.\n</p>\n\n<h3>Short Salt</h3>\n\n<p>\nIf the salt is too short, an attacker can build a lookup table for every\npossible salt. For example, if the salt is only three ASCII characters, there\nare only 95x95x95 = 857,375 possible salts. That may seem like a lot, but if\neach lookup table contains only 1MB of the most common passwords, collectively\nthey will be only 837GB, which is not a lot considering 1000GB hard drives can\nbe bought for under $100 today.\n</p>\n\n<p>\nFor the same reason, the username shouldn't be used as a salt. Usernames may be\nunique to a single service, but they are predictable and often reused for\naccounts on other services.  An attacker can build lookup tables for common\nusernames and use them to crack username-salted hashes.\n</p>\n\n<p>\nTo make it impossible for an attacker to create a lookup table for every\npossible salt, the salt must be long. A good rule of thumb is to use a salt that\nis the same size as the output of the hash function. For example, the output of\nSHA256 is 256 bits (32 bytes), so the salt should be at least 32 random bytes.\n</p>\n\n<h2>The <span style=\"color: red;\">WRONG</span> Way: Double Hashing &amp; Wacky Hash Functions</h2>\n\n<p>\nThis section covers another common password hashing misconception: wacky\ncombinations of hash algorithms. It's easy to get carried away and try to\ncombine different hash functions, hoping that the result will be more secure. In\npractice, though, there is very little benefit to doing it. All it does is\ncreate interoperability problems, and can sometimes even make the hashes less\nsecure.  Never try to invent your own crypto, always use a standard that has\nbeen designed by experts. Some will argue that using multiple hash functions\nmakes the process of computing the hash slower, so cracking is slower, but\nthere's a better way to make the cracking process slower as we'll see later.\n</p>\n\n<p>Here are some examples of poor wacky hash functions I've seen suggested in forums on the internet.</p>\n\n<ul>\n    <li><span class=\"ic\">md5(sha1(password))</span></li>\n    <li><span class=\"ic\">md5(md5(salt) + md5(password))</span></li>\n    <li><span class=\"ic\">sha1(sha1(password))</span></li>\n    <li><span class=\"ic\">sha1(str_rot13(password + salt))</span></li>\n    <li><span class=\"ic\">md5(sha1(md5(md5(password) + sha1(password)) + md5(password)))</span></li>\n</ul> \n\n<p>\nDo not use any of these.\n</p>\n\n<p>\nNote: This section has proven to be controversial. I've received a number of\nemails arguing that wacky hash functions are a good thing, because it's better\nif the attacker doesn't know which hash function is in use, it's less\nlikely for an attacker to have pre-computed a rainbow table for the wacky hash\nfunction, and it takes longer to compute the hash function.\n</p>\n\n<p>\nAn attacker cannot attack a hash when he doesn't know the algorithm, but note <a\nhref=\"https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle\"> Kerckhoffs's\nprinciple</a>, that the attacker will usually have access to the source code\n(especially if it's free or open source software), and that given a few\npassword-hash pairs from the target system, it is not difficult to reverse\nengineer the algorithm. It does take longer to compute wacky hash functions, but\nonly by a small constant factor. It's better to use an iterated algorithm that's\ndesigned to be extremely hard to parallelize (these are discussed below). And,\nproperly salting the hash solves the rainbow table problem.\n</p>\n\n<p>\nIf you really want to use a standardized &quot;wacky&quot; hash function like HMAC, then it's OK.\nBut if your reason for doing so is to make the hash computation slower, read the section below about key stretching first.\n</p>\n\n<p>\nCompare these minor benefits to the risks of accidentally implementing a\ncompletely insecure hash function and the interoperability problems wacky hashes\ncreate. It's clearly best to use a standard and well-tested algorithm.\n</p>\n\n<h2>Hash Collisions</h2>\n\n<p>\nBecause hash functions map arbitrary amounts of data to fixed-length strings,\nthere must be some inputs that hash into the same string. Cryptographic hash\nfunctions are designed to make these collisions incredibly difficult to find.\nFrom time to time, cryptographers find \"attacks\" on hash functions that make\nfinding collisions easier. A recent example is the MD5 hash function, for which\ncollisions have actually been found.\n</p>\n\n<p>\nCollision attacks are a sign that it may be more likely for a string other than\nthe user's password to have the same hash. However, finding collisions in even a\nweak hash function like MD5 requires a lot of dedicated computing power, so it\nis very unlikely that these collisions will happen \"by accident\" in practice. A\npassword hashed using MD5 and salt is, for all practical purposes, just as\nsecure as if it were hashed with SHA256 and salt. Nevertheless, it is a good\nidea to use a more secure hash function like SHA256, SHA512, RipeMD, or\nWHIRLPOOL if possible.\n</p>\n\n<a name=\"properhashing\"></a>\n<h2>The <span style=\"color: green;\">RIGHT</span> Way: How to Hash Properly</h2>\n\n<p>\nThis section describes exactly how passwords should be hashed. The first\nsubsection covers the basics&mdash;everything that is absolutely necessary. The\nfollowing subsections explain how the basics can be augmented to make the hashes\neven harder to crack.\n</p>\n\n<h3>The Basics: Hashing with Salt</h3>\n\n<p>\n<b>Warning: Do not just read this section. You absolutely must implement the\nstuff in the next section: \"Making Password Cracking Harder: Slow Hash\nFunctions\".</b>\n</p>\n\n<p>\nWe've seen how malicious hackers can crack plain hashes very quickly using\nlookup tables and rainbow tables. We've learned that randomizing the hashing\nusing salt is the solution to the problem.  But how do we generate the salt, and\nhow do we apply it to the password?\n</p>\n\n<p>\nSalt should be generated using a <b>Cryptographically Secure Pseudo-Random\nNumber Generator</b> (CSPRNG). CSPRNGs are very different than ordinary\npseudo-random number generators, like the \"C\" language's \n<span class=\"ic\">rand()</span> function.  As the name suggests, CSPRNGs are\ndesigned to be cryptographically secure, meaning they provide a high level of\nrandomness and are completely unpredictable. We don't want our salts to be\npredictable, so we must use a CSPRNG. The following table lists some CSPRNGs\nthat exist for some popular programming platforms.\n</p>\n\n<table id=\"rnglist\">\n    <tr><th>Platform</th><th>CSPRNG</th></tr>\n    <tr><td>PHP</td><td><a href=\"http://php.net/manual/en/function.mcrypt-create-iv.php\">mcrypt_create_iv</a>, <a href=\"http://php.net/manual/en/function.openssl-random-pseudo-bytes.php\">openssl_random_pseudo_bytes</a></td></tr>\n    <tr><td>Java</td><td><a href=\"http://docs.oracle.com/javase/6/docs/api/java/security/SecureRandom.html\">java.security.SecureRandom</a></td></tr>\n    <tr><td>Dot NET (C#, VB)</td><td><a href=\"http://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx\">System.Security.Cryptography.RNGCryptoServiceProvider</a></td></tr>\n    <tr><td>Ruby</td><td><a href=\"http://rubydoc.info/stdlib/securerandom/1.9.3/SecureRandom\">SecureRandom</a></td></tr>\n    <tr><td>Python</td><td><a href=\"https://docs.python.org/3/library/secrets.html\">secrets</a></td></tr>\n    <tr><td>Perl</td><td><a href=\"http://search.cpan.org/~mkanat/Math-Random-Secure-0.06/lib/Math/Random/Secure.pm\">Math::Random::Secure</a></td></tr>\n    <tr><td>C/C++ (Windows API)</td><td><a href=\"http://en.wikipedia.org/wiki/CryptGenRandom\">CryptGenRandom</a></td></tr>\n    <tr><td>Any language on GNU/Linux or Unix</td><td>Read from <a href=\"http://en.wikipedia.org/wiki//dev/random\">/dev/random</a> or /dev/urandom</td></tr>\n</table> \n\n<p> The salt needs to be unique per-user per-password. Every time a user creates an account or\nchanges their password, the password should be hashed using a new random salt. Never reuse a salt.\nThe salt also needs to be long, so that there are many possible salts. As a rule of thumb, make your\nsalt is at least as long as the hash function's output. The salt should be stored in the user\naccount table alongside the hash.  </p>\n\n<h4>To Store a Password</h4>\n\n<ol>\n    <li>Generate a long random salt using a CSPRNG.</li>\n    <li>Prepend the salt to the password and hash it with a <b>standard</b> password hashing function like Argon2, bcrypt, scrypt, or PBKDF2.</li>\n    <li>Save both the salt and the hash in the user's database record.</li>\n</ol>\n\n<h4>To Validate a Password</h4>\n\n<ol>\n    <li>Retrieve the user's salt and hash from the database.</li>\n    <li>Prepend the salt to the given password and hash it using the same hash function.</li>\n    <li>Compare the hash of the given password with the hash from the database. If they match, the password is correct. Otherwise, the password is incorrect.</li>\n</ol>\n\n\n<h4>In a Web Application, <b>always</b> hash on the server</h4>\n<p>\nIf you are writing a web application, you might wonder <em>where</em> to hash.\nShould the password be hashed in the user's browser with JavaScript, or should\nit be sent to the server \"in the clear\" and hashed there?\n</p>\n\n<p> Even if you are hashing the user's passwords in JavaScript, you still have\nto hash the hashes on the server. Consider a website that hashes users'\npasswords in the user's browser without hashing the hashes on the server. To\nauthenticate a user, this website will accept a hash from the browser and check\nif that hash exactly matches the one in the database. This seems more secure\nthan just hashing on the server, since the users' passwords are never sent to\nthe server, but it's not.  </p>\n\n<p>\nThe problem is that the client-side hash logically <em>becomes</em> the user's\npassword. All the user needs to do to authenticate is tell the server the hash\nof their password. If a bad guy got a user's <em>hash</em> they could use it to\nauthenticate to the server, without knowing the user's password! So, if the bad\nguy somehow steals the database of hashes from this hypothetical website,\nthey'll have immediate access to everyone's accounts without having to guess any\npasswords.\n</p>\n\n<p>\nThis isn't to say that you <em>shouldn't</em> hash in the browser, but if you\ndo, you absolutely have to hash on the server too. Hashing in the browser is\ncertainly a good idea, but consider the following points for your implementation:\n</p>\n\n<ul>\n    <li>\n        <p>\n        Client-side password hashing is <b>not</b> a substitute for HTTPS\n        (SSL/TLS).  If the connection between the browser and the server is\n        insecure, a man-in-the-middle can modify the JavaScript code as it is\n        downloaded to remove the hashing functionality and get the user's\n        password.\n        </p>\n    </li>\n\n    <li>\n        <p>\n        Some web browsers don't support JavaScript, and some users disable\n        JavaScript in their browser. So for maximum compatibility, your app\n        should detect whether or not the browser supports JavaScript and emulate\n        the client-side hash on the server if it doesn't.\n        </p>\n    </li>\n\n    <li>\n        <p>\n        You need to salt the client-side hashes too. The obvious solution is to\n        make the client-side script ask the server for the user's salt. Don't do\n        that, because it lets the bad guys check if a username is valid without\n        knowing the password. Since you're hashing and salting (with a good\n        salt) on the server too, it's OK to use the username (or email)\n        concatenated with a site-specific string (e.g. domain name) as the\n        client-side salt.\n        </p>\n    </li>\n</ul>\n\n<h3>Making Password Cracking Harder: Slow Hash Functions</h3>\n\n<p>\n    Salt ensures that attackers can't use specialized attacks like lookup tables\n    and rainbow tables to crack large collections of hashes quickly, but it\n    doesn't prevent them from running dictionary or brute-force attacks on each\n    hash individually. High-end graphics cards (GPUs) and custom hardware can\n    compute billions of hashes per second, so these attacks are still very\n    effective. To make these attacks less effective, we can use a technique\n    known as <b>key stretching</b>.\n</p>\n\n<p>\n    The idea is to make the hash function very slow, so that even with a fast\n    GPU or custom hardware, dictionary and brute-force attacks are too slow to\n    be worthwhile. The goal is to make the hash function slow enough to impede\n    attacks, but still fast enough to not cause a noticeable delay for the user.\n</p>\n\n<p>\n    Key stretching is implemented using a special type of CPU-intensive hash\n    function. Don't try to invent your own&ndash;simply iteratively hashing the\n    hash of the password isn't enough as it can be parallelized in hardware and\n    executed as fast as a normal hash. Use a standard algorithm like <a\n    href=\"http://en.wikipedia.org/wiki/PBKDF2\">PBKDF2</a> or <a href=\"http://en.wikipedia.org/wiki/Bcrypt\">bcrypt</a>.\n    You can find a PHP implementation of <a href=\"https://defuse.ca/php-pbkdf2.htm\">PBKDF2 here</a>.\n</p>\n\n<p>\n    These algorithms take a security factor or iteration count as an argument.\n    This value determines how slow the hash function will be. For desktop\n    software or smartphone apps, the best way to choose this parameter is to run\n    a short benchmark on the device to find the value that makes the hash take\n    about half a second. This way, your program can be as secure as possible\n    without affecting the user experience.\n</p>\n\n<p>\n    If you use a key stretching hash in a web application, be aware that you\n    will need extra computational resources to process large volumes of\n    authentication requests, and that key stretching may make it easier to run a\n    Denial of Service (DoS) attack on your website.  I still recommend using key\n    stretching, but with a lower iteration count. You should calculate the\n    iteration count based on your computational resources and the expected\n    maximum authentication request rate. The denial of service threat can be\n    eliminated by making the user solve a CAPTCHA every time they log in.\n    Always design your system so that the iteration count can be increased or\n    decreased in the future.\n</p>\n\n<p>\n    If you are worried about the computational burden, but still want to use key\n    stretching in a web application, consider running the key stretching\n    algorithm in the user's browser with JavaScript.  The <a href=\"http://crypto.stanford.edu/sjcl/\">Stanford JavaScript Crypto\n    Library</a> includes PBKDF2. The iteration count should be set low enough\n    that the system is usable with slower clients like mobile devices, and the\n    system should fall back to server-side computation if the user's browser\n    doesn't support JavaScript. Client-side key stretching does not remove the\n    need for server-side hashing. You must hash the hash generated by the client\n    the same way you would hash a normal password.\n</p>\n\n<h3>Impossible-to-crack Hashes: Keyed Hashes and Password Hashing Hardware</h3>\n\n<p>\n    As long as an attacker can use a hash to check whether a password guess is\n    right or wrong, they can run a dictionary or brute-force attack on the hash.\n    The next step is to add a <b>secret key</b> to the hash so that only someone\n    who knows the key can use the hash to validate a password. This can be\n    accomplished two ways. Either the hash can be encrypted using a cipher like\n    AES, or the secret key can be included in the hash using a keyed hash\n    algorithm like <a href=\"http://en.wikipedia.org/wiki/HMAC\">HMAC</a>.\n</p>\n\n<p>\n    This is not as easy as it sounds. The key has to be kept secret from an\n    attacker even in the event of a breach. If an attacker gains full access to\n    the system, they'll be able to steal the key no matter where it is stored.\n    The key must be stored in an external system, such as a physically separate\n    server dedicated to password validation, or a special hardware device\n    attached to the server such as the <a href=\"https://www.yubico.com/YubiHSM\">YubiHSM</a>.\n</p>\n\n<p>\n    I highly recommend this approach for any large scale (more than 100,000\n    users) service. I consider it necessary for any service hosting more than\n    1,000,000 user accounts.\n</p>\n\n<p>\n    If you can't afford multiple dedicated servers or special hardware devices,\n    you can still get some of the benefits of keyed hashes on a standard web\n    server. Most databases are breached using <a\n    href=\"http://en.wikipedia.org/wiki/SQL_injection\">SQL Injection Attacks</a>,\n    which, in most cases, don't give attackers access to the local filesystem\n    (disable local filesystem access in your SQL server if it has this feature).\n    If you generate a random key and store it in a file  that isn't accessible\n    from the web, and include it into the salted hashes, then the hashes won't\n    be vulnerable if your database is breached using a simple SQL injection\n    attack. Don't hard-code a key into the source code, generate it randomly\n    when the application is installed. This isn't as secure as using a separate\n    system to do the password hashing, because if there are SQL injection\n    vulnerabilities in a web application, there are probably other types, such\n    as Local File Inclusion, that an attacker could use to read the secret key\n    file. But, it's better than nothing.\n</p>\n\n<p>\n    Please note that keyed hashes do not remove the need for salt. Clever\n    attackers will eventually find ways to compromise the keys, so it is\n    important that hashes are still protected by salt and key stretching.\n</p>\n\n<a name=\"othersecurity\"></a>\n<h2>Other Security Measures</h2>\n\n<p>\nPassword hashing protects passwords in the event of a security breach. It does\nnot make the application as a whole more secure. Much more must be done to\nprevent the password hashes (and other user data) from being stolen in the first\nplace.\n</p>\n\n<p>\nEven experienced developers must be educated in security in order to write secure applications.\nA great resource for learning about web application vulnerabilities is \n<a href=\"https://www.owasp.org/index.php/Main_Page\">The Open Web Application\nSecurity Project (OWASP)</a>. A good introduction is the \n<a href=\"https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf\">OWASP Top Ten Vulnerability List</a>.\nUnless you understand all the vulnerabilities on the list, do not attempt to\nwrite a web application that deals with sensitive data. It is the employer's\nresponsibility to ensure all developers are adequately trained in secure\napplication development.\n</p>\n\n<p>\nHaving a third party \"penetration test\" your application is a good idea. Even\nthe best programmers make mistakes, so it always makes sense to have a security\nexpert review the code for potential vulnerabilities. Find a trustworthy\norganization (or hire staff) to review your code on a regular basis. The\nsecurity review process should begin early in an application's life and continue\nthroughout its development.\n</p>\n\n<p>\nIt is also important to monitor your website to detect a breach if one does\noccur. I recommend hiring at least one person whose full time job is detecting\nand responding to security breaches. If a breach goes undetected, the attacker\ncan make your website infect visitors with malware, so it is extremely important\nthat breaches are detected and responded to promptly.\n</p>\n\n<a name=\"faq\"></a>\n<h2>Frequently Asked Questions</h2>\n<h3>What hash algorithm should I use?</h3>\n<span style=\"color: green;\"><b>DO</b></span> use:\n\n<ul class=\"moveul\">\n    <li>Well-designed key stretching algorithms such as <a href=\"http://en.wikipedia.org/wiki/PBKDF2\">PBKDF2</a>, <a href=\"http://en.wikipedia.org/wiki/Bcrypt\">bcrypt</a>, and <a href=\"http://www.tarsnap.com/scrypt.html\">scrypt</a>.</li>\n    <li>OpenWall's <a href=\"http://www.openwall.com/phpass/\">Portable PHP password hashing\n    framework</a></li>\n    <li><a href=\"https://github.com/defuse/password-hashing\">My implementations of PBKDF2 in PHP, C#, Java, and Ruby.</a></li>\n    <li>Secure versions of <a href=\"http://en.wikipedia.org/wiki/Crypt_(Unix)#Library_Function_crypt.283.29\">crypt</a> ($2y$, $5$, $6$)</li>\n</ul>\n<br />\n<span style=\"color: red;\"><b>DO NOT</b></span> use:\n\n<ul class=\"moveul\">\n    <li>Fast cryptographic hash functions such as MD5, SHA1, SHA256, SHA512, RipeMD, WHIRLPOOL, SHA3, etc.</li>\n    <li>Insecure versions of crypt ($1$, $2$, $2x$, $3$).</li>\n    <li>Any algorithm that you designed yourself. Only use technology that is in the public domain and has been well-tested by experienced cryptographers.</li>\n</ul>\n\n<p>\n    Even though there are no cryptographic attacks on MD5 or SHA1 that make\n    their hashes easier to crack, they are old and are widely considered\n    (somewhat incorrectly) to be inadequate for password storage. So I don't\n    recommend using them. An exception to this rule is PBKDF2, which is\n    frequently implemented using SHA1 as the underlying hash function.\n</p>\n<h3>How should I allow users to reset their password when they forget it?</h3>\n\n<p>\n    It is my personal opinion that all password reset mechanisms in widespread\n    use today are insecure. If you have high security requirements, such as an\n    encryption service would, do not let the user reset their password.\n</p>\n\n<p>\nMost websites use an email loop to authenticate users who have forgotten their\npassword. To do this, generate a random <b>single-use</b> token that is strongly\ntied to the account. Include it in a password reset link sent to the user's\nemail address. When the user clicks a password reset link containing a valid\ntoken, prompt them for a new password. Be sure that the token is strongly tied\nto the user account so that an attacker can't use a token sent to his own email\naddress to reset a different user's password.\n</p>\n\n<p>\nThe token must be set to expire in 15 minutes or after it is used, whichever\ncomes first. It is also a good idea to expire any existing password tokens when\nthe user logs in (they remembered their password) or requests another reset\ntoken. If a token doesn't expire, it can be forever used to break into the\nuser's account.  Email (SMTP) is a plain-text protocol, and there may be\nmalicious routers on the internet recording email traffic. And, a user's email\naccount (including the reset link) may be compromised long after their password\nhas been changed.  Making the token expire as soon as possible reduces the\nuser's exposure to these attacks.\n</p>\n\n<p>\nAttackers will be able to modify the tokens, so don't store the user account\ninformation or timeout information in them. They should be an unpredictable\nrandom binary blob used only to identify a record in a database table.\n</p>\n\n<p>\nNever send the user a new password over email. Remember to pick a new random\nsalt when the user resets their password. Don't re-use the one that was used to\nhash their old password.\n</p>\n\n<h3>What should I do if my user account database gets leaked/hacked?</h3>\n\n<p>\nYour first priority is to determine how the system was compromised and patch\nthe vulnerability the attacker used to get in. If you do not have experience\nresponding to breaches, I highly recommend hiring a third-party security firm.\n</p>\n\n<p>\nIt may be tempting to cover up the breach and hope nobody notices. However, trying to cover up a breach makes you look worse, because you're putting\nyour users at further risk by not informing them that their passwords and other\npersonal information may be\ncompromised. You must inform your users as soon as possible&mdash;even if you don't yet fully understand what happened.  Put a notice on the\nfront page of your website that links to a page with more detailed information,\nand send a notice to each user by email if possible. \n</p>\n\n<p>\nExplain to your users exactly how their passwords were protected&mdash;hopefully\nhashed with salt&mdash;and that even though they were protected with a salted\nhash, a malicious hacker can still run dictionary and brute force attacks on the\nhashes. Malicious hackers will use any passwords they find to try to login to a\nuser's account on a different website, hoping they used the same password on\nboth websites. Inform your users of this risk and recommend that they change\ntheir password on any website or service where they used a similar password.\nForce them to change their password for your service the next time they log in.\nMost users will try to \"change\" their password to the original password to get\naround the forced change quickly. Use the current password hash to ensure that\nthey cannot do this.\n</p>\n\n<p>\nIt is likely, even with salted slow hashes, that an attacker will be able to\ncrack some of the weak passwords very quickly. To reduce the attacker's window of opportunity to use these passwords, you should require, in\naddition to the current password, an email loop for authentication until the\nuser has changed their password. See the previous question, \"How should I allow\nusers to reset their password when they forget it?\" for tips on implementing\nemail loop authentication.\n</p>\n\n<p>\nAlso tell your users what kind of personal information was stored on the\nwebsite. If your database includes credit card numbers, you should instruct your\nusers to look over their recent and future bills closely and cancel their\ncredit card.\n</p>\n\n<h3>What should my password policy be? Should I enforce strong passwords?</h3>\n<p>\nIf your service doesn't have strict security requirements, then don't limit your\nusers. I recommend showing users information about the strength of their\npassword as they type it, letting them decide how secure they want their\npassword to be. If you have special security needs, enforce a minimum length of\n12 characters and require at least two letters, two digits, and two symbols.\n</p>\n<p>\nDo not force your users to change their password more often than once every six\nmonths, as doing so creates \"user fatigue\" and makes users less likely to choose\ngood passwords. Instead, train users to change their password whenever they feel\nit has been compromised, and to never tell their password to anyone. If it is a\nbusiness setting, encourage employees to use paid time to memorize and practice\ntheir password.\n</p>\n\n<h3>If an attacker has access to my database, can't they just replace the hash of my password with their own hash and login?</h3>\n\n<p>\nYes, but if someone has access to your database, they probably already have\naccess to everything on your server, so they wouldn't need to login to your\naccount to get what they want. The purpose of password hashing (in the context\nof a website) is not to protect the website from being breached, but to protect\nthe passwords if a breach does occur.\n</p>\n\n<p>\nYou can prevent hashes from being replaced during a SQL injection attack by\nconnecting to the database with two users with different permissions. One for\nthe 'create account' code and one for the 'login' code. The 'create account'\ncode should be able to read and write to the user table, but the 'login' code\nshould only be able to read.\n</p>\n\n<h3>Why do I have to use a special algorithm like HMAC? Why can't I just append\nthe password to the secret key?</h3>\n\n<p> Hash functions like MD5, SHA1, and SHA2 use the <a href=\"http://en.wikipedia.org/wiki/Merkle%E2%80%93Damg%C3%A5rd_construction\">\nMerkle–Damgård construction</a>, which makes them vulnerable to what are known\nas length extension attacks. This means that given a hash H(X), an attacker can\nfind the value of H(pad(X) + Y), for any other string Y, without knowing X.\npad(X) is the padding function used by the hash.\n</p>\n\n<p>\nThis means that given a hash H(key + message), an attacker can compute H(pad(key +\nmessage) + extension), without knowing the key. If the hash was being used as a\nmessage authentication code, using the key to prevent an attacker from being\nable to modify the message and replace it with a different valid hash, the\nsystem has failed, since the attacker now has a valid hash of message +\nextension.\n</p>\n\n<p>\nIt is not clear how an attacker could use this attack to crack a password hash\nquicker.  However, because of the attack, it is considered bad practice to\nuse a plain hash function for keyed hashing. A clever cryptographer may one day\ncome up with a clever way to use these attacks to make cracking faster, so use\nHMAC.\n</p>\n\n\n<h3>Should the salt come before or after the password?</h3>\n\n<p>\nIt doesn't matter, but pick one and stick with it for interoperability's sake.\nHaving the salt come before the password seems to be more common.\n</p>\n\n<h3>Why does the hashing code on this page compare the hashes in\n&quot;length-constant&quot;\ntime?</h3>\n\n<p>\nComparing the hashes in &quot;length-constant&quot; time ensures that an\nattacker cannot extract the hash of a password in an on-line system using a\ntiming attack, then crack it off-line.\n</p>\n\n<p>\nThe standard way to check if two sequences of bytes (strings) are the same is to\ncompare the first byte, then the second, then the third, and so on. As soon as\nyou find a byte that isn't the same for both strings, you know they are\ndifferent and can return a negative response immediately. If you make it through\nboth strings without finding any bytes that differ, you know the strings are the\nsame and can return a positive result. This means that comparing two strings can\ntake a different amount of time depending on how much of the strings match.\n</p>\n\n<p>\nFor example, a standard comparison of the strings &quot;xyzabc&quot; and\n&quot;abcxyz&quot; would immediately see that the first character is different\nand wouldn't bother to check the rest of the string. On the other hand, when the\nstrings &quot;aaaaaaaaaaB&quot; and &quot;aaaaaaaaaaZ&quot; are compared, the\ncomparison algorithm scans through the block of \"a\" before it determines the\nstrings are unequal.\n</p>\n\n<p>\nSuppose an attacker wants to break into an on-line system that rate limits\nauthentication attempts to one attempt per second. Also suppose the attacker\nknows all of the parameters to the password hash (salt, hash type, etc), except\nfor the hash and (obviously) the password. If the attacker can get a precise\nmeasurement of how long it takes the on-line system to compare the hash of the\nreal password with the hash of a password the attacker provides, he can use the\ntiming attack to extract part of the hash and crack it using an offline attack,\nbypassing the system's rate limiting.\n</p>\n\n<p>\nFirst, the attacker finds 256 strings whose hashes begin with every possible\nbyte.  He sends each string to the on-line system, recording the amount of time\nit takes the system to respond. The string that takes the longest will be the\none whose hash's first byte matches the real hash's first byte. The attacker now\nknows the first byte, and can continue the attack in a similar manner on the\nsecond byte, then the third, and so on. Once the attacker knows enough of the\nhash, he can use his own hardware to crack it, without being rate limited by the\nsystem.\n</p>\n\n<p>\nIt might seem like it would be impossible to run a timing attack over a network.\nHowever, it has been done, and has been\n<a href=\"https://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf\">shown to be practical</a>.\nThat's why the code on this page compares strings in a way that takes the same\namount of time no matter how much of the strings match.\n</p>\n\n<a name=\"slowequals\"></a>\n<h3>How does the SlowEquals code work?</h3>\n\n<p>\nThe previous question explains why SlowEquals is necessary, this one explains\nhow the code actually works.\n</p>\n\n<div class=\"passcrack\">\n1. &nbsp;&nbsp; &nbsp;private static boolean slowEquals(byte[] a, byte[] b)<br />\n2. &nbsp;&nbsp; &nbsp;{<br />\n3. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int diff = a.length ^ b.length;<br />\n4. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; a.length &amp;&amp; i &lt; b.length; i++)<br />\n5. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;diff |= a[i] ^ b[i];<br />\n6. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return diff == 0;<br />\n7. &nbsp;&nbsp; &nbsp;}<br />\n</div>\n\n<p>\nThe code uses the XOR \"^\" operator to compare integers for equality, instead of\nthe \"==\" operator. The reason why is explained below. The result of XORing\ntwo integers will be zero if and only if they are exactly the same. This is\nbecause 0 XOR 0 = 0, 1 XOR 1 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1. If we apply that to\nall the bits in both integers, the result will be zero only if all the bits\nmatched.\n</p>\n\n<p>\nSo, in the first line, if <code>a.length</code> is equal to\n<code>b.length</code>, the diff variable will get a zero value, but if not, it\nwill get some non-zero value. Next, we compare the bytes using XOR, and OR the\nresult into diff. This will set diff to a non-zero value if the bytes differ.\nBecause ORing never un-sets bits, the only way diff will be zero at the end of\nthe loop is if it was zero before the loop began (a.length == b.length) and all\nof the bytes in the two arrays match (none of the XORs resulted in a non-zero\nvalue).\n</p>\n\n<p>\nThe reason we need to use XOR instead of the \"==\" operator to compare integers\nis that \"==\" is usually translated/compiled/interpreted as a branch. For example,\nthe C code \"<code>diff &amp;= a == b</code>\" might compile to the following x86\nassembly:\n</p>\n\n<div class=\"passcrack\">\nMOV EAX, [A]<br />\nCMP [B], EAX<br />\nJZ equal<br />\nJMP done<br />\nequal:<br />\nAND [VALID], 1<br />\ndone:<br />\nAND [VALID], 0<br />\n</div>\n\n<p>\nThe branching makes the code execute in a different amount of time depending on\nthe equality of the integers and the CPU's internal branch prediction state.\n</p>\n\n<p>\nThe C code \"<code>diff |= a ^ b</code>\" should compile to something like\nthe following, whose execution time does not depend on the equality of the\nintegers:\n</p>\n\n<div class=\"passcrack\">\nMOV EAX, [A]<br />\nXOR EAX, [B]<br />\nOR  [DIFF], EAX <br />\n</div>\n\n<h3>Why bother hashing?</h3>\n\n<p>\nYour users are entering their password into your website. They are trusting you\nwith their security. If your database gets hacked, and your users' passwords are\nunprotected, then malicious hackers can use those passwords to compromise your\nusers' accounts on other websites and services (most people use the same\npassword everywhere). It's not just your security that's at risk, it's your\nusers'. You are responsible for your users' security.\n</p>\n\n<div style=\"text-align: center;\">\n    <h4>Article written by <a href=\"https://defuse.ca/\">Defuse Security.</a></h4>\n</div>\n"
  },
  {
    "path": "src/pages/home.php",
    "content": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of CrackStation.\n * \n * CrackStation is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n * \n * CrackStation is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n * \n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nmb_language('uni');\nmb_internal_encoding('UTF-8');\n\nrequire_once('libs/recaptchalib.php');\nrequire_once('libs/CrackHashes.php');\nrequire_once('/storage/creds.php');\n\n// Copied from: https://stackoverflow.com/a/30749288\nfunction checkReCAPTCHA() \n{\n    try {\n        $url = 'https://www.google.com/recaptcha/api/siteverify';\n        $creds = Creds::getCredentials(\"timecapsule_recaptcha\");\n        $data = ['secret'   => $creds[C_PASS],\n                 'response' => $_POST['g-recaptcha-response'],\n                 'remoteip' => $_SERVER['REMOTE_ADDR']];\n\n        $options = [\n            'http' => [\n                'header'  => \"Content-type: application/x-www-form-urlencoded\\r\\n\",\n                'method'  => 'POST',\n                'content' => http_build_query($data) \n            ]\n        ];\n\n        $context  = stream_context_create($options);\n        $result = file_get_contents($url, false, $context);\n        return json_decode($result)->success;\n    }\n    catch (Exception $e) {\n        return null;\n    }\n}\n\nif(isset($_GET['p']))\n{\n\theader(\"HTTP/1.1 301 Moved Permanently\");\n\theader(\"Location: http://crackstation.net/\");\n}\n\nfunction trim_value(&$value)\n{\n    $value = trim($value);\n    $value = trim($value, \"*\"); // For MySQL 4.1+ hashes\n}\n\n?>\n<!-- Set the recaptcha theme. -->\n<script type=\"text/javascript\">\nvar RecaptchaOptions = {\n   theme : 'blackglass'\n};\n</script>\n\n<h1>Free Password Hash Cracker</h1>\n\n<p>\n    Enter up to 20 non-salted hashes, one per line:\n</p>\n\n<script>\n    function onRecaptchaChecked() {\n        document.getElementById(\"submitbutton\").disabled = false;\n    }\n    function onRecaptchaExpired() {\n        document.getElementById(\"submitbutton\").disabled = true;\n    }\n</script>\n\n<!-- Hash cracking form. -->\n<form action=\"/\" method=\"post\">\n<table style=\"width: 100%;\">\n<tr>\n    <td style=\"width: 550px;\">\n        <textarea\n            style=\"width: 100%; height: 180px; border: solid black 1px; background-color: #e9e9e9;\"\n            name=\"hashes\" ><?php \n                if(isset($_POST['hashes'])) {\n                    echo htmlspecialchars($_POST['hashes'], ENT_QUOTES);\n                } \n        ?></textarea>\n    </td>\n    <td>\n        <center>\n            <div class=\"g-recaptcha\" data-theme=\"dark\" data-sitekey=\"6LcnNi8UAAAAALJikXrc6jwNWUm00Yjx_rHCJW7u\" data-callback=\"onRecaptchaChecked\" data-expired-callback=\"onRecaptchaExpired\"></div>\n            <input id=\"submitbutton\" type=\"submit\" name=\"crack\" value=\"Crack Hashes\" style=\"width: 200px; margin-top: 10px;\" disabled/>\n        </center>\n    </td>\n</tr>\n</table>\n</form>\n\n<!-- Supported hash types. -->\n<p style=\"font-size: 8pt; margin: 0; padding: 0;\">\n<b>Supports:</b>\nLM, NTLM, md2, md4, md5, md5(md5_hex), md5-half, sha1, sha224, sha256, sha384,\nsha512, ripeMD160, whirlpool, MySQL 4.1+ (sha1(sha1_bin)), QubesV3.1BackupDefaults\n<br />\n</p>\n\n<!-- Crack results (only shown after a POST) -->\n<div class=\"crackresults\">\n<?php\nif(isset($_POST['crack']))\n{\n    if(checkReCaptcha() === true)\n    {\n        $hashes = str_replace(\"\\r\\n\", \"\\n\", $_POST['hashes']);\n        $hashes = str_replace(\"\\r\", \"\\n\", $hashes);\n        $hashes = explode(\"\\n\", $hashes);\n        array_walk($hashes, 'trim_value');\n        $hashes = array_filter($hashes, function ($item) { return !empty($item); });\n        if(count($hashes) <= 20) {\n            CrackHashes($hashes);\n        } else {\n            echo \"<p style=\\\"color: red;\\\">\n                    <b>Please enter <strong>20</strong> or less hashes.</b>\n                  </p>\";\n        }\n    }\n    else\n    {\n        echo \"<p style=\\\"color: red;\\\">\n                <b>Incorrect captcha. Please try again.</b>\n              </p>\";\n    }\n}\n?>\n</div>\n\n<div class=\"downloaddiv\">\n    <a class=\"downloadlink\"\n       href=\"/crackstation-wordlist-password-cracking-dictionary.htm\">\n            Download CrackStation's Wordlist\n    </a>\n</div>\n\n<a name=\"cracking-hashes\"></a>\n<h2>How CrackStation Works</h2>\n\n<p>\nCrackStation uses massive pre-computed lookup tables to crack password hashes.\nThese tables store a mapping between the hash of a password, and the correct\npassword for that hash. The hash values are indexed so that it is possible to\nquickly search the database for a given hash. If the hash is present in the\ndatabase, the password can be recovered in a fraction of a second.  This only\nworks for \"unsalted\" hashes. For information on password hashing systems that\nare not vulnerable to pre-computed lookup tables, see our <a\nhref=\"hashing-security.htm\">hashing security page</a>.\n</p>\n\n<p>\nCrackstation's lookup tables were created by extracting every word from the\nWikipedia databases and adding with every password list we could find. We also\napplied intelligent word mangling (brute force hybrid) to our wordlists to make\nthem much more effective. For MD5 and SHA1 hashes, we have a 190GB,\n15-billion-entry lookup table, and for other hashes, we have a 19GB\n1.5-billion-entry lookup table.\n</p>\n\n<p>\nYou can download CrackStation's dictionaries <a\nhref=\"/crackstation-wordlist-password-cracking-dictionary.htm\">here</a>, and\nthe lookup table implementation (PHP and C) is available <a\nhref=\"https://github.com/defuse/crackstation-hashdb\">here</a>.\n</p>\n"
  },
  {
    "path": "src/pages/legal-privacy.php",
    "content": "<h1>CrackStation's Terms of Service and Privacy Policy</h1>\r\n\r\n<h2>Terms of Service</h2>\r\n<p>\r\nCrackStation's main goal is to promote the use of properly implemented salted\r\nhashing in new and existing web applications. We provide this service to help\r\nsecurity researchers demonstrate the importance of hash salting. Any users that\r\nchoose to use CrackStation as a malicious tool are solely responsible for their\r\nown actions. We do not ask where our clients get their hashes, so we are unable\r\nto help any law enforcement agency.\r\n</p>\r\n\r\n<h2>Privacy Policy</h2>\r\n<p>\r\nCrackStation respects the privacy of its users. Your IP address and web browser\r\ninformation may be logged as you request web pages from this site, but we do not\r\nsell that information or share that information with anyone. We DO NOT log the\r\nhashes that you crack.  However, you should still not try to crack the hash of\r\nyour own password or other sensitive information, since your connection might be\r\nbeing intercepted by the NSA.\r\n</p>\r\n"
  },
  {
    "path": "src/pages/thank-you.php",
    "content": "<h1>THANKS!</h1>\n\n<p>\nYou just bought the CrackStation wordlist. Thank you VERY much for your support!\n</p>\n\n<p>\nIf you haven't downloaded the wordlist yet, see <a\nhref=\"/buy-crackstation-wordlist-password-cracking-dictionary.htm\">step 2</a>.\n</p>\n\n<p>\nIf you have any questions or concerns, please <a href=\"/contact-us.htm\">contact me</a>.\n</p>\n"
  },
  {
    "path": "src/robots.txt",
    "content": "User-agent: *\nDisallow: /tor-mirror/\n"
  }
]