Creating Bruteforce Program

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2006
Posts: 26
Reputation: portege is an unknown quantity at this point 
Solved Threads: 1
portege portege is offline Offline
Light Poster

Creating Bruteforce Program

 
0
  #1
Jul 20th, 2006
I'm interested in creating a bruteforce program. What is the most computer resource efficient method to count in base 62? (1,2,3...a,b,c...A,B,C)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,679
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1504
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Creating Bruteforce Program

 
0
  #2
Jul 20th, 2006
probably something like below: count using normal integers but convert to base62 for display.

  1. #include <cstring>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main( )
  6. {
  7. long n = 1234576;
  8. char buf[255];
  9. _itoa( n, buf, 62 );
  10. cout << buf << "\n";
  11. return 0;
  12. }

Warning: The above code is not ansi standard. Here is a link you might be able to use if you need something ansi standard.

[edit]I have done a little testing with the algorithms in the link I posted and none of them produce the same result as _itoa() function. The first algorithm for my_atoi() might be a fairly simple fix -- it just leaves off the last digit.[/edit]
Last edited by Ancient Dragon; Jul 20th, 2006 at 6:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,679
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1504
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Creating Bruteforce Program

 
0
  #3
Jul 20th, 2006
Well here is a c++ version that should be portable and returns the same as itoa().

  1. string my_itoa(int value, int base)
  2. {
  3. string s;
  4. for(int i = base; value && i ; --i, value /= base)
  5. {
  6. s = "0123456789abcdefghijklmnopqrstuvwxyz"[value % base] + s;
  7. }
  8. return s;
  9.  
  10. }
Last edited by Ancient Dragon; Jul 20th, 2006 at 8:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: combustion is an unknown quantity at this point 
Solved Threads: 0
combustion combustion is offline Offline
Newbie Poster
 
-3
  #4
Nov 13th, 2009
The problem here is that it wouldn't be able to crack a string such as 000 or 0zzz
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: combustion is an unknown quantity at this point 
Solved Threads: 0
combustion combustion is offline Offline
Newbie Poster
 
0
  #5
Nov 14th, 2009
Here's my code, tested for errors:
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. char chars[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  5. string t;
  6. void checkPassword(string password);
  7. void recurse(int width, int position, string baseString);
  8. int main() {
  9. cout << "Enter a string: " << endl;
  10. cin >> t;
  11. int maxChars = 13;
  12. for(int i=0;i<maxChars+1;i++) {
  13. cout << "checking passwords width [" << i << "]..." << endl;
  14. recurse(i,0,"");
  15. }
  16. return 0;
  17. }
  18. void recurse(int width, int position, string baseString) {
  19. for(int i=0;i<35;i++) {
  20. if (position < width-1) {
  21. recurse(width, position + 1, baseString+chars[i]);
  22. }
  23. checkPassword(baseString+chars[i]);
  24. }
  25. }
  26. void checkPassword(string password) {
  27. if (password==t) {
  28. cout << "match [" << password << "]" << endl;
  29. exit(1);
  30. }
  31. }
it cracks the string h3ar7 in 16 seconds on my computer.
Reply With Quote Quick reply to this message  
Join Date: Dec 2009
Posts: 1
Reputation: burmix is an unknown quantity at this point 
Solved Threads: 0
burmix burmix is offline Offline
Newbie Poster
 
0
  #6
14 Days Ago
There should be 36 in for loop
regards
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,466
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 189
firstPerson's Avatar
firstPerson firstPerson is online now Online
Nearly a Posting Virtuoso
 
0
  #7
14 Days Ago
>>it cracks the string h3ar7 in 16 seconds on my computer.

Thats pretty slow. There is no reason to use recursion here.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle.
2) Problem 2[b]solved by : jonsca
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 8501 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC