Hack Puzzle – 1

I have been thinking for quite some-time to build a puzzle. I think I have built an awesome one and hope everyone finds it awesome to hack :)

You can download the jar from here.

  • Make the program terminate gracefully
Terminate gracegullyImplies that the program should end. And it should not end by throwing an Exception or in an abnormal manner. Using `System.exit` or the program terminating due to an exception is not graceful termination.
To run:
  • java -jar DeadLock2.jar
If successfully run it will output:

Oops there is a deadlock. Please solve the deadlock to make me move forward.

  1. You cannot replace any of the jar contents with your files
  2. You cannot recompile any of the classes in jar and replace them
  3. You are permitted to alter/modify the contents of the jar/class files
  4. You are permitted to add or use any external library to solve it
If successfully solved, the program prints the below:

Puzzle Soved!! Congratulations you have solved the puzzle.

Comment below the tools you used and time it took to solve. Happy Hacking :-)


    hi. Thanks for sharing this. I’m not sure what the catch is, but I decompiled the byte code (contained in the byte array) and found that there would be two changes needed. One to not invoke the wait() method on the lock object and the other to reverse the (42 < 2147483647) check so that it always succeeds. Then compile this code, convert to byte array and replace the array you have in the Deadlock2.class without requiring any code recompilation. Do you have a smarter or a different approach to this?

    • Jatin

      You have found out the solution. But just that making too many changes directly in .class is tedious. Especially editing the wait() part.

      I would make another class, which then calls `main` and then using reflection unblocks it. This way one would just have to change the manifest file. Secondly, for `42<`, open the .class in hex editor, look for that point and then find the byte that has to be changed in the array. Then in the .class file, go make the hex change at the particular point.