Operating System - Linux
1753831 Members
9468 Online
108806 Solutions
New Discussion юеВ

Help me with this shell script pls..

 
Hein van den Heuvel
Honored Contributor

Re: Help me with this shell script pls..

Stuart wrote> Putting into memory is the mistake you're making. You're just after output.


No and No. The per script does not put it into memory either. I was just after proving that it can not be done with reasonable resources.

>> I've got one here that's about 40 lines long that (just mucking around) is brute-forcing a 32 character password.

Why would you try that if you know there does not exist storage in the world to hold the results (5e49 bytes... a 5 with 49 zeroes behind it)?

Karthik> Its just that sum 1 had told we can do this via shell script or perl script .

NOT with the specification you provided.


>> Can u guys post the code of what u tried.

Perl script above

Just change
>> for (' ', 'a'..'c', '0'..'2') {
:
>> if (($j && $x++ < $count) || $x++ < 3 ) {

To

>>>> for (' ', 'a'..'z', '0'..'9') {
:
>>>> if (($j && $x++ < $count) || $x++ < 26 ) {

If you want to go to 9999...9 the change last to:
>>>> if ($x++ < $count) {

Bash script was already posted below your reply above this one.

> I had been tryin this since days.

Ouch!

> Is there any logic for this Problem-

I just use a simple counting technique for a radix-N number.
You know 1 + 1 = 2...
9 + 1 = 0 and increment the next cell.
'a' + 1 = 'b'
'z' + 1 = ' ' and increment the next cell.

Instead of outputting each cell directly, i look up the 'picture' in a table.
One could also count in pictures of course.


On an HP BL860c, with just 7 output chars, the perl script generates the 960801 words in 9.3 seconds.
I killed the shell script after 11:31.6 minutes ( user 7:07.3, sys 1:50.2) just before it was done :-(.
I should have trusted my ball park duration guestimate of 10 minutes better, allowing for a little more.

$ wc -lc *.tmp
931315 7290395 bash.tmp
960801 8647214 perl.tmp

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting


Stuart Browne
Honored Contributor

Re: Help me with this shell script pls..

The perl script there is refusing to start with the numbered values.. was that intentional?
One long-haired git at your service...
Hein van den Heuvel
Honored Contributor

Re: Help me with this shell script pls..

Surprised at the runtime difference?
I wasn't. Mind you, I tried under HPUX un Itanium, not Linux where bash might be more optimized.

>> The perl script there is refusing to start with the numbered values.. was that intentional?

Yes,
following the 'suggestion' in the original question:
".......till a9999999........9........9 "

In an earlier reply I questioned whether that leading 'a' was intentional (symbol or password requirement) or just careless.

It was implemented with the line
>> if (($j && $x++ < $count) || $x++ < 3 ) {
So is $j, the column counter is not zero = true then go through all sample characters. If it is not true then use a different stopper, here hardcoded at 3 = 'c'.
To generate all, simplify that line to:
>> if ($x++ < $count) {

Didn't i write that already above?

I maintain that if this was to be part of a serious application, then a 'real' compiled langues is in order, not perl and certainly not a shell. The generated data should not be stored/listed, but consumed there and then.


If it was a brute-force password cracker, then uppercase would probably need to be part of the character set:
>> for (' ', 'A'..'Z', 'a'..'f', '0'..'9') {

And you could restrict yourself to say 12 chars giving 'only' (26+26+10)**12 words.

Cheers,
Hein.