Too many digits

Discussion of challenges you have already solved
Post Reply
theStack
Posts: 72
Joined: Sun Nov 02, 2008 12:46 am

Too many digits

Post 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)
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post 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.
Skeeve
Posts: 5
Joined: Sun Oct 26, 2008 7:37 am

Post 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.
tog
Posts: 70
Joined: Fri Nov 14, 2008 11:23 am
Location: Germany

Post by tog »

After a disappointing search in man wget I used curl, which has a range-option (-r).
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post 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.
MerickOWA
Posts: 182
Joined: Mon Apr 07, 2008 5:54 pm
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post by MerickOWA »

telnet and notepad! ;)
User avatar
Yharaskrik
Posts: 31
Joined: Wed Nov 05, 2008 11:44 am
Location: Germany

Post by Yharaskrik »

Firefox Plugin "Modify Headers"...
guxx
Posts: 5
Joined: Thu Nov 06, 2008 12:58 pm
Location: Germany

curl

Post by guxx »

After trying wget without success I managed to get it with curl.

Guido
cyberwoozle
Posts: 60
Joined: Fri Nov 07, 2008 10:43 am
Location: Germany

Post 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 ...
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post 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.
cyberwoozle
Posts: 60
Joined: Fri Nov 07, 2008 10:43 am
Location: Germany

Post 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.
megabreit
Posts: 141
Joined: Sat Jan 03, 2009 3:33 pm

Post 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.
Joeb27
Posts: 4
Joined: Sat Oct 16, 2010 11:28 pm

Post 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()
moose
Posts: 67
Joined: Fri Jul 16, 2010 7:32 pm

Post 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
AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post 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.
Post Reply