This challenge gave nothing but a URL: 80. For some reason the organizers decided to run a lot of their services on port 80. Netcatting in reveals a simple hanoi solver. Usually when given a service like this with no binary I start inputting values to see what information I can get or if I can cause any errors/crashes. I try a positive, then a negative number.


The program had an error, and it printed out for us. What is prolog?

Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics. -Wikipedia
With a little bit of Googling around I tried some syntax:

Causing errors

It looks like it is taking our input and putting it directly between the two parentheses of the hanoi function. This is textbook command injection. To test, I decided to print something simple. Playing around

Since the statement ended with a ")." I could leave that off. I did a bit of looking around for ways to execute system commands and I found exec. I ran a test with feedback to make sure it worked.


Got it, so now all there is left to do is find the flag. Usually the flags are kept in the home directory of the user they are running as so I used ls to maneuver my way around. The syntax for adding arguments is strange in prolog.

Finding flag 1

Finding flag 2

Catting the file shows the flag!

The Flag