Page 1 of 1

Too many digits

Posted: Tue Nov 25, 2008 5:43 pm
by theStack
Hi folks,
well solving that was not that hard, my only problem was that I interpreted the numeric value the wrong way at first...
Anyway, my question is: what software do you use for setting/manipulating HTTP Request headers? I guess there are dozens of good Firefox plugins out there, and I solved that "by hand" which telnet so far ;-)

I thought of wget, but didn't find an option to set header fields (except some other stuff as user agent string), and after getting the HTTP Response it revealed that it maybe hadn't been a very good idea anyway:

Code: Select all

X-Wget-Sucks-On-Partial-Content: ############# TRUE ##########
8)

Posted: Tue Nov 25, 2008 6:02 pm
by gfoot
There was some interesting stuff in the error message you get when you don't specify the Range: header, concerning Internet Explorer.

I used telnet, but wrote the query using Python. I almost bothered to find out how to supply these headers to the urllib2 module, but remembered how poor its documentation is, and for something like this it just seems really simple to do it via telnet.

It would be more interesting if the challenge involved querying various different parts of the file, and programmatically deciding which bit to fetch next. Maybe a bit like the Cavern Master challenges, or maybe a huge maze where you start in the middle and have to find your way out.

Posted: Tue Nov 25, 2008 6:08 pm
by Skeeve
Well, the difficult part was to find out, what a sexdecillion is ;-)
Anyway, with Python and httplib its quite easy to set the HTTP header.

Posted: Tue Nov 25, 2008 8:38 pm
by tog
After a disappointing search in man wget I used curl, which has a range-option (-r).

Posted: Tue Nov 25, 2008 8:49 pm
by m!nus
wget has a header option: --header which works but wget can't handle 206 partitial content that way.
i ended up using netcat and headers in a text file.

Posted: Tue Nov 25, 2008 9:41 pm
by MerickOWA
telnet and notepad! ;)

Posted: Tue Nov 25, 2008 9:52 pm
by Yharaskrik
Firefox Plugin "Modify Headers"...

curl

Posted: Tue Nov 25, 2008 11:05 pm
by guxx
After trying wget without success I managed to get it with curl.

Guido

Posted: Thu Dec 25, 2008 1:53 pm
by cyberwoozle
This was my first challenge i got more than a hint for and to be honest i'm not proud of it.
What i don't understand (and hopefully someone can explain to me) is: I tried to enter the "Range:bytes"-specifier into the URL:

http://www.hacker.org/challenge/misc/to ... number.txt HTTP/1.1\r\nRange: bytes=999999999999999999999999999999999999999999999999999-1000000000000000000000000000000000000000000000000099

Why does this not work? It works on any other page (of course with a smaller range-start) but not on hacker.org.

...the frustrated one ...

Posted: Thu Dec 25, 2008 5:46 pm
by gfoot
I'm not sure - what you put in your post was a bit unclear (you didn't seem to use GET anywhere, for example). My request was just:

Code: Select all

GET /challenge/misc/toomany/infinite_number.txt HTTP/1.1
Host: www.hacker.org
Range: bytes=...-...

with the actual numbers filled in too.

Posted: Fri Dec 26, 2008 1:04 pm
by cyberwoozle
Indeed i've put the entire request in the URL (in one line, as in my post above).

The reason was, that i found an explanation on the internet, which said:

For any file, including binaries, but not CGI/1.1 output or parsed or filtered documents, the server will honor a byte range. A request for:

http://host/dir/foo;bytes=256-1024

will cause the server to return bytes 256 to 1024 inclusive.


and i tired this with some websites and it worked.

But on hacker.org it didn't work and i still don't know, why not.

So my problem was not to find the beginning and the end of the range, but the way to send it.

Posted: Sun Jan 11, 2009 8:42 pm
by megabreit
The important thing here is (if you use telnet, like me) to include the "Host:" line as in gfoots posting:

Code: Select all

GET /challenge/misc/toomany/infinite_number.txt HTTP/1.1
Host: www.hacker.org
Range: bytes=...-...
It does NOT work if you miss "Host: www.hacker.org"
It's all about the protocol! HTTP 1.1 demands the Host: line.

I never saw another way of requesting a range. But I stopped searching after
I got the right syntax for Range: from the RFC.

Posted: Wed Jun 08, 2011 8:31 pm
by Joeb27
In Python:

Code: Select all

import httplib

h=httplib.HTTPConnection("www.hacker.org")
h.putrequest("GET","/challenge/misc/toomany/infinite_number.txt")
h.putheader("range","bytes=999999999999999999999999999999999999999999999999999-1000000000000000000000000000000000000000000000000098")
h.endheaders()
r=h.getresponse()
r.getheader("content-range")
print r.read()

Posted: Fri Aug 26, 2011 9:27 am
by moose
wolfram|alpha for the number,
FF + Modify headers + Range:bytes=999999999999999999999999999999999999999999999999999-100000000000000000000000000000000000000000000000098

By the way, someone has asked for the answer on stackoverflow:
http://stackoverflow.com/questions/6180 ... -page-body

Posted: Fri Aug 26, 2011 11:09 am
by AMindForeverVoyaging
moose wrote: By the way, someone has asked for the answer on stackoverflow:
http://stackoverflow.com/questions/6180 ... -page-body
That would indeed not be the only time someone has asked for help on stackoverflow or on some other website,
and as far as I know there is no law or rule which forbids to do that.