Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. generate password using brute algo?

generate password using brute algo?

Scheduled Pinned Locked Moved C / C++ / MFC
databasedata-structuresquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    hi all, I am using

    static /*const*/ char alphabet[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";

    static /*const*/ int alphabet_size = sizeof(alphabet) - 1;

    CString str_val=_T("");
    void brute_impl(char * str, int index, int max_depth)
    {
    int i;
    for (i = 0; i < alphabet_size; ++i)
    {
    str[index] = alphabet[i];

        if (index == max\_depth - 1)
        {			
    		str\_val.Format("%s", str);
    
    		//check the password here
    
        }
        else
        {
            brute\_impl(str, index + 1, max\_depth);
        }
    }
    

    }

    void brute_sequential(int max_len)
    {
    char * buf = new char[max_len + 1];

    //buf = malloc(max\_len + 1);
        int i=0;
    
    while(buf\[i\] != NULL)
    {
    	if(i==max\_len+1)
    		break;
    
    	buf\[i\]='\\0';
    
    	i++;
    }
    
    CString str=\_T("");
    str.Format("size of array is %d\\n", i);
    
    
    for (i = 1; i <= max\_len; ++i)
    {
        memset(buf, 0, max\_len + 1);
        brute\_impl(buf, 0, i);
    }
    
    free(buf);
    

    }

    but its time consuming and very slow anybody have more efficient and fast method for this. thanks.

    M 1 Reply Last reply
    0
    • L Le rner

      hi all, I am using

      static /*const*/ char alphabet[] =
      "abcdefghijklmnopqrstuvwxyz"
      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      "0123456789";

      static /*const*/ int alphabet_size = sizeof(alphabet) - 1;

      CString str_val=_T("");
      void brute_impl(char * str, int index, int max_depth)
      {
      int i;
      for (i = 0; i < alphabet_size; ++i)
      {
      str[index] = alphabet[i];

          if (index == max\_depth - 1)
          {			
      		str\_val.Format("%s", str);
      
      		//check the password here
      
          }
          else
          {
              brute\_impl(str, index + 1, max\_depth);
          }
      }
      

      }

      void brute_sequential(int max_len)
      {
      char * buf = new char[max_len + 1];

      //buf = malloc(max\_len + 1);
          int i=0;
      
      while(buf\[i\] != NULL)
      {
      	if(i==max\_len+1)
      		break;
      
      	buf\[i\]='\\0';
      
      	i++;
      }
      
      CString str=\_T("");
      str.Format("size of array is %d\\n", i);
      
      
      for (i = 1; i <= max\_len; ++i)
      {
          memset(buf, 0, max\_len + 1);
          brute\_impl(buf, 0, i);
      }
      
      free(buf);
      

      }

      but its time consuming and very slow anybody have more efficient and fast method for this. thanks.

      M Offline
      M Offline
      MicroVirus
      wrote on last edited by
      #2

      Use a passwords list; you can find them freely on the web.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups