Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Has anyone actually done timed 1 in python


ghost's Avatar
0 0

Ive come close but everything ive coded takes far far too long. Heres the rough steps im taking:

Opening the index of HBH with cookiejar to log me in Getting the source of the timed 1 page Matching the string with a regexp b64 decoding it and sending it back

All these seem to take longer than a second on they're own. I tried it with PHP/cUrl but I dont know enough PHP, and had loads of problems with the curl stuff. Id prefer to stick with python, but im not sure its even possible.

Note: Please dont send me source code answers, I wanna work this one out on my own, but does anybody know if this is at least possible. Am I over-complicating things?

Cheers


Uber0n's Avatar
Member
0 0

I think you're doing it the right way, although your connection might be too slow. Bring the application to school or something and try it there.

I've beaten it both in VB6 and in GML (with a DLL made in C++), and I know a lot of people did it in PHP. Python should definately be able to beat it as well ;)


Mouzi's Avatar
Member
0 0

I still think people are making this too complicated ;P I did all of them with JS. Of course it's good programming experience though to try doing them in different languages.

EDIT: Oops, I haven't done that fourth one yet. EDIT2: Now I have (and with JS again).


ghost's Avatar
0 0

YES!

Did it! Took me far too long (3 hours) but I learnt loads about urllib and python in general. Timed 2 here I come…. :p


Demons Halo's Avatar
Member
0 0

how the heck did you do it? :S I can't get it to work under 1.3 sec!! The requests take 1.2 sec and 0.1 for decoding… :/


clone4's Avatar
Perl-6 Wisdom Seeker
0 0

Demons Halo wrote: how the heck did you do it? :S I can't get it to work under 1.3 sec!! The requests take 1.2 sec and 0.1 for decoding… :/

Your request takes ages, I think it's a slow connection. And the decoding takes way too much time as well, maybe some code optimization


ghost's Avatar
0 0

Well I don't know any python, but in case it works as in many other languages and you gather the information sent to you in chunks then it might be quicker to just get roughly enough to include the data you're after then not care to receive the rest. Should save you a bit of time.


Demons Halo's Avatar
Member
0 0

I've looked through urllib and urllib2. The easiest way to handle cookies is by using the request class with cookies in the headers.

I'm using a 24mbit/s connection so… I doubt the speed thingy :/

best I could do was 1.3sec @ 07.00 before I went to work while there was 5-6 members online.

@COM. hmm you must be right… I'm using read() [15000:-10000] to minimize the search area, although there must be a way to receive only a bit of the source code right away. I'll check it out :)

//D.H.


ghost's Avatar
0 0

i think the fastest way would be by using sockets directly; construct the headers by hand…


Demons Halo's Avatar
Member
0 0

O.o

what difference would it make? the socket requests the URL anyway, which the request class does as well. What I need is some kind a syntax (which I've been googling for), where I can specify what chunk of the source I want to retrieve.


ghost's Avatar
0 0

Why would you want to get part of the source, it wouldnt be significantly faster than getting the whole source…


Demons Halo's Avatar
Member
0 0

what is the problem then? :( :(

I was thinking like: request less data -> less work time.

Reading the full source, sorting out the string and decode it takes less than 0,1 second. It's the requesting and submitting parts that are slow, and they are pretty much as short as they can be:

from urllib2 import *

url='http://www.hellboundhackers.org/challenges/timed/timed1/index.php'

headers = {'COOKIE': 'xxx', 'Referer': 'http://www.hellboundhackers.org/'}
req = Request(url, None, headers)                    
response = urlopen(req)

It can't be any simpler than that :S the same thing goes for submitting with a little url editing!


ghost's Avatar
0 0

idk… i used sockets and it took me a couple of tries…


ghost's Avatar
0 0

Need some help… Keep getting YOU MUST BE LOGGED IN TO PLAY!


ghost's Avatar
0 0

i did login with the code on the thread the one with cookielib but when i open the challenge index i still get ' YOU MUST BE LOGGED IN TO PLAY!'

did try HBH class from the link provided, everything okay except time limit and with HBH class i got 2 line of Set-Cookie and urllib2 just 1 with PHPSESSID i'm trying to understang the difference


ynori7's Avatar
Future Emperor of Earth
0 0

Use the code from stdio's post in that thread, and then when you access the timed challenge page use the "opener" variable which contains the all the headers and cookies and stuff.