Permanent Programming 2

Put your programming skills to the test in these challenges.

Re: Permanent Programming 2

Post by junk79 on Sat Oct 09, 2010 9:41 am
([msg=47284]see Re: Permanent Programming 2[/msg])

hey phoenix, don't know much c# but maybe instead of trying to open the file directly maybe you need to set up a request to the server and use the data you get back. I say this because i'm guessing the only place that the file would exist is in your browsers cache after it's been generated server-side.

let me know if that helps at all?

kr


I am having the same problem with java. I can access http://www.hackthissite.org/missions/prog/2/ using URL objects and BufferedInputStream etc.

But when I try to access http://www.hackthissite.org/missions/prog/2/PNG I don't find anything to read.

I have tried to understand kr's suggestion. However I do not know what kind of request I should send, nor how to do it.

I have also tried retrieving the image from a local location on my browser's cache - using both firefox and ie, but cannot locate the image in temporary internet files or any other folders i have checked.

I have read the documentation for URL, URLConnection and HttpURLConnection but I still cannot figure out a solution. I am completely new to this area of programming but have searched extensively on google for suggestions.

If anyone could give me a few pointers I would be very grateful.

Thank you,

junk

-- Sun Oct 10, 2010 6:39 pm --

Hi,

Still stuck here.

I have also tried creating a shell script to download the image but that has not worked out any better.

I have been looking into Adress Bar query strings I might be able to attach to URL objects in Java but have not been able to find an appropriate one.

Even some simple explanation as to why the image cannot be accessed in the same way as /missions/prog/2/ would be very welcome.

Thanks again,

junk
junk79
New User
New User
 
Posts: 3
Joined: Thu Sep 23, 2010 7:30 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Defience on Mon Oct 11, 2010 2:22 pm
([msg=47384]see Re: Permanent Programming 2[/msg])

I'm not a java user but what I did for this was to login to the site, go to prog 2 and right click on the image. I then saved it into my python folder and ran my program. What's important to note is that when you do try to save the image it wants to save it as a firefox document named 'PNG'. You need to change the 'save as' type to 'all files', then save it with a .png extension: example PNG.png
User avatar
Defience
Addict
Addict
 
Posts: 1281
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by junk79 on Wed Oct 13, 2010 2:49 pm
([msg=47466]see Re: Permanent Programming 2[/msg])

Hi Defience,

Thank you for your advice. However, I would love to be able to read the image automatically, if just for the challenge.

My most recent attempt has been this:
1) Set up a Socket connection to the ip address of the website..
2) through the socket, print a GET request for the file and print a Host header and print enter- I have also tried sending my session id cookie
3) when I try to read the subsequent bytestream there is nothing to read

Considering that the above does not work, at all, I hope it is not considered a spoiler.

This approach has worked for me on other websites, but does not work here.

If someone were able to advise me as to why this does not work please let me know. I mean, if I could receive some information as to whether the problem pertains to e.g. the format of the site (.php files for instance) or the site's security, that would be really helpful for me.

Thanks again,

Junk
junk79
New User
New User
 
Posts: 3
Joined: Thu Sep 23, 2010 7:30 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by markmb on Sun Dec 05, 2010 5:22 pm
([msg=50060]see Re: Permanent Programming 2[/msg])

I've made a program in PHP that works perfectly, it takes the image, looks for the white dots, looks its number, etc. I get a "possible" answer, but when I tried to do the mission, I got this error message:

Warning: imagecreatefrompng(): Cannot read image data in .... on line ...

I've been analysing the problem and I have arrived to the conclusion that PHP is not logged in, and because of this, it can't access to the .png.

Does anyone have any possible solution, please?

EDIT: well, I can read here that they save the image, but I think that I don't have enough time. I'll try it and tell.

EDIT2: I'm too slow, I can't save the image and execute the program in 15 seconds :cry:
markmb
New User
New User
 
Posts: 2
Joined: Sat Dec 04, 2010 5:30 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by fashizzlepop on Sun Dec 05, 2010 8:16 pm
([msg=50067]see Re: Permanent Programming 2[/msg])

Have PHP setup a "cookie jar" and have it log in, then access the mission file and then process the image. Later POST (or is it GET?) your answer.

Google "cookie jar" for help.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by c0br42 on Thu Dec 16, 2010 8:19 pm
([msg=50542]see Re: Permanent Programming 2[/msg])

i pretty much have a program that takes the png file and processes correctly and all that.. one problem (there always seems to be one of those) that nasty time limit cuts me of far before i can download the image manually so it can be processed by my python script. That said, I'm having a problem getting the image to automatically download. I don't understand why, but you cant download it like /2/image.png it's stored instead like /1/PGN. Even the HTML accesses it by <img src='/2/PGN'></img> =/ so idk wats up.. but I'm sure(and hopeful) you guys will at least point something out that will help
Image
User avatar
c0br42
Experienced User
Experienced User
 
Posts: 56
Joined: Sat Sep 18, 2010 3:59 pm
Location: /home/c0br42
Blog: View Blog (0)


Re: Permanent Programming 2

Post by mojo1948 on Thu Dec 16, 2010 9:37 pm
([msg=50547]see Re: Permanent Programming 2[/msg])

-> urllib2
search the forums for urllib2 also
Never stop learning.
User avatar
mojo1948
Experienced User
Experienced User
 
Posts: 60
Joined: Sun Jul 18, 2010 5:45 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by JiminPark on Mon Dec 27, 2010 7:54 am
([msg=51212]see Re: Permanent Programming 2[/msg])

I just solved this challenge using Adobe Air.
If you have trouble opening http://www.hackthissite.org/missions/prog/2/PNG, think once about 301.
JiminPark
New User
New User
 
Posts: 6
Joined: Sun May 16, 2010 11:42 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Illusion03 on Wed Dec 29, 2010 7:10 pm
([msg=51327]see Re: Permanent Programming 2[/msg])

Hey Guys I am also pretty struck at the same URL problem , I m trying to access http://www.hackthissite.org/missions/prog/2/PNG using my curl script and i am getting a 301 ( Moved permanently error) and if i use http://www.hackthissite.org/missions/prog/2/PNG/ i am getting a INVALID REFERRER , so i m kind off dazzled and It'll be great if i get some help on this !

I have done all the other calculations , I m getting a perfect answer now I just need to access the PNG image so that i can submit it in 15 sec ! Hope to hear from u guys soon :D
Illusion03
New User
New User
 
Posts: 16
Joined: Wed Oct 22, 2008 11:27 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by OnlyHuman on Wed Dec 29, 2010 9:31 pm
([msg=51329]see Re: Permanent Programming 2[/msg])

You should be able to solve both of those problems by setting curl opts. The following is from the PHP implementation of cURL. But PyCurl, and other variants, offer the same features, just using a different syntax. You'll need to translate accordingly.

The referer can be set with either:

Code: Select all
curl_setopt($ch, CURLOPT_REFERER, <referer-url-goes-here>)
// ---or---
curl_setopt($ch, CURLOPT_AUTOREFERER, true);

The first gives you total control of the referer, and the second handles everything automatically. Either choice should work.

I'm not 100% sure about the 301 problem, but the first thing that comes to mind is this:

Code: Select all
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);

It handles a few different redirect issues automatically. I'm not sure how it will respond to a 301, but I have used it in the past to handle somewhat similar issues. Might be worth a shot.
OnlyHuman
Poster
Poster
 
Posts: 191
Joined: Sat Aug 22, 2009 1:37 am
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests