keepass > 99999999
#1
Hi,

I have forgot my exact keepass password and as such I wanted to try to bruteforce it with the remaining knowledge that I have of it. However, funnily enough my sense for security makes it twice as hard for me. As I upped the iteration count into the 9 digits, while hashcat does only accept 8 digits hashes. I had a look at the code and my idea was to just increase the allowed max digits (module_1340, line 132) from 8 to 9.
However, my PC is set up for Windows and thus, I fiddled around with cross compiling in a newly set up VM but I did not manage to get it successfully running. (I also found this link https://github.com/hashcat/hashcat/blob/...#L555-L560 as a hint for compiling the iconv (which is the problem I also ran into))

Is there already a way to have a 9 digits iteration count for keepass?
And if not, can somebody point me towards setting up the mingw crosscompiler and actually compile hashcat on a fresh ubuntu vm?

Thanks!
uraks
Reply
#2
if you only have windows (or mainly use windows and are more comforatble just running/compiling it on win), just compile it with mysys or cygwin:
- https://github.com/hashcat/hashcat/blob/...D_MSYS2.md or
- https://github.com/hashcat/hashcat/blob/..._CYGWIN.md

for the cross-compilation you would need to have the mingw packages installed, on ubuntu I think you need these:
Code:
g++-mingw-w64-x86-64
gcc-mingw-w64-base
gcc-mingw-w64-x86-64
mingw-w64-common
mingw-w64-x86-64-dev

to have some binaries like these available for the compilation/make steps:
Code:
x86_64-w64-mingw32-gcc
x86_64-w64-mingw32-g++
x86_64-w64-mingw32-ar

I can't really think of any other problem (besides the iconv as you mentioned)...
you would need to let us know the exact error message (the first ones are of course the most important to fix first) when compiling, otherwise it's just a guessing game what problem you could experience. Without the output of:
Code:
make clean
make win

we can't really tell what the problem could be.


I understand your problem with the 9 digit limitation.... but on the other side are you sure you know enough about the password pattern and charset and length to make this cracking attempt even feasible ? This is a very high number of iterations, so you must have a very good idea what the password candidates should look like. otherwise it's probably getting infeasible/uncrackable. Please elaborate how much you know about the password length, pattern, set of characters , does it use common dictionary words etc ?
Reply
#3
Thanks for the answer, I will elaborate on all fronts.



Regarding the password I'm pretty sure that I almost know it, but just got some variations that I typically use wrong, as such I created already a dictionary with around 18.000 candidates, so yea that should take some time but sounds feasible. Regarding charset, I should also be fine as I was running tests with newly created keepass databases to make sure the process works apart from that 8 digit limit on iterations.




Now regarding compilation, let me preface this that I'm not the C/C++ coder, usually I develop in Java, so all these compilation stuff is pretty new to me, though I fiddled with it from time to time. Windows is the main system set up for me, in the VM hashcat won't work direkt as I have no CUDA support there, that's why I'm trying to compile it for windows.



I tried the cygwin approach and made sure that I have all the listed packages installed with cygwin. I was following the cygwin instructions like that and when running make ran into this:



Code:
make: g++: No such file or directory


make: *** [src/Makefile:555: obj/strlist.NATIVE.o] Error 127


make: *** Waiting for unfinished jobs....


make: g++: No such file or directory


make: *** [src/Makefile:555: obj/strfn.NATIVE.o] Error 127



So then I thought that I just linux for the compilation stuff, as I feel that actually compilation on linux is much easier than on windows, but maybe that is just because of my inexperience with it... Anyway, here comes the ubuntu endeavour. After writing all of this including the errors I actually found a way to interpret the hints differently and was able to fix the problem. So I will just keep this error log, may it be useful for somebody else. In the end is a short summary on what is exactly needed to do.



After running make clean and make win:



Code:
x86_64-w64-mingw32-gcc  -std=gnu99 -W -Wall -Wextra -O2 -pipe -Iinclude/ -IOpenCL/ -Ideps/LZMA-SDK/C -Ideps/zlib -Ideps/zlib/contrib -Ideps/OpenCL-Headers -DWITH_BRAIN -Ideps/xxHash -DWITH_CUBIN -Ideps/unrar -fPIC -I/opt/win-iconv-64/include/ -DWITH_HWMON  -c -o obj/convert.WIN.o src/convert.c



In file included from src/backend.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



In file included from src/benchmark.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



In file included from src/convert.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



In file included from src/autotune.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



make: *** [src/Makefile:689: obj/benchmark.WIN.o] Error 1



make: *** Waiting for unfinished jobs....



compilation terminated.



In file included from src/bitmap.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



In file included from src/bitops.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



In file included from src/combinator.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



make: *** [src/Makefile:689: obj/autotune.WIN.o] Error 1



make: *** [src/Makefile:689: obj/convert.WIN.o] Error 1



compilation terminated.



make: *** [src/Makefile:689: obj/bitops.WIN.o] Error 1



In file included from src/affinity.c:7:



include/types.h:37:10: fatal error: iconv.h: No such file or directory



  37 | #include <iconv.h>



      |          ^~~~~~~~~



compilation terminated.



make: *** [src/Makefile:689: obj/bitmap.WIN.o] Error 1



make: *** [src/Makefile:689: obj/backend.WIN.o] Error 1



make: *** [src/Makefile:689: obj/combinator.WIN.o] Error 1



make: *** [src/Makefile:689: obj/affinity.WIN.o] Error 1



Go figures, iconv.h is missing, after searching for that, I downloaded some libraries from gnu.org, and compiled them but that wasn't working. After some more searches I found this forum entry (https://github.com/hashcat/hashcat/blob/...#L555-L560) pointing to some remarks in the Makefile.



Code:
## To compile win-iconv with mingw clone from here: https://github.com/win-iconv/win-iconv


## Then patch the makefile with the patches from tools/win-iconv-64.diff and run make install




It seems like I need to crosscompile that version to get it runnning. Ok. As I had read a lot about crosscompiling and exchanging compilers etc. I figured I need to compile the referenced iconv repository, so I cloned the given repo. At first, I saw there is the CMakeLists.txt, so I tried creating a build folder and calling

Code:
CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ cmake ..

, which gave me yet another error that the compiler does not support the -rdynamic flag, at which point I posted here.




Now, while writing this, I found another way to interpret that remark in the Makefile, i.e. maybe using the tool hashcat will actually compile the cloned iconv for me already?



That was not the case and I tried to apply the patch to hashcats Makefile in src:



Code:
patch Makefile ../tools/win-iconv-64.diff


patching file Makefile


Hunk #1 FAILED at 6.


Hunk #2 FAILED at 19.


2 out of 2 hunks FAILED -- saving rejects to file Makefile.rej




After having a look at that, it seems like the tool diff is outdated, as it doesn't match. So then I tried to just manually do the changes where possible (but there is no RANLIB and no DLLTOOL, so it basically does not match very well and the build runs directly into include problems as well and doesn't solve the iconv problem, also changing the prefix got me wondering how that could ever work).



