04-05-2022, 04:21 AM
I figured I'd add to this now evolving howto guide into attacking (and fail so far) a default password document for those of you using windows. I spend a lot of time getting openSSL to work in visual studio C++ so you won't have to make the same mistakes.
First the installation and compilation is described in this youtube video.
install youtube guide for openSSL
But you'll see he has a hard time at the end of the video finding a working example of the implementation compatible with the latest revision.
#include <cstdio>
#include <string>
#include <iostream>
#include <stdio.h>
#include <openssl/md5.h>
#pragma warning(disable : 4996)
void main{
unsigned char digest[MD5_DIGEST_LENGTH];
string md5_text="hello world";
test_string = md5_text.c_str();
MD5((unsigned char*)test_string, strlen(test_string), (unsigned char*)&digest);
cout << int(digest[0]) << ' ' << int(digest[1]) << endl;
}
*note to lack of "&" in front of the test_string in the MD5 call. The &test_string shows up in a lot of examples and really screws things up, so don't do it!
Also this implementation allows you to change the length of MD5_text without the compiler yelling at you which is helpful to try different guesses.
#include <openssl/sha.h>
void main {
unsigned char digest[SHA_DIGEST_LENGTH];
string sha1_text="hello world";
test_string = sha1_text.c_str();
SHA1((unsigned char*)test_string, strlen(test_string), (unsigned char*)&digest);
cout << int(digest[0]) << ' ' << int(digest[1]) << endl;
}
That still won't work without the windows SDK installed and you'll have to link additional libraries from the SDK.
linker/input/additional dependencies (for the x64 debug and release)
Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\Crypt32.Lib
Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\WS2_32.Lib
Although the openSSL MD5 implementation is faster than anything I found online, I did find a faster SHA1 version
So it took a lot of work to get openSSL SHA1 to actually work, I was better of with the stand alone version. Live and learn.
First the installation and compilation is described in this youtube video.
install youtube guide for openSSL
But you'll see he has a hard time at the end of the video finding a working example of the implementation compatible with the latest revision.
#include <cstdio>
#include <string>
#include <iostream>
#include <stdio.h>
#include <openssl/md5.h>
#pragma warning(disable : 4996)
void main{
unsigned char digest[MD5_DIGEST_LENGTH];
string md5_text="hello world";
test_string = md5_text.c_str();
MD5((unsigned char*)test_string, strlen(test_string), (unsigned char*)&digest);
cout << int(digest[0]) << ' ' << int(digest[1]) << endl;
}
*note to lack of "&" in front of the test_string in the MD5 call. The &test_string shows up in a lot of examples and really screws things up, so don't do it!
Also this implementation allows you to change the length of MD5_text without the compiler yelling at you which is helpful to try different guesses.
#include <openssl/sha.h>
void main {
unsigned char digest[SHA_DIGEST_LENGTH];
string sha1_text="hello world";
test_string = sha1_text.c_str();
SHA1((unsigned char*)test_string, strlen(test_string), (unsigned char*)&digest);
cout << int(digest[0]) << ' ' << int(digest[1]) << endl;
}
That still won't work without the windows SDK installed and you'll have to link additional libraries from the SDK.
linker/input/additional dependencies (for the x64 debug and release)
Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\Crypt32.Lib
Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\WS2_32.Lib
Although the openSSL MD5 implementation is faster than anything I found online, I did find a faster SHA1 version
So it took a lot of work to get openSSL SHA1 to actually work, I was better of with the stand alone version. Live and learn.