Full Code of defuse/crackstation for AI

master 61d0fe75933e cached
25 files
42.1 MB
47.0k tokens
44 symbols
1 requests
Download .txt
Repository: defuse/crackstation
Branch: master
Commit: 61d0fe75933e
Files: 25
Total size: 42.1 MB

Directory structure:
gitextract_l2rebmfd/

├── .gitmodules
├── LICENSE
├── gfx/
│   └── crackstation_header.psd
└── src/
    ├── blocked.html
    ├── css/
    │   ├── main.css
    │   ├── mainmenu2.css
    │   └── style.css
    ├── downloads/
    │   ├── crackstation-human-only.txt.gz.torrent
    │   └── crackstation.txt.gz.torrent
    ├── index.php
    ├── libs/
    │   ├── CrackHashes.php
    │   ├── URLParse.php
    │   ├── phpcount.php
    │   └── recaptchalib.php
    ├── pages/
    │   ├── 404.php
    │   ├── aboutus.php
    │   ├── buy-crackstation-wordlist-cracking-dictionary.php
    │   ├── contactus.php
    │   ├── downloads.php
    │   ├── hashing-security-draft.php
    │   ├── hashing-security.php
    │   ├── home.php
    │   ├── legal-privacy.php
    │   └── thank-you.php
    └── robots.txt

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitmodules
================================================
[submodule "src/source/password-hashing"]
	path = src/source/password-hashing
	url = git@git.defuse.ca:gits/password-hashing.git


================================================
FILE: LICENSE
================================================
                    GNU AFFERO GENERAL PUBLIC LICENSE
                       Version 3, 19 November 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.

  A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate.  Many developers of free software are heartened and
encouraged by the resulting cooperation.  However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.

  The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community.  It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server.  Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.

  An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals.  This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU Affero General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Remote Network Interaction; Use with the GNU General Public License.

  Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software.  This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time.  Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source.  For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code.  There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.


================================================
FILE: gfx/crackstation_header.psd
================================================
[File too large to display: 41.9 MB]

================================================
FILE: src/blocked.html
================================================
<html>
    <head>
        <title>Error 403: Access Denied</title>
    </head>
    <body>
        <h1>Forbidden</h1>
    </body>
    <p>Either you're trying to access something you're not supposed to, or you've been banned.</p>
    <p>If you think you've been banned, email havoc@defuse.ca to appeal.</p>

    <!--
     This stuff is here to make sure internet explorer displays this message.
     This stuff is here to make sure internet explorer displays this message.
     This stuff is here to make sure internet explorer displays this message.
     This stuff is here to make sure internet explorer displays this message.
     -->
</html>


================================================
FILE: src/css/main.css
================================================
/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* Some parts of this style sheet come from http://grc.com/ */

/* CSS Sticky footer from: http://www.cssstickyfooter.com/using-sticky-footer-code.html */

/* TAGS {{{1 */

html {
    height: 100%;
    width: 100%;
}

body {
	width:100%; 
	height:100%;
	color:black;
	font-size:10pt;
	font-family: verdana, tahoma, arial, helvetica, sans-serif, "MS Sans Serif";
    background-color: white;
}

/*Opera Fix (css sticky footer) */
body:before {
	content:"";
	height:100%;
	float:left;
	width:0;
	margin-top:-32767px;/
}

body, img, button, iframe, ul, li, hr  { 
	margin:0; padding:0; border:0; 
}

table { 
	margin:0;
	padding:0;
	text-align:left;
	font-size:10pt; 
}

textarea {
    resize: none;
}

/* GLOBAL (All Pages) Styles {{{1 */
#wrap {
    min-height: 100%;
    width: 100%;
    min-width: 900px; /* Must be big enough to fit content and it's p+m */
}

#sm {
    text-align: center;
    position: absolute;
    top: 62px;
    right: 30px;
    font-size: 16pt;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
}

#sm a {
    color: white;
    text-decoration: none;
}

#sm a:hover {
    color: #00FFFF;
}

#twitterlogo {
    vertical-align: middle;
    margin-right: 2px;
    padding-bottom: 2px;
}

#homediv {
	text-align: center; 
	color: white;
}

#homediv h2 {
	margin-top: 30px;
}

#homediv li {
	font-size: 20px;
	margin-top: 10px;
}

.homelink {
	color: white;
	text-decoration: none;
}

.homeul {
	text-align: left;
	width: 420px;
	margin: 0 auto;
}

#content {
	text-align: left;
	margin: 0 auto; 
	width: 80%; 
	max-width: 1000px; 
	min-width: 800px;
	margin-top:5px;
	background-color:white;
	padding-left: 30px;
	padding-right:30px;

	padding-top:5px;

    /*overflow: auto;*/
    padding-bottom: 140px; /* total #footer height + desired padding */

}

#contenthome {
	margin-top:20px;
}

#contenthome li {
    margin-bottom: 5px;
}


#content h1 {
	width:100%;
	padding-bottom:5px;
	text-align: center;
	padding-top: 0;
	margin-top:0;
	border-bottom: solid #000000 5px; /*#333333*/
    font-size: 25px;
    font-family: "Times New Roman", "Times", serif;
    font-weight: normal;
}

#content h2 {
	font-size: 16pt;
    border-bottom: solid 1px #AAAAAA;
    font-family: "Times New Roman", "Times", serif;
    font-weight: normal;
}

#content h3 {
	font-size: 13pt;
}

#content h4 {
	font-size: 10pt;
}

.majorlink {
	color:white;
	text-decoration: none;
	font-size: 16px;
}

a:hover {
	color:#FF0000;
}

#undergrad {
	background-image: url('/images/undergrad.png');
	height: 10px;
	margin-top: 1px;
	width: 100%;
}

#latest a:link {
	color: red;
}

#latest a:hover {
	color: white;
}

#latest a:visited {
	color: red;
}

ul {
    padding-left:40px;
}

.linkblock {
    margin: 0 auto;
    background:#ddffff;
    border: solid #66ccdd 2px;
}

.linkblockheader {
    margin-top:20px;
    text-align:center;
}

.linkblock td {
    padding-right:5px;
    text-decoration:underline;
}

/* These DO NOT affect the PASTEBIN page! */
.div1 {
	background-color: #d4d4d4 ;
	word-wrap: break-word;
}

.div0 {
	word-wrap: break-word;
}

#footerborder {
    background-image: url('images/undergrad-inverted.png');
    height: 10px;
}

#footerwrapper {
    position: relative;
    margin-top: -105px; /* #footer total height (padding too) + 10px footerborder */
    clear: both;
    width: 100%;
    min-width: 900px;
}

/* Hide the footer while printing */
@media print {
    #footerwrapper {
        display:none;
    }
}


#footer {
    background-color: black;
    /*border-top: solid #202020 1px;*/
    padding-top: 5px;
    padding-bottom: 10px;
    padding-left: 10px;
    padding-right: 10px;
    margin: 0;
    color: white;
    height: 80px;
}

#footer a {
    color: #CCCCCC;
}

#footer a:hover {
    color: red;
}

.codeskillbox {
	background-color: white;
	color: black;
	font-size: 40px;
	text-align: center;
	border: solid black 1px;
	margin: 0 auto;
	margin-bottom: 30px;
	width: 750px;
}

.codeskillheader {
	background-color: #000;
	color: white;
	text-align: center;
	padding: 5px;
	font-size: 20px;
	border-bottom: solid black 1px;
}

.honestywarebox {
    background-color: #aadaff;
    border: solid black 1px;
    padding: 10px;
}

.honestywarebox h2 {
    text-align: center;
    border-style: none !important;
    padding: 0;
    margin: 0;
}

.code {
    padding: 10px; 
    font-family: monospace;
    color: #c0c0c0;
    background-color: #000000;
    border-radius: 15px;
    box-shadow: 6px 6px 4px 2px #888 ;
    background-image: url('/images/code-top.png');
    background-repeat: repeat-x;
}

.codehl {
    font-weight: bold;
}

.badcode {
    background-image: url('/images/grid-red.gif') !important;
}
/* PPHOS {{{1 */
/* ============ PPHOS ================= */

.hosval {
    border: solid 1px gray;
}

.nopaddingatall {
	padding: 0;
	margin: 0;
}

.pphostbl {
    width: 100%;
    border-collapse:collapse;
}

.pphostbl th {
    padding: 5px;
    background-color: black;
    color:white;
    border: solid 1px gray;
}

.alt {
    background-color: #e5e5e5;
}


/* PASSWORD BLOCKS {{{1 */
/* ========== PASSWORD BLOCKS ========= */

.blocksection h2 {
    border-bottom: solid black 1px;
    padding: 0;
    margin: 0;
    margin-bottom: 15px;
    text-align: center;
}

.blocksection {
    width: 700px;
    margin: 0 auto;
    border: solid black 3px;
    margin-bottom: 20px;
    background-color: #FFFFFF;
}

#blockfactory {

}

#blocksorter {

}

#passwordpractice {

}

#passwordsecurity {

}

.selectedBlock {
    border: solid black 3px;
    padding: 3px;
    margin: 3px;
    position: relative;
    display: inline-block;
    width: auto;
}

.unselectedBlock {
    border: solid black 1px;
    padding: 3px;
    margin: 3px;
    position: relative;
    display: inline-block;
    width: auto;
}

.typefactory {
    padding: 10px;
    border-top: solid black 1px;
    border-bottom: solid black 1px;
    display: none;
    background-color: #DDDDDD;
}

#customfactory {
    display:none;
}

#paddingfactory {
    display:none;
}

#blockpreview {
    text-align: center;
    font-size: 15px;
    margin: 20px;
    display: none;
}

#blockview {
    text-align: center;
}

.ftlink {
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-decoration: underline;
    cursor: pointer;
    display: inline-block;
}

.starblock {
    display: inline;
}

.ftlink:hover {
    color: #0000CC;
}

#ftheader {
    text-align: center; 
    font-weight: bold;
}

.fakelink {
    text-decoration: underline;
    color: blue;
}

.restable {
    width: 500px;
    margin: 0 auto;
    font-size: 12pt;
    border-collapse: collapse;
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.restable td {
    border: solid #000000 1px;
    margin: 0;
}

.res1 {
    background-color: #90EE90;
}

.res2 {
    background-color: #FFFFE0;
}

.res3 {
    background-color: #D87093;
}

.wldl {
    color: black;
    text-decoration: none;
}

.wldl2 {
    color: black;
    text-decoration: none;
    font-size: 16pt;
}

.wldl2:hover {
    color: green;
}

.wldl:hover {
    color: green;
}


================================================
FILE: src/css/mainmenu2.css
================================================
/*==============================================================================

	NOTE: I've made a lot of modifications to this file for this website.
    You'll probably	want to get a fresh copy from...
	            
                http://www.grc.com/menu2/invitro.htm

	GRC multi-level script-free pure-CSS menuing system stylesheet.
   This code is hereby placed into the public domain by its author
   Steve Gibson. It may be freely used for any purpose whatsoever.

	Computed Geometries:	with a default 12px font, 1.0em == 12px and
	1px == 0.08333em.
	Thus, our 98px wide Freeware & Research buttons are 8.166666em wide.

                      PUBLIC DOMAIN CONTRIBUTION NOTICE							 
   This work has been explicitly placed into the Public Domain for the
	benefit of anyone who may find it useful for any purpose whatsoever.
	
==============================================================================*/

.headerlink {
	padding-right:15px;
}

.downimg {
	color: #990000;
    padding: 0;
    margin: 0;
    padding-left: 15px;
    padding-top: 6px;
}


 /*================= STYLES FOR THE GRC MASTHEAD & CONTROLS ==================*/

.menuminwidth0 {             /* for all browsers (non-IE) that obey min-width */
	position:relative;
	border:0;
	margin:0;
	padding:0;
	width:100%;
	height:119px;/* 36px masthead height + 18px button height + 1px lower border*/
	min-width:800px;
}

/* suppress our whole menu when not an interactive mode (when printing, etc.) */
@media print, projection { .menuminwidth0 { d\isplay:none; } }

* html .menuminwidth1 { /* this allows IE5/6 to simulate min-width capability */
	position:relative;  /* we can simulate a minimum width by creating a large */
	float:left;          /* border in this first div, then placing our content */
	height: 1px;          /* into a second nested div (see 2nd nested div next */
	border-left:800px solid #fff;    /* CSS box-model borders are a fixed size */
}

* html .menuminwidth2 {    /* used to simulate min-width capability for IE5/6 */
	position:relative;
	margin-left:-800px;
	height: 1px;
}

#masthead {
	position:relative;      /* position our child objects relative to this div */
	float:left;
	vertical-align:top;	         /* protect from super-large user text sizing */
	border:0;
	margin:0;
	padding:0;
	width:100%;                                  /* grey-fill the entire width */
	height:100px;                 /* set the overall height above the menu-bar */

	background:#000;
	background-image: url('/images/crackstation_header.png');
	background-repeat: no-repeat;
	color:white;
}

#mastheadlogo {
	float:left;
	vertical-align:top;
	border:0;
	padding:0;
	margin: 28px 0 0 15px;
}


 /*========================= TOP OF THE MENU CASCADE =========================*/

.menu {
	position:relative;        /* establish a menu-relative positioning context */
	float:left;                                     /* play nicely with others */
	margin:0;
	padding:0;
	border:0;
	height:22px;                                  /* the menu's overall height */
	width:100%;         /* we always want our menu to fill the available space */
	/*background:#232323;*/
	background:black;
	background-image: url('/images/navbg.png');
	background-repeat: repeat-x;
	font-family: Verdana, Helvetica, Arial, sans-serif;
	font-size:14px;         /* this (and also below) sets the menu's font size */ /*FIREXWARE EDIT: was 12*/
	border-bottom:1px solid black;        /* give us a black border underneath */
}

.menu img {
	vertical-align: top;      /* prevent images from being pushed down by text */
}

.menu ul {
	padding-left:5px;
	margin:0;
	list-style-type:none;          /* we don't want to view the list as a list */
	line-height:1.5em;           /* globally set the menu's item spacing. note */
}                               /* this must be 1.0 or 1.5 or 2.0 for Mozilla */

.menu li {
	float:left;    /* this creates the side-by-side array of top-level buttons */
	position:relative;    /* create local positioning contexts for each button */
	margin:0;
}

.menu ul li table {
	margin:-1px 0;              /* IE5 needs -1px top and bottom table margins */
	m\argin:0;               /* re-zero the table margins for everyone but IE5 */
	border-collapse:collapse;      /* IE5 needs this for the sub-menus to work */
	font-size:12px;        /* this sets the base font size for our entire menu */
}

.drop {
	display:block;
	padding:0px 0.33em;	       /* this sets the l/r margins for our menu item */
	margin:0;
	text-align:right;   /* this right alignment goes with the float:left below */
	cursor:pointer;      /* IE tries to switch back to an I-beam, don't let it */
	cursor:hand;           /* IE5 only knows about "hand", so set it both ways */
}

.drop span {        /* this simultaneously left and right aligns the text and */
	float:left;       /* the >> in the drop-down menus which link to sub-menus */
}

.rightmenu {
	position:relative;  /* establish a local positioning context for YAH label */
	float:right;                  /* and right-align it at the top of our page */
}

#research {            /* this rightmost "Research" button must be positioned */
	position:absolute;       /* absolutely so that the YAH (you are here) text */
	top:0px;               /* label will slide underneath it under Opera v8.54 */
	left:364px;    /* which has a z-order sequencing bug with abs-pos elements */
}

#other {                  /* this rightmost "Other" button must be positioned */
	position:absolute;       /* absolutely so that the YAH (you are here) text */
	top:0px;               /* label will slide underneath it under Opera v8.54 */
	left:462px;    /* which has a z-order sequencing bug with abs-pos elements */
}

/*======================== TOP LEVEL MENU DEFINITIONS ========================*/

.menu ul li ul {
	display:none;                  /* initially hide the entire list hierarchy */
	padding:1px;                               /* this is our box border width */
}

.menu ul li a,
.menu ul li a:visited {                    /* unselected top-level menu items */
	display:block;
	float:left;
	text-decoration:none;
	color:white;
	height:18px;
}

.menu ul li:hover a,
.menu ul li a:hover {                        /* selected top-level menu items */
	/*border-bottom:1px solid white;*/    /* these 2 lines create the push-in illusion */
	height:16px;
    color: #FFAAAA;
}

/*======================== 2ND LEVEL MENU DEFINITIONS ========================*/

.menu ul li:hover ul,
.menu ul li a:hover ul {                           /* 2nd level drop-down box */
	display:block;
	position:absolute;
	margin:0;
	top:18px;              /* place us just up underneath the top-level images */
	left:-1px;       /* left-align our drop-down to the previous button border */
	height:auto;      /* the drop-down height will be determiend by line count */
	width:13.5em;
	color:black;                        /* this sets the unselected-text color */
	background:black;         /* this sets our menu's effective "border" color */
	border: solid #404040 1px;
}

.menu ul li:hover ul.leftbutton,
.menu ul li a:hover ul.leftbutton {/* our first dropdown should not be skewed */
	left:0px;
}

.menu ul li:hover ul.skinny,
.menu ul li a:hover ul.skinny {             /* 2nd level skinny drop-down box */
	width:8.08333em;   /* with a 12px default font, this is 97px width (97/12) */
}

