by mzungudo on Sun Mar 11, 2012 10:00 am
([msg=64953]see Re: Programming 9[/msg])
A few pointers to anyone stuck on this mission. Do not be fooled, this mission is actually very easy. If you can read code and you completed algebra in school than you can do this mission. Now, if you know php and have a web-server to run php code than I suggest using it for this mission, because the only insane part of this mission is emulating the php servers integer handling exactly. Let me explain:
I first wrote this mission using a 32bit version of perl I could encrypt and decrypt perfectly my own strings and keys perfectly. When I ran the program to solve the mission online however, I only got crappy extended ascii characters that couldn't possibly be the answer. After some debugging I found out that Perl's built in binary XOR overflows with numbers above 2^32-1, and will return 32 1s for any number above that without any warning. However, perl can do algebra computations above 2^32 fine. The only way to know if you computer is overflowing is to actually watch the binary calculations carefully, not just look at the final decimal outputs. Thanks to QtDevl I was able to discover that the server code handles all the binary calculations as 64 bit integers, not 32 bit. I was able to implement this fine using perl's BigInt package, but than ran into problems because the Perl pack function errors without warning when you try to pack an integer over 32 bits. However, with some more debugging I figured out that the PHP pack function used in the script has an implicit modulus 2^32 with it to handle this situation. With those corrections the code works fine. It took me 20 minutes to write the sudoku and decryption methods. It took me like 10 days to figure out these two small, but crucial details.
Long story short, if you have run into problems with getting a solution that works with the website, even though you can properly encrypt and decrypt your own strings and keys properly. Then your problem likely has to do with a difference between how your program's language handles integers compared to the php server which is producing the sudoku and the encrypted blowfish string. The two things you need to know to fix your code:
1)The server script uses 64-bit integers to handle all encryption and decryption manipulations (ie XOR)
2)There is a hidden modulus 4294967296 associated with numbers passed to the pack function in the script.
If any of this is considered too much of a spoiler, please just let me know and I will rewrite it more cryptically. However, I figured the mission was actually in writing the necessary decryption methods and sudoku solver, rather than in deciphering exactly how the php server is handling the numbers. I am not even sure if it is possible to figure that out on your own. It would have been impossible for me without extensive help from QtDevl who happened to do it in php and was willing to give me a ridiculous amount of output from each step. I apologize if I am wrong in this assumption. If I am right and figuring these two things out is not supposed to be the mission, then Id suggest someone please add these two details to the mission page or make them explicit in the php script.
Hope this helps others.