Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,72 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
with CryptAda.Digests.Message_Digests.SHA_256;
|
||||
with CryptAda.Digests.Hashes;
|
||||
with CryptAda.Pragmatics;
|
||||
|
||||
procedure Brute_Force is
|
||||
use CryptAda.Digests.Message_Digests;
|
||||
use CryptAda.Digests.Hashes;
|
||||
use CryptAda.Digests;
|
||||
use CryptAda.Pragmatics;
|
||||
|
||||
Wanted_Sums : constant array (1 .. 3) of String (1 .. 64) :=
|
||||
(1 => "1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad",
|
||||
2 => "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
|
||||
3 => "74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f");
|
||||
Wanted_Hash : constant array (1 .. 3) of Hashes.Hash :=
|
||||
(1 => Hashes.To_Hash (Wanted_Sums (1)),
|
||||
2 => Hashes.To_Hash (Wanted_Sums (2)),
|
||||
3 => Hashes.To_Hash (Wanted_Sums (3)));
|
||||
|
||||
subtype Ciffer is Byte range Character'Pos ('a') .. Character'Pos ('z');
|
||||
subtype Code is Byte_Array (1 .. 5);
|
||||
|
||||
task type Worker (First : Byte) is
|
||||
end Worker;
|
||||
|
||||
procedure Compare (Hash : in Hashes.Hash; Bytes : in Code) is
|
||||
begin
|
||||
for I in Wanted_Hash'Range loop
|
||||
if Hash = Wanted_Hash (I) then
|
||||
Ada.Text_IO.Put (Wanted_Sums (I) & " ");
|
||||
for C of Bytes loop
|
||||
Ada.Text_IO.Put (Character'Val (C));
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end if;
|
||||
end loop;
|
||||
end Compare;
|
||||
|
||||
task body Worker is
|
||||
Handle : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
|
||||
Digest : constant Message_Digest_Ptr := Get_Message_Digest_Ptr (Handle);
|
||||
Bytes : Code;
|
||||
Hash : Hashes.Hash;
|
||||
begin
|
||||
Bytes (Bytes'First) := First;
|
||||
|
||||
for B2 in Ciffer'Range loop
|
||||
for B3 in Ciffer'Range loop
|
||||
for B4 in Ciffer'Range loop
|
||||
Bytes (2 .. 4) := B2 & B3 & B4;
|
||||
for B5 in Ciffer'Range loop
|
||||
Bytes (5) := B5;
|
||||
Digest_Start (Digest);
|
||||
Digest_Update (Digest, Bytes);
|
||||
Digest_End (Digest, Hash);
|
||||
Compare (Hash, Bytes);
|
||||
end loop;
|
||||
end loop;
|
||||
end loop;
|
||||
end loop;
|
||||
end Worker;
|
||||
|
||||
type Worker_Access is access Worker;
|
||||
Work : Worker_Access;
|
||||
pragma Unreferenced (Work);
|
||||
begin
|
||||
for C in Ciffer'Range loop
|
||||
Work := new Worker (First => C);
|
||||
end loop;
|
||||
end Brute_Force;
|
||||
|
|
@ -1,113 +1,97 @@
|
|||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#include <openssl/sha.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// g++ -O3 -march=native pbf.cpp -o pbf -lssl -lcrypto
|
||||
|
||||
struct sha256 {
|
||||
unsigned char digest[SHA256_DIGEST_LENGTH];
|
||||
void compute(const char* str, int len) {
|
||||
SHA256((const unsigned char*)str, len, digest);
|
||||
}
|
||||
bool parse(const std::string& hash) {
|
||||
if (hash.length() != 2 * SHA256_DIGEST_LENGTH) {
|
||||
std::cerr << "Invalid SHA-256 hash\n";
|
||||
return false;
|
||||
}
|
||||
const char* p = hash.c_str();
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i, p += 2) {
|
||||
if (hash.length() != 64) return false;
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
|
||||
unsigned int x;
|
||||
if (sscanf(p, "%2x", &x) != 1) {
|
||||
std::cerr << "Cannot parse SHA-256 hash\n";
|
||||
return false;
|
||||
}
|
||||
if (sscanf(&hash[i * 2], "%2x", &x) != 1) return false;
|
||||
digest[i] = x;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const sha256& a, const sha256& b) {
|
||||
return memcmp(a.digest, b.digest, SHA256_DIGEST_LENGTH) == 0;
|
||||
}
|
||||
|
||||
bool next_password(std::string& passwd, size_t start) {
|
||||
size_t len = passwd.length();
|
||||
for (size_t i = len - 1; i >= start; --i) {
|
||||
char c = passwd[i];
|
||||
if (c < 'z') {
|
||||
++passwd[i];
|
||||
return true;
|
||||
}
|
||||
passwd[i] = 'a';
|
||||
}
|
||||
return false;
|
||||
inline bool operator==(const sha256& a, const sha256& b) {
|
||||
auto ap = (const uint64_t*)a.digest, bp = (const uint64_t*)b.digest;
|
||||
return ap[0] == bp[0] && ap[1] == bp[1] && ap[2] == bp[2] && ap[3] == bp[3];
|
||||
}
|
||||
|
||||
class password_finder {
|
||||
public:
|
||||
password_finder(int);
|
||||
void find_passwords(const std::vector<std::string>&);
|
||||
|
||||
private:
|
||||
int length;
|
||||
void find_passwords(char);
|
||||
std::vector<std::string> hashes;
|
||||
std::vector<sha256> digests;
|
||||
std::atomic<size_t> count;
|
||||
void find_passwords(char);
|
||||
public:
|
||||
password_finder(int len) : length(len) {}
|
||||
void find_passwords(const std::vector<std::string>&);
|
||||
};
|
||||
|
||||
password_finder::password_finder(int len) : length(len) {}
|
||||
|
||||
void password_finder::find_passwords(char ch) {
|
||||
std::string passwd(length, 'a');
|
||||
passwd[0] = ch;
|
||||
sha256 digest;
|
||||
while (count > 0) {
|
||||
digest.compute(passwd.c_str(), length);
|
||||
for (int m = 0; m < hashes.size(); ++m) {
|
||||
if (digest == digests[m]) {
|
||||
--count;
|
||||
std::ostringstream out;
|
||||
out << "password: " << passwd << ", hash: " << hashes[m]
|
||||
<< '\n';
|
||||
std::cout << out.str();
|
||||
char passwd[6] = {ch, 'a', 'a', 'a', 'a', '\0'};
|
||||
unsigned char digest_buf[SHA256_DIGEST_LENGTH];
|
||||
const uint64_t* targets[3];
|
||||
for (size_t i = 0; i < hashes.size(); ++i)
|
||||
targets[i] = (const uint64_t*)digests[i].digest;
|
||||
|
||||
SHA256_CTX ctx;
|
||||
do {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx, passwd, 5);
|
||||
SHA256_Final(digest_buf, &ctx);
|
||||
#pragma GCC diagnostic pop
|
||||
auto dp = (const uint64_t*)digest_buf;
|
||||
|
||||
for (size_t m = 0; m < hashes.size(); ++m) {
|
||||
auto tp = targets[m];
|
||||
if (dp[0] == tp[0] && dp[1] == tp[1] && dp[2] == tp[2] && dp[3] == tp[3]) {
|
||||
if (count.fetch_sub(1, std::memory_order_relaxed) > 0)
|
||||
printf("password: %s, hash: %s\n", passwd, hashes[m].c_str());
|
||||
if (count == 0) return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!next_password(passwd, 1))
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 4; i >= 1; --i) {
|
||||
if (passwd[i] < 'z') { ++passwd[i]; goto next; }
|
||||
passwd[i] = 'a';
|
||||
}
|
||||
return;
|
||||
next:;
|
||||
} while (count > 0);
|
||||
}
|
||||
|
||||
void password_finder::find_passwords(const std::vector<std::string>& h) {
|
||||
hashes = h;
|
||||
digests.resize(hashes.size());
|
||||
for (int i = 0; i < hashes.size(); ++i) {
|
||||
if (!digests[i].parse(hashes[i]))
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < hashes.size(); ++i)
|
||||
if (!digests[i].parse(hashes[i])) return;
|
||||
count = hashes.size();
|
||||
std::vector<std::future<void>> futures;
|
||||
const int n = 26;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
char c = 'a' + i;
|
||||
futures.push_back(
|
||||
std::async(std::launch::async, [this, c]() { find_passwords(c); }));
|
||||
}
|
||||
for (char c = 'a'; c <= 'z'; ++c)
|
||||
futures.push_back(std::async(std::launch::async, [this, c]() { find_passwords(c); }));
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::vector<std::string> hashes{
|
||||
password_finder(5).find_passwords({
|
||||
"1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad",
|
||||
"3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
|
||||
"74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f"};
|
||||
password_finder pf(5);
|
||||
pf.find_passwords(hashes);
|
||||
return 0;
|
||||
"74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f"});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,52 @@
|
|||
// $ gcc -o parabrutfor parabrutfor.c -fopenmp -lssl -lcrypto
|
||||
// $ export OMP_NUM_THREADS=4
|
||||
// $ gcc -O3 -march=native -fopenmp -o parabrutfor parabrutfor.c -lssl -lcrypto
|
||||
// $ ./parabrutfor
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <omp.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
int matches(byte *a, byte* b) {
|
||||
for (int i = 0; i < 32; i++)
|
||||
if (a[i] != b[i])
|
||||
return 0;
|
||||
return 1;
|
||||
static void parse_hash(const char* s, byte* out) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
unsigned int x;
|
||||
sscanf(&s[i * 2], "%2x", &x);
|
||||
out[i] = x;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
byte targets[3][32];
|
||||
parse_hash("1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad", targets[0]);
|
||||
parse_hash("3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b", targets[1]);
|
||||
parse_hash("74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f", targets[2]);
|
||||
|
||||
byte* StringHashToByteArray(const char* s) {
|
||||
byte* hash = (byte*) malloc(32);
|
||||
char two[3];
|
||||
two[2] = 0;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
two[0] = s[i * 2];
|
||||
two[1] = s[i * 2 + 1];
|
||||
hash[i] = (byte)strtol(two, 0, 16);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
void printResult(byte* password, byte* hash) {
|
||||
char sPass[6];
|
||||
memcpy(sPass, password, 5);
|
||||
sPass[5] = 0;
|
||||
printf("%s => ", sPass);
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
||||
printf("%02x", hash[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
|
||||
#pragma omp for
|
||||
for (int a = 0; a < 26; a++)
|
||||
{
|
||||
byte password[5] = { 97 + a };
|
||||
byte* one = StringHashToByteArray("1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad");
|
||||
byte* two = StringHashToByteArray("3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b");
|
||||
byte* three = StringHashToByteArray("74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f");
|
||||
for (password[1] = 97; password[1] < 123; password[1]++)
|
||||
for (password[2] = 97; password[2] < 123; password[2]++)
|
||||
for (password[3] = 97; password[3] < 123; password[3]++)
|
||||
for (password[4] = 97; password[4] < 123; password[4]++) {
|
||||
byte *hash = SHA256(password, 5, 0);
|
||||
if (matches(one, hash) || matches(two, hash) || matches(three, hash))
|
||||
printResult(password, hash);
|
||||
}
|
||||
free(one);
|
||||
free(two);
|
||||
free(three);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
const uint64_t (*tp)[4] = (const uint64_t (*)[4])targets;
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int a = 0; a < 26; a++) {
|
||||
byte pw[6] = { 'a' + a, 'a', 'a', 'a', 'a', '\0' };
|
||||
byte digest[32];
|
||||
SHA256_CTX ctx;
|
||||
for (pw[1] = 'a'; pw[1] <= 'z'; pw[1]++)
|
||||
for (pw[2] = 'a'; pw[2] <= 'z'; pw[2]++)
|
||||
for (pw[3] = 'a'; pw[3] <= 'z'; pw[3]++)
|
||||
for (pw[4] = 'a'; pw[4] <= 'z'; pw[4]++) {
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx, pw, 5);
|
||||
SHA256_Final(digest, &ctx);
|
||||
const uint64_t* dp = (const uint64_t*)digest;
|
||||
for (int t = 0; t < 3; t++)
|
||||
if (dp[0] == tp[t][0] && dp[1] == tp[t][1] &&
|
||||
dp[2] == tp[t][2] && dp[3] == tp[t][3]) {
|
||||
printf("%s => ", pw);
|
||||
for (int i = 0; i < 32; i++) printf("%02x", digest[i]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue