README 3.72 KB
Newer Older
clement's avatar
clement committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    SHA1BruteForce, brute-force attack to recover SHA-1 hashed password.
    Copyright (C) 2017  Clément Février

1/ License

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

    Contact informations:
    Email
     clement+dev@forumanalogue.fr
    Post address
     4 impasse de l'Abbaye
     38100 Grenoble
     FRANCE

2/ About

This is a simple C++ software to recover a password
for SHA-1 hash. It is performing a brute-force attack.
Complexity: It is a simple brute-force algorithm,
            so the complexity increases exponentially
            with the size of the password.
Multithreading: On a N_CORE computer,
                if SEQTIME is the maximum time
                when launched with one thread,
                then the maximum time is
                SEQTIME / N_TREAD when N_THREAD < N_CORE
                and SEQTIME / N_CORE when N_THREAD > N_CORE

3/ Install

Clément Février's avatar
Clément Février committed
43
You need GCC < 8, Boost and Libtomcrypt.
clement's avatar
clement committed
44 45 46 47 48 49 50 51 52 53 54 55
The restriction comes from an incompatibility between GCC 8
and Boost.
On Ubuntu,

$ sudo apt install g++ libboost-all-dev libtomcrypt-dev

4/ Use

4.1/ main.cpp

Modify the parameters in main.cpp.
* HASH:      The SHA-1 hash.
Clément Février's avatar
Clément Février committed
56
             Two accepted formats:
clement's avatar
clement committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
             1/ Without spaces, as usually stored.
                You need to ensure
                that it is 40 character-long.
                Example for the password ZZZ
                116ff222a3b49b63348d7782e4b43ffe2dcbb198
             2/ With spaces.
                No restriction on the length of the string.
                But you need to ensure to have
                20 spaced-separated hexadecimal numbers.
                It is the format used to display hashes
                in this program.
                Example for the password ZZZZZZ
                18 f3 f 1b a4 c6 2e 2b 46 e 69 33 6 b3 9a d e2 7d 74 7c
* MaxLength: Maximum length of the password to test.
* N_THREAD:  Number of threads to launch.
             The program will launch at most
             a number of thread corresponding
             to the number of character to test.
             In other words, the length of list.
Clément Février's avatar
Clément Février committed
76
             In this case, it is 95.
clement's avatar
clement committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

4.2/ Makefile

4.2.1/ (Optional) Profiling

You can use the Makefile as it is,
but I recommend to add the flags specific to your architecture.
Also, you can profile the code with the following steps.
Set the variable test in main.cpp. For example, change line 91

 const std::string test = "";

to

 const std::string test = "!!!";

Add the flag -fprofile-generate
to the variable CC in the Makefile.
Clément Février's avatar
Clément Février committed
95
Clean objects in case already compile before
clement's avatar
clement committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
and recompile with the new flag.

$ make clean; make -j 2

Execute the code to generate the profile.

$ ./sha1

Modify main.cpp to reverte back test to ""
otherwise the SHA-1 hash that you want to crack will be ignore.

Modify the variable CC in the Makefile
to substitute -fprofile-generate
by -fprofile-use -fprofile-correction.

4.2.2/ Compiling

Then compile with

$ make

or

$ make -j 2

for parallel compiling.
Any number greater than 2 will not have effect
because there is only 2 objects.

4.3/ sha1

Launch it with
Clément Février's avatar
Clément Février committed
128
$ ./sha1
clement's avatar
clement committed
129 130
It will display the SHA-1 hash and the corresponding password
if it find it.