.menu ul.rightmenu li:hover ul,
.menu ul.rightmenu li a:hover ul {    /* 2nd level neighborhood drop-down box */
	left:auto;
	right:0;         /* nudge the right menu right to line up under the border */
	width:400px;      /* with a 12px default font, this is 228px width (228/12) */
}

* html .menu ul.rightmenu li a:hover ul {         /* IE5/6 needs a tweak here */
	right:-1px;
}

.menu ul li:hover ul li a,
.menu ul li a:hover ul li a {                   /* 2nd level unselected items */
	border:0;
	margin:0;
	padding:0;
	height:auto;
	color:#FFFFFF;               /* this sets the unselected drop-down text color */
	/*background:#444444;*/      /* this sets the drop-down menu background color */
	background:black;
	width:13.5em;
}

.menu ul li:hover ul li:hover a,
.menu ul li a:hover ul li a:hover {                /* 2nd level selected item */
	color: #FFAAAA;
	background:black;
}

.menu ul li:hover ul.skinny li a,
.menu ul li a:hover ul.skinny li a,
.menu ul li:hover ul.skinny li a:hover,
.menu ul li a:hover ul.skinny li a:hover {     /* 2nd level un+selected items */
	width:8.08333em;
}

/*======================== 3RD LEVEL MENU DEFINITIONS ========================*/

.menu ul li:hover ul li ul,
.menu ul li a:hover ul li a ul {             /* hide inactive 3rd-level menus */
	visibility:hidden;
}
     
.menu ul li:hover ul li:hover ul,
.menu ul li a:hover ul li a:hover ul {             /* 3rd level drop-down box */
	visibility:visible;
	position:absolute;
	margin-top:-1px;	      /* bring the top edge of the 3rd level menu up one */
	top:0;
	/*left:8.08333em;*/ /*CHANGE BY FIREXWARE: use super wide always*/
	left:13.5em;
	width:14em;
}

.menu ul li:hover ul li:hover ul li a,
.menu ul li a:hover ul li a:hover ul li a {     /* 3rd level unselected items */
	width:14em;
	background:#444444;
	background:black;
	color:white;
}

.menu ul li:hover ul li:hover ul li a:hover,
.menu ul li a:hover ul li a:hover ul li a:hover {    /* level3 selected items */
	width:14em;
	color: #FFAAAA;
	background:black;
}

#text {           /* the Mac's standard Safari browser will not see this code */
	height:1.215em;#           /* ...  but every other browser will and should */
} /* Safari barfs on the illegal pound sign (#) after the rule's property val */


.darr {
	color: #990000;
}


================================================
FILE: src/css/style.css
================================================
/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* Custom stuff */

ul, ol {
    margin-left: 30px;
}

.crackresults {
    margin-top: 10px;
}

.results
{
	width: 100%;
}

.results th
{
    text-align: center;
}

.results td
{
	text-align:left;
}


.fail
{
    background-color: #FF0000;
}

.results td
{
	padding:5px;
    font-family: monospace;
    border: solid black 1px;
}

.suc
{
	background-color: #00FF00;
}

.part
{
    background-color: #FFFF00;
}

.ic{
    color:#000000;
    font-family: monospace;
}

.sca {
    display: block;
    height: 100%;
    width: 100%;
}

.shortcuts{
    width:100%;
    color: #000000;
}

.shortcuts td {
    background-color: #F0F0F0;
    border: solid 1px black;
    padding: 5px;
    font-weight: bold;
    color: #000000;
}

.shortcuts td a{
    font-weight:normal;
    text-decoration: none;
    color: #000000;
}

.shortcuts td a:visited {
    color: #000000;
}
.shortcuts td:hover {
    background-color: #DDDDDD;
}

#rnglist {
    margin: 0 auto;
}

#rnglist td {
    border: solid 1px #AAAAAA;
    padding: 10px;
}

.passcrack{
    padding: 10px; 
    font-family: monospace;
    color: #c0c0c0;
    background-color: #000000;
    border-radius: 15px;
    box-shadow: 6px 6px 4px 2px #888 ;
    background-image: url('/images/code-top.png');
    background-repeat: repeat-x;
}

.downloaddiv {
    padding: 10px;
    font-size: 16pt;
    text-align: center;
}

.downloadlink {
    color: black;
    padding: 5px;
}


================================================
FILE: src/index.php
================================================
<?php

/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// Standardize the times & dates to UTC because people don't live in the same timezone as the server.
date_default_timezone_set("UTC"); 

// HSTS header (force HTTPS)
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' &&
    $_SERVER['HTTP_HOST'] != "localhost" && 
    $_SERVER['HTTP_HOST'] != "192.168.1.102")
{
    header('Strict-Transport-Security: max-age=31536000; includeSubDomains; preload'); /* one year */
}

//Strengthen the server's CSPRNG
$entropy = implode(gettimeofday()) . implode($_SERVER) . implode($_GET) . implode($_POST) . implode($_COOKIE) . implode($_ENV) . microtime() . mt_rand() . mt_rand();
file_put_contents("/dev/urandom", $entropy);

require_once('libs/URLParse.php'); 
require_once('libs/phpcount.php');

$name = URLParse::ProcessURL();
PHPCount::AddHit($name, $_SERVER['REMOTE_ADDR']);

// Prevent pages from being displayed in iframes. Not supported by all browsers.
header('X-Frame-Options: SAMEORIGIN'); 

header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title><?php 
            $title = URLParse::getPageTitle($name);
            echo htmlspecialchars($title, ENT_QUOTES);
?></title>
<meta name="description" content="<?php 
            $metd = URLParse::getPageMetaDescription($name);
            echo htmlspecialchars($metd, ENT_QUOTES);
?>" />
<meta name="keywords" content="<?php 
            $metk = URLParse::getPageMetaKeywords($name);
            echo htmlspecialchars($metk, ENT_QUOTES);
?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="google-site-verification" content="AeVohZfbCxeMLV4i1tKOdEgAOxhl8JgvNEpi11neLLk" />
<meta name="google-site-verification" content="bJfNsQVzNQLRCAQiZD0kUNF-gFYS16YnaCZDJEX-dLk" />
<link rel="stylesheet" media="all" type="text/css" href="/css/mainmenu2.css" />
<link rel="stylesheet" media="all" type="text/css" href="/css/main.css" />
<link rel="stylesheet" media="all" type="text/css" href="/css/style.css" />
<?php
    if ($name === "") {
    ?>
        <script src='https://www.google.com/recaptcha/api.js'></script>
    <?
    }
?>
<!--[if !IE 7]>
	<style type="text/css">
		#wrap {display:table;height:100%}
	</style>
<![endif]-->
</head>
<body <?php if( $name == "" ) echo 'style="background:white;" '; ?> >
<div id="wrap">

<!-- This menuing system was made by Steve Gibson at GRC.COM 
            see more at http://www.grc.com/menudemo.htm -->

<div class="menuminwidth0"><div class="menuminwidth1"><div class="menuminwidth2">
<div id="masthead">
    <div style="font-size:30px;"><img src="/images/1by1.gif" alt="CrackStation" /></div>
    <div id="sm">
        <a href="https://defuse.ca/" title="Defuse Security">Defuse.ca</a>
        &nbsp;&middot;&nbsp;
        <a href="https://twitter.com/defusesec" title="Follow @DefuseSec on twitter!">
            <img id="twitterlogo" src="/images/twitter.png" alt="Follow me on twitter!" height="25" width="30" />
            Twitter
        </a>
    </div>
</div>

<div class="menu">

<ul>
    <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]-->
        <ul class="leftbutton">
            <li><a href="/">&nbsp;Free Hash Cracker</a></li>
            <li><a href="crackstation-wordlist-password-cracking-dictionary.htm">&nbsp;Wordlist Download</a></li>
            <li><a href="/about-us.htm">&nbsp;About Us</a></li>
            <li><a href="/contact-us.htm">&nbsp;Contact Us</a></li>
            <li><a href="/legal-privacy.htm">&nbsp;ToS &amp; Privacy Policy</a></li>
        </ul>
        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
</ul>


<ul>
    <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]-->
        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
</ul>

<ul>
    <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]-->
        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
</ul>

</div> <!-- close "menu" div -->
<hr style="display:none" />
</div></div></div> <!-- close the "minwidth" wrappers -->
<!-- End of menu -->

<!--[if !IE]>-->
<div id="undergrad"></div>
<!--<![endif]-->

<!--[If gt IE 6]>
<div id="undergrad"></div>
<![endif]-->

<div id="content">
<?php
    $included = URLParse::IncludePageContents();
?>
</div>

</div> <!-- Wrap -->
    <div id="footerwrapper">
    <div id="footerborder"></div>
    <div id="footer">
    <?php
        $last_modified = htmlspecialchars(
                                date("F j, Y, g:ia e", filemtime($included)),
                                ENT_QUOTES
                                );
        $unique =  PHPCount::GetHits($name, true);
        $hits = PHPCount::GetHits($name);
        $total = PHPCount::GetTotalHits();
        $totalu = PHPCount::GetTotalHits(true);
    ?>
    <table>
        <tr>
            <th>Last Modified: &nbsp;&nbsp;</th>
            <td><?php echo $last_modified;?></td>
        </tr>
        <tr>
            <th>Page Hits:</th>
            <td><?php echo $hits; ?></td>
        </tr>
        <tr>
            <th>Unique Hits:</th>
            <td><?php echo $unique; ?></td>
        </tr>
    </table>
<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>
<a href="https://defuse.ca/">Defuse Security</a> | 
    <a href="https://z.cash/">Zcash</a> |
    <a href="https://defuse.ca/pastebin.htm">Secure Pastebin</a> | 
    <a href="https://github.com/defuse/crackstation">Source Code</a>
    </div> <!-- end footer -->
    </div> <!-- footerwrapper -->
<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["setDoNotTrack", true]);
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://defuse.ca/piwik/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "2"]);
    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
    g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript>
<img src="https://defuse.ca/piwik/piwik.php?idsite=2&amp;rec=1" style="border:0" alt="" />
</noscript>
<!-- End Piwik Code -->

<!--[if !(lt IE 8)]><!-->
   <script type="text/javascript">
     (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)})()
   </script>
<!--<![endif]-->
</body>
</html>


================================================
FILE: src/libs/CrackHashes.php
================================================
<?php

/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once(getenv("CRACKSTATION_DEPENDS_DIR") . "/crackstation-hashdb/LookupTable.php");

function CrackHashes($hashes)
{
	echo "<table class=\"results\">";
	echo "<tr><th>Hash</th><th>Type</th><th>Result</th></tr>";

    foreach($hashes as $hash) {
        $supported_lookups = array(
            array(
                'index' => 'lm.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'LM',
            ),
            array(
                'index' => 'ntlm.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'NTLM',
            ),
            array(
                'index' => 'mysql4.1+.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'MySQL4.1+',
            ),
            /* md5(md5) must come before actual md5, since the hash might be in
               the wordlist. */
            array(
                'index' => 'md5md5.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'md5(md5)',
            ),
            array(
                'index' => 'md5.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'md5',
            ),
            array(
                'index' => 'sha1.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'sha1',
            ),
            array(
                'index' => 'md2.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'md2',
            ),
            array(
                'index' => 'md4.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'md4',
            ),
            array(
                'index' => 'sha256.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'sha256',
            ),
            array(
                'index' => 'sha224.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'sha224',
            ),
            array(
                'index' => 'sha384.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'sha384',
            ),
            array(
                'index' => 'sha512.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'sha512',
            ),
            array(
                'index' => 'whirlpool.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'whirlpool',
            ),
            array(
                'index' => 'ripemd160.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'ripemd160',
            ),
            array(
                'index' => 'qubesv3.1.idx',
                'dict' => 'REALUNIQ.lst',
                'alg' => 'QubesV3.1BackupDefaults',
            ),
            /* Big ones. */
            array(
                'index' => 'md5-huge.idx',
                'dict' => 'HUGELIST.lst',
                'alg' => 'md5',
            ),
            array(
                'index' => 'sha1-huge.idx',
                'dict' => 'HUGELIST.lst',
                'alg' => 'sha1',
            ),
        );

        $html_escaped_hash = htmlentities(
            wordwrap($hash, 64, "\n", true),
            ENT_QUOTES
        );
        $html_escaped_hash = str_replace("\n", "<br />\n", $html_escaped_hash);

        /* Try to crack the hash with every lookup table, collecting all of the
            results. */
        $results = array();
        foreach($supported_lookups as $lookup) {

            $index_path = getenv("CRACKSTATION_DEPENDS_DIR") . "/cracking/" . $lookup['index'];
            $dict_path = getenv("CRACKSTATION_DEPENDS_DIR") . "/cracking/" . $lookup['dict'];

            $lut = new LookupTable($index_path, $dict_path, $lookup['alg']);

            try {
                $results = array_merge($results, $lut->crack($hash));
                /* Exit early.
                   This does two things. Firstly, it avoids duplication between
                   md5.idx/md5-huge.idx and sha1.idx/sha1-huge.idx. Secondly, it
                   speeds things up since for example if we've already cracked
                   it as an md5 hash it's very unlikely to also be a sha1 hash.
                */
                foreach ($results as $result) {
                    if ($result->isFullMatch()) {
                        break 2;
                    }
                }
            } catch (HashFormatException $ex) {
                echo "<tr class=\"fail\"><td>$html_escaped_hash</td><td>Unknown</td><td>Unrecognized hash format.</td></tr>";
                /* WARNING: Curently a throw of HashFormatException for one
                   algorithm means it will throw for *all* algorithms. That may
                   not remain to be the case. */
                goto nexthash;
            }
        }

        /* Show all of the results for this hash. */
        if (count($results) == 0) {
            echo "<tr class=\"fail\"><td>$html_escaped_hash</td><td>Unknown</td><td>Not found.</td></tr>";
        } else {
            foreach ($results as $result) {
                if ($result->isFullMatch()) {
                    $tr_class = "suc";
                } else {
                    $tr_class = "part";
                }
                echo "<tr class=\"$tr_class\">";
                echo "<td>$html_escaped_hash</td>";
                $html_escaped_alg = htmlentities($result->getAlgorithmName(), ENT_QUOTES);
                echo "<td>$html_escaped_alg</td>";
                $html_escaped_plaintext = htmlentities($result->getPlaintext(), ENT_QUOTES);
                echo "<td>$html_escaped_plaintext</td>";
                echo "</tr>";
            }
        }

nexthash:
    }

    echo "</table>";
    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>';
}
?>


================================================
FILE: src/libs/URLParse.php
================================================
<?php

/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 *      Defuse Cyber-Security's Secure & Lightweight CMS in PHP for Linux.
 *      Setup & Usage Instructions: https://defuse.ca/helloworld-cms.htm
 */

/*
 * The purpose of this class is to process the current request URL to 
 * determine which page is to be displayed to the user, or to which URL
 * the user should be redirected. Once the user has been redirected to
 * the correct URL, and the desired page is determined, the page contents
 * can be loaded from a file into a dynamically generated web page.
 *
 * The URL parsing is split into four processes:
 * 1. First, the hostname (domain name) the request was made to is verified 
 *    against a list of "accepted hosts." If the hostname doesn't match any of
 *    these accepted hosts, the user is redirected to the same URL on the
 *    "master host." The accepted hosts and master host variables can be set
 *     by modifying the $ACCEPTED_HOSTS and $MASTER_HOST variables respectively.
 * 2. Second, an HTTPS connection is enforced if $FORCE_HTTPS is set to true.
 *    If $FORCE_HTTPS === true and the current connection is not secure, the
 *    user is redirected to a secure (https) URL.
 * 3. The desired page is determined from the URL (see below). If this page
 *    is really an alias for another page, the user is redirected to the proper
 *    page.
 * 4. If the user did not request the page using the cannonical filename,
 *    they are redirected to the cannonical URL for the page (see below).
 *
 * How the desired page is determined from the URL:
 *
 * Every page has a name, and there are two valid URLs for each page name.
 * For a page named "foobar", the following are valid URLs for the page:
 *      1. http://example.com/foobar
 *      2. http://example.com/foobar.htm
 * (2) is the cannonical URL for the page. So if the user were to type (1) into
 * their browser, they would be redirected to (2). The URL without the .htm
 * extension is recognized as a convienience so the URL can be spoken without
 * explicitly pronouncing the "dot h-t-m."
 *
 * Names can also contain forward slashes, allowing virtual directories to be
 * created. For example, the page name "foo/bar" is valid, with the following
 * URLs:
 *      1. http://example.com/foo/bar
 *      2. http://example.com/foo/bar.htm
 * With (2) being the cannonical form.
 * There is a special case of these names where no ".htm" extension is allowed.
 * For example, the name "" (meaning the homepage) is accessible though:
 *          http://example.com/
 * but NOT through:
 *          http://example.com/.htm
 * The same applies to names ending in "/", e.g. "foo/" is accessible through:
 *          http://example.com/foo/
 * but NOT through:
 *          http://example.com/foo/.htm
 * Note that a page named "foo/" and "foo" can exist simultaneously, but since
 * it is common to ommit the trailing "/" when typing the URL, this practice
 * is strongly discouraged. If the name "foo/" exists and the user omits the 
 * trailing "/", they will be redirected to the "foo/" URL. But if "foo/" and
 * "foo" both exist, they will be redirected to "foo.htm".
 */

// Keys used for definining page data arrays
define('P_FILE', 0); // File content (suffix to $ROOT_FOLDER)
define('P_TITL', 1); // <title>text</title>
define('P_METD', 2); // META tag description
define('P_METK', 3); // META tag keywords
define('P_RDIR', 4); // Redirect URL (has precidence)

class URLParse
{
    private static $ROOT_FOLDER = "pages/";
    private static $MASTER_HOST = "crackstation.net";
    private static $ACCEPTED_HOSTS = array(
                                            "crackstation.h.defuse.ca",
                                            "crackstation:20443"
                                            );
    private static $FORCE_HTTPS = true;
    private static $DEFAULT_TITLE = "CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.";
    private static $DEFAULT_META_DESC = "Crackstation is the most effective hash cracking service. We crack: MD5, SHA1, SHA2, WPA, and much more...";
    private static $DEFAULT_META_KEYWORDS = "md5 cracking, sha1 cracking, hash cracking, password cracking";

    private static $PAGE_INFO = array(
            "" =>           array(
                P_FILE => "home.php",
                ),
            // Handles /index and /index.htm
            "index" =>      array(
                P_RDIR => "",
                ),
            "index.html" =>  array(
                P_RDIR => "",
                ),
            "index.php" =>  array(
                P_RDIR => "",
                ),
            "cracking-services.html" => array(
                P_RDIR => "cracking-services",
            ),
            "cracking-services" => array(
                P_FILE => "cracking-services.php",
                P_TITL => "CrackStation - Advanced Password Hash Cracking Services",
                P_METD => "Hash and encryption cracking. MD5, LM, WPA, WEP, ANY algorithm. Bulk cracking.",
                P_METK => "password cracking, wpa cracking, bulk cracking, md5 cracking",
                ),
            "hashing-security.html" => array(
                P_RDIR => "hashing-security",
                ),
            "hashing-security" => array(
                P_FILE => "hashing-security.php",
                P_TITL => "Secure Salted Password Hashing - How to do it Properly",
                P_METD => "How to hash passwords properly using salt. Why hashes should be salted and how to use salt correctly.",
                P_METK => "salt, salted hashing, secure password hashing, password hashing, proper way to hash passwords",
                ),
            "hashing-security-draft" => array(
                P_FILE => "hashing-security-draft.php",
                P_TITL => "Secure Salted Password Hashing - How to do it Properly",
                P_METD => "How to hash passwords properly using salt. Why hashes should be salted and how to use salt correctly.",
                P_METK => "salt, salted hashing, secure password hashing, password hashing, proper way to hash passwords",
                ),
            "downloads" => array(
                P_FILE => "downloads.php",
                P_TITL => "CrackStation Tools & Downloads",
                P_METD => "Free tools & Downloads provided by CrackStation",
                P_METK => "hash tools, hash cracking, password cracking",
                ),
            "contact-us" => array(
                P_FILE => "contactus.php",
                P_TITL => "CrackStation Contact",
                P_METD => "Instructions for contacting CrackStation",
                P_METK => "crackstation contact",
                ),
            "about-us" => array(
                P_FILE => "aboutus.php",
                P_TITL => "CrackStation Contact",
                P_METD => "What CrackStation is and why we exist",
                P_METK => "crackstation contact",
                ),
            "thank-you" => array(
                P_FILE => "thank-you.php",
                P_TITL => "Thanks!",
                P_METD => "Donation Confirmation Page"
                ),
            "buy-crackstation-wordlist-password-cracking-dictionary" => array(
                P_RDIR => "crackstation-wordlist-password-cracking-dictionary"
                ),
            "crackstation-wordlist-password-cracking-dictionary" => array(
                P_FILE => "buy-crackstation-wordlist-cracking-dictionary.php",
                P_TITL => "CrackStation's Password Cracking Dictionary (Pay what you want!)",
                P_METD => "Download CrackStation's password cracking wordlist.",
                P_METK => "password cracking wordlist, biggest password cracking wordlist, cracking dictionary",
                ),
            "how-crackstation-works" => array(
                P_FILE => "how-crackstation-works.php",
                P_TITL => "How CrackStation Works",
                P_METD => "How CrackStation's non-salted hash cracking system works.",
                P_METK => "hash lookup table, binary search, hash cracking"
                ),
            "legal-privacy.html" => array(
                P_RDIR => "legal-privacy"
                ),
            "legal-privacy" => array(
                P_FILE => "legal-privacy.php",
                P_TITL => "CrackStation - Legal and Privacy",
                P_METD => "CrackStation.net's privacy policy",
                P_METK => "hash cracking legal, penetration testing, password security",
                ),
            );

    // Page to be displayed for invalid URLs
    private static $FILE_NOT_FOUND = array(
                        P_FILE => "404.php",
                        P_TITL => "File Not Found",
                        );
                        

    private static $to_show;

    public static function ProcessURL()
    {
        // Check the host the request was made to, and redirect if necessary.
        self::checkHost(); 
        // Check the HTTPS status, redirect if necessary.
        self::checkHTTPS();

        $page_info_key = self::getPageArrayKey();
        if($page_info_key === false)
        {
            self::send404Headers();
            self::$to_show = self::$FILE_NOT_FOUND;
            return "404";
        }
        else
        {
            $page_array = self::$PAGE_INFO[$page_info_key];
            self::checkRedirectRequest($page_array);
            self::ensureHTMOrSlashExtension($page_array, $page_info_key);
            self::$to_show = $page_array;
            return $page_info_key;
        }
    }

    public static function getPageTitle($name)
    {
        if(array_key_exists($name, self::$PAGE_INFO))
        {
            $page_array = self::$PAGE_INFO[$name];
            if(array_key_exists(P_TITL, $page_array))
                return $page_array[P_TITL];
            else
                return self::$DEFAULT_TITLE;
        }
        else
            return self::$DEFAULT_TITLE;
    }

    public static function getPageMetaDescription($name)
    {
        if(array_key_exists($name, self::$PAGE_INFO))
        {
            $page_array = self::$PAGE_INFO[$name];
            if(array_key_exists(P_METD, $page_array))
                return $page_array[P_METD];
            else
                return self::$DEFAULT_META_DESC;
        }
        else
            return self::$DEFAULT_META_DESC;
    }

    public static function getPageMetaKeywords($name)
    {
        if(array_key_exists($name, self::$PAGE_INFO))
        {
            $page_array = self::$PAGE_INFO[$name];
            if(array_key_exists(P_METK, $page_array))
                return $page_array[P_METK];
            else
                return self::$DEFAULT_META_KEYWORDS;
        }
        else
            return self::$DEFAULT_META_KEYWORDS;
    }

    // Includes the page contents (ProcessURL must be called first). 
    // Returns the name of the included page.
    public static function IncludePageContents()
    {
        $included = "";
        if(isset(self::$to_show) && array_key_exists(P_FILE, self::$to_show) && 
                        file_exists(self::$ROOT_FOLDER . self::$to_show[P_FILE]))
        {
            $included = self::$ROOT_FOLDER . self::$to_show[P_FILE]; 
            include($included);
        }
        else
        {
            $included = self::$ROOT_FOLDER . self::$FILE_NOT_FOUND[P_FILE]; 
            include($included); 
        }
        return $included;
    }

    // Make sure the request is coming to one of the accepted hosts, and if not,
    // redirect to the master host.
    private static function checkHost()
    {
        $http_host = $_SERVER['HTTP_HOST'];
        if($http_host != self::$MASTER_HOST && !in_array($http_host, self::$ACCEPTED_HOSTS))
        {
            // We anticipate the HTTPS requirement here so that we can avoid a 
            // second redirect from checkHTTPS()
            // Use https:// protocol if:
            //          1. $FORCE_HTTPS is true
            //      or, 2. HTTPS is already in use.
            if(self::$FORCE_HTTPS || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'))
                $protocol = "https://";
            else
                $protocol = "http://";

            // Redirect to the master host
            self::permRedirect($protocol . self::$MASTER_HOST . "/" . 
                            self::getUrlFile() . self::getUrlParams());
        }
    }

    // If $FORCE_HTTPS is true and HTTPS is not in use, redirect to an HTTPS URL
    private static function checkHTTPS()
    {
        if(self::$FORCE_HTTPS && (empty($_SERVER["HTTPS"]) || $_SERVER['HTTPS'] == 'off'))
        {
            self::permRedirect("https://" . $_SERVER['HTTP_HOST'] . "/" . 
                            self::getUrlFile() . self::getUrlParams());
        }
    }

    // Returns the page name ($PAGE_INFO key) for the currently requested page, or
    // false if the page requested is not present in $PAGE_INFO.
    // e.g. if the url is either:
    //    a) http://example.com/foo.htm
    // or b) http://example.com/foo
    // this method will return 'foo', if $PAGE_INFO['foo'] exists.
    private static function getPageArrayKey()
    {
        $page_name = strtolower(self::getUrlFile());
        $htm_removed = false;

        // Remove the .htm extension if present
        if(strpos($page_name, ".htm") === strlen($page_name) - 4)
        {
            $page_name = substr($page_name, 0, strlen($page_name) - 4);
            $htm_removed = true;

            // If the page name ends in a "/", it is not valid, e.g:
            // http://example.com/.htm
            // http://example.com/foo/.htm
            if(empty($page_name) || $page_name[strlen($page_name) - 1] == "/")
                return false;
        }

        // Return the page array if the page exists, otherwise boolean false.
        if(array_key_exists($page_name, self::$PAGE_INFO))
        {
            return $page_name;
        }
        elseif(array_key_exists($page_name . "/", self::$PAGE_INFO) && !$htm_removed)
        {
            return $page_name . "/";
        }
        else
        {
            return false;
        }
    }

    // Checks if the P_RDIR index exists in the page array and redirects to
    // the specified page if so.
    private static function checkRedirectRequest($page_array)
    {
        if(array_key_exists(P_RDIR, $page_array))
        {
            $redir = $page_array[P_RDIR];

            // Anticipate the need for .htm extension to avoid a second redirect
            // All pages that don't end in a / must end in .htm
            if(!empty($redir) && $redir[strlen($redir) - 1] != "/")
            {
                $redir .= ".htm";
            }

            // Redirect, keeping the URL parameters.
            self::permRedirect(self::getUrlFront() . $redir . self::getUrlParams());
        }
    }

    // Ensures that the current URL ends in .htm, if it is the URL of a normal
    // page, or ends in "/" if it is the URL of a virtual directory root.
    // http://example.com/?bar => http://example.com/?bar
    // http://example.com/foo/bar?baz => http://example.com/foo/bar.htm?baz
    // http://example.com/hello => http://example.com/hello/ (if $proper_name is "hello/")
    private static function ensureHTMOrSlashExtension($page_array, $proper_name)
    {
        $file = self::getUrlFile();

        // If the page is a directory (other than the root)...
        if(!empty($proper_name) && $proper_name[strlen($proper_name) - 1] == "/") 
        {
            if($file[strlen($file) - 1] != "/") // ... make sure it ends in "/"
            {
                // Redirect to the / version, preserving the parameters
                self::permRedirect(self::getUrlFront() . $file . "/" . self::getUrlParams()); 
            }
        }
        // Otherwise, if it's a normal page name, it should end in .htm
        elseif(!empty($file) && strpos($file, ".htm") != strlen($file) - 4)
        {
            // Redirect to the .htm version, preserving the parameters
            self::permRedirect(self::getUrlFront() . $file . ".htm" . self::getUrlParams()); 
        }
    }

    // Returns the URL parameters, if any.
    // If there are URL parameters, a the parameter string (including "?")
    // will be returned. If there are none, the empty string is returned.
    private static function getUrlParams()
    {
        $url = $_SERVER['REQUEST_URI'];
        $question = strpos($url, "?");
        if($question !== FALSE)
            return substr($url, $question);
        else
            return "";
    }

    // Returns the file part of the URL. This is everything after (not including)
    // the first "/" after the host name and before (not including) the "?" in
    // front of the URL parameters.
    // e.g. http://example.com/foo/bar.htm?baz=foo returns "foo/bar.htm"
    private static function getUrlFile()
    {
        $url = $_SERVER['REQUEST_URI'];
        $first_slash = self::getFirstSlashIndex($url);
        $question = strpos($url, "?");
        if($question === false)
            return substr($url, $first_slash + 1);
        else
            return substr($url, $first_slash + 1, $question - $first_slash - 1);
    }

    // Returns the protocol and host part of the URL, including the "/" after
    // the host name.
    private static function getUrlFront()
    {
        $url = $_SERVER['REQUEST_URI'];
        $first_slash = self::getFirstSlashIndex($url);
        return substr($url, 0, $first_slash + 1);
    }

    // Returns the index of the slash after the hostname, or the index of the
    // last character in the string if there is none.
    private static function getFirstSlashIndex($url)
    {
        $prot_end = strpos($url, "://");
        if($prot_end === false)
            $prot_end = 0;
        else
            $prot_end += 3; // skip over the ://

        // find the first slash after the end of the protocol specifier
        $first_slash = strpos($url, "/", $prot_end);

        // If there is no slash after the protocol specifier, the entire URL
        // is considered the "front" so we return the index of the last element.
        if($first_slash === false)
            return strlen($url) - 1;
        else
            return $first_slash;
    }

    // Send a HTTP 301 Moved Permanently redirect and cease script execution.
    private static function permRedirect($newUrl)
    {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: $newUrl");
        die();
    }

    // Send the HTTP 404 Not Found header
    private static function send404Headers()
    {
        header("HTTP/1.0 404 Not Found");
        header("Status: 404 Not Found");
    }
}
?>


================================================
FILE: src/libs/phpcount.php
================================================
<?php
// WARNING: HACKED BY ADDING 'cs' PREFIX TO EVERY TABLE NAME.
/*
 * phpcount.php Ver.1.1- An "anoymizing" hit counter.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * This PHP Class provides a hit counter that is able to track unique hits
 * without recording the visitor's IP address in the database. It does so by 
 * recording the hash of the IP address and page name.
 *
 * By hashing the IP address with page name as salt, you prevent yourself from
 * being able to track a user as they navigate your site. You also prevent 
 * yourself from being able to recover anyone's IP address without brute forcing
 * through all of the assigned IP address blocks in use by the internet.
 *
 * Contact: havoc AT defuse.ca
 * WWW:     https://defuse.ca/
 *
 * USAGE:
 *        In your script, use reqire_once() to import this script, then call the
 *        functions like PHPCount::AddHit(...); See each function for help.
 *
 * NOTE: You must set the database credentials in the InitDB method.
 */

require_once('/storage/creds.php');

class PHPCount
{
   /*
    * Defines how many seconds a hit should be rememberd for. This prevents the
    * database from perpetually increasing in size. Thirty days (the default)
    * works well. If someone visits a page and comes back in a month, it will be
    * counted as another unique hit.
    */
    const HIT_OLD_AFTER_SECONDS = 2592000; // default: 30 days.

    // Don't count hits from search robots and crawlers.
    const IGNORE_SEARCH_BOTS = true;

    // Don't count the hit if the browser sends the DNT: 1 header.
    const HONOR_DO_NOT_TRACK = false;

    private static $IP_IGNORE_LIST = array(
        '127.0.0.1',
    );

    private static $DB = false;

    private static function InitDB()
    {
        if(self::$DB)
            return;

        try
        {
            // TODO: Set the database login credentials.
            $creds = Creds::getCredentials("df_phpcount");
            self::$DB = new PDO(
                "mysql:host={$creds[C_HOST]};dbname={$creds[C_DATB]}",
                $creds[C_USER], // Username
                $creds[C_PASS], // Password
                array(PDO::ATTR_PERSISTENT => true)
            );
            self::$DB->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
            unset($creds);
        }
        catch(Exception $e)
        {
            die('Failed to connect to phpcount database');
        }
    }

    /*
     * Adds a hit to a page specified by a unique $pageID string.
     */
    public static function AddHit($pageID)
    {
        if(self::IGNORE_SEARCH_BOTS && self::IsSearchBot())
            return false;
        if(in_array($_SERVER['REMOTE_ADDR'], self::$IP_IGNORE_LIST))
            return false;
        if(
            self::HONOR_DO_NOT_TRACK &&
            isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == "1"
        ) {
            return false;
        }

        self::InitDB();

        self::Cleanup();
        self::CreateCountsIfNotPresent($pageID);
        if(self::UniqueHit($pageID))
        {
            self::CountHit($pageID, true);
            self::LogHit($pageID);
        }
        self::CountHit($pageID, false);

        return true;
    }
    
    /*
     * Returns (int) the amount of hits a page has
     * $pageID - the page identifier
     * $unique - true if you want unique hit count
     */
    public static function GetHits($pageID, $unique = false)
    {
        self::InitDB();

        self::CreateCountsIfNotPresent($pageID);

        $q = self::$DB->prepare(
            'SELECT hitcount FROM cshits
             WHERE pageid = :pageid AND isunique = :isunique'
        );
        $q->bindParam(':pageid', $pageID);
        $q->bindParam(':isunique', $unique);
        $q->execute();

        if(($res = $q->fetch()) !== FALSE)
        {
            return (int)$res['hitcount'];
        }
        else
        {
            die("Missing hit count from database!");
            return false;
        }
    }
    
    /*
     * Returns the total amount of hits to the entire website
     * When $unique is FALSE, it returns the sum of all non-unique hit counts
     * for every page. When $unique is TRUE, it returns the sum of all unique
     * hit counts for every page, so the value that's returned IS NOT the 
     * amount of site-wide unique hits, it is the sum of each page's unique
     * hit count.
     */
    public static function GetTotalHits($unique = false)
    {
        self::InitDB();

        $q = self::$DB->prepare(
            'SELECT hitcount FROM cshits WHERE isunique = :isunique'
        );
        $q->bindParam(':isunique', $unique);
        $q->execute();
        $rows = $q->fetchAll();

        $total = 0;
        foreach($rows as $row)
        {
            $total += (int)$row['hitcount'];
        }
        return $total;
    }
    
    /*====================== PRIVATE METHODS =============================*/
    
    private static function IsSearchBot()
    {
        // Of course, this is not perfect, but it at least catches the major
        // search engines that index most often.
        $keywords = array(
            'bot',
            'spider',
            'spyder',
            'crawlwer',
            'walker',
            'search',
            'yahoo',
            'holmes',
            'htdig',
            'archive',
            'tineye',
            'yacy',
            'yeti',
        );

        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);

        foreach($keywords as $keyword) 
        {
            if(strpos($agent, $keyword) !== false)
                return true;
        }

        return false;
    }

    private static function UniqueHit($pageID)
    {
        $ids_hash = self::IDHash($pageID);

        $q = self::$DB->prepare(
            'SELECT time FROM csnodupes WHERE ids_hash = :ids_hash'
        );
        $q->bindParam(':ids_hash', $ids_hash);
        $q->execute();

        if(($res = $q->fetch()) !== false)
        {
            if($res['time'] > time() - self::HIT_OLD_AFTER_SECONDS)
                return false;
            else
                return true;
        }
        else
        {
            return true;
        }
    }
    
    private static function LogHit($pageID)
    {
        $ids_hash = self::IDHash($pageID);

        $q = self::$DB->prepare(
            'SELECT time FROM csnodupes WHERE ids_hash = :ids_hash'
        );
        $q->bindParam(':ids_hash', $ids_hash);
        $q->execute();

        $curTime = time();

        if(($res = $q->fetch()) !== false)
        {
            $s = self::$DB->prepare(
                'UPDATE csnodupes SET time = :time WHERE ids_hash = :ids_hash'
            );
            $s->bindParam(':time', $curTime);
            $s->bindParam(':ids_hash', $ids_hash);
            $s->execute();
        }
        else
        {
            $s = self::$DB->prepare(
                'INSERT INTO csnodupes (ids_hash, time)
                 VALUES( :ids_hash, :time )'
            );
            $s->bindParam(':time', $curTime);
            $s->bindParam(':ids_hash', $ids_hash);
            $s->execute();
        }
    }
    
    private static function CountHit($pageID, $unique)
    {
        $q = self::$DB->prepare(
            'UPDATE cshits SET hitcount = hitcount + 1 ' .
            'WHERE pageid = :pageid AND isunique = :isunique'
        );
        $q->bindParam(':pageid', $pageID);
        $unique = $unique ? '1' : '0';
        $q->bindParam(':isunique', $unique);
        $q->execute();
    }
    
    private static function IDHash($pageID)
    {
        $visitorID = $_SERVER['REMOTE_ADDR'];
        return hash("SHA256", $pageID . $visitorID);
    }
    
    private static function CreateCountsIfNotPresent($pageID)
    {
        // Non-unique
        $q = self::$DB->prepare(
            'SELECT pageid FROM cshits WHERE pageid = :pageid AND isunique = 0'
        );
        $q->bindParam(':pageid', $pageID);
        $q->execute();

        if($q->fetch() === false)
        {
            $s = self::$DB->prepare(
                'INSERT INTO cshits (pageid, isunique, hitcount) 
                 VALUES (:pageid, 0, 0)'
            );
            $s->bindParam(':pageid', $pageID);
            $s->execute();
        }

        // Unique
        $q = self::$DB->prepare(
            'SELECT pageid FROM cshits WHERE pageid = :pageid AND isunique = 1'
        );
        $q->bindParam(':pageid', $pageID);
        $q->execute();

        if($q->fetch() === false)
        {
            $s = self::$DB->prepare(
                'INSERT INTO cshits (pageid, isunique, hitcount) 
                 VALUES (:pageid, 1, 0)'
            );
            $s->bindParam(':pageid', $pageID);
            $s->execute();
        }
    }
    
    private static function Cleanup()
    {
        $last_interval = time() - self::HIT_OLD_AFTER_SECONDS;

        $q = self::$DB->prepare(
            'DELETE FROM csnodupes WHERE time < :time'
        );
        $q->bindParam(':time', $last_interval);
        $q->execute();
    }
}


================================================
FILE: src/libs/recaptchalib.php
================================================
<?php
/*
 * This is a PHP library that handles calling reCAPTCHA.
 *    - Documentation and latest version
 *          http://recaptcha.net/plugins/php/
 *    - Get a reCAPTCHA API Key
 *          https://www.google.com/recaptcha/admin/create
 *    - Discussion group
 *          http://groups.google.com/group/recaptcha
 *
 * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
 * AUTHORS:
 *   Mike Crawford
 *   Ben Maurer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

/**
 * The reCAPTCHA server URL's
 */
define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");

/**
 * Encodes the given data into a query string format
 * @param $data - array of string elements to be encoded
 * @return string - encoded request
 */
function _recaptcha_qsencode ($data) {
        $req = "";
        foreach ( $data as $key => $value )
                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';

        // Cut the last '&'
        $req=substr($req,0,strlen($req)-1);
        return $req;
}



/**
 * Submits an HTTP POST to a reCAPTCHA server
 * @param string $host
 * @param string $path
 * @param array $data
 * @param int port
 * @return array response
 */
function _recaptcha_http_post($host, $path, $data, $port = 80) {

        $req = _recaptcha_qsencode ($data);

        $http_request  = "POST $path HTTP/1.0\r\n";
        $http_request .= "Host: $host\r\n";
        $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
        $http_request .= "Content-Length: " . strlen($req) . "\r\n";
        $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
        $http_request .= "\r\n";
        $http_request .= $req;

        $response = '';
        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
                die ('Could not open socket');
        }

        fwrite($fs, $http_request);

        while ( !feof($fs) )
                $response .= fgets($fs, 1160); // One TCP-IP packet
        fclose($fs);
        $response = explode("\r\n\r\n", $response, 2);

        return $response;
}



/**
 * Gets the challenge HTML (javascript and non-javascript version).
 * This is called from the browser, and the resulting reCAPTCHA HTML widget
 * is embedded within the HTML form it was called from.
 * @param string $pubkey A public key for reCAPTCHA
 * @param string $error The error given by reCAPTCHA (optional, default is null)
 * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)

 * @return string - The HTML to be embedded in the user's form.
 */
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
{
	if ($pubkey == null || $pubkey == '') {
		die ("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>");
	}
	
	if ($use_ssl) {
                $server = RECAPTCHA_API_SECURE_SERVER;
        } else {
                $server = RECAPTCHA_API_SERVER;
        }

        $errorpart = "";
        if ($error) {
           $errorpart = "&amp;error=" . $error;
        }
        return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>

	<noscript>
        <div style="background-color: white; border: solid black 3px; margin: 20px;">
  		<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
  		<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
  		<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
        </div>
	</noscript>';
}




/**
 * A ReCaptchaResponse is returned from recaptcha_check_answer()
 */
class ReCaptchaResponse {
        var $is_valid;
        var $error;
}


/**
  * Calls an HTTP POST function to verify if the user's guess was correct
  * @param string $privkey
  * @param string $remoteip
  * @param string $challenge
  * @param string $response
  * @param array $extra_params an array of extra variables to post to the server
  * @return ReCaptchaResponse
  */
function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
	if ($privkey == null || $privkey == '') {
		die ("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>");
	}

	if ($remoteip == null || $remoteip == '') {
		die ("For security reasons, you must pass the remote ip to reCAPTCHA");
	}

	
	
        //discard spam submissions
        if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
                $recaptcha_response = new ReCaptchaResponse();
                $recaptcha_response->is_valid = false;
                $recaptcha_response->error = 'incorrect-captcha-sol';
                return $recaptcha_response;
        }

        $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
                                          array (
                                                 'privatekey' => $privkey,
                                                 'remoteip' => $remoteip,
                                                 'challenge' => $challenge,
                                                 'response' => $response
                                                 ) + $extra_params
                                          );

        $answers = explode ("\n", $response [1]);
        $recaptcha_response = new ReCaptchaResponse();

        if (trim ($answers [0]) == 'true') {
                $recaptcha_response->is_valid = true;
        }
        else {
                $recaptcha_response->is_valid = false;
                $recaptcha_response->error = $answers [1];
        }
        return $recaptcha_response;

}

/**
 * gets a URL where the user can sign up for reCAPTCHA. If your application
 * has a configuration page where you enter a key, you should provide a link
 * using this function.
 * @param string $domain The domain where the page is hosted
 * @param string $appname The name of your application
 */
function recaptcha_get_signup_url ($domain = null, $appname = null) {
	return "https://www.google.com/recaptcha/admin/create?" .  _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
}

function _recaptcha_aes_pad($val) {
	$block_size = 16;
	$numpad = $block_size - (strlen ($val) % $block_size);
	return str_pad($val, strlen ($val) + $numpad, chr($numpad));
}

/* Mailhide related code */

function _recaptcha_aes_encrypt($val,$ky) {
	if (! function_exists ("mcrypt_encrypt")) {
		die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
	}
	$mode=MCRYPT_MODE_CBC;   
	$enc=MCRYPT_RIJNDAEL_128;
	$val=_recaptcha_aes_pad($val);
	return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
}


function _recaptcha_mailhide_urlbase64 ($x) {
	return strtr(base64_encode ($x), '+/', '-_');
}

/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
function recaptcha_mailhide_url($pubkey, $privkey, $email) {
	if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
		die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
		     "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
	}
	

	$ky = pack('H*', $privkey);
	$cryptmail = _recaptcha_aes_encrypt ($email, $ky);
	
	return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
}

/**
 * gets the parts of the email to expose to the user.
 * eg, given johndoe@example,com return ["john", "example.com"].
 * the email is then displayed as john...@example.com
 */
function _recaptcha_mailhide_email_parts ($email) {
	$arr = preg_split("/@/", $email );

	if (strlen ($arr[0]) <= 4) {
		$arr[0] = substr ($arr[0], 0, 1);
	} else if (strlen ($arr[0]) <= 6) {
		$arr[0] = substr ($arr[0], 0, 3);
	} else {
		$arr[0] = substr ($arr[0], 0, 4);
	}
	return $arr;
}

/**
 * Gets html to display an email address given a public an private key.
 * to get a key, go to:
 *
 * http://www.google.com/recaptcha/mailhide/apikey
 */
function recaptcha_mailhide_html($pubkey, $privkey, $email) {
	$emailparts = _recaptcha_mailhide_email_parts ($email);
	$url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
	
	return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
		"' 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]);

}


?>


================================================
FILE: src/pages/404.php
================================================
<div style="text-align:center;">
<span style="font-size: 36pt;">Oops!</span><br />
<span style="font-size: 26pt;">This page does not exist.</span> <br /><br /><br /><br />
<img src="/images/divzero.png" /> <br /><br /><br /><br />
<span style="font-size: 14pt; color: #888888;">(ERROR 404)</span>
</div>


================================================
FILE: src/pages/aboutus.php
================================================
<div class="box">
<div class="padding">
<h1>About CrackStation</h1>

<p>
CrackStation is a security awareness project started by <a href="https://defuse.ca/">Defuse
Security</a>. Its purpose is to raise awareness about insecure password storage in web
applications, and to provide guidance to implementors of user authentication systems. By making
large hash lookup tables freely available to the public, we make it easier for security researchers
to demonstrate why password storage solutions, like non-salted hashing, are insecure.
</p>

<p>
While CrackStation does provide paid services, its goal is not to make a profit. The money is used
to pay for the hardware required to run CrackStation, and any left-overs go toward other security
research projects (the results of which are released into the public domain). You may support
CrackStation and other Defuse Security projects by donating using the PayPal donate button
above.
</p>

<p>
If you have any questions, comments, or concerns about CrackStation, or would like help implementing
secure password storage in an authentication system, please contact us. You can find
our contact information on the <a href="/contact-us.htm">Contact Information Page</a>.
</p>

</div>
</div>


================================================
FILE: src/pages/buy-crackstation-wordlist-cracking-dictionary.php
================================================
<h1>CrackStation's Password Cracking Dictionary</h1>

<p>
I am releasing CrackStation's main password cracking dictionary (1,493,677,782
words, 15GB) for download.
</p>

<h2>What's in the list?</h2>

<p>
The list contains every wordlist, dictionary, and password database leak that
I could find on the internet (and I spent a LOT of time looking). It also
contains every word in the Wikipedia databases (pages-articles, retrieved 2010,
all languages) as well as lots of books from <a
href="http://www.gutenberg.org/">Project Gutenberg</a>. It also includes the
passwords from some low-profile database breaches that were being sold in the
underground years ago.
</p>

<p>
The format of the list is a standard text file sorted in non-case-sensitive
alphabetical order. Lines are separated with a newline "\n" character.
</p>

<p>
You can test the list without downloading it by giving SHA256 hashes to the <a
href="/">free hash cracker</a>. Here's a <a
href="https://defuse.ca/checksums.htm"> tool for computing hashes easily</a>.
Here are the results of cracking <a
href="https://defuse.ca/blog/cracking-linkedin-hashes-with-crackstation">LinkedIn's</a>
and <a
href="https://defuse.ca/blog/cracking-eharmonys-unsalted-hashes-with-crackstation">
eHarmony's</a> password hash leaks with the list.
</p>

<p>
The list is responsible for
cracking about 30% of all hashes given to CrackStation's free hash cracker, but
that figure should be taken with a grain of salt because some people try hashes
of really weak passwords just to test the service, and others try to crack their
hashes with other online hash crackers before finding CrackStation. Using the
list, we were able to crack 49.98% of one customer's set of 373,000
human password hashes to motivate their move to a better salting scheme.
</p>

<h2>Download</h2>

<p>
<b>Note:</b> To download the torrents, you will need a torrent client like
Transmission (for Linux and Mac), or uTorrent for Windows.
</p>

<div style="text-align: center;">
    <a class="wldl" href="/downloads/crackstation.txt.gz.torrent">
        <span style="font-size: 20pt;">Torrent (Fast)</span>
        <br />
        GZIP-compressed (level 9). 4.2 GiB compressed. 15 GiB uncompressed.
    </a>
    <br /><br />
    <a class="wldl" href="/files/crackstation.txt.gz">
        <span style="font-size: 16pt;">HTTP Mirror (Slow)</span>
    </a>
</div>

<h4>Checksums (crackstation.txt.gz)</h4>

<pre>
MD5:    4748a72706ff934a17662446862ca4f8
SHA1:   efa3f5ecbfba03df523418a70871ec59757b6d3f
SHA256: a6dc17d27d0a34f57c989741acdd485b8aee45a6e9796daf8c9435370dc61612
</pre>

<a name="humanpasswords"></a>
<h3>Smaller Wordlist (Human Passwords Only)</h3>

<p>
I got some requests for a wordlist with just the "real human" passwords leaked
from various website databases. This smaller list contains just those passwords.
There are about 64 million passwords in this list!
</p>

<div style="text-align: center;">
    <a class="wldl" href="/downloads/crackstation-human-only.txt.gz.torrent">
        <span style="font-size: 20pt;">Torrent (Fast)</span>
        <br />
        GZIP-compressed. 247 MiB compressed. 684 MiB uncompressed.
    </a>
    <br /><br />
    <a class="wldl" href="/files/crackstation-human-only.txt.gz">
        <span style="font-size: 16pt;">HTTP Mirror (Slow)</span>
    </a>
    <br />
</div>

<h4>Checksums (crackstation-human-only.txt.gz)</h4>

<pre>
MD5:    fbc3ca43230086857aac9b71b588a574
SHA1:   116c5f60b50e80681842b5716be23951925e5ad3
SHA256: 201f8815c71a47d39775304aa422a505fc4cca18493cfaf5a76e608a72920267
</pre>

<h3>Sharing and Licensing</h3>

<div style="text-align: center;">
<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>.
</div>

<p>
You <em>are</em> allowed to share these lists! They are both licensed under
the <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">Creative
Commons Attribution-ShareAlike 3.0</a> license. If you do share them, I would
appreciate it if you included a link to this page.
</p>



================================================
FILE: src/pages/contactus.php
================================================
<div class="box">
<div class="padding">
<h1>Contacting CrackStation</h1>

<p>
If you purchased the wordlist and it isn't working for you, or otherwise need
support with the website, or just want to provide feedback, please email me. You
can find my contact information
<a href="https://defuse.ca/contact.htm">here</a>.
</p>

</div>
</div>


================================================
FILE: src/pages/downloads.php
================================================
<h3>HashDB</h3>

<h3>PHP Cracking Script</h3>

<h3>Waterfall</h3>

<h3>Wordlists</h3>



================================================
FILE: src/pages/hashing-security-draft.php
================================================
<h1>How to Store Passwords</h1>

<p>
This article will walk you through the design of a secure password storage
system. Along the way, we'll encounter many common mistakes, and for each
mistake, we'll understand why it's a mistake and how to fix it.
</p>

