Just a little bruteforce number I need help with

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
#include <iostream>
#include <string>
#include <ctime>
#include <limits>
using namespace std;
//-------------------------------------Declarations of Variables------------------------------------------------------//
	_int64 password; // The input number
	_int64 tryer = 0; // Even Numbers Bruteforce
	_int64 tryer1 = 0; // +1
	_int64 tryer2 = 0; // Odd Numbers Bruteforce
	int indicator = 0; // Whether it has succeed or not.
	//---------------------------Testing Bruteforce (Optional to speed up process) WARNING, can hog up computer-----//
	_int64 tryer3 = 0; // +4 Bruteforce
	_int64 tryer4 = 0; //+5 Bruteforce
	_int64 tryer5 = 0; // +6 Bruteforce
	_int64 tryer6 = 0; // +7 bruteforce
	_int64 tryer7 = 0; //+8 Bruteforce
	_int64 tryer8 = 0; //+9 Bruteforce
	_int64 tryer9 = 0; // +10 bruteforce
	_int64 timer = 0; // Timer!
//--------------------------------------------------------------------------------------------------------------------//
//--------------------------------------------Classes for functions---------------------------------------------------//
void AddNumbers(){ // Added to simplify and make things neater.
	tryer1 += 1;
	tryer += 2;
	tryer2 += 3;
	tryer3 += 4;
	tryer4 += 5;
	tryer5 += 6;
	tryer6 += 7;
	tryer7 += 8;
	tryer8 += 9;
	tryer9 += 10;
}
void SM(int x){ // Made to save time instead of typing them out one by one.
	if(x == password){
		indicator = 1;
		cout << "Success! Your password have just been cracked and it is: " << x << endl;
	}
}
void Check(){
	if(password == 1){
		cout << "Hey kiddo, this ain't no joke, if it was 1 it would have been already bypassed!" << endl;
		system("PAUSE");
		}
	if(password >= 9223372036854775807){
		cout << "Sorry, the password you have just entered has reached the maximum value." << endl;
	}
}
//--------------------------------------------------------------------------------------------------------------------//
int main(){
	cout << "Welcome to the program made by Darren Kok!\n" << endl;
	cout << "Please enter the number you want cracked. Note: Try your best to enter 10 or less than that digits. " << endl;
	cin >> password;
	Check();
	while(indicator != 1){ // bruteforce.
	SM(tryer);
	SM(tryer1);
	SM(tryer2);
	SM(tryer3);
	SM(tryer4);
	SM(tryer5);
	SM(tryer6);
	SM(tryer7);
	SM(tryer8);
	SM(tryer9);
	AddNumbers();
		}
	system("PAUSE");
} 
 



UPDATE: Final piece of work, how can I make the bruteforce faster?
Last edited on
Can someone please teach me how to make the bruteforce faster?
You're kind of on the wrong track... with a weird form of loop unrolling. (Trading simplicity for the bloat of duplicate code.)
http://en.wikipedia.org/wiki/Loop_unwinding

Can someone please teach me how to make the bruteforce faster?

Bruteforce isn't fast.
Bruteforcing means checking all the possible solutions until you find the valid one. Its "speed" is determined by the hardware, and is degraded by how many possible solutions it has to go through.

1) You can gain speed by devising an algorithm which isn't bruteforce, that is to say it doesn't check through all possibilities. An example is a dictionary attack, where you have a database of "most common" numbers.
http://en.wikipedia.org/wiki/Dictionary_attack

2) You may gain some speed by using threads. Many modern computers have CPU's with multiple cores. For two cores, you assign one core to check the first half of possible values, and the other one to check the second half.
http://en.wikipedia.org/wiki/Thread_%28computing%29
http://en.wikipedia.org/wiki/C%2B%2B11#Threading_facilities
http://en.cppreference.com/w/cpp/thread/thread/thread
Also this line doesn't look valid to me:
if(password >> 9223372036854775807){

Perhaps you want:
1
2
3
4
5
6
#include <limits>

// ...

if (password > std::numeric_limits<_int64>::max()) {
// you may remove the `std::' if you have a `using namespace std;' 

http://cplusplus.com/reference/std/limits/numeric_limits/

Also, void main() is not standard C++, please use int main() instead.
http://www.stroustrup.com/bs_faq2.html#void-main
Topic archived. No new replies allowed.