Maximus1 Posted July 17, 2010 Share Posted July 17, 2010 hi i want to write a program which works like a brute force attack. i need it because i want to download pages from a website and this is the only way i see to get on the last part of the link. the following makes a random generated 5 char "word" but is not exat what i need. $zeichen = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" $string = StringSplit ($zeichen,"") $anzahl_der_zeichen = 5 $zeichen2 = "" For $i = 1 To $anzahl_der_zeichen $zeichen2 &= $string[Random(1,UBound ($string)-1)] Next MsgBox (0,"",$zeichen2) i need it like this: AAAAA AAAAB . . . AAAAZ AAABA . . . can you help me? Link to comment Share on other sites More sharing options...
MvGulik Posted July 17, 2010 Share Posted July 17, 2010 What your looking for is called "Permutation" -> Use with forum search feature. (Some completely ready to go code available.) "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Spiff59 Posted July 17, 2010 Share Posted July 17, 2010 (edited) Hmm... 26 ^ 5 = 11,881,376. That's one big-ass list of strings. I've commited the sin of calling a routine recursively, but I can't see doing it in less lines of code: #include <Array.au3> Global $len = 3 Global $Array_Idx, $Array_Max = 26 ^ $len, $Array[$Array_Max + 1] = [$Array_Max] Letter_Generator($len) If $len < 5 Then _ArrayDisplay($Array) Else MsgBox(1,"", "Element " & $Array_Max & " = " & $Array[$Array_Max]) EndIf ;=============================================================================== Func Letter_Generator($idx, $tmp = "") $idx -= 1 For $x = 1 To 26 If $idx Then Letter_Generator($idx, $tmp & Chr(64 + $x)) Else $Array_Idx += 1 $Array[$Array_Idx] = $tmp & Chr(64 + $x) EndIf Next EndFunc If you call it with "5" as the parameter, then go have a cup of coffee while it's running, it may be done when you get back. Edit: The routine works with the bigger numbers, and is fairly fast. It's the _ArrayDisplay() I stuck at the end that takes all day and eventually kills my 2GB machine with an "error allocating memory" error when the $len parameter is > 4. Maybe asking to build and display a ListView with 12 million elements is a bit much I put a "safety valve" in the demo. Edit2: If you don't need them in an array, you could scrap all that and just do this: Letter_Generator(5) ;=============================================================================== Func Letter_Generator($idx, $tmp = "") $idx -= 1 For $x = 1 To 26 If $idx Then Letter_Generator($idx, $tmp & Chr(64 + $x)) Else ToolTip($tmp & Chr(64 + $x)) ; Process($tmp & Chr(64 + $x)) ; call your own function for individual processing here EndIf Next EndFunc Edited July 17, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
Maximus1 Posted July 17, 2010 Author Share Posted July 17, 2010 i`ve generated a permutation file (79MB) but there must be a way to make one "word" and work with it. after the job is done the next will processed. Generate permutation AAAAA ----> work with it Generate next permutation AAAAB ----> work with it . . . . Link to comment Share on other sites More sharing options...
Spiff59 Posted July 17, 2010 Share Posted July 17, 2010 Looks like I posted my last edit the exact same time that you just posted. Replacing the (slow) Tooltip() in the second example with a call to your own function will do what you want. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 17, 2010 Share Posted July 17, 2010 If you provide some of the exact text you want and a sample of how it shows in the string of the html code, there may be a method totaly different to what you are trying to do. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now