Advertisements

General Musing

blaze your trail

Solving the URL shortening problem #twitter #tweet

leave a comment »

I don’t understand why url expansion after url shortening is such an issue that it needs to be implemented for each service separately. It relies on the same protocol HTTP and should be easy to reliably reverse this. Almost all url shortening services rely on 3xx redirection to forward the request using the Location header.

Using the example of the short URL for this post “http://wp.me/phhhb-ul“:

HEAD /phhhb-ul HTTP/1.1
HOST: wp.me

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 20 Apr 2010 18:22:53 GMT
Content-Type: text/html
Connection: close
Location: http://webhat.wordpress.com/?p=1881
Content-Length: 0

Specifically 301 is used as search engines – such as , Yahoo! and Bing – will index the real address rather than the shortened address. Naturally this can be done by a twitter client too.

A url can be put into this script which recursively checks the url. Example run:

$ php http.php http://bit.ly/b0Y2ds
Connect to: bit.ly (128.121.254.201)
Redirection to: http://wp.me/phhhb-ul
Connect to: wp.me (76.74.254.123)
Redirection to: http://webhat.wordpress.com/?p=1881
Connect to: webhat.wordpress.com (76.74.255.123)
Redirection to: http://specialbrands.net/?p=1881
Connect to: specialbrands.net (72.233.2.58)
True URL: http://specialbrands.net/?p=1881

Quite simple really.

Advertisements

Written by Daniël W. Crompton (webhat)

April 20, 2010 at 8:10 pm

Posted in programming, risk, security

Tagged with , , , , ,

Please Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: