• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

analyzing code; can you decrypt this?

KMK0420

Weaksauce
Joined
Dec 7, 2005
Messages
75
i have some background in html, vb, c++, etc, but nowhere near enough to do any type of valuable programming.

i need a little help here. im trying to decrypt this code, and through a few hours i got to the main part that i would like to decrypt but i cant seem to figure it out. heres what i mean.

CODE:

--------------
s = unescape(_url);
importString = s.substr(s.lastIndexOf("?") + 1, s.length);
splitString = importString.split("!");
total = splitString.length - 1;
var decodedString;
for (i = 0; total >= 0; i++)
{
chunk = splitString;
decoded = String.fromCharCode(chunk);
decodedString = decodedString + decoded;
--total;
} // end of for
imageType = decodedString.slice(-1);
imageString = "poop/" + decodedString + ".jpg";
------------------

now, say your "input variable" is something along the lines of:

74!66!95!51!95!50!95!54!95!80!95!50!

what would the decodedString be for that example? (without any spaces - the post adds the space before the 95)

also, would you mind explaining to me how to decrypt any given example?

i know its poop/#.jpg

but the # is what i need help with. heh. any ideas??
 
"Decrypt" is the wrong word, by the way. "Understand" is more appropriate.

I don't like Java, but I think it's just finding each integer between the bangs and converting it to a character assuming it's the ASCII value of the character.

So "74!66!95!51!95!50!95!54!95!80! 95!50!" is converted to "JB_9_2_6_P_2".

Trying to hack some images of a website, are we?
 
Well, there's not much of an algorithm.

importString.split("!") takes importString and finds each "!". It takes the characters between the current "!" and the last "!" and puts them into an array.

The code then rips through that array, converting the strings into characters and concatenating the characters into a new string.
 
hmm. reminds me of vb.

now, how did you know how to decode that? like how did you know the process involved with converting the strings into the new characters/strings? and what exactly is that process?
 
Code:
importString = s.substr(s.lastIndexOf("?") + 1, s.length);
Gets a substring starting from the last occurance of "?" in the string "s" to the end of the string.

Code:
splitString = importString.split("!");

creates an array "splitString" containing each fragment of "importString" which is seperated by a "!"

Code:
total = splitString.length - 1;
var decodedString;
for (i = 0; total >= 0; i++)
{
    chunk = splitString[i];
    decoded = String.fromCharCode(chunk);
    decodedString = decodedString + decoded;
    --total;
} // end of for

iterates through each string in splitString, and converts each array member into it's ASCII value which is then appended to decodedString

Also probably the worst use of a for loop I've ever seen in my life.

It should look like this:
Code:
var decodedString;
for (i = 0; i < splitString.length(); i++)
{
    decodedString = decodedString + String.fromCharCode(splitString[i]);
} // end of for

understanding code just takes some experience. Sometimes going through it line by line helps, sometimes looking at the big picture helps, but you really need to understand what things are typically used for so you can make good assumptions.
 
KMK0420 said:
now, how did you know how to decode that? like how did you know the process involved with converting the strings into the new characters/strings? and what exactly is that process?

I've been writing software for almost 30 years. That experience was primarily useful here because you never told us what language you were usign or what platform you were running on. I had to guess, and guesses tend to get better with experience.

Though I've never written a full application in Java, I know it from writing JavaScript and reading Java code that I've had to translate or study.

For the parts I don't know, I look 'em up. You could, too:

Java String
Java String.Split
Java String.fromCharCodeJava String.length
 
thanks for your input guys, somewhat off topic, do any of you know any websites that actually can teach java/javascript and/or any other interesting languages besides vb? i mean, i know there are always courses i can take at school, but i'd like to learn on my own you know. most google searches come back with some crusty websites that don't really get you anywhere..

i understand the process a lot more now. but still am curious as to how you just "figured out" what the ascii equivilent was..
 
ASCII Chart

I believe Java uses Unicode, though URLs don't. We should never see a string in this code that uses Unicode, then. But if you want a Unicode chart, you can find one at unicode.org.
 
ASCII is a standard - every ASCII character has a defined value. Google 'ascii table' and you'll find a list of these values.

If you already know the basics of programming(though I'm kinda assuming you don't at this point. :p ), you can learn a lot about a language by looking at its specifications. Like if you wanted to know about a language's string manipulation functions, you would check the specifications to see what functions are available and how to use them.

If, however, you don't know basic programming concepts, then you'll have to start with that. For this, take a look at this site:
http://math.hws.edu/javanotes/
I just found that with a bit of searching. I've not actually used it, but it looks decent.
 
Back
Top