PDA

View Full Version : A small challenge


XER
December 25th, 2008, 07:04
My dad's an arrogant bastard and thinks this source code is air tight. I thought I'd put it to the test here.

Code:


Here is code where you can seek equation to determine fyt (command$):


4 gh = 1056: fyt = VAL(COMMAND$)
5 ON ERROR GOTO 6000
10 CLS
12 IF gh <> 1056 THEN PRINT "NOT SUCCESSFUL": END ELSE GOSUB 7000
IF PW <> VAL(COMMAND$) THEN 5000 ELSE PRINT "SUCCESSFUL": END
5000 PRINT "NOT SUCCESSFUL": END
6000 PRINT "ERROR": END
7000 PW1 = 120900!: : FYT2 = INT(SQR(fyt))
7020 PW2 = 83 - FYT2
PW = PW1 + PW2
7030 RETURN


Solve for PW.

Iwarez
December 25th, 2008, 16:27
To be an arrogant bastard he should first improve his coding. It must be the worst coding style I have ever seen

Anyway, the answer is 120636

A question though: What is the variable gh good for and why is it checked? It's not used apart from the check which can't fail.

Woodmann
December 25th, 2008, 17:51
Howdy,

I sat here and stared at that code and I have a very vague sense of that style.

He must be my age (old) .

That code was airtight before we had math .

Sorry Dad.

Woodmann

XER
December 25th, 2008, 19:47
Nice job Iwarez! That didn't' take long, as I expected =). Would you be kind enough to post how or what method you used to get the answer? My dad wants to know.

As for the 'gh' variable', I was wondering that myself when I looked at it. The only thing I could think of is that 'gh' plays a roll somewhere else in the program and he just fixed the value to 1056 instead of deleting the code at line at 12. And yes Woodmann, it is old code. My dad originally painted this program on a cave wall . Not to say that you're as old as that .

P.S. - I'm dazzled by everyone's level of expertise here. I'm a little unsure of my own reversing progress. Would you guys mind telling me how long you've been reversing and/or how long it's taken you to get proficient? By proficient I mean being able to sit down with a piece of disassembled code and understand what it's doing.

Woodmann
December 25th, 2008, 21:27
Howdy,

Square root? (I dont remember what that button means on my calculator) of 120900=347
347-83=264

120900-264=120636

I'm a hack so I dont look at such things as the gh variable.
I mean I looked at it but it didnt make any sense to me so I ignored it.

As for how long have I been doing this, thats kind of arbitrary. It depends on your age.
I am from the age or BASIC, actually, I am older than that .

Young'ins these days are born of computers. I was born before color TV .

Woodmann

blabberer
December 26th, 2008, 13:17
how would one tend to solve it

pw = pw1 +pw2
pw = pw1 + 83 -fyt2
pw = pw1 + 83 - int(sqr(fyt))
pw = 120900 + 83 - int(sqr(fyt))
pw = 120983 - int(sqr(fyt))

since pw <> fyt

pw + sqrt (pw) = 120983

or in mathematical notation

y = x + root(x)

which can be deduced
or we can use some online graph plotter

see pic

the url is in pic

evaluator
December 26th, 2008, 15:13
Don Wooma!!!
(i nothing understood, BUT!) finally you shoWed grEat reWer_sing!
~8D

XER
December 26th, 2008, 16:46
Ah, I thought of linear equations myself. Thank you for taking the time to post your method blabberer =).

XER

Woodmann
December 26th, 2008, 17:52
Errrrrrr.........

Don Wooma i understood grEat but not .

Party on Wayne.

Woodmann

blabberer
December 27th, 2008, 13:38
Quote:
[Originally Posted by XER;78371]Ah, I thought of linear equations myself. Thank you for taking the time to post your method blabberer =).

XER

well you should have thought about quadratic equations as well

Code:

y = x + root x

120983 = x + sqrt(x)


let x = z^2

so

y = z^2 + z

z^2 +z -120983 = 0

solving this quadratic equation

ax^2 + bx +c = 0

where a= 1, b= 1, c= -120983

you get 347.326465353055 and -348.326465353055 as roots

ie
z = sqrt(x) = 347.326465353055

z^2 = x = 120635.673534646915325797833025

so y = x + sqrt(x) = 120982.999999999970325797833025 ~ = 120983

so since we are considering the integer part of sqrt

we should roundup 120635,67####
to 120636 which is your pw