MadAndroid

Especial character combination goes wrong

16 posts in this topic

#1 ·  Posted (edited)

Hi,

I am trying to use Autoit for the first time and stuck on a problem. My program has to make the all combinations from a subset of ASCII table and is reproduced below:

; Declare a 1-dimensional array, and create an array showing the Possible Combinations
Local $aArrayesp[26] = ['"','@',"$","%",'&',"*","(",")","_","+","=","-","'","?",":",">","<",",",".",";","/",'^',"~",'']
Local $aArraymin[26] = ["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"]
Local $aArraymai[26] = ["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"]
Local $aArraytot[89] = ['"',"!","@","#","$","%","&","*","(",")","_","+","=","-","'","?",":",">","<",",",".",";","/","^","~"," ","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"," ","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"]
Local $aArrayespmai[52] = ['"','@','$','%','&','*','(',')','_','+','=','-',"'","?",':','>',"<",',','.',';','/','^','~','','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']


HotKeySet("{ESC}", "Terminate")

Run ("C:\Windows\system32\Notepad.exe")
WinWaitActive("[CLASS:Notepad]")

For $1 = 0 to UBound($aArrayesp)-1
   $chave = $aArrayesp[$1]
   Send("1 For" & $chave & "{ENTER}")
   For $2 = 0 to UBound($aArrayespmai)-1
      $chave = $aArrayesp[$1] & $aArrayespmai[$2]
      Send("2 For" & $chave & "{ENTER}")
      For $3 = 0 to UBound($aArrayespmai)-1
           $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3]
         Send("3 For" & $chave & "{ENTER}")
         For $4 = 0 to UBound($aArrayespmai)-1
            $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4]
            Send("4 For" & $chave & "{ENTER}")
            For $5 = 0 to UBound($aArrayesp)-1
                  $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4] & $aArrayesp[$5]
               Send("5 For" & $chave & "{ENTER}")
               For $6 = 0 to UBound($aArrayesp)-1
                        $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4] & $aArrayesp[$5] & $aArrayesp[$6]
                  Send("6 For" & $chave & "{ENTER}")
                  For $7 = 0 to UBound($aArrayesp)-1
                     $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4] & $aArrayesp[$5] & $aArrayesp[$6] & $aArrayesp[$7]
                     Send("7 For" & $chave & "{ENTER}")
                     For $8 = 0 to UBound($aArrayesp)-1
                                 $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4] & $aArrayesp[$5] & $aArrayesp[$6] & $aArrayesp[$7] & $aArrayesp[$8]
                        Send("8 For" & $chave & "{ENTER}")
                        For $9 = 0 to UBound($aArrayesp)-1
                                    $chave = $aArrayesp[$1] & $aArrayespmai[$2] & $aArrayespmai[$3] & $aArrayespmai[$4] & $aArrayesp[$5] & $aArrayesp[$6] & $aArrayesp[$7] & $aArrayesp[$8] & $aArrayesp[$9]
                           Send("9 For" & $chave & "{ENTER}")
                        Next
                     Next
                  Next
               Next
            Next
         Next
      Next
   Next
Next


Func Terminate()
    Exit
EndFunc   ;==>Terminate

RESULT:

1 For"
2 For""
3 For"""
4 For""""
5 For"""""
6 For""""""
7 For"""""""
8 For""""""""
9 For"""""""""
9 For""""""""@
9 For""""""""$
9 For""""""""%
9 For""""""""&
9 For""""""""*
9 For""""""""(
9 For"""""""")
9 For""""""""_
9 For""""""""
9 For""""""""=


... Lines with combintions supressed to reduce size

...

9 For"""""""_
9 For""""""""
9 For"""""""
9 For""""""":
9 For""""""">
9 For"""""""<                          PROBLEM WITH A COMBINATION BETWEEN ' " ' AND "<" . I THINK THE CODE BEGAN TO RETROCED THE COMBINATIONS

9 For"""""""<              
9 For""""""">
9 For""""""":
9 For"""""""
9 For"""""""9 For"""""""^          ANOTHER PROBLEM WITH A COMBINATION BETWEEN ' " ' AND " ' " APPARENTLY
9 For"""""""
9 For"""""""
9 For"""""""
8 For"""""""=
9 For"""""""="
9 For"""""""=@
9 For"""""""=$
9 For"""""""=%
9 For"""""""=&
9 For"""""""=*

Well, I have tried many combinations to change " and ' in order to make the Autoit compilator understand this is a combination of characteres and not a command itself but unfortunately I think it misunderstood that sometimes. It also becames crazy and started to make many "calls" to external programs such as Outlook, Media Player, etc.

I hope somebody could help me with this problem or have an idea to change the code for a better one.

Thanks

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That program is not making calls to external applications. What's happening is you're using Send(), which sends keystrokes to the active window. For some reason the other applications must have become active (like, either you clicked on them, or they popped up themselves for some reason).

Using Send() like this program does makes no sense, at least I think so. There are many ways to do the same thing your current program does but much faster, better and more flexibly. But rather than simply rewriting your current program into a more efficient version, I suggest the following: you explain what you want the program to do, and others can then suggest better ways to do it. Not to be mean, but it would probably be a good idea to start from scratch :)

And welcome to the forum!

/edit: and oh yeah, stop focusing on the difference between " and ', they do pretty much the exact same thing. It's just that if you have a string with lots of double quotes, it's more convenient to put it between single quotes so you don't have to escape all of them (and vice versa). That's definitely not the problem.

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

notepad freezes after a while and then send() start to goes crazy like you said, you can use consolewrite instead of send to notepad for small things, then copy/paste from console output to notepad, but it is probably not a good idea in your case with this script, for this you can use filewrite, its way more faster

example, Consolewrite("1 For" & $chave & @crlf) or filewrite ("test.txt","1 For" & $chave & @crlf)

what is the '1 for' for?, just for testing?, i'll write you an example for generating chrs of up to 3 combinations

Share this post


Link to post
Share on other sites

SadBunny,

Thank you for your welcome and replay to my post and yes, I can explain what I want to do: write in the Notepad.exe all combinations between the subset of ASCII tables:

Local $aArrayesp[26] = ['"','@',"$","%",'&',"*","(",")","_","+","=","-","'","?",":",">","<",",",".",";","/",'^',"~",'']

Local $aArrayespmai[52] = ['"','@','$','%','&','*','(',')','_','+','=','-',"'","?",':','>',"<",',','.',';','/','^','~','','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']

My code do that but as I have explained, at a certain point it seemed to "interpret" my sends as commands.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Use the send command with the RAW parameter, but why not simply write it directly to the file?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

There are better ways to a. generate those strings and b. write them to notepad. My point is, I can't imagine the end goal is to have a notepad full of strings. What are you actually trying to do, what do you need that data for, what do you want to do with it? There are bound to be better solutions.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

MadAndroid,

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.


M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

this one will generate up to 3 chr combinations, in the $aArrayComb variable you pick your combinations of chr to generate

HotKeySet("{ESC}", "Terminate")
;CREATE character map
$aArrayEspString = "'" & '"@$%&*()_+=-?:><,.;/^~'
$aArrayMinString = 'abcdefghijklmnopqrstuvwxyz'
$aArrayMaiString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$aArrayNumString = '0123456789'

;add chrs you whant to generate with to $aArrayComb
;~ $aArrayComb = $aArrayNumString&$aArrayMinString      ;EXAMPLE of numbers + alphabet lowercase
;~ $aArrayComb = $aArrayMinString                       ;EXAMPLE alphabet lowercase
;~ $aArrayComb = $aArrayMaiString&$aArrayMaiString      ;EXAMPLE alphabet lowercase and uppercase
$aArrayComb = $aArrayEspString & $aArrayMinString & $aArrayMaiString & $aArrayNumString ;EXAMPLE of all chrs

;create array, first item is index
$aArrayComb = StringSplit($aArrayComb, "") ;this will generate an array and the first array "$aArrayComb[0]" will be the index, so no need to use "UBound($aArrayesp)-1" in the for to loop, use $aArrayComb[0] instead

FileDelete("ChrsGen.txt");clear previously generated text file
$chave = ""
For $1 = 1 To $aArrayComb[0] ; $1=1 to start from $aArrayComb[1] because $aArrayComb[0] is the array index
    For $2 = 1 To $aArrayComb[0]
        For $3 = 1 To $aArrayComb[0]
            $chave &= $aArrayComb[$1] & $aArrayComb[$2] & $aArrayComb[$3] & @CRLF

            ;the best option it is to write file after all is done but if you want to look at it while it works then here you go, bit it is very slow this way
;~          FileWrite("ChrsGen.txt", $chave)
;~          Consolewrite($chave & @crlf) ;not a good one in this case
        Next
    Next
Next
FileWrite("ChrsGen.txt", $chave)

Func Terminate()
    Exit
EndFunc   ;==>Terminate

I did place the characters in a string to make it easier to pick character combinations, you can go and add more for to next loops but it will get slow the more you add, but not as slow as your notepad method was

i don't know if there is a better way to generate combinations, but hope this helps, if there is a better way i hope to get an example also from some one else =P

Edited by jvds
my spelling is a messy mess + removed junk line in code

Share this post


Link to post
Share on other sites

Does anyone realize that this script will do somewhere in the ballpark of 34 trillion Send() operations to Notepad? As almost all of them will be 13 characters long, that will lead to some 441 terabytes of data you're trying to pump into a notepad window. This is never going to complete.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

I would like to thank you all for the tips (including the way to post codes). In order to explain why I use the Notepad I have to say that it was really to test the code. I would not intented to let it run until ends. It was just to understand why the code was generating wrong combinations. I agree it was not the better way but I began to use Autoit this week and do not know how to do many things. I will make the suggested modifications on my code and see if it do what I need.

Sadbunny, this code is a question for implementation of algorithms of a college class. The question is not exactly like that I posted but I believe the rest I would manage to do. 

 

Share this post


Link to post
Share on other sites

Still, that code will generate hundreds of terabytes of data. Is that the desired outcome?


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Jvds,

I liked very much your idea. Very small and concise your code. Can you suggest anyway to make it ask the initial combination to start ? I mean, if I want for example to start with "@3@" and the program has to continue the rest of combinations, how do I do ?

Thanks a lot.

Share this post


Link to post
Share on other sites

at a certain point it seemed to "interpret" my sends as commands.

You should have a look at the meaning of special characters in the Send function
BTW this looks much more like some bruteforce test rather than an 'implementation of algorithms of a college class'

Share this post


Link to post
Share on other sites

Exactly, this stinks naïve attempt to bruteforce a password and try to foul contributors in believing it's something else thru evasive unbelievable reason.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Guys, first of all there`s many hacker brute force software with faster implementations using hash or wordlists avaiable for download. Why should I lose my time creating something that will produce hundreds of terabytes as SadBunny pointed so well ? Besides the first problem I poited out was explained well by JVDS post which said Notepad freezes and suggested the use of a file. I`ve already tried and solve this first problem.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now