I'm working on an (long overdue) project for my security class - the assignment is to create a brute-force script that can generate a six digit password given a hint (ex. "1234") - the password can be lowercase letters & numbers.

Now my question:

Is there an easy way to script this in Perl using the matching/substitution functionality built into the regular expressions?

The issue I'm trying to conquer (w/ Java currently) is that the "hint" can be at any position within the string - I'm trying to write a recursive function but need to figure out how go through ever permutation given that not all of the characters in the string will be changing:

For instance, a six digit password with the hint "1234" will need to generate 1234xx, x1234x, and xx1234. The hint can be anything as long as it is shorter than the length of the password.

Any advice would be much appreciated!

Thanks!

In reply to Brute Force Algorithm with Perl reg exprs? by scotchfx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.