<div style="background-color: #FFCCCC; border: solid red 1px; padding: 10px;">
<strong>IMPORTANT WARNING:</strong> If you are thinking of writing your own
password hashing code, <strong>please don't!</strong>. It's too easy to screw
up. No, that cryptography course you took in university doesn't make you exempt
from this warning. This applies to everyone: <strong>DO NOT WRITE YOUR OWN
CRYPTO!</strong> The problem of storing passwords has already been solved. Use either use either <a
href="http://www.openwall.com/phpass/">phpass</a> or the source code given on
this page.
</div>

<p>
If for some reason you missed that big red warning note, please go read it now.
Really, this guide is <b>not</b> meant to walk you through the process of
writing your own storage system, it's to explain the reasons why passwords
should be stored a certain way.
</p>

<p>
With that in mind, we can begin. To understand password storage, we will start
with an insecure system and iteratively improve it until it is secure. At each
iteration, we'll see how an attacker can take advantage of the vulnerability,
and how we as defenders can make the attacker's job harder.
</p>

<p>
For concreteness, we'll use a standard web site login system as an
example. 
</p>

<h2>Weak System #1: Plain Text Storage</h2>

<p>
The most obvious way to store passwords is to just put them straight into the
database without any kind of encryption or hashing. Obviously, this is
a horrible idea, since if an attacker gains access to your database, they will
have all of your users' passwords, and you'll be in PR hell trying to win back
your users' trust.
</p>

<p>
Worse, if attackers know you're storing passwords in plain text, they will
target you, because password databases are valuable and can be sold on the black
market.
</p>

<p>
It's a huge risk, not just to you, but to your users too. It's very common for
people to re-use the same password on multiple websites. If your website exposes
a user's password to an attacker, that attacker might be able to use it to log
in to the user's account on another website. You might be tempted to blame the
user for re-using their password, but if you had protected the passwords, the
user wouldn't be at risk, so it <em>is</em> partly your responsibility.
</p>

<p>
Another problem you'll have, if you store passwords in plain text, is that when
you get hacked, it will be nearly impossible to give your users a secure way to
reclaim their account, even after you've fixed the vulnerability. Once the
attacker has all of the passwords, they can log in to any accounts they're
interested in, set new passwords, and have permanent access to the accounts.
Protecting the password database buys you a little bit of time to tell your
users that they need to change their password.
</p>

<h2>Weak System #2: Encryption</h2>

<p>
The next obvious step is to encrypt passwords with symmetric encryption. As
we'll see, this turns out to be a bad idea.
</p>

<p>
Symmetric encryption works by using a random key to encrypt some data. The
encrypted data is called the ciphertext. To turn the ciphertext back into the
original data, you need to know the key that it was encrypted with. Without the
key, you can't decrypt the ciphertext.
</p>

<p>
You might think encrypting passwords would be a good idea. It's not, because
where do you store the key? The server that creates user accounts and verifies
usernames and passwords has to have access to it. So, chances are, if an
attacker can get the encrypted password database, they'll be able to get the
encryption key, and will be able to decrypt all of the passwords.
</p>

<h2>Weak System #3: Hashing Without Salt</h2>

<p>
To move on to a more secure design, we need to realize that to verify
a password, you don't actually need to know the correct password. It is possible
to compute the "fingerprint" of a password, with the following properties:
</p>

<ul>
    <li>It's very unlikely for two different passwords to have the same fingerprint.</li>
    <li>It's hard to "reverse" the fingerprint back into the password.</li>
</ul>

<p>
This can be done with a cryptographic hash function like SHA256. These functions
compute a fixed-length fingerprint from a variable-length input. They have the
properties we want: It's hard to find two inputs that hash to the same value,
and given an output, it's very difficult to find the input.
</p>

<p>
Here are some example SHA256 hashes. You can see that even if the input only
changes by one letter, the output looks completely different.
</p>

<div class="passcrack" style="text-align: center;">
hash("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />
hash("hbllo") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366<br />
hash("waltz") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542<br />
</div>

<p>
We can use a function like this to protect passwords. Instead of storing the
password in plain text, or encrypting the password, we can store the hash of the
password. Then, when a user logs in, we hash the password they've given us and
compare it to the hash that's saved in the database. Because the chance of two
passwords producing the same hash is extremely low (one of the properties of
a hash function), the chance of someone getting in with the wrong password is
also extremely low.
</p>

<p>
You might think we can stop here. In fact, we can't, because storing passwords
this way is insecure. 
</p>

<p>
To see why, consider what happens when two users have the same password: the
hashes are the same! An attacker can tell, just by comparing the hashes, which
users are using the same password. Clearly this is a vulnerability, since if the
attacker wants to get in to Alice's account, and sees that Bob has the same
password, the attacker can bribe (or torture) Bob for <em>his</em> password to
get into <em>Alice's</em> account.
</p>

<p>
That's not the only reason. Another reason is that the same password always
hashes to the same value. There's a one-to-one correspondence between hashes and
passwords. This means that an attacker can <b>pre-compute</b> huge tables of
hashes, then search for the hash they want to crack in that table. Because the
search 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
trying to guess the password for each hash.
</p>

<p>
To see how fast it can be, copy and paste these SHA256 hashes into <a href="https://crackstation.net/">CrackStation's Hash Cracker</a>:
</p>

<div class="passcrack" style="text-align: center;">
c11083b4b0a7743af748c85d343dfee9fbb8b2576c05f3a7f0d632b0926aadfc<br />
08eac03b80adc33dc7d8fbe44b7c7b05d3a2c511166bdb43fcb710b03ba919e7<br />
e4ba5cbd251c98e6cd1c23f126a3b81d8d8328abc95387229850952b3ef9f904<br />
5206b8b8a996cf5320cb12ca91c7b790fba9f030408efe83ebb83548dc3007bd<br />
</div>

<p>
The result is that all four hashes can be cracked in under a second. This is
obviously much faster than trying to guess each hash's password one by one.
Using this technique, an attacker can crack most of the hashes in your user
account database in a matter of minutes.
</p>

<p>
These password cracking databases are very real, and are used by attackers all
the time. One special type, called a "<a href="https://en.wikipedia.org/wiki/Rainbow_table">Rainbow Table</a>", can fit the MD5 hashes of
all possible 8 character passwords into a <a
href="https://www.freerainbowtables.com/en/tables2/">1049 GB file</a> that can be
downloaded from the Internet.
</p>

<h2>Weak System #4: Hashing With Salt</h2>

<p>
The attacks we saw in the previous section were possible because every time the
same password was hashed, the result was the same. This let attackers see who
was using the same password, and let them build a huge database of hashes that
could be quickly searched to find the password for a given hash.
</p>

<p>
To prevent these attacks, we need to make sure that even if two users use the
same password, or if one user uses the same password twice, the hash values are
always different. This is done by adding some randomness to the hashing process.
</p>

<p>
To hash a password, we use a cryptographically secure pseudo-random number
generator (CSPRNG) to generate a random string, called a <b>salt</b>, which we
prepend to the password before hashing it. We then save that random number with
the hash, since we'll need to verify passwords against the hash.
</p>

<p>
Here's what it looks like in pseudocode. The double bar symbol "A || B" means
concatenate the string A with the string B.
</p>

<div class="passcrack">
<pre>
# When a new account is created, or a user changes their password.
create_hash(PASSWORD):
    Generate a random string SALT with a CSPRNG.
    HASH = sha256(SALT || PASSWORD).
    return (SALT, HASH).


# When a user tries to log in.
check_password((SALT, HASH), PASSWORD_GUESS):
    GUESS_HASH = sha256(SALT || PASSWORD_GUESS).
    if GUESS_HASH equals HASH:
        return TRUE.
    else:
        return FALSE.
</pre>
</div>

<p>
Assuming the salt is long enough, always generated with a CSPRNG, and no salt is
ever used to hash more than one password, the attacks of the previous section
are no longer possible. The only way to crack these hashes is to test password
guesses for each hash individually. However, <b>this is still not good enough!</b>
</p>

<p>
Hash functions like SHA256 were designed to be fast. Good CPUs can compute
millions of SHA256 hashes per second, and good GPUs (graphics processors) can
compute <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
ASICs) can reach even higher speeds. This is exactly the opposite of what we
want, since it means an attacker who stole the user account database can crack
the hashes a rate of billions of password guesses per second. Not good.
</p>

<p>
This is the last hurdle in the race. Once we pass it, we'll finally arrive at
a secure password storage system.
</p>


<h2>Secure System #1: Slow Hashing</h2>

<p>
In the previous section, we added salt to our passwords to prevent
pre-computation attacks. We then saw that hash functions like SHA256 can be
computed extremely quickly by GPUs and custom hardware, letting attackers test
billions of passwords per second.
</p>

<p>
Password hashing functions don't need to be that fast. You probably won't be
handling millions of authentication requests per second from one server, so
there's no reason an authentication server will ever need to compute millions of
hashes per second. It's alright if the password hashing process is 1,000 times
or even 1,000,000 times slower than a regular hash function. To make things
harder for GPUs and custom hardware, <b>we also want the hashing process to need
lots of memory</b>.
</p>

<p>
It's not enough to add a call to <kbd>sleep()</kbd> or a time-consuming "no op"
loop into the password hashing code. An attacker can remove it and compute
hashes as fast as they want. Instead, the hashing function has to be truly hard
to compute. There should be no way to compute it any faster or with less memory.
More correctly stated, there should be no way to reduce the overall <kbd>time
* area</kbd> needed to compute the function, where "area" means the size of the
circuit you need to compute the hash in a given amount of time.
</p>

<p>
We want the defender's (password authenticator's) implementation of the function
to be as optimal as possible. This is important, since if the defender is taking
10x longer to compute the function, the attacker, using a 10x more efficient
implementation, has an advantage over the defender. That means these functions
should be implemented in native code (assembly language or C/C++), and not in
a scripting language.
</p>

<p>
Researchers are still figuring out how to best design these slow hashes. There's
a competition going on right now, called the <a
href="https://password-hashing.net/">Password Hashing Competition (PHC)</a>,  to find
the best one. It's similar in nature to the <a
href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard_process">competition
that selected the AES cipher</a>. Even though the competition hasn't finished
yet, we already have some slow hash functions that we think are good, and are in
common use. These are: <a href="https://www.tarsnap.com/scrypt/scrypt.pdf">scrypt</a>,
<a href="https://en.wikipedia.org/wiki/Bcrypt">bcrypt</a>, and
<a href="https://en.wikipedia.org/wiki/PBKDF2">PBKDF2</a>.
</p>

<p>
If you want to know more about how slow hashes are designed, read the <a
href="https://www.tarsnap.com/scrypt/scrypt.pdf">Scrypt paper</a> and the <a
href="http://eprint.iacr.org/2013/525.pdf">Catena paper</a>. You should also
join and read the <a href="https://password-hashing.net/interaction.html">PHC
mailing list</a>, since research in this area is evolving quickly! Whatever you
do, <b>do not try to design and use your own slow hash function</b>. Stick to
the ones that already exist and have been used for a while. Feel free to design
(and break) your own as a learning exercise, but for crying out loud, don't use
it.
</p>

<p>
So, if we choose scrypt as our slow hash, we can store passwords securely like
this. It's the same as before, except we're using scrypt instead of SHA256.
</p>

<div class="passcrack">
<pre>
# When a new account is created, or a user changes their password.
create_hash(PASSWORD):
    Generate a random string SALT with a CSPRNG.
    HASH = scrypt(SALT, PASSWORD).
    return (SALT, HASH).


# When a user tries to log in.
check_password((SALT, HASH), PASSWORD_GUESS):
    GUESS_HASH = scrypt(SALT, PASSWORD_GUESS).
    if GUESS_HASH equals HASH:
        return TRUE.
    else:
        return FALSE.
</pre>
</div>

<p>
- want defender to be optimized
- the functions are parameterized (take time and memory parameters)
- summarry like "we've mitigated pre-computation attacks as well as made it
extremely difficult for GPUs or whatever"
</p>

<pre>
     - Weak passwords can still be found .. intro next section with
       security-by-obscurity key.
     - AKA key stretching,
    - Offloading to the client (sjcl) -- does not remove need for server hashing
    - Re-read old post since this is missing some stuff that was covered in it
</pre>

<p>
Even with the salt and slow hashing, weak passwords can still be cracked.
In the next section, we'll see how, with the help of some special hardware, we
can protect our hashes so that even the weak ones can't be cracked.
</p>

<h2>Increasing Security: Hardware Security Modules</h2>

<pre>
    - Use hardware device with embedded key to do the hashing, so that unless
      it's physically stolen and tampered with, the passwords are really safe.
    - Also possible to do w/o custom hardware... just set up dedicated password
      authentication box that does nothing but hash passwords; no services, etc.
    - Mandatory for websites with more than 100k users.
    - Cloud options? (amazon thing)?
    - Physical options? (yubihsm?)
</pre>

<h2>Common Mistakes</h2>

<p>
Be on the lookout for these common password hashing mistakes.
</p>

<h3>Salt Reuse</h3>

<h3>Short Salts</h3>

<h3>Generating Salts with a Weak Random Number Generator</h3>

<h2>Frequently Asked Questions</h2>

<pre>
    - Basically the same list of FAQ from the original article except emphasize
        slow hashing.

     - In "what to do when" section... "don't clutter up the notice message with
all the crap about salt and hashing and scrypt, they won't understand. Just tell
them to change their password if they used it anywhere else etc. But do publish
the information about hashing, just don't make it distracting or give a false
sense of security."
</pre>

<h2>Source Code</h2>

<pre>
    - Embed the source code here.
    - Putting the source code way down here might make people miss it, so add
      prominent links up at the top (not just in the red warning box).
</pre>


================================================
FILE: src/pages/hashing-security.php
================================================
<h1>Salted Password Hashing - Doing it Right</h1>

<p>
If you're a web developer, you've probably had to make a user account system.
The most important aspect of a user account system is how user passwords are
protected. User account databases are hacked frequently, so you absolutely must
do something to protect your users' passwords if your website is ever breached.
The best way to protect passwords is to employ <b>salted password hashing</b>.
This page will explain why it's done the way it is.
</p>

<p>
There are a lot of conflicting ideas and misconceptions on how to do password
hashing properly, probably due to the abundance of misinformation on the web.
Password hashing is one of those things that's so simple, but yet so many people
get wrong. With this page, I hope to explain not only the correct way to do it,
but why it should be done that way.
</p>


<div style="background-color: #FFCCCC; border: solid red 1px; padding: 10px;">
<strong>IMPORTANT WARNING:</strong> If you are thinking of writing your own
password hashing code, <strong>please don't!</strong>. It's too easy to screw
up. No, that cryptography course you took in university doesn't make you exempt
from this warning. This applies to everyone: <strong>DO NOT WRITE YOUR OWN
CRYPTO!</strong> The problem of storing passwords has already been solved. Use
either use either <a href="http://www.openwall.com/phpass/">phpass</a>, the PHP,
C#, Java, and Ruby implementations in <a
href="https://github.com/defuse/password-hashing">defuse/password-hashing</a>,
or <a
href="https://download.libsodium.org/doc/password_hashing/index.html">libsodium</a>.
</div>

<p>
If for some reason you missed that big red warning note, please go read it now.
Really, this guide is <b>not</b> meant to walk you through the process of
writing your own storage system, it's to explain the reasons why passwords
should be stored a certain way.
</p>

<p>You may use the following links to jump to the different sections of this page.</p>

<table class="shortcuts">
<tbody><tr>
    <td><a href="#normalhashing" class="sca" title="What are hash functions and why are they used?">1. What is password hashing?</a></td>
    <td><a href="#attacks" class="sca" title="Methods for making hash cracking more efficient">2. How Hashes are Cracked</a></td>

    <td><a href="#salt" class="sca" title="Adding salt to render hash cracking attacks less effective">3. Adding Salt</a></td>
</tr>
<tr>
    <td><a href="#ineffective" class="sca" title="The wrong way to do password hashing">4. Ineffective Hashing Methods</a></td>
    <td><a href="#properhashing" class="sca" title="The right way to do password hashing, with salt">5. How to hash properly</a></td>
    <td><a href="#faq" class="sca" title="Frequently asked questions about password hashing and salt">6. Frequently Asked Questions</a></td>
</tr>
</tbody></table>

<a name="normalhashing"></a>
<h2>What is password hashing?</h2>
        <div class="passcrack" style="text-align: center;">
            hash("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />
            hash("hbllo") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366<br />
            hash("waltz") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542<br />
        </div>
<p>
Hash algorithms are one way functions. They turn any amount of data into
a fixed-length "fingerprint" that cannot be reversed. They also have the
property that if the input changes by even a tiny bit, the resulting hash is
completely different (see the example above). This is great for protecting
passwords, because we want to store passwords in a form that protects them even
if the password file itself is compromised, but at the same time, we need to be
able to verify that a user's password is correct.
</p>

<p>
The general workflow for account registration and authentication in a hash-based
account system is as follows:
</p>
<ol class="moveul">
    <li>The user creates an account.</li>
    <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>

    <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>
    <li>If the hashes match, the user is granted access. If not, the user is told they entered invalid login credentials.</li>
    <li>Steps 3 and 4 repeat every time someone tries to login to their account.</li>
</ol>

<p>
In step 4, never tell the user if it was the username or password they got wrong. Always display
a generic message like "Invalid username or password." This prevents attackers from enumerating
valid usernames without knowing their passwords.
</p>

<p>
It should be noted that the hash functions used to protect passwords are not the
same as the hash functions you may have seen in a data structures course. The
hash functions used to implement data structures such as hash tables are
designed to be fast, not secure. Only <b>cryptographic hash functions</b> may be
used to implement password hashing.  Hash functions like SHA256, SHA512, RipeMD,
and WHIRLPOOL are cryptographic hash functions.
</p>

<p>
It is easy to think that all you have to do is run the password through a
cryptographic hash function and your users' passwords will be secure. This is
far from the truth. There are many ways to recover passwords from plain hashes
very quickly. There are several easy-to-implement techniques that make these
"attacks" much less effective. To motivate the need for these techniques,
consider this very website. On the front page, you can submit a list of hashes
to be cracked, and receive results in less than a second. Clearly, simply
hashing the password does not meet our needs for security.
</p>

<p>The next section will discuss some of the common attacks used to crack plain password hashes.</p>

<a name="attacks"></a>
<h2>How Hashes are Cracked</h2>
<ul class="moveul" >
<li>
    <h3>Dictionary and Brute Force Attacks</h3>
    <table style="margin: 0 auto;">
    <tbody><tr>
    <td>
    <div class="passcrack" title="Cracking a hash with a wordlist">
        <center>Dictionary Attack</center><br />
        Trying apple &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: failed<br />
        Trying blueberry &nbsp;&nbsp;&nbsp;: failed<br />
        Trying justinbeiber : failed<br />
        <center>...</center>
        Trying letmein &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: failed<br />

        <span style="color: green;">Trying s3cr3t &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: success!</span><br />
    </div>
    </td>
    <td>
    <div class="passcrack" title="Cracking a hash by brute force">
        <center>Brute Force Attack</center><br />
        Trying aaaa : failed<br />
        Trying aaab : failed<br />
        Trying aaac : failed<br />
        <center>...</center>
        Trying acdb : failed<br />
        <span style="color: green;">Trying acdc : success!</span><br />
    </div>
    </td>
    </tr>
    </tbody></table>
    <p>
    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.
    The two most common ways of guessing passwords are <b>dictionary attacks</b> and <b>brute-force attacks</b>.
    </p>

    <p>
    A dictionary attack uses a file containing words, phrases, common passwords,
    and other strings that are likely to be used as a password. Each word in the
    file is hashed, and its hash is compared to the password hash. If they
    match, that word is the password. These dictionary files are constructed by
    extracting words from large bodies of text, and even from real databases of
    passwords. Further processing is often applied to dictionary files, such as
    replacing words with their "leet speak" equivalents ("hello" becomes
    "h3110"), to make them more effective.
    </p>

    <p>
    A brute-force attack tries every possible combination of characters up to a
    given length. These attacks are very computationally expensive, and are
    usually the least efficient in terms of hashes cracked per processor time,
    but they will always eventually find the password. Passwords should be long
    enough that searching through all possible character strings to find it will
    take too long to be worthwhile.
    </p>

    <p>
    There is no way to prevent dictionary attacks or brute force attacks. They
    can be made less effective, but there isn't a way to prevent them
    altogether. If your password hashing system is secure, the only way to crack
    the hashes will be to run a dictionary or brute-force attack on each hash.
    </p>
</li>

<li>
    <h3>Lookup Tables</h3>
    <center>
    <div class="passcrack" style="text-align: center;" title="Cracking many hashes with a pre-computed lookup table">
        <span style="color: green;">Searching: 5f4dcc3b5aa765d61d8327deb882cf99: FOUND: password5</span><br />
        Searching: 6cbe615c106f422d23669b610b564800: &nbsp;not in database<br />
        <span style="color: green;">Searching: 630bf032efe4507f2c57b280995925a9: FOUND: letMEin12 </span><br />
        <span style="color: green;">Searching: 386f43fab5d096a7a66d67c8f213e5ec: FOUND: mcd0nalds</span><br />
        <span style="color: green;">Searching: d5ec75d5fe70d428685510fae36492d9: FOUND: p@ssw0rd!</span><br />
    </span>
    </center>

    <p>
    Lookup tables are an extremely effective method for cracking many hashes of
    the same type very quickly. The general idea is to <b>pre-compute</b> the
    hashes of the passwords in a password dictionary and store them, and their
    corresponding password, in a lookup table data structure. A good
    implementation of a lookup table can process hundreds of hash lookups per
    second, even when they contain many billions of hashes.
    </p>

    <p>
    If you want a better idea of how fast lookup tables can be, try cracking the
    following sha256 hashes with CrackStation's <a href="/">free hash
    cracker</a>.
    </p>

    <div class="passcrack" style="text-align: center;" title="Example hashes to be cracked">
    c11083b4b0a7743af748c85d343dfee9fbb8b2576c05f3a7f0d632b0926aadfc<br />
    08eac03b80adc33dc7d8fbe44b7c7b05d3a2c511166bdb43fcb710b03ba919e7<br />
    e4ba5cbd251c98e6cd1c23f126a3b81d8d8328abc95387229850952b3ef9f904<br />
    5206b8b8a996cf5320cb12ca91c7b790fba9f030408efe83ebb83548dc3007bd<br />
    </div>

</li>

<li>
    <h3>Reverse Lookup Tables</h3>
    <center>
    <div class="passcrack" style="text-align: left;" title="Cracking many hashes with a pre-computed lookup table">
        <span style="color: green;">Searching for hash(apple) in users' hash list... &nbsp;&nbsp;&nbsp;&nbsp;: Matches [alice3, 0bob0, charles8]</span><br />
        <span style="color: green;">Searching for hash(blueberry) in users' hash list... : Matches [usr10101, timmy, john91]</span><br />
        <span style="color: green;">Searching for hash(letmein) in users' hash list... &nbsp;&nbsp;: Matches [wilson10, dragonslayerX, joe1984]</span><br />
        <span style="color: green;">Searching for hash(s3cr3t) in users' hash list... &nbsp;&nbsp;&nbsp;: Matches [bruce19, knuth1337, john87]</span><br />
        <span>Searching for hash(z@29hjja) in users' hash list... &nbsp;: No users used this password</span><br />
    </span>
    </center>
    <p>
        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.
    </p>

    <p>
    First, the attacker creates a lookup table that maps each password hash from
    the compromised user account database to a list of users who had that hash.
    The attacker then hashes each password guess and uses the lookup table to
    get a list of users whose password was the attacker's guess. This attack is
    especially effective because it is common for many users to have the same
    password. 
    </p>
</li>

<li>
    <h3>Rainbow Tables</h3>
    <p>
    Rainbow tables are a time-memory trade-off technique. They are like lookup
    tables, except that they sacrifice hash cracking speed to make the lookup
    tables smaller. Because they are smaller, the solutions to more hashes can
    be stored in the same amount of space, making them more effective. Rainbow
    tables that can crack any md5 hash of a password up to 8 characters long <a
    href="http://www.freerainbowtables.com/en/tables2/">exist</a>.
    </p>
</li>
</ul>

<p>
Next, we'll look at a technique called salting, which makes it impossible to use
lookup tables and rainbow tables to crack a hash.
</p>

<a name="salt"></a>
<h2>Adding Salt</h2>
<div class="passcrack" style="text-align: center;" title="Salt example">
    hash("hello") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824<br />
    hash("hello" + "QxLUF1bgIAdeQX") = 9e209040c863f84a31e719795b2577523954739fe5ed3b58a75cff2127075ed1<br />

    hash("hello" + "bv5PehSMfV11Cd") = d1d3ec2e6f20fd420d50e2642992841d8338a314b8ea157c9e18477aaef226ab<br />
    hash("hello" + "YYLmfY6IehjZMQ") = a49670c3c18b9e079b9cfaf51634f563dc8ae3070db2c4a8544305df1b60f007
</div>

<p>
Lookup tables and rainbow tables only work because each password is hashed the
exact same way. If two users have the same password, they'll have the same
password hashes.  We can prevent these attacks by randomizing each hash, so that
when the same password is hashed twice, the hashes are not the same.
</p>

<p>
We can randomize the hashes by appending or prepending a random string, called a
<b>salt</b>, to the password before hashing. As shown in the example above, this
makes the same password hash into a completely different string every time. To
check if a password is correct, we need the salt, so it is usually stored in the
user account database along with the hash, or as part of the hash string itself.
</p>

<p>
The salt does not need to be secret. Just by randomizing the hashes, lookup
tables, reverse lookup tables, and rainbow tables become ineffective. An
attacker won't know in advance what the salt will be, so they can't pre-compute
a lookup table or rainbow table. If each user's password is hashed with a
different salt, the reverse lookup table attack won't work either. 
</p>

<p>
In the next section, we'll look at how salt is commonly implemented incorrectly.
</p>

<a name="ineffective"></a>
<h2>The <span style="color: red;">WRONG</span> Way: Short Salt &amp; Salt Reuse</h2>

<p>
The most common salt implementation errors are reusing the same salt in multiple
hashes, or using a salt that is too short.
</p>

<h3>Salt Reuse</h3>

<p>
A common mistake is to use the same salt in each hash. Either the salt is
hard-coded into the program, or is generated randomly once. This is ineffective
because if two users have the same password, they'll still have the same hash.
An attacker can still use a reverse lookup table attack to run a dictionary
attack on every hash at the same time. They just have to apply the salt to each
password guess before they hash it. If the salt is hard-coded into a popular
product, lookup tables and rainbow tables can be built for that salt, to make it
easier to crack hashes generated by the product.
</p>

<p>
A new random salt must be generated each time a user creates an account or changes their password.
</p>

<h3>Short Salt</h3>

<p>
If the salt is too short, an attacker can build a lookup table for every
possible salt. For example, if the salt is only three ASCII characters, there
are only 95x95x95 = 857,375 possible salts. That may seem like a lot, but if
each lookup table contains only 1MB of the most common passwords, collectively
they will be only 837GB, which is not a lot considering 1000GB hard drives can
be bought for under $100 today.
</p>

<p>
For the same reason, the username shouldn't be used as a salt. Usernames may be
unique to a single service, but they are predictable and often reused for
accounts on other services.  An attacker can build lookup tables for common
usernames and use them to crack username-salted hashes.
</p>

<p>
To make it impossible for an attacker to create a lookup table for every
possible salt, the salt must be long. A good rule of thumb is to use a salt that
is the same size as the output of the hash function. For example, the output of
SHA256 is 256 bits (32 bytes), so the salt should be at least 32 random bytes.
</p>

<h2>The <span style="color: red;">WRONG</span> Way: Double Hashing &amp; Wacky Hash Functions</h2>

<p>
This section covers another common password hashing misconception: wacky
combinations of hash algorithms. It's easy to get carried away and try to
combine different hash functions, hoping that the result will be more secure. In
practice, though, there is very little benefit to doing it. All it does is
create interoperability problems, and can sometimes even make the hashes less
secure.  Never try to invent your own crypto, always use a standard that has
been designed by experts. Some will argue that using multiple hash functions
makes the process of computing the hash slower, so cracking is slower, but
there's a better way to make the cracking process slower as we'll see later.
</p>

<p>Here are some examples of poor wacky hash functions I've seen suggested in forums on the internet.</p>

<ul>
    <li><span class="ic">md5(sha1(password))</span></li>
    <li><span class="ic">md5(md5(salt) + md5(password))</span></li>
    <li><span class="ic">sha1(sha1(password))</span></li>
    <li><span class="ic">sha1(str_rot13(password + salt))</span></li>
    <li><span class="ic">md5(sha1(md5(md5(password) + sha1(password)) + md5(password)))</span></li>
</ul> 

<p>
Do not use any of these.
</p>

<p>
Note: This section has proven to be controversial. I've received a number of
emails arguing that wacky hash functions are a good thing, because it's better
if the attacker doesn't know which hash function is in use, it's less
likely for an attacker to have pre-computed a rainbow table for the wacky hash
function, and it takes longer to compute the hash function.
</p>

<p>
An attacker cannot attack a hash when he doesn't know the algorithm, but note <a
href="https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle"> Kerckhoffs's
principle</a>, that the attacker will usually have access to the source code
(especially if it's free or open source software), and that given a few
password-hash pairs from the target system, it is not difficult to reverse
engineer the algorithm. It does take longer to compute wacky hash functions, but
only by a small constant factor. It's better to use an iterated algorithm that's
designed to be extremely hard to parallelize (these are discussed below). And,
properly salting the hash solves the rainbow table problem.
</p>

<p>
If you really want to use a standardized &quot;wacky&quot; hash function like HMAC, then it's OK.
But if your reason for doing so is to make the hash computation slower, read the section below about key stretching first.
</p>

<p>
Compare these minor benefits to the risks of accidentally implementing a
completely insecure hash function and the interoperability problems wacky hashes
create. It's clearly best to use a standard and well-tested algorithm.
</p>

<h2>Hash Collisions</h2>

<p>
Because hash functions map arbitrary amounts of data to fixed-length strings,
there must be some inputs that hash into the same string. Cryptographic hash
functions are designed to make these collisions incredibly difficult to find.
From time to time, cryptographers find "attacks" on hash functions that make
finding collisions easier. A recent example is the MD5 hash function, for which
collisions have actually been found.
</p>

<p>
Collision attacks are a sign that it may be more likely for a string other than
the user's password to have the same hash. However, finding collisions in even a
weak hash function like MD5 requires a lot of dedicated computing power, so it
is very unlikely that these collisions will happen "by accident" in practice. A
password hashed using MD5 and salt is, for all practical purposes, just as
secure as if it were hashed with SHA256 and salt. Nevertheless, it is a good
idea to use a more secure hash function like SHA256, SHA512, RipeMD, or
WHIRLPOOL if possible.
</p>

<a name="properhashing"></a>
<h2>The <span style="color: green;">RIGHT</span> Way: How to Hash Properly</h2>

<p>
This section describes exactly how passwords should be hashed. The first
subsection covers the basics&mdash;everything that is absolutely necessary. The
following subsections explain how the basics can be augmented to make the hashes
even harder to crack.
</p>

<h3>The Basics: Hashing with Salt</h3>

<p>
<b>Warning: Do not just read this section. You absolutely must implement the
stuff in the next section: "Making Password Cracking Harder: Slow Hash
Functions".</b>
</p>

<p>
We've seen how malicious hackers can crack plain hashes very quickly using
lookup tables and rainbow tables. We've learned that randomizing the hashing
using salt is the solution to the problem.  But how do we generate the salt, and
how do we apply it to the password?
</p>

<p>
Salt should be generated using a <b>Cryptographically Secure Pseudo-Random
Number Generator</b> (CSPRNG). CSPRNGs are very different than ordinary
pseudo-random number generators, like the "C" language's 
<span class="ic">rand()</span> function.  As the name suggests, CSPRNGs are
designed to be cryptographically secure, meaning they provide a high level of
randomness and are completely unpredictable. We don't want our salts to be
predictable, so we must use a CSPRNG. The following table lists some CSPRNGs
that exist for some popular programming platforms.
</p>

<table id="rnglist">
    <tr><th>Platform</th><th>CSPRNG</th></tr>
    <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>
    <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>
    <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>
    <tr><td>Ruby</td><td><a href="http://rubydoc.info/stdlib/securerandom/1.9.3/SecureRandom">SecureRandom</a></td></tr>
    <tr><td>Python</td><td><a href="https://docs.python.org/3/library/secrets.html">secrets</a></td></tr>
    <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>
    <tr><td>C/C++ (Windows API)</td><td><a href="http://en.wikipedia.org/wiki/CryptGenRandom">CryptGenRandom</a></td></tr>
    <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>
</table> 

<p> The salt needs to be unique per-user per-password. Every time a user creates an account or
changes their password, the password should be hashed using a new random salt. Never reuse a salt.
The salt also needs to be long, so that there are many possible salts. As a rule of thumb, make your
salt is at least as long as the hash function's output. The salt should be stored in the user
account table alongside the hash.  </p>

<h4>To Store a Password</h4>

<ol>
    <li>Generate a long random salt using a CSPRNG.</li>
    <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>
    <li>Save both the salt and the hash in the user's database record.</li>
</ol>

<h4>To Validate a Password</h4>

<ol>
    <li>Retrieve the user's salt and hash from the database.</li>
    <li>Prepend the salt to the given password and hash it using the same hash function.</li>
    <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>
</ol>


<h4>In a Web Application, <b>always</b> hash on the server</h4>
<p>
If you are writing a web application, you might wonder <em>where</em> to hash.
Should the password be hashed in the user's browser with JavaScript, or should
it be sent to the server "in the clear" and hashed there?
</p>

<p> Even if you are hashing the user's passwords in JavaScript, you still have
to hash the hashes on the server. Consider a website that hashes users'
passwords in the user's browser without hashing the hashes on the server. To
authenticate a user, this website will accept a hash from the browser and check
if that hash exactly matches the one in the database. This seems more secure
than just hashing on the server, since the users' passwords are never sent to
the server, but it's not.  </p>

<p>
The problem is that the client-side hash logically <em>becomes</em> the user's
password. All the user needs to do to authenticate is tell the server the hash
of their password. If a bad guy got a user's <em>hash</em> they could use it to
authenticate to the server, without knowing the user's password! So, if the bad
guy somehow steals the database of hashes from this hypothetical website,
they'll have immediate access to everyone's accounts without having to guess any
passwords.
</p>

<p>
This isn't to say that you <em>shouldn't</em> hash in the browser, but if you
do, you absolutely have to hash on the server too. Hashing in the browser is
certainly a good idea, but consider the following points for your implementation:
</p>

<ul>
    <li>
        <p>
        Client-side password hashing is <b>not</b> a substitute for HTTPS
        (SSL/TLS).  If the connection between the browser and the server is
        insecure, a man-in-the-middle can modify the JavaScript code as it is
        downloaded to remove the hashing functionality and get the user's
        password.
        </p>
    </li>

    <li>
        <p>
        Some web browsers don't support JavaScript, and some users disable
        JavaScript in their browser. So for maximum compatibility, your app
        should detect whether or not the browser supports JavaScript and emulate
        the client-side hash on the server if it doesn't.
        </p>
    </li>

    <li>
        <p>
        You need to salt the client-side hashes too. The obvious solution is to
        make the client-side script ask the server for the user's salt. Don't do
        that, because it lets the bad guys check if a username is valid without
        knowing the password. Since you're hashing and salting (with a good
        salt) on the server too, it's OK to use the username (or email)
        concatenated with a site-specific string (e.g. domain name) as the
        client-side salt.
        </p>
    </li>
</ul>

<h3>Making Password Cracking Harder: Slow Hash Functions</h3>

<p>
    Salt ensures that attackers can't use specialized attacks like lookup tables
    and rainbow tables to crack large collections of hashes quickly, but it
    doesn't prevent them from running dictionary or brute-force attacks on each
    hash individually. High-end graphics cards (GPUs) and custom hardware can
    compute billions of hashes per second, so these attacks are still very
    effective. To make these attacks less effective, we can use a technique
    known as <b>key stretching</b>.
</p>

<p>
    The idea is to make the hash function very slow, so that even with a fast
    GPU or custom hardware, dictionary and brute-force attacks are too slow to
    be worthwhile. The goal is to make the hash function slow enough to impede
    attacks, but still fast enough to not cause a noticeable delay for the user.
</p>

<p>
    Key stretching is implemented using a special type of CPU-intensive hash
    function. Don't try to invent your own&ndash;simply iteratively hashing the
    hash of the password isn't enough as it can be parallelized in hardware and
    executed as fast as a normal hash. Use a standard algorithm like <a
    href="http://en.wikipedia.org/wiki/PBKDF2">PBKDF2</a> or <a href="http://en.wikipedia.org/wiki/Bcrypt">bcrypt</a>.
    You can find a PHP implementation of <a href="https://defuse.ca/php-pbkdf2.htm">PBKDF2 here</a>.
</p>

<p>
    These algorithms take a security factor or iteration count as an argument.
    This value determines how slow the hash function will be. For desktop
    software or smartphone apps, the best way to choose this parameter is to run
    a short benchmark on the device to find the value that makes the hash take
    about half a second. This way, your program can be as secure as possible
    without affecting the user experience.
</p>

<p>
    If you use a key stretching hash in a web application, be aware that you
    will need extra computational resources to process large volumes of
    authentication requests, and that key stretching may make it easier to run a
    Denial of Service (DoS) attack on your website.  I still recommend using key
    stretching, but with a lower iteration count. You should calculate the
    iteration count based on your computational resources and the expected
    maximum authentication request rate. The denial of service threat can be
    eliminated by making the user solve a CAPTCHA every time they log in.
    Always design your system so that the iteration count can be increased or
    decreased in the future.
</p>

<p>
    If you are worried about the computational burden, but still want to use key
    stretching in a web application, consider running the key stretching
    algorithm in the user's browser with JavaScript.  The <a href="http://crypto.stanford.edu/sjcl/">Stanford JavaScript Crypto
    Library</a> includes PBKDF2. The iteration count should be set low enough
    that the system is usable with slower clients like mobile devices, and the
    system should fall back to server-side computation if the user's browser
    doesn't support JavaScript. Client-side key stretching does not remove the
    need for server-side hashing. You must hash the hash generated by the client
    the same way you would hash a normal password.
</p>

<h3>Impossible-to-crack Hashes: Keyed Hashes and Password Hashing Hardware</h3>

<p>
    As long as an attacker can use a hash to check whether a password guess is
    right or wrong, they can run a dictionary or brute-force attack on the hash.
    The next step is to add a <b>secret key</b> to the hash so that only someone
    who knows the key can use the hash to validate a password. This can be
    accomplished two ways. Either the hash can be encrypted using a cipher like
    AES, or the secret key can be included in the hash using a keyed hash
    algorithm like <a href="http://en.wikipedia.org/wiki/HMAC">HMAC</a>.
</p>

<p>
    This is not as easy as it sounds. The key has to be kept secret from an
    attacker even in the event of a breach. If an attacker gains full access to
    the system, they'll be able to steal the key no matter where it is stored.
    The key must be stored in an external system, such as a physically separate
    server dedicated to password validation, or a special hardware device
    attached to the server such as the <a href="https://www.yubico.com/YubiHSM">YubiHSM</a>.
</p>

<p>
    I highly recommend this approach for any large scale (more than 100,000
    users) service. I consider it necessary for any service hosting more than
    1,000,000 user accounts.
</p>

<p>
    If you can't afford multiple dedicated servers or special hardware devices,
    you can still get some of the benefits of keyed hashes on a standard web
    server. Most databases are breached using <a
    href="http://en.wikipedia.org/wiki/SQL_injection">SQL Injection Attacks</a>,
    which, in most cases, don't give attackers access to the local filesystem
    (disable local filesystem access in your SQL server if it has this feature).
    If you generate a random key and store it in a file  that isn't accessible
    from the web, and include it into the salted hashes, then the hashes won't
    be vulnerable if your database is breached using a simple SQL injection
    attack. Don't hard-code a key into the source code, generate it randomly
    when the application is installed. This isn't as secure as using a separate
    system to do the password hashing, because if there are SQL injection
    vulnerabilities in a web application, there are probably other types, such
    as Local File Inclusion, that an attacker could use to read the secret key
    file. But, it's better than nothing.
</p>

<p>
    Please note that keyed hashes do not remove the need for salt. Clever
    attackers will eventually find ways to compromise the keys, so it is
    important that hashes are still protected by salt and key stretching.
</p>

<a name="othersecurity"></a>
<h2>Other Security Measures</h2>

<p>
Password hashing protects passwords in the event of a security breach. It does
not make the application as a whole more secure. Much more must be done to
prevent the password hashes (and other user data) from being stolen in the first
place.
</p>

<p>
Even experienced developers must be educated in security in order to write secure applications.
A great resource for learning about web application vulnerabilities is 
<a href="https://www.owasp.org/index.php/Main_Page">The Open Web Application
Security Project (OWASP)</a>. A good introduction is the 
<a href="https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf">OWASP Top Ten Vulnerability List</a>.
Unless you understand all the vulnerabilities on the list, do not attempt to
write a web application that deals with sensitive data. It is the employer's
responsibility to ensure all developers are adequately trained in secure
application development.
</p>

<p>
Having a third party "penetration test" your application is a good idea. Even
the best programmers make mistakes, so it always makes sense to have a security
expert review the code for potential vulnerabilities. Find a trustworthy
organization (or hire staff) to review your code on a regular basis. The
security review process should begin early in an application's life and continue
throughout its development.
</p>

<p>
It is also important to monitor your website to detect a breach if one does
occur. I recommend hiring at least one person whose full time job is detecting
and responding to security breaches. If a breach goes undetected, the attacker
can make your website infect visitors with malware, so it is extremely important
that breaches are detected and responded to promptly.
</p>

<a name="faq"></a>
<h2>Frequently Asked Questions</h2>
<h3>What hash algorithm should I use?</h3>
<span style="color: green;"><b>DO</b></span> use:

<ul class="moveul">
    <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>
    <li>OpenWall's <a href="http://www.openwall.com/phpass/">Portable PHP password hashing
    framework</a></li>
    <li><a href="https://github.com/defuse/password-hashing">My implementations of PBKDF2 in PHP, C#, Java, and Ruby.</a></li>
    <li>Secure versions of <a href="http://en.wikipedia.org/wiki/Crypt_(Unix)#Library_Function_crypt.283.29">crypt</a> ($2y$, $5$, $6$)</li>
</ul>
<br />
<span style="color: red;"><b>DO NOT</b></span> use:

<ul class="moveul">
    <li>Fast cryptographic hash functions such as MD5, SHA1, SHA256, SHA512, RipeMD, WHIRLPOOL, SHA3, etc.</li>
    <li>Insecure versions of crypt ($1$, $2$, $2x$, $3$).</li>
    <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>
</ul>

<p>
    Even though there are no cryptographic attacks on MD5 or SHA1 that make
    their hashes easier to crack, they are old and are widely considered
    (somewhat incorrectly) to be inadequate for password storage. So I don't
    recommend using them. An exception to this rule is PBKDF2, which is
    frequently implemented using SHA1 as the underlying hash function.
</p>
<h3>How should I allow users to reset their password when they forget it?</h3>

<p>
    It is my personal opinion that all password reset mechanisms in widespread
    use today are insecure. If you have high security requirements, such as an
    encryption service would, do not let the user reset their password.
</p>

<p>
Most websites use an email loop to authenticate users who have forgotten their
password. To do this, generate a random <b>single-use</b> token that is strongly
tied to the account. Include it in a password reset link sent to the user's
email address. When the user clicks a password reset link containing a valid
token, prompt them for a new password. Be sure that the token is strongly tied
to the user account so that an attacker can't use a token sent to his own email
address to reset a different user's password.
</p>

<p>
The token must be set to expire in 15 minutes or after it is used, whichever
comes first. It is also a good idea to expire any existing password tokens when
the user logs in (they remembered their password) or requests another reset
token. If a token doesn't expire, it can be forever used to break into the
user's account.  Email (SMTP) is a plain-text protocol, and there may be
malicious routers on the internet recording email traffic. And, a user's email
account (including the reset link) may be compromised long after their password
has been changed.  Making the token expire as soon as possible reduces the
user's exposure to these attacks.
</p>

<p>
Attackers will be able to modify the tokens, so don't store the user account
information or timeout information in them. They should be an unpredictable
random binary blob used only to identify a record in a database table.
</p>

<p>
Never send the user a new password over email. Remember to pick a new random
salt when the user resets their password. Don't re-use the one that was used to
hash their old password.
</p>

<h3>What should I do if my user account database gets leaked/hacked?</h3>

<p>
Your first priority is to determine how the system was compromised and patch
the vulnerability the attacker used to get in. If you do not have experience
responding to breaches, I highly recommend hiring a third-party security firm.
</p>

<p>
It 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
your users at further risk by not informing them that their passwords and other
personal information may be
compromised. 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
front page of your website that links to a page with more detailed information,
and send a notice to each user by email if possible. 
</p>

<p>
Explain to your users exactly how their passwords were protected&mdash;hopefully
hashed with salt&mdash;and that even though they were protected with a salted
hash, a malicious hacker can still run dictionary and brute force attacks on the
hashes. Malicious hackers will use any passwords they find to try to login to a
user's account on a different website, hoping they used the same password on
both websites. Inform your users of this risk and recommend that they change
their password on any website or service where they used a similar password.
Force them to change their password for your service the next time they log in.
Most users will try to "change" their password to the original password to get
around the forced change quickly. Use the current password hash to ensure that
they cannot do this.
</p>

<p>
It is likely, even with salted slow hashes, that an attacker will be able to
crack some of the weak passwords very quickly. To reduce the attacker's window of opportunity to use these passwords, you should require, in
addition to the current password, an email loop for authentication until the
user has changed their password. See the previous question, "How should I allow
users to reset their password when they forget it?" for tips on implementing
email loop authentication.
</p>

<p>
Also tell your users what kind of personal information was stored on the
website. If your database includes credit card numbers, you should instruct your
users to look over their recent and future bills closely and cancel their
credit card.
</p>

<h3>What should my password policy be? Should I enforce strong passwords?</h3>
<p>
If your service doesn't have strict security requirements, then don't limit your
users. I recommend showing users information about the strength of their
password as they type it, letting them decide how secure they want their
password to be. If you have special security needs, enforce a minimum length of
12 characters and require at least two letters, two digits, and two symbols.
</p>
<p>
Do not force your users to change their password more often than once every six
months, as doing so creates "user fatigue" and makes users less likely to choose
good passwords. Instead, train users to change their password whenever they feel
it has been compromised, and to never tell their password to anyone. If it is a
business setting, encourage employees to use paid time to memorize and practice
their password.
</p>

<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>

<p>
Yes, but if someone has access to your database, they probably already have
access to everything on your server, so they wouldn't need to login to your
account to get what they want. The purpose of password hashing (in the context
of a website) is not to protect the website from being breached, but to protect
the passwords if a breach does occur.
</p>

<p>
You can prevent hashes from being replaced during a SQL injection attack by
connecting to the database with two users with different permissions. One for
the 'create account' code and one for the 'login' code. The 'create account'
code should be able to read and write to the user table, but the 'login' code
should only be able to read.
</p>

<h3>Why do I have to use a special algorithm like HMAC? Why can't I just append
the password to the secret key?</h3>

<p> Hash functions like MD5, SHA1, and SHA2 use the <a href="http://en.wikipedia.org/wiki/Merkle%E2%80%93Damg%C3%A5rd_construction">
Merkle–Damgård construction</a>, which makes them vulnerable to what are known
as length extension attacks. This means that given a hash H(X), an attacker can
find the value of H(pad(X) + Y), for any other string Y, without knowing X.
pad(X) is the padding function used by the hash.
</p>

<p>
This means that given a hash H(key + message), an attacker can compute H(pad(key +
message) + extension), without knowing the key. If the hash was being used as a
message authentication code, using the key to prevent an attacker from being
able to modify the message and replace it with a different valid hash, the
system has failed, since the attacker now has a valid hash of message +
extension.
</p>

<p>
It is not clear how an attacker could use this attack to crack a password hash
quicker.  However, because of the attack, it is considered bad practice to
use a plain hash function for keyed hashing. A clever cryptographer may one day
come up with a clever way to use these attacks to make cracking faster, so use
HMAC.
</p>


<h3>Should the salt come before or after the password?</h3>

<p>
It doesn't matter, but pick one and stick with it for interoperability's sake.
Having the salt come before the password seems to be more common.
</p>

<h3>Why does the hashing code on this page compare the hashes in
&quot;length-constant&quot;
time?</h3>

<p>
Comparing the hashes in &quot;length-constant&quot; time ensures that an
attacker cannot extract the hash of a password in an on-line system using a
timing attack, then crack it off-line.
</p>

<p>
The standard way to check if two sequences of bytes (strings) are the same is to
compare the first byte, then the second, then the third, and so on. As soon as
you find a byte that isn't the same for both strings, you know they are
different and can return a negative response immediately. If you make it through
both strings without finding any bytes that differ, you know the strings are the
same and can return a positive result. This means that comparing two strings can
take a different amount of time depending on how much of the strings match.
</p>

<p>
For example, a standard comparison of the strings &quot;xyzabc&quot; and
&quot;abcxyz&quot; would immediately see that the first character is different
and wouldn't bother to check the rest of the string. On the other hand, when the
strings &quot;aaaaaaaaaaB&quot; and &quot;aaaaaaaaaaZ&quot; are compared, the
comparison algorithm scans through the block of "a" before it determines the
strings are unequal.
</p>

<p>
Suppose an attacker wants to break into an on-line system that rate limits
authentication attempts to one attempt per second. Also suppose the attacker
knows all of the parameters to the password hash (salt, hash type, etc), except
for the hash and (obviously) the password. If the attacker can get a precise
measurement of how long it takes the on-line system to compare the hash of the
real password with the hash of a password the attacker provides, he can use the
timing attack to extract part of the hash and crack it using an offline attack,
bypassing the system's rate limiting.
</p>

<p>
First, the attacker finds 256 strings whose hashes begin with every possible
byte.  He sends each string to the on-line system, recording the amount of time
it takes the system to respond. The string that takes the longest will be the
one whose hash's first byte matches the real hash's first byte. The attacker now
knows the first byte, and can continue the attack in a similar manner on the
second byte, then the third, and so on. Once the attacker knows enough of the
hash, he can use his own hardware to crack it, without being rate limited by the
system.
</p>

<p>
It might seem like it would be impossible to run a timing attack over a network.
However, it has been done, and has been
<a href="https://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf">shown to be practical</a>.
That's why the code on this page compares strings in a way that takes the same
amount of time no matter how much of the strings match.
</p>

<a name="slowequals"></a>
<h3>How does the SlowEquals code work?</h3>

<p>
The previous question explains why SlowEquals is necessary, this one explains
how the code actually works.
</p>

<div class="passcrack">
1. &nbsp;&nbsp; &nbsp;private static boolean slowEquals(byte[] a, byte[] b)<br />
2. &nbsp;&nbsp; &nbsp;{<br />
3. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int diff = a.length ^ b.length;<br />
4. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; a.length &amp;&amp; i &lt; b.length; i++)<br />
5. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;diff |= a[i] ^ b[i];<br />
6. &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return diff == 0;<br />
7. &nbsp;&nbsp; &nbsp;}<br />
</div>

