This fragment is about to be reported (you'll remain on this page): You can enter a comment to clarify the mistake if you would like to: |
General overview of the game protection and some helpful files.
One of the readers of my visual novel hacking tutorial has asked me to check on the protection of «Kimi ga Aruji de Shitsuji ga Ore de» (君が主で執事が俺で). Here goes a brief technical overview and some handy files to help in the translation of this game for those who're interested.
Update: thanks to someone's comment it's now clear that Kimi uses an industrial cryptography which is the same both on its .nsa archives and nscript.dat. Here is located the tool for decrypting them – run it as
shdecrkansa.exe arc.nsa decoded.nsa and use any standard NSA extractor like NSAOut from Insani.
nscripter.dat can be decoded in a similar manner except that you'll need to use a hex editor to apply bitwise XOR by key 0x84 on each of the decoded file byte.
And since this is symmetrical cryptography you can encode the edited files back into original format by passing it to decrkansa again.
Kimi ga Aruji (Kimi for shortness from now on) is an NScripter-powered visual novel (English page on Insani.org) – this means all of its script data is contained in nscript.dat and resources like images and music – in different .nsa archives.
Unlike original NScripter Kimi uses symmetrical XOR encryption on its nscript.dat which is ridiculously complicated.
Below follows a list of code blocks of interest in the disassembled listing based on my game copy with the MD5 hash of きみある.exe being 3F76E89BB6FB8F4ADD5F532BE063875F (663552 bytes in size).
asmESI). I say partly because immediately after this the script initialization routine applies simple «wind XOR» on it with constant key 0x84 (loop at 0x00444530). Maybe it's default NScripter protection, who knows.
Finally, now
asmESI contains the script in plain text form. Note that there's a global Pointer variable at 0x5DC5D8 that must point to the decoded buffer – the script initialization subroutine sets it after allocating the buffer and it has the same value as
asmESI by the time it gains control back.
After this point script initialization subroutine works with raw script creating game window by checking for ;modeXXX comment in the beginning of it. Execution continues as normal.
So how can this roublesome XOR-ring be worked around? I've decided to simply remove the protection code and replace it with simple reading of the raw nscript.dat provided it's unencrypted (it's easy to obtain by setting a break point after the last XOR loop – e.g. at 0x00444539 and then using a memory dumper like LordPE to save the buffer contents.
Nice feature of symmetric encryption is that you can encrypt the script back using the same approach – put raw nscript.dat, set a break point after the loop, dump the memory and you'll get the protected nscript.dat's contents which can be used with the original (unpatched) EXE file.
No more necessary – see the update on top of the article.
Hopefully now you feed ready to contribute to the community and translate the game. You need a decoded nscript.dat (download) and the unprotected きみある.exe (download). Drop both into the game install directory. Note that original きみある.exe won't run with the replaced nscript.dat and unprotected.exe won't run with the original nscript.dat.
The .dat file is a simple text file in Shift JIS encoding. Standard Windows Notepad is able to open and edit it successfully if your system works in Japanese locale – the only problem is line endings which are in Unix style (LF) instead of Windows (CR LF). For this reason if the script looks like a single long line when you open it in your text editor you need to convert line endings; there are two ways:
This should cover it. If you have questions feel free to ask in the comments. You can also check my Visual Novel tools page for other useful utilities.
6 May 2012
Anonymous
Just dropping by to say that according to asmodean KimiAru's archives are indeed encrypted. Having seen the text spacing problem on ex-Project Dawn's new website dailystarstudios.weebly.com and keeping in mind that real translation projects often need image editing and reinsertion, I'd say it's easier to port the whole thing to some flavour of NScripter clone (port = decrypt both script and resources and use them with (P)ONScripter or whatever has better international support; VN scene isn't exclusive to English translations only).
Is there anything to say about Kud Wafter other than «interesting»?
6 May 2012
Proger_XP
Oh dear, so they used a real cryptography there. I'm too little familiar with serious cryptographic algorithms so I'm just happy I didn't go for reversing the entire thing.
His tool can also decrypt the .dat file so looks like they've used the same protection on all game data. Many thanks for the link, updated the post.
Yes, this may be so. I think that for the time being original engine will do just fine and if Pyrex manages to make significant progress existing translation can always be ported to another engine using a simple script.
Is this your way of asking me to check the protection? I have only browsed through the main page and don't have much to say about the project. It has great CG, though, that's for sure.
4 May 2012
Anonymous
nScripter's standard script obfuscation scheme is XORing nscript.dat with 0×84. 0.txt and 00.txt can be plaintext Shift-JIS located in the same directory the main executable is in, they override nscript.dat (if any). If the whole decrypted script is kept in RAM, you can dump it «as is», save it as 0.txt (or, having XORed it first, as nscript.dat) and use vanilla nScripter available on its homepage (see Wikipedia) instead of KimiAru custom build. This will ruin the learning process of a rookie hacker, though.
4 May 2012
Proger_XP
Hey, thanks for dropping in, Anonymous!
Then my guess was correct. It would seem strange for the authors to make such a mind-blowing protection and then spice it up with a wind crypt using constant key.
In Kimi's engine, 0.txt and 00.txt loading is broken – try doing this and you'll get an Access Violation at 0x00000000; looks like there was some #define debug which contained code for loading those files instead of simply checking for their existence.
It was on my mind to use English NScripter builds but I'm afraid Kimi might have some extra code vital for normal execution since it's pretty large. But this is something to deal with after any serious translation is done; let's hope for Project Dawn who seem to have taken the challenge. At least that's what PyrexMaster has told to me.
19 July 2012
PyrexMaster
That dude who posted about us can't even finish his own projects… and btw it only happened once… I stooped after my fan creation failed… and as for Shuffle!… MangaGamer issued a C&D tell us to stop… then I suggested we try to work together… They said no… So I had no choice but to stop work on Shuffle! Essnence…
And after that I just dumped the old site and started up Daily Star Studios… I did not disappear… I simply changed the name…
The person known as Strum can't even finish his own projects…
M&M ~Torokeru Mahou to Amai Jumon~:
Now according to VNDB the demo version for M&M was released on… 2011-01-12… OVER a year ago… and I've been watching his website because I actually anticipate the release of both games… yet sadly… that 92%… I haven't seen it change since last year…
He also has not updated his site since the release of the demo version for M&M… therefore he has no right to speak about my faults…
4 May 2012
Proger_XP
Then my another guess was right again. Thanks for sharing the info.
I usually have too little time to help every TL project out there so I helped Project Dawn after they'd contacted me. If they don't do much progress anyone can take the files in this article and try their skills on this game. It's a free market.
But being banned from VNDB is certainly something to think about…
I thought it was reversed far and wide by Haeleth long time ago. I didn't think Key still releases games based on it, very interesting.
4 May 2012
Anonymous
I don't have the game to test it on (and, to tell the truth, I'm not even interested in it), so I spoke based on my past experiences with other nScripter-based VNs. Come to think of it, I forgot that some modern nScripter games use encrypted game archives as well, hence swapping KimiAru's .exe with the «stock» nScripter isn't guaranteed to work.
On a side note, I wouldn't bet on the project's success due to Project Dawn's track record, as mentioned in http://forums.novelnews.net/showpost.php?p=70129&postcount=257 If anything, Kud Wafter translation on hosikuzu.wordpress.com seems (more) promising, and any efforts made to help them/her likely won't be wasted. Also, RealLive is more of a challenge than nScripter.