Permanent Programming 2

Put your programming skills to the test in these challenges.

Re: Permanent Programming 2

Post by sesteves86 on Tue Nov 08, 2011 6:00 am
([msg=62868]see Re: Permanent Programming 2[/msg])

It was tought to make it under the 15 sec and to discover the 1st character problem, but it tastes good when we solve it 8-)
1st I was trying to decode the image with smallbasic, then the output I would copy-paste throught notepad to excel and get the remaining decoding there, but would take 15-20 sec to do the job.
I see that the goal is to make all the work with only 1 program.
sesteves86
New User
New User
 
Posts: 1
Joined: Tue Nov 08, 2011 5:56 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by zyewni on Thu May 10, 2012 4:18 am
([msg=66251]see Re: Permanent Programming 2[/msg])

Weirdest thing - decided I'd have a go at this mission this morning.
Had to learn to work with images in PHP - interesting and fun. So script connects, logs in, hits the challenge page, goes and gets the image.
Spent a good hour working out the next bit (cut me some slack, had the baby to care for too).

Once I had everything worked out, and had verified that my responses were making sense over and over, I added in the lines to put the solution in the post data and send it. First try, I got an error, but not the one I was expecting - "YOU HAVE ALREADY COMPLETED THIS MISSION".

This script couldn't have sent the answer during my tests, because I never added it to the post data. And it's impossible that I would have completed it before - I just learned the necessary skills this morning. Odd.

And I never did figure out how to display the image in my browser after
Code: Select all
$source = connect($sess,"missions/prog/2/PNG/",$postdata);
$image = imagecreatefromstring($source);

I tried all sorts of function calls, just kept displaying symbol soup. Everything parses fine, I just would have liked to output the image as well as debugging strings.
zyewni
New User
New User
 
Posts: 3
Joined: Sun May 06, 2012 12:28 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by wan26 on Thu Jun 21, 2012 9:55 am
([msg=67417]see Re: Permanent Programming 2[/msg])

I did this in c++ by saving the .png [set the download path to my codeblocks project directory] and pasted the answer from my terminal, for a bit I was wondering why my answer was wrong. This is the place in my function that creates morse tripped up;

Code: Select all
for (int x = 1; x<=49; x++) { // I set the max value of x to 39 because i was testing a particular image for a while, finally changed it 49 to accept more values ha

    outfile << char(array[x] - array[y]);
        y++;
    }


Glad it's over! But at least I have some nifty things to re use later. I recommend the cimg library if you're going to write it all in c++, it worked wonders.
User avatar
wan26
Experienced User
Experienced User
 
Posts: 91
Joined: Sun Jan 22, 2012 6:46 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by That_One_Hacker on Tue Jan 19, 2016 12:06 am
([msg=91326]see Re: Permanent Programming 2[/msg])

I used c++ as well and I would also recommend the CImg library. It's quick and easy to learn (if you already know c++). These are definately some great challenges to help yourself become a better programmer. So if you are thinking about cheating, I would suggest writing the code yourself, instead of just blowing through all of the chellenges, so you can learn something new. I've only done 2 of the programming challenges so far but I have been challenged more with this program than any of the programming courses I have taken at my college (as of now). Then again, I have never thought about doing anything like parsing through pixels of an image but that just means this was a good mission.
That_One_Hacker
New User
New User
 
Posts: 2
Joined: Mon Jan 18, 2016 4:06 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Pure_Cadence on Mon Feb 08, 2016 10:37 pm
([msg=91534]see Re: Permanent Programming 2[/msg])

I solved it in Java. Make sure to add the first byte into the array. I skipped over the first one (lets say 46) and that messed me up.
User avatar
Pure_Cadence
New User
New User
 
Posts: 17
Joined: Sun Jan 17, 2016 9:31 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by oasis on Tue Nov 08, 2016 7:21 am
([msg=93083]see Re: Permanent Programming 2[/msg])

I'm having trouble doing this in Java. I'm trying to use the getRbg(x,y) method but I'm not sure how to check if the pixel is white. I tried
Code: Select all
if(red == 255 && green == 255 && blue == 255)
with no luck.

-- Tue Nov 08, 2016 9:46 am --

oasis wrote:I'm having trouble doing this in Java. I'm trying to use the getRbg(x,y) method but I'm not sure how to check if the pixel is white. I tried
Code: Select all
if(red == 255 && green == 255 && blue == 255)
with no luck.


I've figured it out. Now I need to try and convert the morse code to text. Is it all in capital letters? Also do the pixels in the picture change every time we load the page?

EDIT: I have completed the mission. I had to slightly cheat. I knew my first letter wasn't right so I added "-" to my first array and it worked! You need a black belt in copy and paste. It would be good to do this without copy and paste but no idea how that would be done with Java.
oasis
New User
New User
 
Posts: 11
Joined: Thu Apr 24, 2008 12:57 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Diggersby on Fri Jan 20, 2017 1:06 am
([msg=93327]see Re: Permanent Programming 2[/msg])

I am attempting to solve this problem in J, but I am having difficulty requesting the image from the website. I successfully make a socket connection to the website:
Code: Select all
NB. Define verb (function) socketinit
socketinit =: 3 : 0
NB. Create socket named sk
sk =: 0 >@{ sdcheck sdsocket''
NB. Retrieve IP of y (or for non-J programmers, the parameter to the right of socketinit)
IP=. sdcheck sdgethostbyname (y)
NB. define port
prt=. 80
NB. make socket connection
sdconnect sk;IP,(<prt)
NB.defining the HTTP GET request
getreq =: (; format httpReq)
req sdsend sk,0
getres =: sdcheck sdrecv sk,100000,0
)

NB. formats the httpReq I have defined below to be of the
NB. proper format.
format =: (CR,LF)&(,~)&.>@:<;._2

NB. HTTP Request to retrieve image.
httpReq =: 0 : 0
GET /missions/prog/2/PNG.png/ HTTP/1.1
Host: www.hackthissite.org
Connection: keep-alive
)


I know not all of you are familiar with this language, so I would like to make it clear that my question is more to do with my GET request being formatted properly. Or if I'm overlooking some important prerequisite to requesting the image.
I should be clear that after the use of the "format" function on the httpreq, the variable "getreq" goes,
'GET /missions/prog/2/PNG.png/ HTTP/1.1',CR,LF,'Host: www.hackthissite.org',CR,LF,'Connection: keep-alive',CR,LF,CR,LF

Thanks for reading! :)
Diggersby
New User
New User
 
Posts: 9
Joined: Mon Jan 16, 2017 3:17 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by boriz666 on Fri Jan 20, 2017 4:27 am
([msg=93328]see Re: Permanent Programming 2[/msg])

Greetings Sir,
I am not familiar with J myself, but I believe you have not logged in to the
site, that is needed in order to get the image. In http terms you need to set
the cookie you get when providing the correct credentials.

In my case i program in perl and i have made a function in order to log into
hts programmatically. The $ua object is a global variable that holds state
like cookies and other useragent settings.

I am not familiar with J, what mechanisms you have available for storing the
cookies the website sends you, but when you login you have to save the
Set-Cookie header field and resend it as a Cookie header field in subsequent
requests.

I hope this clears it up and will get you on the path.

Code: Select all
sub siteLogin {
  my $login = shift;
  my $pass = shift;

  my $req = HTTP::Request->new(POST => "https://www.hackthissite.org/user/login");
  $req->header('Host', 'www.hackthissite.org');
  $req->header('Referer', 'https://www.hackthissite.org/');
  $req->content_type('application/x-www-form-urlencoded');
  $req->content("username=" . $login . "&password=" . $pass . "&btn_submit=Login");

  my $res = $ua->request($req);
  return 1;
}
boriz666
Experienced User
Experienced User
 
Posts: 98
Joined: Tue Mar 24, 2015 11:53 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Diggersby on Fri Jan 20, 2017 8:48 am
([msg=93329]see Re: Permanent Programming 2[/msg])

boriz666 wrote:Greetings Sir,
I am not familiar with J myself, but I believe you have not logged in to the
site, that is needed in order to get the image. In http terms you need to set
the cookie you get when providing the correct credentials.

In my case i program in perl and i have made a function in order to log into
hts programmatically. The $ua object is a global variable that holds state
like cookies and other useragent settings.

I am not familiar with J, what mechanisms you have available for storing the
cookies the website sends you, but when you login you have to save the
Set-Cookie header field and resend it as a Cookie header field in subsequent
requests.

I hope this clears it up and will get you on the path.


Thank you very much. I had also tried logging in with a post request but I had kept neglecting to copy down the cookie. I feel silly now. Your assistance is greatly appreciated. :)

[
Diggersby
New User
New User
 
Posts: 9
Joined: Mon Jan 16, 2017 3:17 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by aConvolutedConscious on Sat May 27, 2017 11:52 pm
([msg=93729]see Re: Permanent Programming 2[/msg])

Never mind. I figured it out!

-- Sun May 28, 2017 2:57 am --

Spyrall2 wrote:Just for the fun of it I made a program that does the opposite : D (converts text -> morse -> image) ^^
This is my message to the HTS-community : D

(btw - to read 'EVERYTHING' you'll also need to implement morse for ; , . ' - and " " (a space in morse code -> /)
Image

Spyral

THIS IS A TEST TO SEE IF THE PROGRAM REALLY WORKS :D, OF COURSE I ALREADY KNOW IT DOES, BUT HEY, CAN'T BLAME ME FOR TOYING WITH IT :D, HIT HERE HTS-MEMBER, LOVE YOU :P

That's what I got.

I think I'll give this a go as well.
User avatar
aConvolutedConscious
New User
New User
 
Posts: 15
Joined: Thu Apr 27, 2017 10:33 am
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests