dispacct@hotmail.com (Curious) writes:
[color=blue]
> I'm working on a challenge given to me. The Javascript I have been
> given parses the user input in two ways.
>
> Firstly it generates two numbers. One is the sum of the CharCodes and
> the other is the product of multiply each of the charcodes together
> and usisng the Modulus function.[/color]
The char codes are 8 bits or 16 bits? What is the modulus? 256?
[color=blue]
> If the text string is correct, the string is then used to decode (via
> a relatively simple crypt) another string, which then gives you the
> correct target url.[/color]
How do you recognize a correct URL?
[color=blue]
> I hope that makes sense - if it doesn't, its pretty unimportant as the
> question I have is as follows :[/color]
You got me curious :) I love a good challenge :=
[color=blue]
> In javascript, how do I code something that allows me to cycle through
> all the possible text strings. Ideally, I would like to read from a
> dictionary file and then start a brute force.[/color]
The dictionary file is harder than just brute forcing, mainly due to
Javscript in browsers having restricted access to file functions.
Ofcourse, you could include the dictionary in the directly.
Iterating through *all* strings will take a while. After all, there
are infinitly many (but in practice restricted to the size of
available memory or browser specific limits). With luck, the string
you are looking for is of limited length, so you won't have to
search *too* long.
[color=blue]
> Throughout each cycle, I imagine you just set input_user (in this
> case) to the value of the next line in the file. For a dictionary
> attack I imagine. That bit isn't too tricky I don't think but I can't
> get my head around it. Maybe more coffee would help?[/color]
Getting the dictionary into the Javascript is the hard part. When you
have it, iterating through it is trivial.
[color=blue]
> And I'm sure struggling to put together a brute forcer so I turn to
> you guys and gals to ask if you could help me and point me in the
> right direction on how to code this.[/color]
First you need to limit the different characters you can use in the
password. If you allow all of the thousands of Unicode characters,
then you will never get anywhere. The smaller the set of characters,
the sooner you will hit the correct string.
---
function StringEnumerator(chars) {
this.characters = chars;
this.stringNumber = 0;
this.stringLength = 0;
this.stringNumberLimit = 1;
}
StringEnumerator.prototype.next = function() {
var res = "";
var idx = this.stringNumber;
var len = this.characters.length;
for (var i=0;i<this.stringLength;i++) {
res += this.characters.charAt(idx%len);
idx = Math.floor(idx/len)
}
this.stringNumber++;
if (this.stringNumber == this.stringNumberLimit) {
this.stringNumber = 0;
this.stringNumberLimit *= len;
this.stringLength ++;
}
return res;
}
---
Example use:
---
var characters = "abcdefghiklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXY Z"+
"1234567890 ,.-+/*:;<>!?@#$&"; // or something
var strEnum = new StringEnumerator(characters);
var str1 = strEnum.next();
var str2 = strEnum.next();
var str3 = strEnum.next();
var str4 = strEnum.next();
---
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'