<p>
The code uses the XOR "^" operator to compare integers for equality, instead of
the "==" operator. The reason why is explained below. The result of XORing
two integers will be zero if and only if they are exactly the same. This is
because 0 XOR 0 = 0, 1 XOR 1 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1. If we apply that to
all the bits in both integers, the result will be zero only if all the bits
matched.
</p>

<p>
So, in the first line, if <code>a.length</code> is equal to
<code>b.length</code>, the diff variable will get a zero value, but if not, it
will get some non-zero value. Next, we compare the bytes using XOR, and OR the
result into diff. This will set diff to a non-zero value if the bytes differ.
Because ORing never un-sets bits, the only way diff will be zero at the end of
the loop is if it was zero before the loop began (a.length == b.length) and all
of the bytes in the two arrays match (none of the XORs resulted in a non-zero
value).
</p>

<p>
The reason we need to use XOR instead of the "==" operator to compare integers
is that "==" is usually translated/compiled/interpreted as a branch. For example,
the C code "<code>diff &amp;= a == b</code>" might compile to the following x86
assembly:
</p>

<div class="passcrack">
MOV EAX, [A]<br />
CMP [B], EAX<br />
JZ equal<br />
JMP done<br />
equal:<br />
AND [VALID], 1<br />
done:<br />
AND [VALID], 0<br />
</div>

