-
Notifications
You must be signed in to change notification settings - Fork 126
/
bruteforce_example_checksum.cpp
113 lines (95 loc) · 2.94 KB
/
bruteforce_example_checksum.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
bruteforce_example_checksum.cpp - C++ modular and iterative bruteforce engine.
Copyright (C) 2013 Axel "0vercl0k" Souchet - http://www.twitter.com/0vercl0k
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/>.
*/
#include <iostream>
#include <string>
#include <cstring>
//thx thaw <3
std::string bf(void (*hashing)(unsigned char*, unsigned int, unsigned char*),
const unsigned char* hash,
unsigned int hs,
const std::string& charset,
unsigned int min,
unsigned int max)
{
std::string result("not found");
unsigned int* idx = new unsigned int[max];
unsigned char* input = new unsigned char[hs];
unsigned char* output = new unsigned char[hs];
unsigned int charset_size = charset.size() - 1;
unsigned int size = min;
unsigned int i;
for(i = 0; i < size; ++i)
input[i] = charset[idx[i] = 0];
while(size <= max)
{
hashing(input, size, output);
if(!memcmp(hash, output, hs))
{
result = "";
for(i = 0; i < size; ++i)
result += charset[idx[i]];
break;
}
for(i = 0; i < size; ++i)
{
if(idx[i] == charset_size)
{
input[i] = charset[idx[i] = 0];
if(i + 1 == size)
{
i = ++size - 1;
input[i] = charset[idx[i] = 0];
break;
}
}
else
{
input[i] = charset[++idx[i]];
break;
}
}
}
delete[] idx;
delete[] input;
delete[] output;
return result;
}
void sub_41EC50(unsigned char *in, unsigned int len, unsigned char *out)
{
unsigned int v1; // edx@1
unsigned char *v2; // ecx@1
int v3; // esi@1
char v4; // al@2
v2 = in;
v3 = -559038737;
v1 = 0;
do
v4 = *v2++;
while ( v4 );
if ( v2 != in + 1 )
{
do
v3 = 1535553534 * in[v1++] - 942085638 * v3;
while ( v1 < strlen((const char*)in) );
}
*((unsigned int*)out) = v3;
}
int main(int argc, char** argv)
{
unsigned int hash = 0xC4B1801C;
std::string charset("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
std::cout << bf(sub_41EC50, (const unsigned char*)&hash, 4, charset, 1, 5) << std::endl;
return 0;
}