Then, I also saw that this project has a Makefile as well, so I looked into it. And it looked exactly like the diff files that are within the hashcat tools! So I patched this time the actual intended Makefile and used make install. Success!




Afterwards, make win for hashcat runs without a problem.



TLDR;


get and crosscompile win-iconv-64 first:


Code:
git clone https://github.com/win-iconv/win-iconv


move it to /opt/win-iconv-64


cd /opt/win-iconv-64


patch Makefile ~/hashcat/tools/win-iconv-64.diff


make install




That installs crosscompiled iconv header files, now you can compile hashcat, using


Code:
make win



I think this should find its way into the compile instructions for windows on linux. What's wrong with the cygwin installation on windows, I don't know.



The build is currently still running, so I think it should work now. Smile





Thanks!



uraks

Edit: removed lots of unnecessary line breaks between all lines... If they are still there I don't know, must be a problem with this editor...
Reply
#4
glad you figured it out.
Yeah, you need to patch the iconv Makefile (not hashcat's Makefile)... maybe we should make this more clear, but at the end we don't really recommend the cross-compilation approach for the general users... it makes more sense to just compile it natively, in general (and even this only affects very, very small amount of users, most can just use the beta/release version, of course).

Your error, on the other hand, for the native / cygwin compilation:
Code:
g++: No such file or directory

tells me that you didn't install the tools required as per the guide I've linked you above. It says that some build tools need to be installed while configuring/installing cygwin (https://github.com/hashcat/hashcat/blob/...stallation). I think/hope if you follow all the steps mentioned in the guide, everything should be working fine. I'm pretty sure about this, because these guides were, as far as I remember, directly created or improved by users that wanted support for cygwin / msys compilation on windows and they tested these steps (it could also be that some things changed in the mean time but I think with all the packages installed as mentioned, you should also have the g++ compiler ready etc).
Reply
#5
(03-02-2021, 12:00 AM)uraks Wrote: Hi,

I have forgot my exact keepass password and as such I wanted to try to bruteforce it with the remaining knowledge that I have of it. However, funnily enough my sense for security makes it twice as hard for me. As I upped the iteration count into the 9 digits, while hashcat does only accept 8 digits hashes. I had a look at the code and my idea was to just increase the allowed max digits (module_1340, line 132) from 8 to 9.
However, my PC is set up for Windows and thus, I fiddled around with cross compiling in a newly set up VM but I did not manage to get it successfully running. (I also found this link https://github.com/hashcat/hashcat/blob/...#L555-L560 as a hint for compiling the iconv (which is the problem I also ran into))

Is there already a way to have a 9 digits iteration count for keepass?
And if not, can somebody point me towards setting up the mingw crosscompiler and actually compile hashcat on a fresh ubuntu vm?

Thanks!
uraks

 Hello. I have same problem as you. Forgot my password from Keepass database (I know what it is, but I made a mistake and one letter is wrong) and upped iteration count into the 9 digits, so I can't use hashcat.
 
 Since I'm not a developer or coder it's really hard for me to understand, not to say to make all that action you described.
 I'm trying for more than a week to understand all this commands, errors in hashcat, with varied success I made others database and found how to use hashcat but when I tried on my primal one, Error. Almost 3 day search on the internet didn't give me any result, but, finally I've found this forum thread, but unfortunately I can't solve it by myself.

So, I have a small request if its possible:
Can you send modified file where you upped to 9 digits a Keepass hash mod ?

Best regards, Ady.

I'm sorry for my English level, I'm still learning.
Reply