<p>
The branching makes the code execute in a different amount of time depending on
the equality of the integers and the CPU's internal branch prediction state.
</p>

<p>
The C code "<code>diff |= a ^ b</code>" should compile to something like
the following, whose execution time does not depend on the equality of the
integers:
</p>

<div class="passcrack">
MOV EAX, [A]<br />
XOR EAX, [B]<br />
OR  [DIFF], EAX <br />
</div>

<h3>Why bother hashing?</h3>

<p>
Your users are entering their password into your website. They are trusting you
with their security. If your database gets hacked, and your users' passwords are
unprotected, then malicious hackers can use those passwords to compromise your
users' accounts on other websites and services (most people use the same
password everywhere). It's not just your security that's at risk, it's your
users'. You are responsible for your users' security.
</p>

<div style="text-align: center;">
    <h4>Article written by <a href="https://defuse.ca/">Defuse Security.</a></h4>
</div>


================================================
FILE: src/pages/home.php
================================================
<?php

/*
 * CrackStation, a web-based hash cracking website.
 * Copyright (C) 2013  Taylor Hornby
 * 
 * This file is part of CrackStation.
 * 
 * CrackStation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * CrackStation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

mb_language('uni');
mb_internal_encoding('UTF-8');

require_once('libs/recaptchalib.php');
require_once('libs/CrackHashes.php');
require_once('/storage/creds.php');

// Copied from: https://stackoverflow.com/a/30749288
function checkReCAPTCHA() 
{
    try {
        $url = 'https://www.google.com/recaptcha/api/siteverify';
        $creds = Creds::getCredentials("timecapsule_recaptcha");
        $data = ['secret'   => $creds[C_PASS],
                 'response' => $_POST['g-recaptcha-response'],
                 'remoteip' => $_SERVER['REMOTE_ADDR']];

        $options = [
            'http' => [
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($data) 
            ]
        ];

        $context  = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        return json_decode($result)->success;
    }
    catch (Exception $e) {
        return null;
    }
}

if(isset($_GET['p']))
{
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://crackstation.net/");
}

function trim_value(&$value)
{
    $value = trim($value);
    $value = trim($value, "*"); // For MySQL 4.1+ hashes
}

?>
<!-- Set the recaptcha theme. -->
<script type="text/javascript">
var RecaptchaOptions = {
   theme : 'blackglass'
};
</script>

<h1>Free Password Hash Cracker</h1>

<p>
    Enter up to 20 non-salted hashes, one per line:
</p>

<script>
    function onRecaptchaChecked() {
        document.getElementById("submitbutton").disabled = false;
    }
    function onRecaptchaExpired() {
        document.getElementById("submitbutton").disabled = true;
    }
</script>

<!-- Hash cracking form. -->
<form action="/" method="post">
<table style="width: 100%;">
<tr>
    <td style="width: 550px;">
        <textarea
            style="width: 100%; height: 180px; border: solid black 1px; background-color: #e9e9e9;"
            name="hashes" ><?php 
                if(isset($_POST['hashes'])) {
                    echo htmlspecialchars($_POST['hashes'], ENT_QUOTES);
                } 
        ?></textarea>
    </td>
    <td>
        <center>
            <div class="g-recaptcha" data-theme="dark" data-sitekey="6LcnNi8UAAAAALJikXrc6jwNWUm00Yjx_rHCJW7u" data-callback="onRecaptchaChecked" data-expired-callback="onRecaptchaExpired"></div>
            <input id="submitbutton" type="submit" name="crack" value="Crack Hashes" style="width: 200px; margin-top: 10px;" disabled/>
        </center>
    </td>
</tr>
</table>
</form>

<!-- Supported hash types. -->
<p style="font-size: 8pt; margin: 0; padding: 0;">
<b>Supports:</b>
LM, NTLM, md2, md4, md5, md5(md5_hex), md5-half, sha1, sha224, sha256, sha384,
sha512, ripeMD160, whirlpool, MySQL 4.1+ (sha1(sha1_bin)), QubesV3.1BackupDefaults
<br />
</p>

<!-- Crack results (only shown after a POST) -->
<div class="crackresults">
<?php
if(isset($_POST['crack']))
{
    if(checkReCaptcha() === true)
    {
        $hashes = str_replace("\r\n", "\n", $_POST['hashes']);
        $hashes = str_replace("\r", "\n", $hashes);
        $hashes = explode("\n", $hashes);
        array_walk($hashes, 'trim_value');
        $hashes = array_filter($hashes, function ($item) { return !empty($item); });
        if(count($hashes) <= 20) {
            CrackHashes($hashes);
        } else {
            echo "<p style=\"color: red;\">
                    <b>Please enter <strong>20</strong> or less hashes.</b>
                  </p>";
        }
    }
    else
    {
        echo "<p style=\"color: red;\">
                <b>Incorrect captcha. Please try again.</b>
              </p>";
    }
}
?>
</div>

<div class="downloaddiv">
    <a class="downloadlink"
       href="/crackstation-wordlist-password-cracking-dictionary.htm">
            Download CrackStation's Wordlist
    </a>
</div>

<a name="cracking-hashes"></a>
<h2>How CrackStation Works</h2>

<p>
CrackStation uses massive pre-computed lookup tables to crack password hashes.
These tables store a mapping between the hash of a password, and the correct
password for that hash. The hash values are indexed so that it is possible to
quickly search the database for a given hash. If the hash is present in the
database, the password can be recovered in a fraction of a second.  This only
works for "unsalted" hashes. For information on password hashing systems that
are not vulnerable to pre-computed lookup tables, see our <a
href="hashing-security.htm">hashing security page</a>.
</p>

<p>
Crackstation's lookup tables were created by extracting every word from the
Wikipedia databases and adding with every password list we could find. We also
applied intelligent word mangling (brute force hybrid) to our wordlists to make
them much more effective. For MD5 and SHA1 hashes, we have a 190GB,
15-billion-entry lookup table, and for other hashes, we have a 19GB
1.5-billion-entry lookup table.
</p>

<p>
You can download CrackStation's dictionaries <a
href="/crackstation-wordlist-password-cracking-dictionary.htm">here</a>, and
the lookup table implementation (PHP and C) is available <a
href="https://github.com/defuse/crackstation-hashdb">here</a>.
</p>


================================================
FILE: src/pages/legal-privacy.php
================================================
<h1>CrackStation's Terms of Service and Privacy Policy</h1>

<h2>Terms of Service</h2>
<p>
CrackStation's main goal is to promote the use of properly implemented salted
hashing in new and existing web applications. We provide this service to help
security researchers demonstrate the importance of hash salting. Any users that
choose to use CrackStation as a malicious tool are solely responsible for their
own actions. We do not ask where our clients get their hashes, so we are unable
to help any law enforcement agency.
</p>

<h2>Privacy Policy</h2>
<p>
CrackStation respects the privacy of its users. Your IP address and web browser
information may be logged as you request web pages from this site, but we do not
sell that information or share that information with anyone. We DO NOT log the
hashes that you crack.  However, you should still not try to crack the hash of
your own password or other sensitive information, since your connection might be
being intercepted by the NSA.
</p>


================================================
FILE: src/pages/thank-you.php
================================================
<h1>THANKS!</h1>

<p>
You just bought the CrackStation wordlist. Thank you VERY much for your support!
</p>

<p>
If you haven't downloaded the wordlist yet, see <a
href="/buy-crackstation-wordlist-password-cracking-dictionary.htm">step 2</a>.
</p>

<p>
If you have any questions or concerns, please <a href="/contact-us.htm">contact me</a>.
</p>


================================================
FILE: src/robots.txt
================================================
User-agent: *
Disallow: /tor-mirror/
Download .txt
gitextract_l2rebmfd/

├── .gitmodules
├── LICENSE
├── gfx/
│   └── crackstation_header.psd
└── src/
    ├── blocked.html
    ├── css/
    │   ├── main.css
    │   ├── mainmenu2.css
    │   └── style.css
    ├── downloads/
    │   ├── crackstation-human-only.txt.gz.torrent
    │   └── crackstation.txt.gz.torrent
    ├── index.php
    ├── libs/
    │   ├── CrackHashes.php
    │   ├── URLParse.php
    │   ├── phpcount.php
    │   └── recaptchalib.php
    ├── pages/
    │   ├── 404.php
    │   ├── aboutus.php
    │   ├── buy-crackstation-wordlist-cracking-dictionary.php
    │   ├── contactus.php
    │   ├── downloads.php
    │   ├── hashing-security-draft.php
    │   ├── hashing-security.php
    │   ├── home.php
    │   ├── legal-privacy.php
    │   └── thank-you.php
    └── robots.txt
Download .txt
SYMBOL INDEX (44 symbols across 5 files)

FILE: src/libs/CrackHashes.php
  function CrackHashes (line 25) | function CrackHashes($hashes)

FILE: src/libs/URLParse.php
  class URLParse (line 90) | class URLParse
    method ProcessURL (line 199) | public static function ProcessURL()
    method getPageTitle (line 223) | public static function getPageTitle($name)
    method getPageMetaDescription (line 237) | public static function getPageMetaDescription($name)
    method getPageMetaKeywords (line 251) | public static function getPageMetaKeywords($name)
    method IncludePageContents (line 267) | public static function IncludePageContents()
    method checkHost (line 286) | private static function checkHost()
    method checkHTTPS (line 308) | private static function checkHTTPS()
    method getPageArrayKey (line 323) | private static function getPageArrayKey()
    method checkRedirectRequest (line 358) | private static function checkRedirectRequest($page_array)
    method ensureHTMOrSlashExtension (line 381) | private static function ensureHTMOrSlashExtension($page_array, $proper...
    method getUrlParams (line 405) | private static function getUrlParams()
    method getUrlFile (line 419) | private static function getUrlFile()
    method getUrlFront (line 432) | private static function getUrlFront()
    method getFirstSlashIndex (line 441) | private static function getFirstSlashIndex($url)
    method permRedirect (line 461) | private static function permRedirect($newUrl)
    method send404Headers (line 469) | private static function send404Headers()

FILE: src/libs/phpcount.php
  class PHPCount (line 43) | class PHPCount
    method InitDB (line 65) | private static function InitDB()
    method AddHit (line 92) | public static function AddHit($pageID)
    method GetHits (line 124) | public static function GetHits($pageID, $unique = false)
    method GetTotalHits (line 157) | public static function GetTotalHits($unique = false)
    method IsSearchBot (line 178) | private static function IsSearchBot()
    method UniqueHit (line 209) | private static function UniqueHit($pageID)
    method LogHit (line 232) | private static function LogHit($pageID)
    method CountHit (line 265) | private static function CountHit($pageID, $unique)
    method IDHash (line 277) | private static function IDHash($pageID)
    method CreateCountsIfNotPresent (line 283) | private static function CreateCountsIfNotPresent($pageID)
    method Cleanup (line 320) | private static function Cleanup()

FILE: src/libs/recaptchalib.php
  function _recaptcha_qsencode (line 47) | function _recaptcha_qsencode ($data) {
  function _recaptcha_http_post (line 67) | function _recaptcha_http_post($host, $path, $data, $port = 80) {
  function recaptcha_get_html (line 106) | function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
  class ReCaptchaResponse (line 139) | class ReCaptchaResponse {
  function recaptcha_check_answer (line 154) | function recaptcha_check_answer ($privkey, $remoteip, $challenge, $respo...
  function recaptcha_get_signup_url (line 204) | function recaptcha_get_signup_url ($domain = null, $appname = null) {
  function _recaptcha_aes_pad (line 208) | function _recaptcha_aes_pad($val) {
  function _recaptcha_aes_encrypt (line 216) | function _recaptcha_aes_encrypt($val,$ky) {
  function _recaptcha_mailhide_urlbase64 (line 227) | function _recaptcha_mailhide_urlbase64 ($x) {
  function recaptcha_mailhide_url (line 232) | function recaptcha_mailhide_url($pubkey, $privkey, $email) {
  function _recaptcha_mailhide_email_parts (line 250) | function _recaptcha_mailhide_email_parts ($email) {
  function recaptcha_mailhide_html (line 269) | function recaptcha_mailhide_html($pubkey, $privkey, $email) {

FILE: src/pages/home.php
  function checkReCAPTCHA (line 31) | function checkReCAPTCHA()
  function trim_value (line 63) | function trim_value(&$value)
Condensed preview — 25 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (197K chars).
[
  {
    "path": ".gitmodules",
    "chars": 129,
    "preview": "[submodule \"src/source/password-hashing\"]\n\tpath = src/source/password-hashing\n\turl = git@git.defuse.ca:gits/password-has"
  },
  {
    "path": "LICENSE",
    "chars": 34520,
    "preview": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C)"
  },
  {
    "path": "src/blocked.html",
    "chars": 643,
    "preview": "<html>\n    <head>\n        <title>Error 403: Access Denied</title>\n    </head>\n    <body>\n        <h1>Forbidden</h1>\n    "
  },
  {
    "path": "src/css/main.css",
    "chars": 7921,
    "preview": "/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is part of "
  },
  {
    "path": "src/css/mainmenu2.css",
    "chars": 9672,
    "preview": "/*==============================================================================\n\n\tNOTE: I've made a lot of modification"
  },
  {
    "path": "src/css/style.css",
    "chars": 2363,
    "preview": "/*\r\n * CrackStation, a web-based hash cracking website.\r\n * Copyright (C) 2013  Taylor Hornby\r\n * \r\n * This file is part"
  },
  {
    "path": "src/index.php",
    "chars": 8269,
    "preview": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is p"
  },
  {
    "path": "src/libs/CrackHashes.php",
    "chars": 6759,
    "preview": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is p"
  },
  {
    "path": "src/libs/URLParse.php",
    "chars": 19598,
    "preview": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is p"
  },
  {
    "path": "src/libs/phpcount.php",
    "chars": 9714,
    "preview": "<?php\n// WARNING: HACKED BY ADDING 'cs' PREFIX TO EVERY TABLE NAME.\n/*\n * phpcount.php Ver.1.1- An \"anoymizing\" hit coun"
  },
  {
    "path": "src/libs/recaptchalib.php",
    "chars": 10011,
    "preview": "<?php\n/*\n * This is a PHP library that handles calling reCAPTCHA.\n *    - Documentation and latest version\n *          h"
  },
  {
    "path": "src/pages/404.php",
    "chars": 304,
    "preview": "<div style=\"text-align:center;\">\n<span style=\"font-size: 36pt;\">Oops!</span><br />\n<span style=\"font-size: 26pt;\">This p"
  },
  {
    "path": "src/pages/aboutus.php",
    "chars": 1236,
    "preview": "<div class=\"box\">\n<div class=\"padding\">\n<h1>About CrackStation</h1>\n\n<p>\nCrackStation is a security awareness project st"
  },
  {
    "path": "src/pages/buy-crackstation-wordlist-cracking-dictionary.php",
    "chars": 4116,
    "preview": "<h1>CrackStation's Password Cracking Dictionary</h1>\n\n<p>\nI am releasing CrackStation's main password cracking dictionar"
  },
  {
    "path": "src/pages/contactus.php",
    "chars": 339,
    "preview": "<div class=\"box\">\n<div class=\"padding\">\n<h1>Contacting CrackStation</h1>\n\n<p>\nIf you purchased the wordlist and it isn't"
  },
  {
    "path": "src/pages/downloads.php",
    "chars": 87,
    "preview": "<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",
    "chars": 16342,
    "preview": "<h1>How to Store Passwords</h1>\n\n<p>\nThis article will walk you through the design of a secure password storage\nsystem. "
  },
  {
    "path": "src/pages/hashing-security.php",
    "chars": 50139,
    "preview": "<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 acc"
  },
  {
    "path": "src/pages/home.php",
    "chars": 6028,
    "preview": "<?php\n\n/*\n * CrackStation, a web-based hash cracking website.\n * Copyright (C) 2013  Taylor Hornby\n * \n * This file is p"
  },
  {
    "path": "src/pages/legal-privacy.php",
    "chars": 1013,
    "preview": "<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 "
  },
  {
    "path": "src/pages/thank-you.php",
    "chars": 346,
    "preview": "<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 "
  },
  {
    "path": "src/robots.txt",
    "chars": 37,
    "preview": "User-agent: *\nDisallow: /tor-mirror/\n"
  }
]

// ... and 3 more files (download for full content)

About this extraction

This page contains the full source code of the defuse/crackstation GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 25 files (42.1 MB), approximately 47.0k tokens, and a symbol index with 44 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!